summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRamiro Estrugo <ramiro@src.gnome.org>2001-03-31 10:01:16 +0000
committerRamiro Estrugo <ramiro@src.gnome.org>2001-03-31 10:01:16 +0000
commit270d2b506fe1bd5935ac194734fe65528972f234 (patch)
treeacd56a66398232b8a207d01f8dee7b59ef359df2
parent72b381a4a677bff17d8f86cfc0eafc8663be1a82 (diff)
downloadnautilus-270d2b506fe1bd5935ac194734fe65528972f234.tar.gz
Use _while_alive for the preferences callback to avoid potential problem.
* src/nautilus-window-menus.c: (nautilus_window_initialize_bookmarks_menu): Use _while_alive for the preferences callback to avoid potential problem. (update_user_level_menu_item), (user_level_changed_callback), (nautilus_window_initialize_menus_part_1): Fix bug 6615 - Holding open Preferences menu blocks user-level menu item changes. The user level menu items where getting out of whack if more that 1 NautilusWindow existed at the time of a user level change. The fix was to keep track of user level changes and update the menu items when needed. Also a tiny function renaming to make its function clearer.
-rw-r--r--ChangeLog16
-rw-r--r--src/nautilus-navigation-window-menus.c59
-rw-r--r--src/nautilus-window-menus.c59
3 files changed, 96 insertions, 38 deletions
diff --git a/ChangeLog b/ChangeLog
index 4be7a6097..a265379b2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
2001-03-31 Ramiro Estrugo <ramiro@eazel.com>
+ * src/nautilus-window-menus.c:
+ (nautilus_window_initialize_bookmarks_menu): Use _while_alive
+ for the preferences callback to avoid potential problem.
+ (update_user_level_menu_item), (user_level_changed_callback),
+ (nautilus_window_initialize_menus_part_1):
+ Fix bug 6615 - Holding open Preferences menu blocks user-level
+ menu item changes.
+
+ The user level menu items where getting out of whack if more that
+ 1 NautilusWindow existed at the time of a user level change. The
+ fix was to keep track of user level changes and update the menu
+ items when needed. Also a tiny function renaming to make its
+ function clearer.
+
+2001-03-31 Ramiro Estrugo <ramiro@eazel.com>
+
* configure.in:
Fix bug 7952 - configure.in reference to mozilla source is wrong.
Update the Url to reflect reality.
diff --git a/src/nautilus-navigation-window-menus.c b/src/nautilus-navigation-window-menus.c
index 56e8a5651..67c04e17b 100644
--- a/src/nautilus-navigation-window-menus.c
+++ b/src/nautilus-navigation-window-menus.c
@@ -1139,9 +1139,10 @@ nautilus_window_initialize_bookmarks_menu (NautilusWindow *window)
/* Recreate static & dynamic part of menu if preference about
* showing static bookmarks changes.
*/
- nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS,
- nautilus_window_bookmarks_preference_changed_callback,
- window);
+ nautilus_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS,
+ nautilus_window_bookmarks_preference_changed_callback,
+ window,
+ GTK_OBJECT (window));
/* Recreate dynamic part of menu if bookmark list changes */
gtk_signal_connect_object_while_alive (GTK_OBJECT (get_bookmark_list ()),
@@ -1179,35 +1180,53 @@ nautilus_window_initialize_go_menu (NautilusWindow *window)
}
static void
-add_user_level_menu_item (NautilusWindow *window,
- const char *menu_path,
- guint user_level)
+update_user_level_menu_item (NautilusWindow *window,
+ const char *menu_path,
+ guint item_user_level)
{
-
+
guint current_user_level;
char *icon_name;
-
+
if (window->details->shell_ui == NULL) {
return;
}
-
+
current_user_level = nautilus_preferences_get_user_level ();
- icon_name = get_user_level_icon_name (user_level, current_user_level == user_level);
-
+ icon_name = get_user_level_icon_name (item_user_level, current_user_level == item_user_level);
nautilus_window_ui_freeze (window);
nautilus_bonobo_set_icon (window->details->shell_ui,
menu_path,
icon_name);
-
g_free (icon_name);
nautilus_window_ui_thaw (window);
}
+static void
+user_level_changed_callback (gpointer callback_data)
+{
+ NautilusWindow *window;
+
+ g_return_if_fail (NAUTILUS_IS_WINDOW (callback_data));
+
+ window = NAUTILUS_WINDOW (callback_data);
+
+ update_user_level_menu_item (window,
+ NAUTILUS_MENU_PATH_NOVICE_ITEM,
+ NAUTILUS_USER_LEVEL_NOVICE);
+ update_user_level_menu_item (window,
+ NAUTILUS_MENU_PATH_INTERMEDIATE_ITEM,
+ NAUTILUS_USER_LEVEL_INTERMEDIATE);
+ update_user_level_menu_item (window,
+ NAUTILUS_MENU_PATH_EXPERT_ITEM,
+ NAUTILUS_USER_LEVEL_ADVANCED);
+}
+
/**
* nautilus_window_initialize_menus
*
@@ -1280,14 +1299,16 @@ nautilus_window_initialize_menus_part_1 (NautilusWindow *window)
nautilus_window_update_show_hide_menu_items (window);
- add_user_level_menu_item (window, NAUTILUS_MENU_PATH_NOVICE_ITEM,
- NAUTILUS_USER_LEVEL_NOVICE);
- add_user_level_menu_item (window, NAUTILUS_MENU_PATH_INTERMEDIATE_ITEM,
- NAUTILUS_USER_LEVEL_INTERMEDIATE);
- add_user_level_menu_item (window, NAUTILUS_MENU_PATH_EXPERT_ITEM,
- NAUTILUS_USER_LEVEL_ADVANCED);
- bonobo_ui_component_thaw (window->details->shell_ui, NULL);
+ /* Keep track of user level changes to update the user level menu item icons */
+ nautilus_preferences_add_callback_while_alive ("user_level",
+ user_level_changed_callback,
+ window,
+ GTK_OBJECT (window));
+ /* Update the user level menu items for the first time */
+ user_level_changed_callback (window);
+ bonobo_ui_component_thaw (window->details->shell_ui, NULL);
+
#ifndef ENABLE_PROFILER
nautilus_bonobo_set_hidden (window->details->shell_ui, NAUTILUS_MENU_PATH_PROFILER, TRUE);
#endif
diff --git a/src/nautilus-window-menus.c b/src/nautilus-window-menus.c
index 56e8a5651..67c04e17b 100644
--- a/src/nautilus-window-menus.c
+++ b/src/nautilus-window-menus.c
@@ -1139,9 +1139,10 @@ nautilus_window_initialize_bookmarks_menu (NautilusWindow *window)
/* Recreate static & dynamic part of menu if preference about
* showing static bookmarks changes.
*/
- nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS,
- nautilus_window_bookmarks_preference_changed_callback,
- window);
+ nautilus_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS,
+ nautilus_window_bookmarks_preference_changed_callback,
+ window,
+ GTK_OBJECT (window));
/* Recreate dynamic part of menu if bookmark list changes */
gtk_signal_connect_object_while_alive (GTK_OBJECT (get_bookmark_list ()),
@@ -1179,35 +1180,53 @@ nautilus_window_initialize_go_menu (NautilusWindow *window)
}
static void
-add_user_level_menu_item (NautilusWindow *window,
- const char *menu_path,
- guint user_level)
+update_user_level_menu_item (NautilusWindow *window,
+ const char *menu_path,
+ guint item_user_level)
{
-
+
guint current_user_level;
char *icon_name;
-
+
if (window->details->shell_ui == NULL) {
return;
}
-
+
current_user_level = nautilus_preferences_get_user_level ();
- icon_name = get_user_level_icon_name (user_level, current_user_level == user_level);
-
+ icon_name = get_user_level_icon_name (item_user_level, current_user_level == item_user_level);
nautilus_window_ui_freeze (window);
nautilus_bonobo_set_icon (window->details->shell_ui,
menu_path,
icon_name);
-
g_free (icon_name);
nautilus_window_ui_thaw (window);
}
+static void
+user_level_changed_callback (gpointer callback_data)
+{
+ NautilusWindow *window;
+
+ g_return_if_fail (NAUTILUS_IS_WINDOW (callback_data));
+
+ window = NAUTILUS_WINDOW (callback_data);
+
+ update_user_level_menu_item (window,
+ NAUTILUS_MENU_PATH_NOVICE_ITEM,
+ NAUTILUS_USER_LEVEL_NOVICE);
+ update_user_level_menu_item (window,
+ NAUTILUS_MENU_PATH_INTERMEDIATE_ITEM,
+ NAUTILUS_USER_LEVEL_INTERMEDIATE);
+ update_user_level_menu_item (window,
+ NAUTILUS_MENU_PATH_EXPERT_ITEM,
+ NAUTILUS_USER_LEVEL_ADVANCED);
+}
+
/**
* nautilus_window_initialize_menus
*
@@ -1280,14 +1299,16 @@ nautilus_window_initialize_menus_part_1 (NautilusWindow *window)
nautilus_window_update_show_hide_menu_items (window);
- add_user_level_menu_item (window, NAUTILUS_MENU_PATH_NOVICE_ITEM,
- NAUTILUS_USER_LEVEL_NOVICE);
- add_user_level_menu_item (window, NAUTILUS_MENU_PATH_INTERMEDIATE_ITEM,
- NAUTILUS_USER_LEVEL_INTERMEDIATE);
- add_user_level_menu_item (window, NAUTILUS_MENU_PATH_EXPERT_ITEM,
- NAUTILUS_USER_LEVEL_ADVANCED);
- bonobo_ui_component_thaw (window->details->shell_ui, NULL);
+ /* Keep track of user level changes to update the user level menu item icons */
+ nautilus_preferences_add_callback_while_alive ("user_level",
+ user_level_changed_callback,
+ window,
+ GTK_OBJECT (window));
+ /* Update the user level menu items for the first time */
+ user_level_changed_callback (window);
+ bonobo_ui_component_thaw (window->details->shell_ui, NULL);
+
#ifndef ENABLE_PROFILER
nautilus_bonobo_set_hidden (window->details->shell_ui, NAUTILUS_MENU_PATH_PROFILER, TRUE);
#endif