Mercurial > pidgin
changeset 23317:d4cc956acb37
merge of '00a9efda899566f921e7c8bbe98a0eb684855f62'
and '3eeb91e664292daec9b2da60f43bbda91140b1de'
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 07 Jun 2008 20:37:46 +0000 |
parents | 4a657f024a3a (diff) b3ec26e66e26 (current diff) |
children | c200661b5c5c 5b8239453a1e |
files | |
diffstat | 1 files changed, 76 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin/gtksavedstatuses.c Sat Jun 07 18:52:57 2008 +0000 +++ b/pidgin/gtksavedstatuses.c Sat Jun 07 20:37:46 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", @@ -717,8 +749,8 @@ } -static gboolean -status_editor_destroy_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data) +static void +status_editor_destroy_cb(GtkWidget *widget, gpointer user_data) { StatusEditor *dialog = user_data; @@ -726,19 +758,13 @@ g_free(dialog->original_title); g_object_unref(G_OBJECT(dialog->model)); g_free(dialog); - - return FALSE; } static void status_editor_cancel_cb(GtkButton *button, gpointer user_data) { StatusEditor *dialog = user_data; - - status_editor_remove_dialog(dialog); gtk_widget_destroy(dialog->window); - g_free(dialog->original_title); - g_free(dialog); } static void @@ -842,20 +868,11 @@ g_free(message); g_free(unformatted); - status_editor_remove_dialog(dialog); - gtk_widget_destroy(dialog->window); - g_free(dialog->original_title); - -/* - if (status_window != NULL) - add_status_to_saved_status_list(status_window->model, saved_status); -*/ - /* If they clicked on "Save & Use" or "Use," then activate the status */ if (button != dialog->save_button) purple_savedstatus_activate(saved_status); - g_free(dialog); + gtk_widget_destroy(dialog->window); } static void @@ -871,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; @@ -889,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); } @@ -945,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); } } @@ -990,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", @@ -1016,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)) @@ -1030,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); } @@ -1042,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) @@ -1133,7 +1180,7 @@ dialog->window = win = pidgin_create_dialog(_("Status"), PIDGIN_HIG_BORDER, "status", TRUE); - g_signal_connect(G_OBJECT(win), "delete_event", + g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(status_editor_destroy_cb), dialog); /* Setup the vbox */ @@ -1198,6 +1245,7 @@ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_STRING); /* Create the treeview */ @@ -1325,25 +1373,20 @@ } } -static gboolean -substatus_editor_destroy_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data) +static void +substatus_editor_destroy_cb(GtkWidget *widget, gpointer user_data) { SubStatusEditor *dialog = user_data; substatus_editor_remove_dialog(dialog); g_free(dialog); - - return FALSE; } static void substatus_editor_cancel_cb(GtkButton *button, gpointer user_data) { SubStatusEditor *dialog = user_data; - - substatus_editor_remove_dialog(dialog); gtk_widget_destroy(dialog->window); - g_free(dialog); } @@ -1356,12 +1399,11 @@ 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)) { gtk_widget_destroy(dialog->window); - g_free(dialog); return; } @@ -1372,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; @@ -1383,13 +1426,13 @@ STATUS_EDITOR_COLUMN_STATUS_NAME, name, STATUS_EDITOR_COLUMN_STATUS_MESSAGE, message, STATUS_EDITOR_COLUMN_WINDOW, NULL, + STATUS_EDITOR_COLUMN_STATUS_ICON, stock, -1); } gtk_widget_destroy(dialog->window); g_free(id); g_free(message); - g_free(dialog); } static void @@ -1438,7 +1481,7 @@ dialog->window = win = pidgin_create_dialog(tmp, PIDGIN_HIG_BORDER, "substatus", TRUE); g_free(tmp); - g_signal_connect(G_OBJECT(win), "delete_event", + g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(substatus_editor_destroy_cb), dialog); /* Setup the vbox */