Mercurial > pidgin
changeset 23316:4a657f024a3a
Show the stock status icons in the status list and status menus. Closes
#6038.
committer: Sadrul Habib Chowdhury <imadil@gmail.com>
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Sat, 07 Jun 2008 20:37:18 +0000 |
parents | 26a1c551221b |
children | d4cc956acb37 |
files | pidgin/gtksavedstatuses.c |
diffstat | 1 files changed, 69 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin/gtksavedstatuses.c Sat Jun 07 19:11:48 2008 +0000 +++ b/pidgin/gtksavedstatuses.c Sat Jun 07 20:37:18 2008 +0000 @@ -59,6 +59,7 @@ STATUS_WINDOW_COLUMN_MESSAGE, /** A hidden column containing a pointer to the editor for this saved status. */ STATUS_WINDOW_COLUMN_WINDOW, + STATUS_WINDOW_COLUMN_ICON, STATUS_WINDOW_NUM_COLUMNS }; @@ -80,6 +81,7 @@ STATUS_EDITOR_COLUMN_STATUS_ID, STATUS_EDITOR_COLUMN_STATUS_NAME, STATUS_EDITOR_COLUMN_STATUS_MESSAGE, + STATUS_EDITOR_COLUMN_STATUS_ICON, STATUS_EDITOR_NUM_COLUMNS }; @@ -392,12 +394,35 @@ g_list_free(sel_paths); } +static const gchar * +get_stock_icon_from_primitive(PurpleStatusPrimitive type) +{ + switch (type) { + case PURPLE_STATUS_AVAILABLE: + return PIDGIN_STOCK_STATUS_AVAILABLE; + case PURPLE_STATUS_AWAY: + return PIDGIN_STOCK_STATUS_AWAY; + case PURPLE_STATUS_EXTENDED_AWAY: + return PIDGIN_STOCK_STATUS_XA; + case PURPLE_STATUS_INVISIBLE: + return PIDGIN_STOCK_STATUS_INVISIBLE; + case PURPLE_STATUS_OFFLINE: + return PIDGIN_STOCK_STATUS_OFFLINE; + case PURPLE_STATUS_UNAVAILABLE: + return PIDGIN_STOCK_STATUS_BUSY; + default: + /* this shouldn't happen */ + return NULL; + } +} + static void add_status_to_saved_status_list(GtkListStore *model, PurpleSavedStatus *saved_status) { GtkTreeIter iter; const char *title; const char *type; + const gchar *icon; char *message; if (purple_savedstatus_is_transient(saved_status)) @@ -406,14 +431,16 @@ title = purple_savedstatus_get_title(saved_status); type = purple_primitive_get_name_from_type(purple_savedstatus_get_type(saved_status)); message = purple_markup_strip_html(purple_savedstatus_get_message(saved_status)); + icon = get_stock_icon_from_primitive(purple_savedstatus_get_type(saved_status)); gtk_list_store_append(model, &iter); gtk_list_store_set(model, &iter, + STATUS_WINDOW_COLUMN_ICON, icon, STATUS_WINDOW_COLUMN_TITLE, title, STATUS_WINDOW_COLUMN_TYPE, type, STATUS_WINDOW_COLUMN_MESSAGE, message, -1); - free(message); + g_free(message); } static void @@ -479,7 +506,8 @@ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, - G_TYPE_POINTER); + G_TYPE_POINTER, + G_TYPE_STRING); /* Create the treeview */ treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(dialog->model)); @@ -517,6 +545,10 @@ gtk_tree_view_column_set_sort_column_id(column, STATUS_WINDOW_COLUMN_TYPE); gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); + renderer = gtk_cell_renderer_pixbuf_new(); + gtk_tree_view_column_pack_start(column, renderer, TRUE); + gtk_tree_view_column_add_attribute(column, renderer, "stock-id", + STATUS_WINDOW_COLUMN_ICON); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(column, renderer, TRUE); gtk_tree_view_column_add_attribute(column, renderer, "text", @@ -856,6 +888,26 @@ } static GtkWidget * +create_stock_item(const gchar *str, const gchar *icon) +{ + GtkWidget *menuitem = gtk_menu_item_new(); + GtkWidget *label = gtk_label_new_with_mnemonic(str); + GtkWidget *hbox = gtk_hbox_new(FALSE, 4); + GtkIconSize icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); + GtkWidget *image = gtk_image_new_from_stock(icon, icon_size);; + + gtk_widget_show(label); + gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); + gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); + gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); + + gtk_container_add(GTK_CONTAINER(menuitem), hbox); + + return menuitem; +} + +static GtkWidget * create_status_type_menu(PurpleStatusPrimitive type) { int i; @@ -874,7 +926,9 @@ * status types, so don't show them in the list. */ continue; - item = gtk_menu_item_new_with_label(purple_primitive_get_name_from_type(i)); + + item = create_stock_item(purple_primitive_get_name_from_type(i), + get_stock_icon_from_primitive(i)); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); } @@ -930,6 +984,7 @@ STATUS_EDITOR_COLUMN_STATUS_ID, NULL, STATUS_EDITOR_COLUMN_STATUS_NAME, NULL, STATUS_EDITOR_COLUMN_STATUS_MESSAGE, NULL, + STATUS_EDITOR_COLUMN_STATUS_ICON, NULL, -1); } } @@ -975,6 +1030,10 @@ gtk_tree_view_column_set_title(column, _("Status")); gtk_tree_view_insert_column(GTK_TREE_VIEW(dialog->treeview), column, -1); gtk_tree_view_column_set_resizable(column, TRUE); + renderer = gtk_cell_renderer_pixbuf_new(); + gtk_tree_view_column_pack_start(column, renderer, FALSE); + gtk_tree_view_column_add_attribute(column, renderer, "stock-id", + STATUS_EDITOR_COLUMN_STATUS_ICON); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(column, renderer, TRUE); gtk_tree_view_column_add_attribute(column, renderer, "text", @@ -1001,6 +1060,7 @@ { GdkPixbuf *pixbuf; const char *id = NULL, *name = NULL, *message = NULL; + PurpleStatusPrimitive prim = PURPLE_STATUS_UNSET; pixbuf = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_MEDIUM); if ((pixbuf != NULL) && !purple_account_is_connected(account)) @@ -1015,6 +1075,7 @@ type = purple_savedstatus_substatus_get_type(substatus); id = purple_status_type_get_id(type); name = purple_status_type_get_name(type); + prim = purple_status_type_get_primitive(type); if (purple_status_type_get_attr(type, "message")) message = purple_savedstatus_substatus_get_message(substatus); } @@ -1027,6 +1088,7 @@ STATUS_EDITOR_COLUMN_STATUS_ID, id, STATUS_EDITOR_COLUMN_STATUS_NAME, name, STATUS_EDITOR_COLUMN_STATUS_MESSAGE, message, + STATUS_EDITOR_COLUMN_STATUS_ICON, get_stock_icon_from_primitive(prim), -1); if (pixbuf != NULL) @@ -1183,6 +1245,7 @@ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_STRING); /* Create the treeview */ @@ -1336,7 +1399,7 @@ PurpleStatusType *type; char *id = NULL; char *message = NULL; - const char *name = NULL; + const char *name = NULL, *stock = NULL; if (!gtk_combo_box_get_active_iter(dialog->box, &iter)) { @@ -1351,6 +1414,7 @@ if (purple_status_type_get_attr(type, "message") != NULL) message = gtk_imhtml_get_markup(GTK_IMHTML(dialog->message)); name = purple_status_type_get_name(type); + stock = get_stock_icon_from_primitive(purple_status_type_get_primitive(type)); status_editor = dialog->status_editor; @@ -1362,6 +1426,7 @@ STATUS_EDITOR_COLUMN_STATUS_NAME, name, STATUS_EDITOR_COLUMN_STATUS_MESSAGE, message, STATUS_EDITOR_COLUMN_WINDOW, NULL, + STATUS_EDITOR_COLUMN_STATUS_ICON, stock, -1); }