Commit 1fd31530 authored by John Sullivan's avatar John Sullivan
Browse files

Some work towards bug 1401 (bookmark icon never updates).

	No visible effect yet.

	* libnautilus-extensions/nautilus-bookmark.h:
	Added nautilus_bookmark_get_file prototype, not yet
	called or implemented.

	* libnautilus-extensions/nautilus-file.h,
	* libnautilus-extensions/nautilus-file.c:
	(nautilus_file_check_if_ready): New function, does
	nothing yet.

	* libnautilus-extensions/nautilus-icon-factory.h:
	Added nautilus_icon_factory_is_icon_ready_for_file
	prototype, not yet called or implemented.

	* src/nautilus-window-menus.c:
	(nautilus_window_initialize_bookmarks_menu),
	(nautilus_window_initialize_go_menu),
	(nautilus_window_remove_bookmarks_menu_callback),
	(nautilus_window_remove_go_menu_callback),
	(refresh_bookmarks_menu),
	(refresh_bookmarks_menu_idle_callback),
	(schedule_refresh_bookmarks_menu), (refresh_go_menu),
	(refresh_go_menu_idle_callback), (schedule_refresh_go_menu):
	Made the code that rebuilds the Go and Bookmarks menus when
	there's been a change to the bookmarks use idle handling to
	batch up requests. This will be important when bookmarks
	broadcast updates for their icons.

	* src/nautilus-window-private.h: Defined NautilusWindowDetails
	struct. We should eventually migrate all of the fields
	of NautilusWindow in here, but I didn't do that now.
	Added two fields used by bookmark-menu-updating code.
	* src/nautilus-window.h: Made a details field using
	NautilusWindowDetails.

	* src/nautilus-window.c:
	(nautilus_window_init): Create details field.
	(nautilus_window_destroy): Clean up any pending idle bookmark
	refreshing stuff.
parent f971d7c5
2000-06-16 John Sullivan <sullivan@eazel.com>
Some work towards bug 1401 (bookmark icon never updates).
No visible effect yet.
* libnautilus-extensions/nautilus-bookmark.h:
Added nautilus_bookmark_get_file prototype, not yet
called or implemented.
* libnautilus-extensions/nautilus-file.h,
* libnautilus-extensions/nautilus-file.c:
(nautilus_file_check_if_ready): New function, does
nothing yet.
* libnautilus-extensions/nautilus-icon-factory.h:
Added nautilus_icon_factory_is_icon_ready_for_file
prototype, not yet called or implemented.
* src/nautilus-window-menus.c:
(nautilus_window_initialize_bookmarks_menu),
(nautilus_window_initialize_go_menu),
(nautilus_window_remove_bookmarks_menu_callback),
(nautilus_window_remove_go_menu_callback),
(refresh_bookmarks_menu),
(refresh_bookmarks_menu_idle_callback),
(schedule_refresh_bookmarks_menu), (refresh_go_menu),
(refresh_go_menu_idle_callback), (schedule_refresh_go_menu):
Made the code that rebuilds the Go and Bookmarks menus when
there's been a change to the bookmarks use idle handling to
batch up requests. This will be important when bookmarks
broadcast updates for their icons.
* src/nautilus-window-private.h: Defined NautilusWindowDetails
struct. We should eventually migrate all of the fields
of NautilusWindow in here, but I didn't do that now.
Added two fields used by bookmark-menu-updating code.
* src/nautilus-window.h: Made a details field using
NautilusWindowDetails.
* src/nautilus-window.c:
(nautilus_window_init): Create details field.
(nautilus_window_destroy): Clean up any pending idle bookmark
refreshing stuff.
2000-06-16 Rebecka Schulman <rebecka@eazel.com>
 
* libnautilus-extensions/nautilus-global-preferences.c:
......@@ -8,7 +52,6 @@
* src/nautilus-search-bar.h:
Changed search preferences, and fixed search icon
2000-06-16 Darin Adler <darin@eazel.com>
 
