Commit 65e9e66c authored by John Sullivan's avatar John Sullivan

Fixed bug 4355: Built-in bookmarks icons change after first view

	Also reduced the number of times that refresh_bookmarks_menu
	is called since it was showing up in some profiling.

	* libnautilus-extensions/nautilus-bookmark.h:
	* libnautilus-extensions/nautilus-bookmark.c:
	(nautilus_bookmark_initialize_class), (nautilus_bookmark_set_name),
	(bookmark_file_changed_callback): Split the "changed" signal into
	"appearance_changed" and "content_changed". "appearance_changed" is
	emitted only if the name or icon change. "content_changed" is emitted
	if the URI changes.

	* src/nautilus-bookmark-list.c: (insert_bookmark_internal):
	Connect to both appearance_changed and content_changed.

	* src/nautilus-window-menus.c: (bookmark_holder_new):
	Refresh menu only on appearance_changed, not content_changed.

	* data/static_bookmarks.xml: Added "i-web" as icon name for
	all the built-in bookmarks, since this is the icon they will
	end up with after being visited. (Now, visiting a built-in
	bookmark will not cause a refresh of the bookmarks menu.)
parent 13a6070f
2001-03-20 John Sullivan <sullivan@eazel.com>
Fixed bug 4355: Built-in bookmarks icons change after first view
Also reduced the number of times that refresh_bookmarks_menu
is called since it was showing up in some profiling.
* libnautilus-extensions/nautilus-bookmark.h:
* libnautilus-extensions/nautilus-bookmark.c:
(nautilus_bookmark_initialize_class), (nautilus_bookmark_set_name),
(bookmark_file_changed_callback): Split the "changed" signal into
"appearance_changed" and "content_changed". "appearance_changed" is
emitted only if the name or icon change. "content_changed" is emitted
if the URI changes.
* src/nautilus-bookmark-list.c: (insert_bookmark_internal):
Connect to both appearance_changed and content_changed.
* src/nautilus-window-menus.c: (bookmark_holder_new):
Refresh menu only on appearance_changed, not content_changed.
* data/static_bookmarks.xml: Added "i-web" as icon name for
all the built-in bookmarks, since this is the icon they will
end up with after being visited. (Now, visiting a built-in
bookmark will not cause a refresh of the bookmarks menu.)
2001-03-20 John Sullivan <sullivan@eazel.com>
* src/file-manager/fm-directory-view.c: (run_script_callback):
......
<?xml version="1.0"?>
<bookmarks>
<folder _name="Software">
<bookmark _name="Allaire" uri="http://services.eazel.com/redirect?http://ad.doubleclick.net/clk%3b2508286%3b5488574%3bx?http://allaire11.allaire.com/download/ordercd.cfm"/>
<bookmark _name="Borland" uri="http://services.eazel.com/redirect?http://www.borland.com/kylix/"/>
<bookmark _name="Eazel" uri="http://services.eazel.com/redirect?http://www.eazel.com"/>
<bookmark _name="MandrakeSoft" uri="http://services.eazel.com/redirect?http://mandrakesoft.com/"/>
<bookmark _name="Netraverse" uri="http://services.eazel.com/redirect?http://www.netraverse.com"/>
<bookmark _name="Red Hat" uri="http://services.eazel.com/redirect?http://www.redhat.com"/>
<bookmark _name="Sun StarOffice" uri="http://services.eazel.com/redirect?http://www.sun.com/products/staroffice/"/>
<bookmark _name="Zero-Knowledge" uri="http://services.eazel.com/redirect?http://www.zeroknowledge.com"/>
<bookmark _name="Allaire" icon_name="i-web" uri="http://services.eazel.com/redirect?http://ad.doubleclick.net/clk%3b2508286%3b5488574%3bx?http://allaire11.allaire.com/download/ordercd.cfm"/>
<bookmark _name="Borland" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.borland.com/kylix/"/>
<bookmark _name="Eazel" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.eazel.com"/>
<bookmark _name="MandrakeSoft" icon_name="i-web" uri="http://services.eazel.com/redirect?http://mandrakesoft.com/"/>
<bookmark _name="Netraverse" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.netraverse.com"/>
<bookmark _name="Red Hat" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.redhat.com"/>
<bookmark _name="Sun StarOffice" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.sun.com/products/staroffice/"/>
<bookmark _name="Zero-Knowledge" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.zeroknowledge.com"/>
</folder>
<folder _name="Hardware">
<bookmark _name="Compaq" uri="http://services.eazel.com/redirect?http://www.compaq.com/products/software/linux/"/>
<bookmark _name="CNET Computers.com" uri="http://services.eazel.com/redirect?http://chkpt.zdnet.com/chkpt/hudc02290/computers.cnet.com/hardware/0-1016.html"/>
<bookmark _name="Dell" uri="http://services.eazel.com/redirect?http://www.dell.com/linux/"/>
<bookmark _name="Penguin Computing" uri="http://services.eazel.com/redirect?http://www.penguincomputing.com/?vid=eazel"/>
<bookmark _name="ZDNet Linux Hardware Database" uri="http://services.eazel.com/redirect?http://chkpt.zdnet.com/chkpt/hud002290/lhd.zdnet.com"/>
<bookmark _name="Compaq" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.compaq.com/products/software/linux/"/>
<bookmark _name="CNET Computers.com" icon_name="i-web" uri="http://services.eazel.com/redirect?http://chkpt.zdnet.com/chkpt/hudc02290/computers.cnet.com/hardware/0-1016.html"/>
<bookmark _name="Dell" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.dell.com/linux/"/>
<bookmark _name="Penguin Computing" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.penguincomputing.com/?vid=eazel"/>
<bookmark _name="ZDNet Linux Hardware Database" icon_name="i-web" uri="http://services.eazel.com/redirect?http://chkpt.zdnet.com/chkpt/hud002290/lhd.zdnet.com"/>
</folder>
<folder _name="News and Media">
<bookmark _name="Binary Freedom" uri="http://services.eazel.com/redirect?http://www.binaryfreedom.com/"/>
<bookmark _name="CNET Linux Center" uri="http://services.eazel.com/redirect?http://chkpt.zdnet.com/chkpt/hudc02290/linux.cnet.com/linux/0-1518529-7-3378110.html"/>
<bookmark _name="LinuxOrbit.com" uri="http://services.eazel.com/redirect?http://www.linuxorbit.com"/>
<bookmark _name="Linux Weekly News" uri="http://services.eazel.com/redirect?http://www.lwn.net"/>
<bookmark _name="O'Reilly" uri="http://services.eazel.com/redirect?http://www.eazel.oreillynet.com"/>
<bookmark _name="OSDN" uri="http://services.eazel.com/redirect?http://www.osdn.com"/>
<bookmark _name="ZDNet Linux Resource Center" uri="http://services.eazel.com/redirect?http://chkpt.zdnet.com/chkpt/hud0022900/linux.zdnet.com"/>
<bookmark _name="Binary Freedom" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.binaryfreedom.com/"/>
<bookmark _name="CNET Linux Center" icon_name="i-web" uri="http://services.eazel.com/redirect?http://chkpt.zdnet.com/chkpt/hudc02290/linux.cnet.com/linux/0-1518529-7-3378110.html"/>
<bookmark _name="LinuxOrbit.com" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.linuxorbit.com"/>
<bookmark _name="Linux Weekly News" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.lwn.net"/>
<bookmark _name="O'Reilly" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.eazel.oreillynet.com"/>
<bookmark _name="OSDN" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.osdn.com"/>
<bookmark _name="ZDNet Linux Resource Center" icon_name="i-web" uri="http://services.eazel.com/redirect?http://chkpt.zdnet.com/chkpt/hud0022900/linux.zdnet.com"/>
</folder>
<folder _name="Web Services">
<bookmark _name="CollabNet" uri="http://services.eazel.com/redirect?http://www.collab.net/community/"/>
<bookmark _name="Covalent" uri="http://services.eazel.com/redirect?http://www.covalent.com"/>
<bookmark _name="Rackspace" uri="http://services.eazel.com/redirect?http://www.rackspace.com"/>
<bookmark _name="Red Hat Network" uri="http://services.eazel.com/redirect?http://www.redhat.com/network/"/>
<bookmark _name="SourceForge" uri="http://services.eazel.com/redirect?http://www.sourceforge.net"/>
<bookmark _name="CollabNet" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.collab.net/community/"/>
<bookmark _name="Covalent" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.covalent.com"/>
<bookmark _name="Rackspace" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.rackspace.com"/>
<bookmark _name="Red Hat Network" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.redhat.com/network/"/>
<bookmark _name="SourceForge" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.sourceforge.net"/>
</folder>
<folder _name="International">
<bookmark _name="Conectiva" uri="http://services.eazel.com/redirect?http://en.conectiva.com/"/>
<bookmark _name="Linux One" uri="http://services.eazel.com/redirect?http://www.linuxone.co.kr/english2/eng/main.htm"/>
<bookmark _name="Open Source Asia" uri="http://www.opensourceasia.com/English/what_e.html"/>
<bookmark _name="RedFlag Linux" uri="http://services.eazel.com/redirect?http://www.redflag-linux.com/english/index.html"/>
<bookmark _name="Sun Wah Linux" uri="http://services.eazel.com/redirect?http://www.sw-linux.com/nonflash_front.htm"/>
<bookmark _name="Conectiva" icon_name="i-web" uri="http://services.eazel.com/redirect?http://en.conectiva.com/"/>
<bookmark _name="Linux One" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.linuxone.co.kr/english2/eng/main.htm"/>
<bookmark _name="Open Source Asia" icon_name="i-web" uri="http://www.opensourceasia.com/English/what_e.html"/>
<bookmark _name="RedFlag Linux" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.redflag-linux.com/english/index.html"/>
<bookmark _name="Sun Wah Linux" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.sw-linux.com/nonflash_front.htm"/>
</folder>
<folder _name="Linux Resources">
<bookmark _name="Debian.org" uri="http://services.eazel.com/redirect?http://www.debian.org"/>
<bookmark _name="Freshmeat.net" uri="http://services.eazel.com/redirect?http://www.freshmeat.net"/>
<bookmark _name="GNOME.org" uri="http://services.eazel.com/redirect?http://www.gnome.org"/>
<bookmark _name="GNU.org" uri="http://services.eazel.com/redirect?http://www.gnu.org"/>
<bookmark _name="Linux Online" uri="http://services.eazel.com/redirect?http://www.linux.org"/>
<bookmark _name="Linux Documentation Project" uri="http://services.eazel.com/redirect?http://www.linuxdoc.org"/>
<bookmark _name="LinuxNewbie.org" uri="http://services.eazel.com/redirect?http://www.linuxnewbie.org"/>
<bookmark _name="OpenOffice" uri="http://services.eazel.com/redirect?http://www.openoffice.org"/>
<bookmark _name="Debian.org" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.debian.org"/>
<bookmark _name="Freshmeat.net" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.freshmeat.net"/>
<bookmark _name="GNOME.org" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.gnome.org"/>
<bookmark _name="GNU.org" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.gnu.org"/>
<bookmark _name="Linux Online" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.linux.org"/>
<bookmark _name="Linux Documentation Project" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.linuxdoc.org"/>
<bookmark _name="LinuxNewbie.org" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.linuxnewbie.org"/>
<bookmark _name="OpenOffice" icon_name="i-web" uri="http://services.eazel.com/redirect?http://www.openoffice.org"/>
</folder>
</bookmarks>
......
......@@ -41,7 +41,8 @@
#include <libnautilus-extensions/nautilus-gtk-extensions.h>
enum {
CHANGED,
APPEARANCE_CHANGED,
CONTENTS_CHANGED,
LAST_SIGNAL
};
......@@ -98,11 +99,19 @@ nautilus_bookmark_initialize_class (NautilusBookmarkClass *class)
object_class->destroy = nautilus_bookmark_destroy;
signals[CHANGED] =
gtk_signal_new ("changed",
signals[APPEARANCE_CHANGED] =
gtk_signal_new ("appearance_changed",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (NautilusBookmarkClass, changed),
GTK_SIGNAL_OFFSET (NautilusBookmarkClass, appearance_changed),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
signals[CONTENTS_CHANGED] =
gtk_signal_new ("contents_changed",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (NautilusBookmarkClass, contents_changed),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
......@@ -287,7 +296,7 @@ nautilus_bookmark_set_name (NautilusBookmark *bookmark, const char *new_name)
g_free (bookmark->details->name);
bookmark->details->name = g_strdup (new_name);
gtk_signal_emit (GTK_OBJECT (bookmark), signals[CHANGED]);
gtk_signal_emit (GTK_OBJECT (bookmark), signals[APPEARANCE_CHANGED]);
}
static gboolean
......@@ -360,19 +369,21 @@ static void
bookmark_file_changed_callback (NautilusFile *file, NautilusBookmark *bookmark)
{
char *file_uri;
gboolean should_emit_changed_signal;
gboolean should_emit_appearance_changed_signal;
gboolean should_emit_contents_changed_signal;
g_assert (NAUTILUS_IS_FILE (file));
g_assert (NAUTILUS_IS_BOOKMARK (bookmark));
g_assert (file == bookmark->details->file);
should_emit_changed_signal = FALSE;
should_emit_appearance_changed_signal = FALSE;
should_emit_contents_changed_signal = FALSE;
file_uri = nautilus_file_get_uri (file);
if (!nautilus_uris_match (bookmark->details->uri, file_uri)) {
g_free (bookmark->details->uri);
bookmark->details->uri = file_uri;
should_emit_changed_signal = TRUE;
should_emit_contents_changed_signal = TRUE;
} else {
g_free (file_uri);
}
......@@ -386,16 +397,20 @@ bookmark_file_changed_callback (NautilusFile *file, NautilusBookmark *bookmark)
*/
nautilus_bookmark_disconnect_file (bookmark);
nautilus_bookmark_connect_file (bookmark);
should_emit_changed_signal = TRUE;
should_emit_appearance_changed_signal = TRUE;
} else if (nautilus_bookmark_update_icon (bookmark)) {
/* File hasn't gone away, but it has changed
* in a way that affected its icon.
*/
should_emit_changed_signal = TRUE;
should_emit_appearance_changed_signal = TRUE;
}
if (should_emit_appearance_changed_signal) {
gtk_signal_emit (GTK_OBJECT (bookmark), signals[APPEARANCE_CHANGED]);
}
if (should_emit_changed_signal) {
gtk_signal_emit (GTK_OBJECT (bookmark), signals[CHANGED]);
if (should_emit_contents_changed_signal) {
gtk_signal_emit (GTK_OBJECT (bookmark), signals[CONTENTS_CHANGED]);
}
}
......
......@@ -56,10 +56,15 @@ struct NautilusBookmarkClass {
/* Signals that clients can connect to. */
/* The changed signal is emitted when the bookmark's
/* The appearance_changed signal is emitted when the bookmark's
* name or icon has changed.
*/
void (* changed) (NautilusBookmark *bookmark);
void (* appearance_changed) (NautilusBookmark *bookmark);
/* The contents_changed signal is emitted when the bookmark's
* URI has changed.
*/
void (* contents_changed) (NautilusBookmark *bookmark);
};
typedef struct NautilusBookmarkClass NautilusBookmarkClass;
......
......@@ -41,7 +41,8 @@
#include <libnautilus-extensions/nautilus-gtk-extensions.h>
enum {
CHANGED,
APPEARANCE_CHANGED,
CONTENTS_CHANGED,
LAST_SIGNAL
};
......@@ -98,11 +99,19 @@ nautilus_bookmark_initialize_class (NautilusBookmarkClass *class)
object_class->destroy = nautilus_bookmark_destroy;
signals[CHANGED] =
gtk_signal_new ("changed",
signals[APPEARANCE_CHANGED] =
gtk_signal_new ("appearance_changed",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (NautilusBookmarkClass, changed),
GTK_SIGNAL_OFFSET (NautilusBookmarkClass, appearance_changed),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
signals[CONTENTS_CHANGED] =
gtk_signal_new ("contents_changed",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (NautilusBookmarkClass, contents_changed),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
......@@ -287,7 +296,7 @@ nautilus_bookmark_set_name (NautilusBookmark *bookmark, const char *new_name)
g_free (bookmark->details->name);
bookmark->details->name = g_strdup (new_name);
gtk_signal_emit (GTK_OBJECT (bookmark), signals[CHANGED]);
gtk_signal_emit (GTK_OBJECT (bookmark), signals[APPEARANCE_CHANGED]);
}
static gboolean
......@@ -360,19 +369,21 @@ static void
bookmark_file_changed_callback (NautilusFile *file, NautilusBookmark *bookmark)
{
char *file_uri;
gboolean should_emit_changed_signal;
gboolean should_emit_appearance_changed_signal;
gboolean should_emit_contents_changed_signal;
g_assert (NAUTILUS_IS_FILE (file));
g_assert (NAUTILUS_IS_BOOKMARK (bookmark));
g_assert (file == bookmark->details->file);
should_emit_changed_signal = FALSE;
should_emit_appearance_changed_signal = FALSE;
should_emit_contents_changed_signal = FALSE;
file_uri = nautilus_file_get_uri (file);
if (!nautilus_uris_match (bookmark->details->uri, file_uri)) {
g_free (bookmark->details->uri);
bookmark->details->uri = file_uri;
should_emit_changed_signal = TRUE;
should_emit_contents_changed_signal = TRUE;
} else {
g_free (file_uri);
}
......@@ -386,16 +397,20 @@ bookmark_file_changed_callback (NautilusFile *file, NautilusBookmark *bookmark)
*/
nautilus_bookmark_disconnect_file (bookmark);
nautilus_bookmark_connect_file (bookmark);
should_emit_changed_signal = TRUE;
should_emit_appearance_changed_signal = TRUE;
} else if (nautilus_bookmark_update_icon (bookmark)) {
/* File hasn't gone away, but it has changed
* in a way that affected its icon.
*/
should_emit_changed_signal = TRUE;
should_emit_appearance_changed_signal = TRUE;
}
if (should_emit_appearance_changed_signal) {
gtk_signal_emit (GTK_OBJECT (bookmark), signals[APPEARANCE_CHANGED]);
}
if (should_emit_changed_signal) {
gtk_signal_emit (GTK_OBJECT (bookmark), signals[CHANGED]);
if (should_emit_contents_changed_signal) {
gtk_signal_emit (GTK_OBJECT (bookmark), signals[CONTENTS_CHANGED]);
}
}
......
......@@ -56,10 +56,15 @@ struct NautilusBookmarkClass {
/* Signals that clients can connect to. */
/* The changed signal is emitted when the bookmark's
/* The appearance_changed signal is emitted when the bookmark's
* name or icon has changed.
*/
void (* changed) (NautilusBookmark *bookmark);
void (* appearance_changed) (NautilusBookmark *bookmark);
/* The contents_changed signal is emitted when the bookmark's
* URI has changed.
*/
void (* contents_changed) (NautilusBookmark *bookmark);
};
typedef struct NautilusBookmarkClass NautilusBookmarkClass;
......
......@@ -194,7 +194,12 @@ insert_bookmark_internal (NautilusBookmarkList *bookmarks,
index);
gtk_signal_connect (GTK_OBJECT (bookmark),
"changed",
"appearance_changed",
bookmark_in_list_changed_callback,
bookmarks);
gtk_signal_connect (GTK_OBJECT (bookmark),
"contents_changed",
bookmark_in_list_changed_callback,
bookmarks);
}
......
......@@ -152,7 +152,7 @@ bookmark_holder_new (NautilusBookmark *bookmark,
new_bookmark_holder->prompt_for_removal = is_bookmarks_menu;
new_bookmark_holder->changed_handler_id =
gtk_signal_connect_object (GTK_OBJECT (bookmark), "changed",
gtk_signal_connect_object (GTK_OBJECT (bookmark), "appearance_changed",
is_bookmarks_menu
? schedule_refresh_bookmarks_menu
: schedule_refresh_go_menu,
......
......@@ -152,7 +152,7 @@ bookmark_holder_new (NautilusBookmark *bookmark,
new_bookmark_holder->prompt_for_removal = is_bookmarks_menu;
new_bookmark_holder->changed_handler_id =
gtk_signal_connect_object (GTK_OBJECT (bookmark), "changed",
gtk_signal_connect_object (GTK_OBJECT (bookmark), "appearance_changed",
is_bookmarks_menu
? schedule_refresh_bookmarks_menu
: schedule_refresh_go_menu,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment