Revision: 1559
http://geeqie.svn.sourceforge.net/geeqie/?rev=1559&view=rev
Author: nadvornik
Date: 2009-03-20 09:46:35 +0000 (Fri, 20 Mar 2009)
Log Message:
-----------
added function to reload external editors at any time
eliminated init_after_global_options()
Modified Paths:
--------------
trunk/src/editors.c
trunk/src/layout.c
trunk/src/layout_util.c
trunk/src/layout_util.h
trunk/src/main.c
trunk/src/main.h
trunk/src/rcfile.c
trunk/src/typedefs.h
Modified: trunk/src/editors.c
===================================================================
--- trunk/src/editors.c 2009-03-19 22:58:28 UTC (rev 1558)
+++ trunk/src/editors.c 2009-03-20 09:46:35 UTC (rev 1559)
@@ -167,8 +167,10 @@
{
/* We only consider desktop entries of Application type */
g_key_file_free(key_file);
+ g_free(type);
return FALSE;
}
+ g_free(type);
editor = g_new0(EditorDescription, 1);
@@ -334,10 +336,11 @@
gchar **split_dirs;
gint i;
- if (!editors)
+ if (editors)
{
- editors = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
(GDestroyNotify)editor_description_free);
+ g_hash_table_destroy(editors);
}
+ editors = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
(GDestroyNotify)editor_description_free);
xdg_data_dirs = getenv("XDG_DATA_DIRS");
if (xdg_data_dirs && xdg_data_dirs[0])
Modified: trunk/src/layout.c
===================================================================
--- trunk/src/layout.c 2009-03-19 22:58:28 UTC (rev 1558)
+++ trunk/src/layout.c 2009-03-20 09:46:35 UTC (rev 1559)
@@ -1758,7 +1758,7 @@
if (lw->ui_manager) g_object_unref(lw->ui_manager);
lw->ui_manager = NULL;
lw->action_group = NULL;
- lw->action_group_external = NULL;
+ lw->action_group_editors = NULL;
gtk_container_remove(GTK_CONTAINER(lw->main_box), lw->group_box);
lw->group_box = NULL;
Modified: trunk/src/layout_util.c
===================================================================
--- trunk/src/layout_util.c 2009-03-19 22:58:28 UTC (rev 1558)
+++ trunk/src/layout_util.c 2009-03-20 09:46:35 UTC (rev 1559)
@@ -1666,7 +1666,13 @@
GList *editors_list;
GList *work;
GList *old_path;
- GString *desc = g_string_new(
+ GString *desc;
+
+ lw->action_group_editors = gtk_action_group_new("MenuActionsExternal");
+ gtk_ui_manager_insert_action_group(lw->ui_manager,
lw->action_group_editors, 1);
+
+ /* lw->action_group_editors contains translated entries, no translate
func is required */
+ desc = g_string_new(
"<ui>"
" <menubar name='MainMenu'>");
@@ -1684,7 +1690,7 @@
{
entry.stock_id = editor->key;
}
- gtk_action_group_add_actions(lw->action_group_external, &entry,
1, lw);
+ gtk_action_group_add_actions(lw->action_group_editors, &entry,
1, lw);
path = layout_actions_editor_menu_path(editor);
layout_actions_editor_add(desc, path, old_path);
@@ -1701,7 +1707,9 @@
"</ui>" );
error = NULL;
- if (!gtk_ui_manager_add_ui_from_string(lw->ui_manager, desc->str, -1,
&error))
+
+ lw->ui_editors_id = gtk_ui_manager_add_ui_from_string(lw->ui_manager,
desc->str, -1, &error);
+ if (!lw->ui_editors_id)
{
g_message("building menus failed: %s", error->message);
g_error_free(error);
@@ -1719,8 +1727,6 @@
lw->action_group = gtk_action_group_new("MenuActions");
gtk_action_group_set_translate_func(lw->action_group, menu_translate,
NULL, NULL);
- lw->action_group_external = gtk_action_group_new("MenuActionsExternal");
- /* lw->action_group_external contains translated entries, no translate
func is required */
gtk_action_group_add_actions(lw->action_group,
menu_entries, G_N_ELEMENTS(menu_entries),
lw);
@@ -1739,7 +1745,6 @@
lw->ui_manager = gtk_ui_manager_new();
gtk_ui_manager_set_add_tearoffs(lw->ui_manager, TRUE);
gtk_ui_manager_insert_action_group(lw->ui_manager, lw->action_group, 0);
- gtk_ui_manager_insert_action_group(lw->ui_manager,
lw->action_group_external, 1);
error = NULL;
if (!gtk_ui_manager_add_ui_from_string(lw->ui_manager,
menu_ui_description, -1, &error))
@@ -1757,6 +1762,32 @@
layout_copy_path_update(lw);
}
+void layout_editors_reload_all(void)
+{
+ GList *work;
+
+ work = layout_window_list;
+ while (work)
+ {
+ LayoutWindow *lw = work->data;
+ work = work->next;
+
+ gtk_ui_manager_remove_ui(lw->ui_manager, lw->ui_editors_id);
+ gtk_ui_manager_remove_action_group(lw->ui_manager,
lw->action_group_editors);
+ g_object_unref(lw->action_group_editors);
+ }
+
+ editor_load_descriptions();
+
+ work = layout_window_list;
+ while (work)
+ {
+ LayoutWindow *lw = work->data;
+ work = work->next;
+ layout_actions_setup_editors(lw);
+ }
+}
+
void layout_actions_add_window(LayoutWindow *lw, GtkWidget *window)
{
GtkAccelGroup *group;
Modified: trunk/src/layout_util.h
===================================================================
--- trunk/src/layout_util.h 2009-03-19 22:58:28 UTC (rev 1558)
+++ trunk/src/layout_util.h 2009-03-20 09:46:35 UTC (rev 1559)
@@ -30,6 +30,7 @@
void layout_copy_path_update_all(void);
+void layout_editors_reload_all(void);
void layout_actions_setup(LayoutWindow *lw);
void layout_actions_add_window(LayoutWindow *lw, GtkWidget *window);
GtkWidget *layout_actions_menu_bar(LayoutWindow *lw);
Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c 2009-03-19 22:58:28 UTC (rev 1558)
+++ trunk/src/main.c 2009-03-20 09:46:35 UTC (rev 1559)
@@ -675,15 +675,6 @@
exit_program_final();
}
-void init_after_global_options(void)
-{
- filter_add_defaults();
- filter_rebuild();
-
- editor_load_descriptions();
-}
-
-
/* This code is supposed to handle situation when a file mmaped by
image_loader
* or by exif loader is truncated by some other process.
* This is probably not completely correct according to posix, because
@@ -788,9 +779,15 @@
options = init_options(NULL);
setup_default_options(options);
- /* load_options calls init_after_global_options() after it parses
global options, we have to call it here if it fails*/
- if (!load_options(options)) init_after_global_options();
+ if (!load_options(options))
+ {
+ /* load_options calls these functions after it parses global
options, we have to call it here if it fails */
+ filter_add_defaults();
+ filter_rebuild();
+ editor_load_descriptions();
+ }
+
/* handle missing config file and commandline additions*/
if (!layout_window_list)
{
Modified: trunk/src/main.h
===================================================================
--- trunk/src/main.h 2009-03-19 22:58:28 UTC (rev 1558)
+++ trunk/src/main.h 2009-03-20 09:46:35 UTC (rev 1559)
@@ -136,8 +136,6 @@
void exit_program(void);
-void init_after_global_options(void);
-
#define CASE_SORT(a, b) ( (options->file_sort.case_sensitive) ? strcmp((a),
(b)) : strcasecmp((a), (b)) )
Modified: trunk/src/rcfile.c
===================================================================
--- trunk/src/rcfile.c 2009-03-19 22:58:28 UTC (rev 1558)
+++ trunk/src/rcfile.c 2009-03-20 09:46:35 UTC (rev 1559)
@@ -775,8 +775,7 @@
struct _GQParserData
{
GList *parse_func_stack;
- gboolean startup; /* reading config for the first time - add
commandline and call init_after_global_options() */
- gboolean global_found;
+ gboolean startup; /* reading config for the first time - add
commandline and defaults */
};
@@ -816,8 +815,8 @@
static void options_parse_filter_end(GQParserData *parser_data,
GMarkupParseContext *context, const gchar *element_name, gpointer data, GError
**error)
{
- if (!parser_data->startup) filter_rebuild();
- /* else this is called in init_after_global_options */
+ if (parser_data->startup) filter_add_defaults();
+ filter_rebuild();
}
static void options_parse_keyword_end(GQParserData *parser_data,
GMarkupParseContext *context, const gchar *element_name, gpointer data, GError
**error)
@@ -882,6 +881,12 @@
}
}
+static void options_parse_global_end(GQParserData *parser_data,
GMarkupParseContext *context, const gchar *element_name, gpointer data, GError
**error)
+{
+ /* on startup there are no layout windows and this just loads the
editors */
+ layout_editors_reload_all();
+}
+
static void options_parse_pane_exif(GQParserData *parser_data,
GMarkupParseContext *context, const gchar *element_name, const gchar
**attribute_names, const gchar **attribute_values, gpointer data, GError
**error)
{
GtkWidget *pane = data;
@@ -990,17 +995,10 @@
if (g_ascii_strcasecmp(element_name, "global") == 0)
{
load_global_params(attribute_names, attribute_values);
- options_parse_func_push(parser_data, options_parse_global,
NULL, NULL);
+ options_parse_func_push(parser_data, options_parse_global,
options_parse_global_end, NULL);
return;
}
- if (parser_data->startup && !parser_data->global_found)
- {
- DEBUG_1(" global end");
- parser_data->global_found = TRUE;
- init_after_global_options();
- }
-
if (g_ascii_strcasecmp(element_name, "layout") == 0)
{
LayoutWindow *lw;
Modified: trunk/src/typedefs.h
===================================================================
--- trunk/src/typedefs.h 2009-03-19 22:58:28 UTC (rev 1558)
+++ trunk/src/typedefs.h 2009-03-20 09:46:35 UTC (rev 1559)
@@ -547,7 +547,8 @@
/* menus, path selector */
GtkActionGroup *action_group;
- GtkActionGroup *action_group_external;
+ GtkActionGroup *action_group_editors;
+ guint ui_editors_id;
GtkUIManager *ui_manager;
guint toolbar_merge_id;
GList *toolbar_actions;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Geeqie-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geeqie-svn