diff options
author | Dan Winship <danw@src.gnome.org> | 2001-07-09 23:20:54 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2001-07-09 23:20:54 +0800 |
commit | 7fa7518bd69dab32b11b7fa53b8b4055873cc5bb (patch) | |
tree | 494ebc92793511e3139fdafa0c9cd236ca3e2ae0 /shell/e-shortcuts.c | |
parent | b9578e485877ed6864aab9bfc84e72cf79c4667d (diff) | |
download | gsoc2013-evolution-7fa7518bd69dab32b11b7fa53b8b4055873cc5bb.tar.gz gsoc2013-evolution-7fa7518bd69dab32b11b7fa53b8b4055873cc5bb.tar.zst gsoc2013-evolution-7fa7518bd69dab32b11b7fa53b8b4055873cc5bb.zip |
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
Diffstat (limited to 'shell/e-shortcuts.c')
-rw-r--r-- | shell/e-shortcuts.c | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/shell/e-shortcuts.c b/shell/e-shortcuts.c index 2942cdd75f..b19336a988 100644 --- a/shell/e-shortcuts.c +++ b/shell/e-shortcuts.c @@ -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); } |