* src/nautilus-location-bar.c: (try_to_expand_path):
......@@ -359,7 +402,7 @@
* icons/emblem-nowrite.png:
new icons from Susan
2000-06-14 Rebecka Schulman <rebecka@eazel.com
2000-06-14 Rebecka Schulman <rebecka@eazel.com>
 
* libnautilus-extensions/nautilus-global-preferences.c:
(global_preferences_create_dialog),
......
......@@ -66,6 +66,7 @@ NautilusBookmark * nautilus_bookmark_new_with_icon (const char *uri,
const char *name,
NautilusScalableIcon *icon);
NautilusBookmark * nautilus_bookmark_copy (NautilusBookmark *bookmark);
NautilusFile * nautilus_bookmark_get_file (NautilusBookmark *bookmark);
char * nautilus_bookmark_get_name (NautilusBookmark *bookmark);
char * nautilus_bookmark_get_uri (NautilusBookmark *bookmark);
NautilusScalableIcon *nautilus_bookmark_get_icon (NautilusBookmark *bookmark);
......
......@@ -2191,6 +2191,14 @@ nautilus_file_activate_custom (NautilusFile *file, gboolean use_new_window)
return FALSE;
}
gboolean
nautilus_file_check_if_ready (NautilusFile *file,
GList *file_attributes)
{
/* FIXME: placeholder, need to implement this. */
return TRUE;
}
void
nautilus_file_call_when_ready (NautilusFile *file,
......
......@@ -97,6 +97,8 @@ void nautilus_file_call_when_ready (NautilusFile
void nautilus_file_cancel_callback (NautilusFile *file,
NautilusFileCallback callback,
gpointer callback_data);
gboolean nautilus_file_check_if_ready (NautilusFile *file,
GList *attributes);
/* Basic attributes for file objects. */
char * nautilus_file_get_name (NautilusFile *file);
......
......@@ -93,6 +93,7 @@ guint nautilus_get_icon_size_for_zoom_level (Nautil
/* Choose the appropriate icon, but don't render it yet. */
NautilusScalableIcon *nautilus_icon_factory_get_icon_for_file (NautilusFile *file,
const char *modifier);
gboolean nautilus_icon_factory_is_icon_ready_for_file (NautilusFile *file);
GList * nautilus_icon_factory_get_emblem_icons_for_file (NautilusFile *file);
NautilusScalableIcon *nautilus_icon_factory_get_icon_by_name (const char *icon_name,
const char *embedded_text);
......
......@@ -66,6 +66,7 @@ NautilusBookmark * nautilus_bookmark_new_with_icon (const char *uri,
const char *name,
NautilusScalableIcon *icon);
NautilusBookmark * nautilus_bookmark_copy (NautilusBookmark *bookmark);
NautilusFile * nautilus_bookmark_get_file (NautilusBookmark *bookmark);
char * nautilus_bookmark_get_name (NautilusBookmark *bookmark);
char * nautilus_bookmark_get_uri (NautilusBookmark *bookmark);
NautilusScalableIcon *nautilus_bookmark_get_icon (NautilusBookmark *bookmark);
......
......@@ -2191,6 +2191,14 @@ nautilus_file_activate_custom (NautilusFile *file, gboolean use_new_window)
return FALSE;
}
gboolean
nautilus_file_check_if_ready (NautilusFile *file,
GList *file_attributes)
{
/* FIXME: placeholder, need to implement this. */
return TRUE;
}
void
nautilus_file_call_when_ready (NautilusFile *file,
......
......@@ -97,6 +97,8 @@ void nautilus_file_call_when_ready (NautilusFile
void nautilus_file_cancel_callback (NautilusFile *file,
NautilusFileCallback callback,
gpointer callback_data);
gboolean nautilus_file_check_if_ready (NautilusFile *file,
GList *attributes);
/* Basic attributes for file objects. */
char * nautilus_file_get_name (NautilusFile *file);
......
......@@ -93,6 +93,7 @@ guint nautilus_get_icon_size_for_zoom_level (Nautil
/* Choose the appropriate icon, but don't render it yet. */
NautilusScalableIcon *nautilus_icon_factory_get_icon_for_file (NautilusFile *file,
const char *modifier);
gboolean nautilus_icon_factory_is_icon_ready_for_file (NautilusFile *file);
GList * nautilus_icon_factory_get_emblem_icons_for_file (NautilusFile *file);
NautilusScalableIcon *nautilus_icon_factory_get_icon_by_name (const char *icon_name,
const char *embedded_text);
......
......@@ -57,8 +57,10 @@ static void clear_appended_bookmark_items (Nau
const char *menu_path,
const char *last_static_item_path);
static NautilusBookmarkList *get_bookmark_list (void);
static void refresh_bookmarks_in_go_menu (NautilusWindow *window);
static void refresh_bookmarks_in_bookmarks_menu (NautilusWindow *window);
static void refresh_go_menu (NautilusWindow *window);
static void refresh_bookmarks_menu (NautilusWindow *window);
static void schedule_refresh_go_menu (NautilusWindow *window);
static void schedule_refresh_bookmarks_menu (NautilusWindow *window);
static void edit_bookmarks (NautilusWindow *window);
......@@ -610,19 +612,19 @@ static void
nautilus_window_initialize_bookmarks_menu (NautilusWindow *window)
{
/* Add current set of bookmarks */
refresh_bookmarks_in_bookmarks_menu (window);
refresh_bookmarks_menu (window);
/* Recreate bookmarks part of menu if bookmark list changes
* or if icon theme changes.
*/
gtk_signal_connect_object_while_alive (GTK_OBJECT (get_bookmark_list ()),
"contents_changed",
refresh_bookmarks_in_bookmarks_menu,
schedule_refresh_bookmarks_menu,
GTK_OBJECT (window));
gtk_signal_connect_object_while_alive (nautilus_icon_factory_get (),
"icons_changed",
refresh_bookmarks_in_bookmarks_menu,
schedule_refresh_bookmarks_menu,
GTK_OBJECT (window));
}
......@@ -640,12 +642,12 @@ nautilus_window_initialize_go_menu (NautilusWindow *window)
*/
gtk_signal_connect_object_while_alive (GTK_OBJECT (nautilus_signaller_get_current ()),
"history_list_changed",
refresh_bookmarks_in_go_menu,
schedule_refresh_go_menu,
GTK_OBJECT (window));
gtk_signal_connect_object_while_alive (nautilus_icon_factory_get (),
"icons_changed",
refresh_bookmarks_in_go_menu,
schedule_refresh_go_menu,
GTK_OBJECT (window));
}
......@@ -1001,14 +1003,32 @@ nautilus_window_initialize_menus (NautilusWindow *window)
nautilus_window_initialize_go_menu (window);
}
void
nautilus_window_remove_bookmarks_menu_callback (NautilusWindow *window)
{
if (window->details->refresh_bookmarks_menu_idle_id != 0) {
gtk_idle_remove (window->details->refresh_bookmarks_menu_idle_id);
window->details->refresh_bookmarks_menu_idle_id = 0;
}
}
void
nautilus_window_remove_go_menu_callback (NautilusWindow *window)
{
if (window->details->refresh_go_menu_idle_id != 0) {
gtk_idle_remove (window->details->refresh_go_menu_idle_id);
window->details->refresh_go_menu_idle_id = 0;
}
}
/**
* refresh_bookmarks_in_bookmarks_menu:
* refresh_bookmarks_menu:
*
* Refresh list of bookmarks at end of Bookmarks menu to match centralized list.
* @window: The NautilusWindow whose Bookmarks menu will be refreshed.
**/
static void
refresh_bookmarks_in_bookmarks_menu (NautilusWindow *window)
refresh_bookmarks_menu (NautilusWindow *window)
{
NautilusBookmarkList *bookmarks;
guint bookmark_count;
......@@ -1016,6 +1036,9 @@ refresh_bookmarks_in_bookmarks_menu (NautilusWindow *window)
g_assert (NAUTILUS_IS_WINDOW (window));
/* Unregister any pending call to this function. */
nautilus_window_remove_bookmarks_menu_callback (window);
bookmarks = get_bookmark_list ();
/* Remove old set of bookmarks. */
......@@ -1044,20 +1067,46 @@ refresh_bookmarks_in_bookmarks_menu (NautilusWindow *window)
}
}
static gboolean
refresh_bookmarks_menu_idle_callback (gpointer data)
{
g_assert (NAUTILUS_IS_WINDOW (data));
refresh_bookmarks_menu (NAUTILUS_WINDOW (data));
/* Don't call this again (unless rescheduled) */
return FALSE;
}
static void
schedule_refresh_bookmarks_menu (NautilusWindow *window)
{
g_assert (NAUTILUS_IS_WINDOW (window));
if (window->details->refresh_bookmarks_menu_idle_id == 0) {
window->details->refresh_bookmarks_menu_idle_id
= gtk_idle_add (refresh_bookmarks_menu_idle_callback,
window);
}
}
/**
* refresh_bookmarks_in_go_menu:
* refresh_go_menu:
*
* Refresh list of bookmarks at end of Go menu to match centralized history list.
* @window: The NautilusWindow whose Go menu will be refreshed.
**/
static void
refresh_bookmarks_in_go_menu (NautilusWindow *window)
refresh_go_menu (NautilusWindow *window)
{
GSList *p;
int index;
g_assert (NAUTILUS_IS_WINDOW (window));
/* Unregister any pending call to this function. */
nautilus_window_remove_go_menu_callback (window);
/* Remove old set of history items. */
clear_appended_bookmark_items (window,
NAUTILUS_MENU_PATH_GO_MENU,
......@@ -1079,6 +1128,29 @@ refresh_bookmarks_in_go_menu (NautilusWindow *window)
}
}
static gboolean
refresh_go_menu_idle_callback (gpointer data)
{
g_assert (NAUTILUS_IS_WINDOW (data));
refresh_go_menu (NAUTILUS_WINDOW (data));
/* Don't call this again (unless rescheduled) */
return FALSE;
}
static void
schedule_refresh_go_menu (NautilusWindow *window)
{
g_assert (NAUTILUS_IS_WINDOW (window));
if (window->details->refresh_go_menu_idle_id == 0) {
window->details->refresh_go_menu_idle_id
= gtk_idle_add (refresh_go_menu_idle_callback,
window);
}
}
static void
user_level_changed_callback (GtkObject *user_level_manager,
gpointer user_data)
......
......@@ -173,6 +173,8 @@ nautilus_window_class_init (NautilusWindowClass *klass)
static void
nautilus_window_init (NautilusWindow *window)
{
window->details = g_new0 (NautilusWindowDetails, 1);
gtk_quit_add_destroy (1, GTK_OBJECT (window));
/* Keep track of sidebar panel changes */
......@@ -459,8 +461,11 @@ nautilus_window_destroy (NautilusWindow *window)
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_SIDEBAR_PANELS_NAMESPACE,
sidebar_panels_changed_callback,
NULL);
nautilus_window_remove_bookmarks_menu_callback (window);
nautilus_window_remove_go_menu_callback (window);
nautilus_window_toolbar_remove_theme_callback();
g_list_free (window->sidebar_panels);
nautilus_view_identifier_free (window->content_view_id);
......
......@@ -63,9 +63,13 @@ typedef enum {
NAUTILUS_LOCATION_CHANGE_RELOAD
} NautilusLocationChangeType;
typedef struct NautilusWindowDetails NautilusWindowDetails;
struct NautilusWindow {
GnomeApp parent_object;
NautilusWindowDetails *details;
/** UI stuff **/
NautilusSidebar *sidebar;
GtkWidget *content_hbox;
......
......@@ -173,6 +173,8 @@ nautilus_window_class_init (NautilusWindowClass *klass)
static void
nautilus_window_init (NautilusWindow *window)
{
window->details = g_new0 (NautilusWindowDetails, 1);
gtk_quit_add_destroy (1, GTK_OBJECT (window));
/* Keep track of sidebar panel changes */
......@@ -459,8 +461,11 @@ nautilus_window_destroy (NautilusWindow *window)
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_SIDEBAR_PANELS_NAMESPACE,
sidebar_panels_changed_callback,
NULL);
nautilus_window_remove_bookmarks_menu_callback (window);
nautilus_window_remove_go_menu_callback (window);
nautilus_window_toolbar_remove_theme_callback();
g_list_free (window->sidebar_panels);
nautilus_view_identifier_free (window->content_view_id);
......
......@@ -63,9 +63,13 @@ typedef enum {
NAUTILUS_LOCATION_CHANGE_RELOAD
} NautilusLocationChangeType;
typedef struct NautilusWindowDetails NautilusWindowDetails;
struct NautilusWindow {
GnomeApp parent_object;
NautilusWindowDetails *details;
/** UI stuff **/
NautilusSidebar *sidebar;
GtkWidget *content_hbox;
......
......@@ -173,6 +173,8 @@ nautilus_window_class_init (NautilusWindowClass *klass)
static void
nautilus_window_init (NautilusWindow *window)
{
window->details = g_new0 (NautilusWindowDetails, 1);
gtk_quit_add_destroy (1, GTK_OBJECT (window));
/* Keep track of sidebar panel changes */
......@@ -459,8 +461,11 @@ nautilus_window_destroy (NautilusWindow *window)
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_SIDEBAR_PANELS_NAMESPACE,
sidebar_panels_changed_callback,
NULL);
nautilus_window_remove_bookmarks_menu_callback (window);
nautilus_window_remove_go_menu_callback (window);
nautilus_window_toolbar_remove_theme_callback();
g_list_free (window->sidebar_panels);
nautilus_view_identifier_free (window->content_view_id);
......
......@@ -63,9 +63,13 @@ typedef enum {
NAUTILUS_LOCATION_CHANGE_RELOAD
} NautilusLocationChangeType;
typedef struct NautilusWindowDetails NautilusWindowDetails;
struct NautilusWindow {
GnomeApp parent_object;
NautilusWindowDetails *details;
/** UI stuff **/
NautilusSidebar *sidebar;
GtkWidget *content_hbox;
......
......@@ -57,8 +57,10 @@ static void clear_appended_bookmark_items (Nau
const char *menu_path,
const char *last_static_item_path);
static NautilusBookmarkList *get_bookmark_list (void);
static void refresh_bookmarks_in_go_menu (NautilusWindow *window);
static void refresh_bookmarks_in_bookmarks_menu (NautilusWindow *window);
static void refresh_go_menu (NautilusWindow *window);
static void refresh_bookmarks_menu (NautilusWindow *window);
static void schedule_refresh_go_menu (NautilusWindow *window);
static void schedule_refresh_bookmarks_menu (NautilusWindow *window);
static void edit_bookmarks (NautilusWindow *window);
......@@ -610,19 +612,19 @@ static void
nautilus_window_initialize_bookmarks_menu (NautilusWindow *window)
{
/* Add current set of bookmarks */
refresh_bookmarks_in_bookmarks_menu (window);
refresh_bookmarks_menu (window);
/* Recreate bookmarks part of menu if bookmark list changes
* or if icon theme changes.
*/
gtk_signal_connect_object_while_alive (GTK_OBJECT (get_bookmark_list ()),
"contents_changed",
refresh_bookmarks_in_bookmarks_menu,
schedule_refresh_bookmarks_menu,
GTK_OBJECT (window));
gtk_signal_connect_object_while_alive (nautilus_icon_factory_get (),
"icons_changed",
refresh_bookmarks_in_bookmarks_menu,
schedule_refresh_bookmarks_menu,
GTK_OBJECT (window));
}
......@@ -640,12 +642,12 @@ nautilus_window_initialize_go_menu (NautilusWindow *window)
*/
gtk_signal_connect_object_while_alive (GTK_OBJECT (nautilus_signaller_get_current ()),
"history_list_changed",
refresh_bookmarks_in_go_menu,
schedule_refresh_go_menu,
GTK_OBJECT (window));
gtk_signal_connect_object_while_alive (nautilus_icon_factory_get (),
"icons_changed",
refresh_bookmarks_in_go_menu,
schedule_refresh_go_menu,
GTK_OBJECT (window));
}
......@@ -1001,14 +1003,32 @@ nautilus_window_initialize_menus (NautilusWindow *window)
nautilus_window_initialize_go_menu (window);
}
void
nautilus_window_remove_bookmarks_menu_callback (NautilusWindow *window)
{
if (window->details->refresh_bookmarks_menu_idle_id != 0) {
gtk_idle_remove (window->details->refresh_bookmarks_menu_idle_id);
window->details->refresh_bookmarks_menu_idle_id = 0;
}
}
void
nautilus_window_remove_go_menu_callback (NautilusWindow *window)
{
if (window->details->refresh_go_menu_idle_id != 0) {
gtk_idle_remove (window->details->refresh_go_menu_idle_id);
window->details->refresh_go_menu_idle_id = 0;
}
}
/**
* refresh_bookmarks_in_bookmarks_menu:
* refresh_bookmarks_menu:
*
* Refresh list of bookmarks at end of Bookmarks menu to match centralized list.
* @window: The NautilusWindow whose Bookmarks menu will be refreshed.
**/
static void
refresh_bookmarks_in_bookmarks_menu (NautilusWindow *window)
refresh_bookmarks_menu (NautilusWindow *window)
{
NautilusBookmarkList *bookmarks;
guint bookmark_count;
......@@ -1016,6 +1036,9 @@ refresh_bookmarks_in_bookmarks_menu (NautilusWindow *window)
g_assert (NAUTILUS_IS_WINDOW (window));
/* Unregister any pending call to this function. */
nautilus_window_remove_bookmarks_menu_callback (window);
bookmarks = get_bookmark_list ();
/* Remove old set of bookmarks. */
......@@ -1044,20 +1067,46 @@ refresh_bookmarks_in_bookmarks_menu (NautilusWindow *window)
}
}
static gboolean
refresh_bookmarks_menu_idle_callback (gpointer data)
{
g_assert (NAUTILUS_IS_WINDOW (data));
refresh_bookmarks_menu (NAUTILUS_WINDOW (data));
/* Don't call this again (unless rescheduled) */
return FALSE;
}
static void
schedule_refresh_bookmarks_menu (NautilusWindow *window)
{
g_assert (NAUTILUS_IS_WINDOW (window));
if (window->details->refresh_bookmarks_menu_idle_id == 0) {
window->details->refresh_bookmarks_menu_idle_id
= gtk_idle_add (refresh_bookmarks_menu_idle_callback,
window);
}
}
/**
* refresh_bookmarks_in_go_menu:
* refresh_go_menu:
*
* Refresh list of bookmarks at end of Go menu to match centralized history list.
* @window: The NautilusWindow whose Go menu will be refreshed.
**/
static void
refresh_bookmarks_in_go_menu (NautilusWindow *window)
refresh_go_menu (NautilusWindow *window)
{
GSList *p;
int index;
g_assert (NAUTILUS_IS_WINDOW (window));
/* Unregister any pending call to this function. */
nautilus_window_remove_go_menu_callback (window);
/* Remove old set of history items. */
clear_appended_bookmark_items (window,
NAUTILUS_MENU_PATH_GO_MENU,
......@@ -1079,6 +1128,29 @@ refresh_bookmarks_in_go_menu (NautilusWindow *window)
}
}
static gboolean
refresh_go_menu_idle_callback (gpointer data)
{
g_assert (NAUTILUS_IS_WINDOW (data));
refresh_go_menu (NAUTILUS_WINDOW (data));
/* Don't call this again (unless rescheduled) */
return FALSE;
}
static void
schedule_refresh_go_menu (NautilusWindow *window)
{
g_assert (NAUTILUS_IS_WINDOW (window));
if (window->details->refresh_go_menu_idle_id == 0) {
window->details->refresh_go_menu_idle_id
= gtk_idle_add (refresh_go_menu_idle_callback,
window);
}
}
static void
user_level_changed_callback (GtkObject *user_level_manager,
gpointer user_data)
......
......@@ -18,6 +18,14 @@ typedef enum {
SYNC_STATE /* Not a real item - a flag */
} NautilusWindowStateItem;