aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-shortcuts.c
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2002-07-10 03:49:15 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2002-07-10 03:49:15 +0800
commit4139f5b3ccabe156364d1999b793804094ac707d (patch)
treecae98a48a7dc52d7e190593fe80ba86d2682b6d1 /shell/e-shortcuts.c
parent992fafd1905a462d10d0db219f7fd7d7dd717106 (diff)
downloadgsoc2013-evolution-4139f5b3ccabe156364d1999b793804094ac707d.tar
gsoc2013-evolution-4139f5b3ccabe156364d1999b793804094ac707d.tar.gz
gsoc2013-evolution-4139f5b3ccabe156364d1999b793804094ac707d.tar.bz2
gsoc2013-evolution-4139f5b3ccabe156364d1999b793804094ac707d.tar.lz
gsoc2013-evolution-4139f5b3ccabe156364d1999b793804094ac707d.tar.xz
gsoc2013-evolution-4139f5b3ccabe156364d1999b793804094ac707d.tar.zst
gsoc2013-evolution-4139f5b3ccabe156364d1999b793804094ac707d.zip
If the custom_icon_name is not NULL, return the pixbuf for it.
* e-shortcuts-view-model.c (get_icon_for_item): If the custom_icon_name is not NULL, return the pixbuf for it. * e-storage-set-view.c: #include "e-icon-factory.h". * e-shortcuts-view.c (impl_shortcut_dropped): Pass the custom_icon_name. (get_shortcut_info): New arg @custom_icon_name_return. (rename_shortcut_cb): Pass the custom_icon_name here. * e-shell-view-menu.c (new_shortcut_dialog_folder_selected_cb): Pass the custom_icon_name for the folder's shortcut. * e-shell-folder-commands.c (e_shell_command_add_to_shortcut_bar): Pass the custom_icon_name for the folder's shortcut. * e-corba-shortcuts.c (impl_add): Use the customIconName member in struct ::Shortcuts::Shortcut. (shorcut_list_to_corba): Set the customIconName member on the returned shortcuts. (impl_get): Likewise. * Evolution-Shortcuts.idl: New member customIconName in struct Shortcut. * e-shortcuts.c (shortcut_item_new): New arg @custom_icon_name; initialize the member in EShortcutItem from it. (shortcut_item_update): New arg @custom_icon_name; set the custom_icon_name from it. Also remove some braindeadness from this code. (update_shortcut_and_emit_signal): New arg @custom_icon_name. (load_shortcuts): Load the custom icon name from the XML [eg. <item name="foo" type="mail" icon="inbox">]. (save_shortcuts): Save the custom icon name in the XML. (e_shortcuts_add_shortcut): New arg @custom_icon_name. (update_shortcuts_by_path): Pass the custom_icon_name to update_shortcut_and_emit_signal(). (e_shortcuts_update_shortcut): New arg @custom_icon_name; pass it to update_shortcut_and_emit_signal(). (e_shortcuts_add_default_group): Pass "inbox" as the custom_icon_name for the inbox shortcut, and NULL for the other shortcuts. * e-shortcuts.h: New member custom_icon_name in EShortcutItem. svn path=/trunk/; revision=17394
Diffstat (limited to 'shell/e-shortcuts.c')
-rw-r--r--shell/e-shortcuts.c97
1 files changed, 56 insertions, 41 deletions
diff --git a/shell/e-shortcuts.c b/shell/e-shortcuts.c
index e253764571..24c62fdfcb 100644
--- a/shell/e-shortcuts.c
+++ b/shell/e-shortcuts.c
@@ -131,7 +131,8 @@ static EShortcutItem *
shortcut_item_new (const char *uri,
const char *name,
int unread_count,
- const char *type)
+ const char *type,
+ const char *custom_icon_name)
{
EShortcutItem *new;
@@ -139,10 +140,11 @@ shortcut_item_new (const char *uri,
name = g_basename (uri);
new = g_new (EShortcutItem, 1);
- new->uri = g_strdup (uri);
- new->name = g_strdup (name);
- new->type = g_strdup (type);
- new->unread_count = unread_count;
+ new->uri = g_strdup (uri);
+ new->name = g_strdup (name);
+ new->type = g_strdup (type);
+ new->custom_icon_name = g_strdup (custom_icon_name);
+ new->unread_count = unread_count;
return new;
}
@@ -152,38 +154,33 @@ shortcut_item_update (EShortcutItem *shortcut_item,
const char *uri,
const char *name,
int unread_count,
- const char *type)
+ const char *type,
+ const char *custom_icon_name)
{
gboolean changed = FALSE;
if (name == NULL)
name = g_basename (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);
+ if (shortcut_item->unread_count != unread_count) {
+ shortcut_item->unread_count = unread_count;
changed = TRUE;
}
- 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;
+#define UPDATE_STRING(member) \
+ if (shortcut_item->member == NULL || member == NULL || \
+ strcmp (shortcut_item->member, member) != 0) { \
+ g_free (shortcut_item->member); \
+ shortcut_item->member = g_strdup (member); \
+ changed = TRUE; \
}
- if (shortcut_item->unread_count != unread_count) {
- shortcut_item->unread_count = unread_count;
- changed = FALSE;
- }
+ UPDATE_STRING (uri);
+ UPDATE_STRING (name);
+ UPDATE_STRING (type);
+ UPDATE_STRING (custom_icon_name);
- 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;
- }
+#undef UPDATE_STRING
return changed;
}
@@ -236,17 +233,18 @@ update_shortcut_and_emit_signal (EShortcuts *shortcuts,
const char *uri,
const char *name,
int unread_count,
- const char *type)
+ const char *type,
+ const char *custom_icon_name)
{
/* Only thing that changed was the unread count */
if (shortcut_item->unread_count != unread_count
- && !shortcut_item_update (shortcut_item, uri, name, unread_count, type)) {
+ && !shortcut_item_update (shortcut_item, uri, name, unread_count, type, custom_icon_name)) {
gtk_signal_emit (GTK_OBJECT (shortcuts), signals[UPDATE_SHORTCUT], group_num, num);
return FALSE;
}
/* Unread count is the same, but other stuff changed */
- else if (shortcut_item_update (shortcut_item, uri, name, unread_count, type)) {
+ else if (shortcut_item_update (shortcut_item, uri, name, unread_count, type, custom_icon_name)) {
gtk_signal_emit (GTK_OBJECT (shortcuts), signals[UPDATE_SHORTCUT], group_num, num);
return TRUE;
}
@@ -336,6 +334,7 @@ load_shortcuts (EShortcuts *shortcuts,
xmlChar *uri;
xmlChar *name;
xmlChar *type;
+ xmlChar *icon;
if (strcmp ((char *) q->name, "item") != 0)
continue;
@@ -351,12 +350,18 @@ load_shortcuts (EShortcuts *shortcuts,
if (folder != NULL) {
name = xmlMemStrdup (e_folder_get_name (folder));
type = xmlMemStrdup (e_folder_get_type_string (folder));
+
+ if (e_folder_get_custom_icon_name (folder) != NULL)
+ icon = xmlMemStrdup (e_folder_get_custom_icon_name (folder));
+ else
+ icon = NULL;
} else {
name = xmlGetProp (q, "name");
type = xmlGetProp (q, "type");
+ icon = xmlGetProp (q, "icon");
}
- shortcut_item = shortcut_item_new (uri, name, 0, type);
+ shortcut_item = shortcut_item_new (uri, name, 0, type, icon);
shortcut_group->shortcuts = g_slist_prepend (shortcut_group->shortcuts,
shortcut_item);
@@ -364,6 +369,8 @@ load_shortcuts (EShortcuts *shortcuts,
xmlFree (name);
if (type != NULL)
xmlFree (type);
+ if (icon != NULL)
+ xmlFree (icon);
}
xmlFree (uri);
@@ -431,6 +438,8 @@ save_shortcuts (EShortcuts *shortcuts,
if (shortcut->type != NULL)
xmlSetProp (shortcut_node, (xmlChar *) "type", shortcut->type);
+ if (shortcut->custom_icon_name != NULL)
+ xmlSetProp (shortcut_node, (xmlChar *) "icon", shortcut->custom_icon_name);
}
}
@@ -526,7 +535,8 @@ update_shortcuts_by_path (EShortcuts *shortcuts,
evolution_uri,
shortcut_item->name,
e_folder_get_unread_count (folder),
- e_folder_get_type_string (folder));
+ e_folder_get_type_string (folder),
+ e_folder_get_custom_icon_name (folder));
}
}
}
@@ -990,7 +1000,8 @@ e_shortcuts_add_shortcut (EShortcuts *shortcuts,
const char *uri,
const char *name,
int unread_count,
- const char *type)
+ const char *type,
+ const char *custom_icon_name)
{
EShortcutsPrivate *priv;
ShortcutGroup *group;
@@ -1010,7 +1021,7 @@ e_shortcuts_add_shortcut (EShortcuts *shortcuts,
if (num == -1)
num = g_slist_length (group->shortcuts);
- item = shortcut_item_new (uri, name, unread_count, type);
+ item = shortcut_item_new (uri, name, unread_count, type, custom_icon_name);
group->shortcuts = g_slist_insert (group->shortcuts, item, num);
@@ -1026,7 +1037,8 @@ e_shortcuts_update_shortcut (EShortcuts *shortcuts,
const char *uri,
const char *name,
int unread_count,
- const char *type)
+ const char *type,
+ const char *custom_icon_name)
{
EShortcutItem *shortcut_item;
@@ -1035,7 +1047,8 @@ e_shortcuts_update_shortcut (EShortcuts *shortcuts,
shortcut_item = get_item (shortcuts, group_num, num);
- update_shortcut_and_emit_signal (shortcuts, shortcut_item, group_num, num, uri, name, unread_count, type);
+ update_shortcut_and_emit_signal (shortcuts, shortcut_item, group_num, num,
+ uri, name, unread_count, type, custom_icon_name);
make_dirty (shortcuts);
}
@@ -1053,22 +1066,24 @@ e_shortcuts_add_default_group (EShortcuts *shortcuts)
e_shortcuts_add_group (shortcuts, -1, utf);
g_free (utf);
- /* FIXME: Inbox shortcut should point to something else for
- people who won't care about using /Local Folders/Inbox */
utf = e_utf8_from_locale_string (_("Summary"));
- e_shortcuts_add_shortcut (shortcuts, 0, -1, E_SUMMARY_URI, utf, 0, "summary");
+ e_shortcuts_add_shortcut (shortcuts, 0, -1, E_SUMMARY_URI, utf, 0, "summary", NULL);
g_free (utf);
+
utf = e_utf8_from_locale_string (_("Inbox"));
- e_shortcuts_add_shortcut (shortcuts, 0, -1, E_LOCAL_INBOX_URI, utf, 0, "mail");
+ e_shortcuts_add_shortcut (shortcuts, 0, -1, E_LOCAL_INBOX_URI, utf, 0, "mail", "inbox");
g_free (utf);
+
utf = e_utf8_from_locale_string (_("Calendar"));
- e_shortcuts_add_shortcut (shortcuts, 0, -1, E_LOCAL_CALENDAR_URI, utf, 0, "calendar");
+ e_shortcuts_add_shortcut (shortcuts, 0, -1, E_LOCAL_CALENDAR_URI, utf, 0, "calendar", NULL);
g_free (utf);
+
utf = e_utf8_from_locale_string (_("Tasks"));
- e_shortcuts_add_shortcut (shortcuts, 0, -1, E_LOCAL_TASKS_URI, utf, 0, "tasks");
+ e_shortcuts_add_shortcut (shortcuts, 0, -1, E_LOCAL_TASKS_URI, utf, 0, "tasks", NULL);
g_free (utf);
+
utf = e_utf8_from_locale_string (_("Contacts"));
- e_shortcuts_add_shortcut (shortcuts, 0, -1, E_LOCAL_CONTACTS_URI, utf, 0, "contacts");
+ e_shortcuts_add_shortcut (shortcuts, 0, -1, E_LOCAL_CONTACTS_URI, utf, 0, "contacts", NULL);
g_free (utf);
}