Return a gboolean saying whether or not the shortcut changed. Use strcmp

* e-shortcuts.c (shortcut_item_update): Return a gboolean saying
	whether or not the shortcut changed. Use strcmp rather than
	pointer comparisons to determine this.
	(update_shortcut_and_emit_signal): propagate the gboolean from
	shortcut_item_update (and only emit the signal if it's TRUE).
	(update_shortcuts_by_path): Only call make_dirty if something
	changed.
	(storage_set_new_folder_callback,
	storage_set_updated_folder_callback): Don't call make_dirty:
	update_shortcuts_by_path will have called it if necessary.

	* e-shell-view.c (updated_folder_cb): Don't call
	update_for_current_uri if the folder that was updated isn't the
	one being displayed.

svn path=/trunk/; revision=10912
This commit is contained in:
Dan Winship
2001-07-09 15:20:54 +00:00
parent b9578e4858
commit 7fa7518bd6
3 changed files with 52 additions and 17 deletions

View File

@ -1,3 +1,20 @@
2001-07-06 Dan Winship <danw@ximian.com>
* e-shortcuts.c (shortcut_item_update): Return a gboolean saying
whether or not the shortcut changed. Use strcmp rather than
pointer comparisons to determine this.
(update_shortcut_and_emit_signal): propagate the gboolean from
shortcut_item_update (and only emit the signal if it's TRUE).
(update_shortcuts_by_path): Only call make_dirty if something
changed.
(storage_set_new_folder_callback,
storage_set_updated_folder_callback): Don't call make_dirty:
update_shortcuts_by_path will have called it if necessary.
* e-shell-view.c (updated_folder_cb): Don't call
update_for_current_uri if the folder that was updated isn't the
one being displayed.
2001-07-06 Jason Leach <jleach@ximian.com>
* e-shortcuts-view.c: Little UI tweak for right click menu,

View File

@ -1122,6 +1122,7 @@ updated_folder_cb (EStorageSet *storage_set,
{
EShellView *shell_view;
EShellViewPrivate *priv;
const char *view_path;
shell_view = E_SHELL_VIEW (data);
priv = shell_view->priv;
@ -1134,6 +1135,10 @@ updated_folder_cb (EStorageSet *storage_set,
g_free (uri);
#endif
view_path = get_storage_set_path_from_uri (priv->uri);
if (strcmp (path, view_path) != 0)
return;
/* Update the folder title bar and the window title bar */
update_for_current_uri (shell_view);
}

View File

@ -141,29 +141,39 @@ shortcut_item_new (const char *uri,
return new;
}
static void
static gboolean
shortcut_item_update (EShortcutItem *shortcut_item,
const char *uri,
const char *name,
const char *type)
{
gboolean changed = FALSE;
if (name == NULL)
name = g_basename (uri);
if (shortcut_item->uri != uri) {
if (shortcut_item->uri == NULL || uri == NULL ||
strcmp (shortcut_item->uri, uri) != 0) {
g_free (shortcut_item->uri);
shortcut_item->uri = g_strdup (uri);
changed = TRUE;
}
if (shortcut_item->name != name) {
if (shortcut_item->name == NULL || name == NULL ||
strcmp (shortcut_item->name, name) != 0) {
g_free (shortcut_item->name);
shortcut_item->name = g_strdup (name);
changed = TRUE;
}
if (shortcut_item->type != type) {
if (shortcut_item->type == NULL || type == NULL ||
strcmp (shortcut_item->type, type) != 0) {
g_free (shortcut_item->type);
shortcut_item->type = g_strdup (type);
changed = TRUE;
}
return changed;
}
static void
@ -205,7 +215,7 @@ shortcut_group_free (ShortcutGroup *group)
/* Utility functions. */
static void
static gboolean
update_shortcut_and_emit_signal (EShortcuts *shortcuts,
EShortcutItem *shortcut_item,
int group_num,
@ -214,8 +224,11 @@ update_shortcut_and_emit_signal (EShortcuts *shortcuts,
const char *name,
const char *type)
{
shortcut_item_update (shortcut_item, uri, name, type);
gtk_signal_emit (GTK_OBJECT (shortcuts), signals[UPDATE_SHORTCUT], group_num, num);
if (shortcut_item_update (shortcut_item, uri, name, type)) {
gtk_signal_emit (GTK_OBJECT (shortcuts), signals[UPDATE_SHORTCUT], group_num, num);
return TRUE;
} else
return FALSE;
}
static void
@ -464,6 +477,7 @@ update_shortcuts_by_path (EShortcuts *shortcuts,
const GSList *p, *q;
char *evolution_uri;
int group_num, num;
gboolean changed = FALSE;
priv = shortcuts->priv;
folder = e_storage_set_get_folder (priv->storage_set, path);
@ -482,19 +496,20 @@ update_shortcuts_by_path (EShortcuts *shortcuts,
shortcut_item = (EShortcutItem *) q->data;
if (strcmp (shortcut_item->uri, evolution_uri) == 0)
update_shortcut_and_emit_signal (shortcuts,
shortcut_item,
group_num,
num,
evolution_uri,
NULL,
e_folder_get_type_string (folder));
changed = update_shortcut_and_emit_signal (shortcuts,
shortcut_item,
group_num,
num,
evolution_uri,
NULL,
e_folder_get_type_string (folder));
}
}
g_free (evolution_uri);
make_dirty (shortcuts);
if (changed)
make_dirty (shortcuts);
}
@ -555,7 +570,6 @@ storage_set_new_folder_callback (EStorageSet *storage_set,
shortcuts = E_SHORTCUTS (data);
update_shortcuts_by_path (shortcuts, path);
make_dirty (shortcuts);
}
static void
@ -568,7 +582,6 @@ storage_set_updated_folder_callback (EStorageSet *storage_set,
shortcuts = E_SHORTCUTS (data);
update_shortcuts_by_path (shortcuts, path);
make_dirty (shortcuts);
}