diff options
author | Xavier Claessens <xclaesse@src.gnome.org> | 2007-05-08 03:48:22 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2007-05-08 03:48:22 +0800 |
commit | c7010d43264dafca66ff65540c5d6666f1c66e2a (patch) | |
tree | b9913e0042b112a9e97eeb7b00521459a568b58c /libempathy-gtk | |
parent | 6e542b100fd2efcfb7b8a3b58bf173fed1e3e494 (diff) | |
download | gsoc2013-empathy-c7010d43264dafca66ff65540c5d6666f1c66e2a.tar gsoc2013-empathy-c7010d43264dafca66ff65540c5d6666f1c66e2a.tar.gz gsoc2013-empathy-c7010d43264dafca66ff65540c5d6666f1c66e2a.tar.bz2 gsoc2013-empathy-c7010d43264dafca66ff65540c5d6666f1c66e2a.tar.lz gsoc2013-empathy-c7010d43264dafca66ff65540c5d6666f1c66e2a.tar.xz gsoc2013-empathy-c7010d43264dafca66ff65540c5d6666f1c66e2a.tar.zst gsoc2013-empathy-c7010d43264dafca66ff65540c5d6666f1c66e2a.zip |
[darcs-to-svn @ Use icon-name API instead of stock icons and update tango icons]
svn path=/trunk/; revision=32
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/Makefile.am | 2 | ||||
-rw-r--r-- | libempathy-gtk/empathy-images.h | 42 | ||||
-rw-r--r-- | libempathy-gtk/gossip-accounts-dialog.c | 15 | ||||
-rw-r--r-- | libempathy-gtk/gossip-chat-window.c | 68 | ||||
-rw-r--r-- | libempathy-gtk/gossip-chat.c | 8 | ||||
-rw-r--r-- | libempathy-gtk/gossip-chat.h | 44 | ||||
-rw-r--r-- | libempathy-gtk/gossip-contact-list.c | 52 | ||||
-rw-r--r-- | libempathy-gtk/gossip-preferences.c | 1 | ||||
-rw-r--r-- | libempathy-gtk/gossip-presence-chooser.c | 29 | ||||
-rw-r--r-- | libempathy-gtk/gossip-private-chat.c | 30 | ||||
-rw-r--r-- | libempathy-gtk/gossip-profile-chooser.c | 10 | ||||
-rw-r--r-- | libempathy-gtk/gossip-stock.c | 129 | ||||
-rw-r--r-- | libempathy-gtk/gossip-stock.h | 63 | ||||
-rw-r--r-- | libempathy-gtk/gossip-ui-utils.c | 125 | ||||
-rw-r--r-- | libempathy-gtk/gossip-ui-utils.h | 14 |
15 files changed, 205 insertions, 427 deletions
diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am index 2818b2a23..c5b66b744 100644 --- a/libempathy-gtk/Makefile.am +++ b/libempathy-gtk/Makefile.am @@ -10,6 +10,7 @@ noinst_LTLIBRARIES = libempathy-gtk.la libempathy_gtk_la_SOURCES = \ ephy-spinner.c ephy-spinner.h \ + empathy-images.h \ empathy-main-window.c empathy-main-window.h \ gossip-accounts-dialog.c gossip-accounts-dialog.h \ gossip-account-widget-generic.c gossip-account-widget-generic.h \ @@ -17,7 +18,6 @@ libempathy_gtk_la_SOURCES = \ gossip-profile-chooser.c gossip-profile-chooser.h \ gossip-cell-renderer-expander.c gossip-cell-renderer-expander.h \ gossip-cell-renderer-text.c gossip-cell-renderer-text.h \ - gossip-stock.c gossip-stock.h \ gossip-spell.c gossip-spell.h \ gossip-contact-groups.c gossip-contact-groups.h \ gossip-contact-list.c gossip-contact-list.h \ diff --git a/libempathy-gtk/empathy-images.h b/libempathy-gtk/empathy-images.h new file mode 100644 index 000000000..439f4c92e --- /dev/null +++ b/libempathy-gtk/empathy-images.h @@ -0,0 +1,42 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Copyright (C) 2007 Collabora Ltd. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Xavier Claessens <xclaesse@gmail.com> + */ + +#ifndef __EMPATHY_IMAGES_H__ +#define __EMPATHY_IMAGES_H__ + +G_BEGIN_DECLS + +#define EMPATHY_IMAGE_OFFLINE "empathy-offline" +#define EMPATHY_IMAGE_AVAILABLE "empathy-available" +#define EMPATHY_IMAGE_BUSY "empathy-busy" +#define EMPATHY_IMAGE_AWAY "empathy-away" +#define EMPATHY_IMAGE_EXT_AWAY "empathy-extended-away" +#define EMPATHY_IMAGE_PENDING "empathy-pending" + +#define EMPATHY_IMAGE_MESSAGE "empathy-message" +#define EMPATHY_IMAGE_TYPING "empathy-typing" +#define EMPATHY_IMAGE_CONTACT_INFORMATION "vcard_16" +#define EMPATHY_IMAGE_GROUP_MESSAGE "gossip-group-message" + +G_END_DECLS + +#endif /* __EMPATHY_IMAGES_ICONS_H__ */ diff --git a/libempathy-gtk/gossip-accounts-dialog.c b/libempathy-gtk/gossip-accounts-dialog.c index ad9f79765..449577aec 100644 --- a/libempathy-gtk/gossip-accounts-dialog.c +++ b/libempathy-gtk/gossip-accounts-dialog.c @@ -305,15 +305,12 @@ accounts_dialog_update_account (GossipAccountsDialog *dialog, if (account) { McProfile *profile; - GdkPixbuf *pixbuf; - - pixbuf = gossip_pixbuf_from_account (account, GTK_ICON_SIZE_DIALOG); - gtk_image_set_from_pixbuf (GTK_IMAGE (dialog->image_type), pixbuf); - if (pixbuf) { - g_object_unref (pixbuf); - } profile = mc_account_get_profile (account); + gtk_image_set_from_icon_name (GTK_IMAGE (dialog->image_type), + mc_profile_get_icon_name (profile), + GTK_ICON_SIZE_DIALOG); + gtk_label_set_text (GTK_LABEL (dialog->label_type), mc_profile_get_display_name (profile)); @@ -412,6 +409,7 @@ accounts_dialog_model_pixbuf_data_func (GtkTreeViewColumn *tree_column, GossipAccountsDialog *dialog) { McAccount *account; + const gchar *icon_name; GdkPixbuf *pixbuf; TelepathyConnectionStatus status; @@ -420,7 +418,8 @@ accounts_dialog_model_pixbuf_data_func (GtkTreeViewColumn *tree_column, COL_ACCOUNT_POINTER, &account, -1); - pixbuf = gossip_pixbuf_from_account (account, GTK_ICON_SIZE_BUTTON); + icon_name = gossip_icon_name_from_account (account); + pixbuf = gossip_pixbuf_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON); if (pixbuf) { if (status == TP_CONN_STATUS_DISCONNECTED || diff --git a/libempathy-gtk/gossip-chat-window.c b/libempathy-gtk/gossip-chat-window.c index 9f6f1a363..feeda5e00 100644 --- a/libempathy-gtk/gossip-chat-window.c +++ b/libempathy-gtk/gossip-chat-window.c @@ -40,6 +40,7 @@ #include <libempathy/gossip-conf.h> #include "gossip-chat-window.h" +#include "empathy-images.h" //#include "gossip-add-contact-dialog.h" //#include "gossip-chat-invite.h" //#include "gossip-contact-info-dialog.h" @@ -48,7 +49,6 @@ #include "gossip-preferences.h" #include "gossip-private-chat.h" //#include "gossip-sound.h" -#include "gossip-stock.h" #include "gossip-ui-utils.h" #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GOSSIP_TYPE_CHAT_WINDOW, GossipChatWindowPriv)) @@ -106,8 +106,6 @@ struct _GossipChatWindowPriv { static void gossip_chat_window_class_init (GossipChatWindowClass *klass); static void gossip_chat_window_init (GossipChatWindow *window); static void gossip_chat_window_finalize (GObject *object); -static GdkPixbuf *chat_window_get_status_pixbuf (GossipChatWindow *window, - GossipChat *chat); static void chat_window_accel_cb (GtkAccelGroup *accelgroup, GObject *object, guint key, @@ -354,9 +352,9 @@ gossip_chat_window_init (GossipChatWindow *window) * stock image */ image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (priv->menu_conv_info)); - gtk_image_set_from_stock (GTK_IMAGE (image), - GOSSIP_STOCK_CONTACT_INFORMATION, - GTK_ICON_SIZE_MENU); + gtk_image_set_from_icon_name (GTK_IMAGE (image), + EMPATHY_IMAGE_CONTACT_INFORMATION, + GTK_ICON_SIZE_MENU); /* Set up smiley menu */ menu = gossip_chat_view_get_smiley_menu ( @@ -502,30 +500,6 @@ gossip_chat_window_finalize (GObject *object) G_OBJECT_CLASS (gossip_chat_window_parent_class)->finalize (object); } -static GdkPixbuf * -chat_window_get_status_pixbuf (GossipChatWindow *window, - GossipChat *chat) -{ - GossipChatWindowPriv *priv; - GdkPixbuf *pixbuf; - - priv = GET_PRIV (window); - - if (g_list_find (priv->chats_new_msg, chat)) { - pixbuf = gossip_stock_render (GOSSIP_STOCK_MESSAGE, - GTK_ICON_SIZE_MENU); - } - else if (g_list_find (priv->chats_composing, chat)) { - pixbuf = gossip_stock_render (GOSSIP_STOCK_TYPING, - GTK_ICON_SIZE_MENU); - } - else { - pixbuf = gossip_chat_get_status_pixbuf (chat); - } - - return pixbuf; -} - static void chat_window_accel_cb (GtkAccelGroup *accelgroup, GObject *object, @@ -668,15 +642,24 @@ static void chat_window_update_status (GossipChatWindow *window, GossipChat *chat) { - GtkImage *image; - GdkPixbuf *pixbuf; + GossipChatWindowPriv *priv; + GtkImage *image; + const gchar *icon_name = NULL; + + priv = GET_PRIV (window); - pixbuf = chat_window_get_status_pixbuf (window, chat); + if (g_list_find (priv->chats_new_msg, chat)) { + icon_name = EMPATHY_IMAGE_MESSAGE; + } + else if (g_list_find (priv->chats_composing, chat)) { + icon_name = EMPATHY_IMAGE_TYPING; + } + else { + icon_name = gossip_chat_get_status_icon_name (chat); + } image = g_object_get_data (G_OBJECT (chat), "chat-window-tab-image"); - gtk_image_set_from_pixbuf (image, pixbuf); + gtk_image_set_from_icon_name (image, icon_name, GTK_ICON_SIZE_MENU); - g_object_unref (pixbuf); - chat_window_update_title (window, chat); chat_window_update_tooltip (window, chat); } @@ -686,7 +669,6 @@ chat_window_update_title (GossipChatWindow *window, GossipChat *chat) { GossipChatWindowPriv *priv; - GdkPixbuf *pixbuf = NULL; const gchar *str; gchar *title; gint n_chats; @@ -742,16 +724,10 @@ chat_window_update_title (GossipChatWindow *window, g_free (title); if (priv->chats_new_msg) { - pixbuf = gossip_stock_render (GOSSIP_STOCK_MESSAGE, - GTK_ICON_SIZE_MENU); + gtk_window_set_icon_name (GTK_WINDOW (priv->dialog), + EMPATHY_IMAGE_MESSAGE); } else { - pixbuf = NULL; - } - - gtk_window_set_icon (GTK_WINDOW (priv->dialog), pixbuf); - - if (pixbuf) { - g_object_unref (pixbuf); + gtk_window_set_icon_name (GTK_WINDOW (priv->dialog), NULL); } } diff --git a/libempathy-gtk/gossip-chat.c b/libempathy-gtk/gossip-chat.c index 85aeee274..e8906dbdd 100644 --- a/libempathy-gtk/gossip-chat.c +++ b/libempathy-gtk/gossip-chat.c @@ -1072,13 +1072,13 @@ gossip_chat_get_tooltip (GossipChat *chat) return NULL; } -GdkPixbuf * -gossip_chat_get_status_pixbuf (GossipChat *chat) +const gchar * +gossip_chat_get_status_icon_name (GossipChat *chat) { g_return_val_if_fail (GOSSIP_IS_CHAT (chat), NULL); - if (GOSSIP_CHAT_GET_CLASS (chat)->get_status_pixbuf) { - return GOSSIP_CHAT_GET_CLASS (chat)->get_status_pixbuf (chat); + if (GOSSIP_CHAT_GET_CLASS (chat)->get_status_icon_name) { + return GOSSIP_CHAT_GET_CLASS (chat)->get_status_icon_name (chat); } return NULL; diff --git a/libempathy-gtk/gossip-chat.h b/libempathy-gtk/gossip-chat.h index 3de788eef..8cbcee0b6 100644 --- a/libempathy-gtk/gossip-chat.h +++ b/libempathy-gtk/gossip-chat.h @@ -66,27 +66,26 @@ struct _GossipChatClass { GObjectClass parent; /* VTable */ - const gchar * (*get_name) (GossipChat *chat); - gchar * (*get_tooltip) (GossipChat *chat); - GdkPixbuf * (*get_status_pixbuf)(GossipChat *chat); - GossipContact * (*get_contact) (GossipChat *chat); - GtkWidget * (*get_widget) (GossipChat *chat); - - gboolean (*get_show_contacts)(GossipChat *chat); - void (*set_show_contacts)(GossipChat *chat, - gboolean show); - - gboolean (*is_group_chat) (GossipChat *chat); - void (*save_geometry) (GossipChat *chat, - gint x, - gint y, - gint w, - gint h); - void (*load_geometry) (GossipChat *chat, - gint *x, - gint *y, - gint *w, - gint *h); + const gchar * (*get_name) (GossipChat *chat); + gchar * (*get_tooltip) (GossipChat *chat); + const gchar * (*get_status_icon_name)(GossipChat *chat); + GossipContact * (*get_contact) (GossipChat *chat); + GtkWidget * (*get_widget) (GossipChat *chat); + + gboolean (*get_show_contacts) (GossipChat *chat); + void (*set_show_contacts) (GossipChat *chat, + gboolean show); + gboolean (*is_group_chat) (GossipChat *chat); + void (*save_geometry) (GossipChat *chat, + gint x, + gint y, + gint w, + gint h); + void (*load_geometry) (GossipChat *chat, + gint *x, + gint *y, + gint *w, + gint *h); }; GType gossip_chat_get_type (void); @@ -103,14 +102,13 @@ void gossip_chat_copy (GossipChat *chat); void gossip_chat_paste (GossipChat *chat); const gchar * gossip_chat_get_name (GossipChat *chat); gchar * gossip_chat_get_tooltip (GossipChat *chat); -GdkPixbuf * gossip_chat_get_status_pixbuf (GossipChat *chat); +const gchar * gossip_chat_get_status_icon_name (GossipChat *chat); GossipContact * gossip_chat_get_contact (GossipChat *chat); GossipContact * gossip_chat_get_own_contact (GossipChat *chat); GtkWidget * gossip_chat_get_widget (GossipChat *chat); gboolean gossip_chat_get_show_contacts (GossipChat *chat); void gossip_chat_set_show_contacts (GossipChat *chat, gboolean show); - gboolean gossip_chat_is_group_chat (GossipChat *chat); gboolean gossip_chat_is_connected (GossipChat *chat); diff --git a/libempathy-gtk/gossip-contact-list.c b/libempathy-gtk/gossip-contact-list.c index bf0556dcb..aa5eb3855 100644 --- a/libempathy-gtk/gossip-contact-list.c +++ b/libempathy-gtk/gossip-contact-list.c @@ -37,11 +37,11 @@ #include <libempathy/empathy-contact-manager.h> #include <libempathy/gossip-debug.h> +#include "empathy-images.h" #include "gossip-contact-list.h" #include "gossip-contact-groups.h" #include "gossip-cell-renderer-expander.h" #include "gossip-cell-renderer-text.h" -#include "gossip-stock.h" #include "gossip-ui-utils.h" //#include "gossip-chat-invite.h" //#include "gossip-contact-info-dialog.h" @@ -257,7 +257,7 @@ static gboolean contact_list_update_list_mode_foreach (GtkTreeModel GossipContactList *list); enum { - COL_PIXBUF_STATUS, + COL_ICON_STATUS, COL_PIXBUF_AVATAR, COL_PIXBUF_AVATAR_VISIBLE, COL_NAME, @@ -288,11 +288,11 @@ static const GtkActionEntry entries[] = { N_("_Group"),NULL, NULL, NULL }, - { "Chat", GOSSIP_STOCK_MESSAGE, + { "Chat", EMPATHY_IMAGE_MESSAGE, N_("_Chat"), NULL, N_("Chat with contact"), G_CALLBACK (contact_list_action_cb) }, - { "Information", GOSSIP_STOCK_CONTACT_INFORMATION, + { "Information", EMPATHY_IMAGE_CONTACT_INFORMATION, N_("Infor_mation"), "<control>I", N_("View contact information"), G_CALLBACK (contact_list_action_cb) }, @@ -308,7 +308,7 @@ static const GtkActionEntry entries[] = { N_("_Remove"), NULL, N_("Remove contact"), G_CALLBACK (contact_list_action_cb) }, - { "Invite", GOSSIP_STOCK_GROUP_MESSAGE, + { "Invite", EMPATHY_IMAGE_GROUP_MESSAGE, N_("_Invite to Chat Room"), NULL, N_("Invite to a currently open chat room"), G_CALLBACK (contact_list_action_cb) }, @@ -602,7 +602,6 @@ contact_list_contact_update (GossipContactList *list, gboolean do_remove = FALSE; gboolean do_set_active = FALSE; gboolean do_set_refresh = FALSE; - GdkPixbuf *pixbuf_presence; GdkPixbuf *pixbuf_avatar; priv = GET_PRIV (list); @@ -701,11 +700,10 @@ contact_list_contact_update (GossipContactList *list, set_model = TRUE; } - pixbuf_presence = gossip_pixbuf_for_contact (contact); pixbuf_avatar = gossip_pixbuf_avatar_from_contact_scaled (contact, 32, 32); for (l = iters; l && set_model; l = l->next) { gtk_tree_store_set (priv->store, l->data, - COL_PIXBUF_STATUS, pixbuf_presence, + COL_ICON_STATUS, gossip_icon_name_for_contact (contact), COL_STATUS, gossip_contact_get_status (contact), COL_IS_ONLINE, now_online, COL_NAME, gossip_contact_get_name (contact), @@ -713,9 +711,6 @@ contact_list_contact_update (GossipContactList *list, -1); } - if (pixbuf_presence) { - g_object_unref (pixbuf_presence); - } if (pixbuf_avatar) { g_object_unref (pixbuf_avatar); } @@ -1036,7 +1031,7 @@ contact_list_get_group (GossipContactList *list, gtk_tree_store_append (priv->store, &iter_group, NULL); gtk_tree_store_set (priv->store, &iter_group, - COL_PIXBUF_STATUS, NULL, + COL_ICON_STATUS, NULL, COL_NAME, name, COL_IS_GROUP, TRUE, COL_IS_ACTIVE, FALSE, @@ -1102,11 +1097,9 @@ contact_list_add_contact (GossipContactList *list, /* If no groups just add it at the top level. */ groups = gossip_contact_get_groups (contact); if (!groups) { - GdkPixbuf *pixbuf_status; GdkPixbuf *pixbuf_avatar; gboolean show_avatar = FALSE; - pixbuf_status = gossip_pixbuf_for_contact (contact); pixbuf_avatar = gossip_pixbuf_avatar_from_contact_scaled (contact, 32, 32); if (priv->show_avatars && !priv->is_compact) { @@ -1125,7 +1118,7 @@ contact_list_add_contact (GossipContactList *list, gtk_tree_store_append (priv->store, &iter, NULL); gtk_tree_store_set (priv->store, &iter, - COL_PIXBUF_STATUS, pixbuf_status, + COL_ICON_STATUS, gossip_icon_name_for_contact (contact), COL_PIXBUF_AVATAR, pixbuf_avatar, COL_PIXBUF_AVATAR_VISIBLE, show_avatar, COL_NAME, gossip_contact_get_name (contact), @@ -1145,16 +1138,12 @@ contact_list_add_contact (GossipContactList *list, if (pixbuf_avatar) { g_object_unref (pixbuf_avatar); } - if (pixbuf_status) { - g_object_unref (pixbuf_status); - } } /* Else add to each group. */ for (l = groups; l; l = l->next) { GtkTreePath *path; GtkTreeIter model_iter_group; - GdkPixbuf *pixbuf_status; GdkPixbuf *pixbuf_avatar; const gchar *name; gboolean created; @@ -1166,7 +1155,6 @@ contact_list_add_contact (GossipContactList *list, continue; } - pixbuf_status = gossip_pixbuf_for_contact (contact); pixbuf_avatar = gossip_pixbuf_avatar_from_contact_scaled (contact, 32, 32); contact_list_get_group (list, name, &iter_group, &iter_separator, &created); @@ -1187,7 +1175,7 @@ contact_list_add_contact (GossipContactList *list, gtk_tree_store_insert_after (priv->store, &iter, &iter_group, NULL); gtk_tree_store_set (priv->store, &iter, - COL_PIXBUF_STATUS, pixbuf_status, + COL_ICON_STATUS, gossip_icon_name_for_contact (contact), COL_PIXBUF_AVATAR, pixbuf_avatar, COL_PIXBUF_AVATAR_VISIBLE, show_avatar, COL_NAME, gossip_contact_get_name (contact), @@ -1207,9 +1195,6 @@ contact_list_add_contact (GossipContactList *list, if (pixbuf_avatar) { g_object_unref (pixbuf_avatar); } - if (pixbuf_status) { - g_object_unref (pixbuf_status); - } if (!created) { continue; @@ -1303,7 +1288,7 @@ contact_list_create_model (GossipContactList *list) } priv->store = gtk_tree_store_new (COL_COUNT, - GDK_TYPE_PIXBUF, /* Status pixbuf */ + G_TYPE_STRING, /* Status icon-name */ GDK_TYPE_PIXBUF, /* Avatar pixbuf */ G_TYPE_BOOLEAN, /* Avatar pixbuf visible */ G_TYPE_STRING, /* Name */ @@ -1834,9 +1819,6 @@ contact_list_cell_set_background (GossipContactList *list, NULL); } } else { - g_object_set (cell, - "cell-background-gdk", NULL, - NULL); #if 0 gint color_sum_normal; gint color_sum_selected; @@ -1873,24 +1855,22 @@ contact_list_pixbuf_cell_data_func (GtkTreeViewColumn *tree_column, GtkTreeIter *iter, GossipContactList *list) { - GdkPixbuf *pixbuf; - gboolean is_group; - gboolean is_active; + gchar *icon_name; + gboolean is_group; + gboolean is_active; gtk_tree_model_get (model, iter, COL_IS_GROUP, &is_group, COL_IS_ACTIVE, &is_active, - COL_PIXBUF_STATUS, &pixbuf, + COL_ICON_STATUS, &icon_name, -1); g_object_set (cell, "visible", !is_group, - "pixbuf", pixbuf, + "icon-name", icon_name, NULL); - if (pixbuf) { - g_object_unref (pixbuf); - } + g_free (icon_name); contact_list_cell_set_background (list, cell, is_group, is_active); } diff --git a/libempathy-gtk/gossip-preferences.c b/libempathy-gtk/gossip-preferences.c index 2179a7efa..a02a4fa96 100644 --- a/libempathy-gtk/gossip-preferences.c +++ b/libempathy-gtk/gossip-preferences.c @@ -33,7 +33,6 @@ #include <libempathy/gossip-conf.h> #include "gossip-preferences.h" -#include "gossip-stock.h" #include "gossip-ui-utils.h" #include "gossip-theme-manager.h" #include "gossip-spell.h" diff --git a/libempathy-gtk/gossip-presence-chooser.c b/libempathy-gtk/gossip-presence-chooser.c index e540c8a4e..46b275456 100644 --- a/libempathy-gtk/gossip-presence-chooser.c +++ b/libempathy-gtk/gossip-presence-chooser.c @@ -34,7 +34,7 @@ #include <libempathy/empathy-marshal.h> #include "gossip-ui-utils.h" -#include "gossip-stock.h" +#include "empathy-images.h" #include "gossip-presence-chooser.h" #include "gossip-status-presets.h" @@ -321,7 +321,6 @@ presence_chooser_show_dialog (GossipPresenceChooser *chooser, GtkWidget *combo; GtkWidget *entry; GtkWidget *checkbutton; - GdkPixbuf *pixbuf; const gchar *default_status; priv = GET_PRIV (chooser); @@ -355,9 +354,9 @@ presence_chooser_show_dialog (GossipPresenceChooser *chooser, G_CALLBACK (presence_chooser_dialog_response_cb), chooser); - pixbuf = gossip_pixbuf_for_presence_state (state); - gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf); - g_object_unref (pixbuf); + gtk_image_set_from_icon_name (GTK_IMAGE (image), + gossip_icon_name_for_presence_state (state), + GTK_ICON_SIZE_MENU); if (!store[state]) { GList *presets, *l; @@ -486,10 +485,10 @@ presence_chooser_menu_add_item (GossipPresenceChooser *chooser, { GtkWidget *item; GtkWidget *image; - const gchar *stock; + const gchar *icon_name; item = gtk_image_menu_item_new_with_label (str); - stock = gossip_stock_for_state (state); + icon_name = gossip_icon_name_for_presence_state (state); if (custom) { g_signal_connect ( @@ -505,7 +504,7 @@ presence_chooser_menu_add_item (GossipPresenceChooser *chooser, chooser); } - image = gtk_image_new_from_stock (stock, GTK_ICON_SIZE_MENU); + image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU); gtk_widget_show (image); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); @@ -943,7 +942,6 @@ presence_chooser_flash_timeout_cb (GossipPresenceChooser *chooser) { GossipPresenceChooserPriv *priv; McPresence state; - GdkPixbuf *pixbuf; static gboolean on = FALSE; priv = GET_PRIV (chooser); @@ -954,9 +952,9 @@ presence_chooser_flash_timeout_cb (GossipPresenceChooser *chooser) state = priv->flash_state_2; } - pixbuf = gossip_pixbuf_for_presence_state (state); - gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), pixbuf); - g_object_unref (pixbuf); + gtk_image_set_from_icon_name (GTK_IMAGE (priv->image), + gossip_icon_name_for_presence_state (state), + GTK_ICON_SIZE_MENU); on = !on; @@ -991,7 +989,6 @@ gossip_presence_chooser_flash_stop (GossipPresenceChooser *chooser, McPresence state) { GossipPresenceChooserPriv *priv; - GdkPixbuf *pixbuf; g_return_if_fail (GOSSIP_IS_PRESENCE_CHOOSER (chooser)); @@ -1002,9 +999,9 @@ gossip_presence_chooser_flash_stop (GossipPresenceChooser *chooser, priv->flash_timeout_id = 0; } - pixbuf = gossip_pixbuf_for_presence_state (state); - gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), pixbuf); - g_object_unref (pixbuf); + gtk_image_set_from_icon_name (GTK_IMAGE (priv->image), + gossip_icon_name_for_presence_state (state), + GTK_ICON_SIZE_MENU); priv->last_state = state; } diff --git a/libempathy-gtk/gossip-private-chat.c b/libempathy-gtk/gossip-private-chat.c index 17c55b19c..a3bdbb6be 100644 --- a/libempathy-gtk/gossip-private-chat.c +++ b/libempathy-gtk/gossip-private-chat.c @@ -44,7 +44,7 @@ #include "gossip-chat.h" #include "gossip-preferences.h" //#include "gossip-sound.h" -#include "gossip-stock.h" +#include "empathy-images.h" #include "gossip-ui-utils.h" #define DEBUG_DOMAIN "PrivateChat" @@ -78,13 +78,9 @@ static void private_chat_widget_destroy_cb (GtkWidget GossipPrivateChat *chat); static const gchar * private_chat_get_name (GossipChat *chat); static gchar * private_chat_get_tooltip (GossipChat *chat); -static GdkPixbuf * private_chat_get_status_pixbuf (GossipChat *chat); +static const gchar * private_chat_get_status_icon_name (GossipChat *chat); static GossipContact *private_chat_get_contact (GossipChat *chat); static GtkWidget * private_chat_get_widget (GossipChat *chat); -/*static GdkPixbuf * private_chat_pad_to_size (GdkPixbuf *pixbuf, - gint width, - gint height, - gint extra_padding_right);*/ G_DEFINE_TYPE (GossipPrivateChat, gossip_private_chat, GOSSIP_TYPE_CHAT); @@ -96,14 +92,14 @@ gossip_private_chat_class_init (GossipPrivateChatClass *klass) object_class->finalize = private_chat_finalize; - chat_class->get_name = private_chat_get_name; - chat_class->get_tooltip = private_chat_get_tooltip; - chat_class->get_status_pixbuf = private_chat_get_status_pixbuf; - chat_class->get_contact = private_chat_get_contact; - chat_class->get_widget = private_chat_get_widget; - chat_class->get_show_contacts = NULL; - chat_class->set_show_contacts = NULL; - chat_class->is_group_chat = NULL; + chat_class->get_name = private_chat_get_name; + chat_class->get_tooltip = private_chat_get_tooltip; + chat_class->get_status_icon_name = private_chat_get_status_icon_name; + chat_class->get_contact = private_chat_get_contact; + chat_class->get_widget = private_chat_get_widget; + chat_class->get_show_contacts = NULL; + chat_class->set_show_contacts = NULL; + chat_class->is_group_chat = NULL; g_type_class_add_private (object_class, sizeof (GossipPrivateChatPriv)); } @@ -283,8 +279,8 @@ private_chat_get_tooltip (GossipChat *chat) status); } -static GdkPixbuf * -private_chat_get_status_pixbuf (GossipChat *chat) +static const gchar * +private_chat_get_status_icon_name (GossipChat *chat) { GossipPrivateChatPriv *priv; GossipContact *contact; @@ -295,7 +291,7 @@ private_chat_get_status_pixbuf (GossipChat *chat) contact = gossip_chat_get_contact (chat); - return gossip_pixbuf_for_contact (contact); + return gossip_icon_name_for_contact (contact); } static GossipContact * diff --git a/libempathy-gtk/gossip-profile-chooser.c b/libempathy-gtk/gossip-profile-chooser.c index 7accbefe4..96c072c9e 100644 --- a/libempathy-gtk/gossip-profile-chooser.c +++ b/libempathy-gtk/gossip-profile-chooser.c @@ -64,16 +64,16 @@ gossip_profile_chooser_new (void) /* set up combo box with new store */ store = gtk_list_store_new (COL_COUNT, - GDK_TYPE_PIXBUF, /* Icon */ - G_TYPE_STRING, /* Label */ - MC_TYPE_PROFILE); /* Profile */ + G_TYPE_STRING, /* Icon name */ + G_TYPE_STRING, /* Label */ + MC_TYPE_PROFILE); /* Profile */ combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); renderer = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, FALSE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer, - "pixbuf", COL_ICON, + "icon-name", COL_ICON, NULL); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, TRUE); @@ -89,7 +89,7 @@ gossip_profile_chooser_new (void) gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, - COL_ICON, gossip_pixbuf_from_profile (profile, GTK_ICON_SIZE_BUTTON), + COL_ICON, mc_profile_get_icon_name (profile), COL_LABEL, mc_profile_get_display_name (profile), COL_PROFILE, profile, -1); diff --git a/libempathy-gtk/gossip-stock.c b/libempathy-gtk/gossip-stock.c deleted file mode 100644 index 1490e65e7..000000000 --- a/libempathy-gtk/gossip-stock.c +++ /dev/null @@ -1,129 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2003-2007 Imendio AB - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: Mikael Hallendal <micke@imendio.com> - * Richard Hult <richard@imendio.com> - * Martyn Russell <martyn@imendio.com> - */ - -#include "config.h" - -#include <gtk/gtk.h> - -#include <libempathy/gossip-paths.h> - -#include "gossip-stock.h" - -static GtkIconFactory *icon_factory = NULL; -static GtkWidget *main_widget = NULL; - -static GtkStockItem stock_items[] = { - { GOSSIP_STOCK_OFFLINE, NULL }, - { GOSSIP_STOCK_AVAILABLE, NULL }, - { GOSSIP_STOCK_BUSY, NULL }, - { GOSSIP_STOCK_AWAY, NULL }, - { GOSSIP_STOCK_EXT_AWAY, NULL }, - { GOSSIP_STOCK_PENDING, NULL }, - { GOSSIP_STOCK_MESSAGE, NULL }, - { GOSSIP_STOCK_TYPING, NULL }, - { GOSSIP_STOCK_CONTACT_INFORMATION, NULL }, - { GOSSIP_STOCK_GROUP_MESSAGE, NULL } -}; - -void -gossip_stock_init (GtkWidget *widget) -{ - GtkIconSet *icon_set; - gint i; - - g_assert (icon_factory == NULL); - - main_widget = g_object_ref (widget); - - gtk_stock_add (stock_items, G_N_ELEMENTS (stock_items)); - - icon_factory = gtk_icon_factory_new (); - gtk_icon_factory_add_default (icon_factory); - g_object_unref (icon_factory); - - for (i = 0; i < G_N_ELEMENTS (stock_items); i++) { - gchar *path, *filename; - GdkPixbuf *pixbuf; - - filename = g_strdup_printf ("%s.png", stock_items[i].stock_id); - path = gossip_paths_get_image_path (filename); - pixbuf = gdk_pixbuf_new_from_file (path, NULL); - g_free (path); - g_free (filename); - - icon_set = gtk_icon_set_new_from_pixbuf (pixbuf); - - gtk_icon_factory_add (icon_factory, - stock_items[i].stock_id, - icon_set); - - gtk_icon_set_unref (icon_set); - - g_object_unref (pixbuf); - } -} - -void -gossip_stock_finalize (void) -{ - g_assert (icon_factory != NULL); - - gtk_icon_factory_remove_default (icon_factory); - g_object_unref (main_widget); - - main_widget = NULL; - icon_factory = NULL; -} - -GdkPixbuf * -gossip_stock_render (const gchar *stock, - GtkIconSize size) -{ - return gtk_widget_render_icon (main_widget, stock, size, NULL); -} - -const gchar * -gossip_stock_for_state (McPresence state) -{ - switch (state) { - case MC_PRESENCE_AVAILABLE: - return GOSSIP_STOCK_AVAILABLE; - case MC_PRESENCE_DO_NOT_DISTURB: - return GOSSIP_STOCK_BUSY; - case MC_PRESENCE_AWAY: - return GOSSIP_STOCK_AWAY; - case MC_PRESENCE_EXTENDED_AWAY: - return GOSSIP_STOCK_EXT_AWAY; - case MC_PRESENCE_HIDDEN: - case MC_PRESENCE_OFFLINE: - case MC_PRESENCE_UNSET: - return GOSSIP_STOCK_OFFLINE; - default: - g_assert_not_reached (); - } - - return NULL; -} - - diff --git a/libempathy-gtk/gossip-stock.h b/libempathy-gtk/gossip-stock.h deleted file mode 100644 index 8cf66eb65..000000000 --- a/libempathy-gtk/gossip-stock.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2003-2007 Imendio AB - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: Mikael Hallendal <micke@imendio.com> - * Richard Hult <richard@imendio.com> - * Martyn Russell <martyn@imendio.com> - */ - -#ifndef __GOSSIP_STOCK_H__ -#define __GOSSIP_STOCK_H__ - -#include <glib.h> -#include <gtk/gtk.h> - -#include <libmissioncontrol/mission-control.h> - -G_BEGIN_DECLS - -#define GOSSIP_STOCK_OFFLINE "gossip-offline" -#define GOSSIP_STOCK_AVAILABLE "gossip-available" -#define GOSSIP_STOCK_BUSY "gossip-busy" -#define GOSSIP_STOCK_AWAY "gossip-away" -#define GOSSIP_STOCK_EXT_AWAY "gossip-extended-away" -#define GOSSIP_STOCK_PENDING "gossip-pending" - -#define GOSSIP_STOCK_MESSAGE "gossip-message" -#define GOSSIP_STOCK_TYPING "gossip-typing" - - -#define GOSSIP_STOCK_CONTACT_INFORMATION "vcard_16" - -#define GOSSIP_STOCK_AIM "gossip-aim" -#define GOSSIP_STOCK_ICQ "gossip-icq" -#define GOSSIP_STOCK_MSN "gossip-msn" -#define GOSSIP_STOCK_YAHOO "gossip-yahoo" - -#define GOSSIP_STOCK_GROUP_MESSAGE "gossip-group-message" - -void gossip_stock_init (GtkWidget *widget); -void gossip_stock_finalize (void); -GdkPixbuf * gossip_stock_render (const gchar *stock, - GtkIconSize size); -const gchar * gossip_stock_for_state (McPresence state); - -G_END_DECLS - -#endif /* __GOSSIP_STOCK_ICONS_H__ */ diff --git a/libempathy-gtk/gossip-ui-utils.c b/libempathy-gtk/gossip-ui-utils.c index b6dfb8f92..9bf2fb36d 100644 --- a/libempathy-gtk/gossip-ui-utils.c +++ b/libempathy-gtk/gossip-ui-utils.c @@ -41,7 +41,9 @@ #include <libempathy/gossip-debug.h> #include "gossip-ui-utils.h" -#include "gossip-stock.h" +#include "empathy-images.h" + +#define DEBUG_DOMAIN "UiUtils" struct SizeData { gint width; @@ -200,24 +202,34 @@ gossip_glade_setup_size_group (GladeXML *gui, } GdkPixbuf * -gossip_pixbuf_from_smiley (GossipSmiley type, - GtkIconSize icon_size) +gossip_pixbuf_from_icon_name (const gchar *icon_name, + GtkIconSize icon_size) { GtkIconTheme *theme; GdkPixbuf *pixbuf = NULL; GError *error = NULL; - gint w, h; - gint size; - const gchar *icon_id; theme = gtk_icon_theme_get_default (); - if (!gtk_icon_size_lookup (icon_size, &w, &h)) { - size = 16; - } else { - size = (w + h) / 2; + pixbuf = gtk_icon_theme_load_icon (theme, + icon_name, + icon_size, + 0, + &error); + if (error) { + gossip_debug (DEBUG_DOMAIN, "Error loading icon: %s", error->message); + g_clear_error (&error); } + return pixbuf; +} + +GdkPixbuf * +gossip_pixbuf_from_smiley (GossipSmiley type, + GtkIconSize icon_size) +{ + const gchar *icon_id; + switch (type) { case GOSSIP_SMILEY_NORMAL: /* :) */ icon_id = "stock_smiley-1"; @@ -306,106 +318,79 @@ gossip_pixbuf_from_smiley (GossipSmiley type, icon_id = NULL; } - pixbuf = gtk_icon_theme_load_icon (theme, - icon_id, /* icon name */ - size, /* size */ - 0, /* flags */ - &error); - return pixbuf; + return gossip_pixbuf_from_icon_name (icon_id, icon_size); } -GdkPixbuf * -gossip_pixbuf_from_profile (McProfile *profile, - GtkIconSize icon_size) -{ - GtkIconTheme *theme; - gint size = 48; - gint w, h; - const gchar *icon_id = NULL; - GError *error = NULL; - - theme = gtk_icon_theme_get_default (); - - if (gtk_icon_size_lookup (icon_size, &w, &h)) { - size = (w + h) / 2; - } - - icon_id = mc_profile_get_icon_name (profile); - - theme = gtk_icon_theme_get_default (); - return gtk_icon_theme_load_icon (theme, - icon_id, /* Icon name */ - size, /* Size */ - 0, /* Flags */ - &error); -} - -GdkPixbuf * -gossip_pixbuf_from_account (McAccount *account, - GtkIconSize icon_size) +const gchar * +gossip_icon_name_from_account (McAccount *account) { McProfile *profile; profile = mc_account_get_profile (account); - return gossip_pixbuf_from_profile (profile, icon_size); + return mc_profile_get_icon_name (profile); } -GdkPixbuf * -gossip_pixbuf_for_presence_state (McPresence state) +const gchar * +gossip_icon_name_for_presence_state (McPresence state) { - const gchar *stock; - - stock = gossip_stock_for_state (state); + switch (state) { + case MC_PRESENCE_AVAILABLE: + return EMPATHY_IMAGE_AVAILABLE; + case MC_PRESENCE_DO_NOT_DISTURB: + return EMPATHY_IMAGE_BUSY; + case MC_PRESENCE_AWAY: + return EMPATHY_IMAGE_AWAY; + case MC_PRESENCE_EXTENDED_AWAY: + return EMPATHY_IMAGE_EXT_AWAY; + case MC_PRESENCE_HIDDEN: + case MC_PRESENCE_OFFLINE: + case MC_PRESENCE_UNSET: + return EMPATHY_IMAGE_OFFLINE; + default: + g_assert_not_reached (); + } - return gossip_stock_render (stock, GTK_ICON_SIZE_MENU); + return NULL; } -GdkPixbuf * -gossip_pixbuf_for_presence (GossipPresence *presence) +const gchar * +gossip_icon_name_for_presence (GossipPresence *presence) { McPresence state; g_return_val_if_fail (GOSSIP_IS_PRESENCE (presence), - gossip_pixbuf_offline ()); + EMPATHY_IMAGE_OFFLINE); state = gossip_presence_get_state (presence); - return gossip_pixbuf_for_presence_state (state); + return gossip_icon_name_for_presence_state (state); } -GdkPixbuf * -gossip_pixbuf_for_contact (GossipContact *contact) +const gchar * +gossip_icon_name_for_contact (GossipContact *contact) { GossipPresence *presence; GossipSubscription subscription; g_return_val_if_fail (GOSSIP_IS_CONTACT (contact), - gossip_pixbuf_offline ()); + EMPATHY_IMAGE_OFFLINE); presence = gossip_contact_get_presence (contact); if (presence) { - return gossip_pixbuf_for_presence (presence); + return gossip_icon_name_for_presence (presence); } subscription = gossip_contact_get_subscription (contact); if (subscription != GOSSIP_SUBSCRIPTION_BOTH && subscription != GOSSIP_SUBSCRIPTION_TO) { - return gossip_stock_render (GOSSIP_STOCK_PENDING, - GTK_ICON_SIZE_MENU); + return EMPATHY_IMAGE_PENDING; } - return gossip_pixbuf_offline (); -} - -GdkPixbuf * -gossip_pixbuf_offline (void) -{ - return gossip_stock_render (GOSSIP_STOCK_OFFLINE, - GTK_ICON_SIZE_MENU); + return EMPATHY_IMAGE_OFFLINE; } GdkPixbuf * diff --git a/libempathy-gtk/gossip-ui-utils.h b/libempathy-gtk/gossip-ui-utils.h index 1e1bb1ee3..d1625cfe3 100644 --- a/libempathy-gtk/gossip-ui-utils.h +++ b/libempathy-gtk/gossip-ui-utils.h @@ -67,16 +67,14 @@ void gossip_glade_setup_size_group (GladeXML *g gchar *first_widget, ...); /* Pixbufs */ -GdkPixbuf * gossip_pixbuf_from_smiley (GossipSmiley type, - GtkIconSize icon_size); -GdkPixbuf * gossip_pixbuf_from_profile (McProfile *account, +GdkPixbuf * gossip_pixbuf_from_icon_name (const gchar *icon_name, GtkIconSize icon_size); -GdkPixbuf * gossip_pixbuf_from_account (McAccount *account, +GdkPixbuf * gossip_pixbuf_from_smiley (GossipSmiley type, GtkIconSize icon_size); -GdkPixbuf * gossip_pixbuf_for_presence_state (McPresence state); -GdkPixbuf * gossip_pixbuf_for_presence (GossipPresence *presence); -GdkPixbuf * gossip_pixbuf_for_contact (GossipContact *contact); -GdkPixbuf * gossip_pixbuf_offline (void); +const gchar * gossip_icon_name_from_account (McAccount *account); +const gchar * gossip_icon_name_for_presence_state (McPresence state); +const gchar * gossip_icon_name_for_presence (GossipPresence *presence); +const gchar * gossip_icon_name_for_contact (GossipContact *contact); GdkPixbuf * gossip_pixbuf_from_avatar_scaled (GossipAvatar *avatar, gint width, gint height); |