# HG changeset patch # User Sadrul Habib Chowdhury # Date 1240464636 0 # Node ID 18543445e9290fce20ba74fedf951032d6fbaba8 # Parent 0011cd06990ab7b7a203859e92d7c1bc2e5ddf25 Reduce code duplication. diff -r 0011cd06990a -r 18543445e929 pidgin/gtksavedstatuses.c --- a/pidgin/gtksavedstatuses.c Thu Apr 23 05:08:06 2009 +0000 +++ b/pidgin/gtksavedstatuses.c Thu Apr 23 05:30:36 2009 +0000 @@ -398,23 +398,7 @@ 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; - } + return pidgin_stock_id_from_status_primitive(type); } static void diff -r 0011cd06990a -r 18543445e929 pidgin/gtkstatusbox.c --- a/pidgin/gtkstatusbox.c Thu Apr 23 05:08:06 2009 +0000 +++ b/pidgin/gtkstatusbox.c Thu Apr 23 05:30:36 2009 +0000 @@ -2145,29 +2145,7 @@ } } - switch (prim) { - case PURPLE_STATUS_UNSET: - stock = NULL; - break; - case PURPLE_STATUS_UNAVAILABLE: - stock = PIDGIN_STOCK_STATUS_BUSY; - break; - case PURPLE_STATUS_AWAY: - stock = PIDGIN_STOCK_STATUS_AWAY; - break; - case PURPLE_STATUS_EXTENDED_AWAY: - stock = PIDGIN_STOCK_STATUS_XA; - break; - case PURPLE_STATUS_INVISIBLE: - stock = PIDGIN_STOCK_STATUS_INVISIBLE; - break; - case PURPLE_STATUS_OFFLINE: - stock = PIDGIN_STOCK_STATUS_OFFLINE; - break; - default: - stock = PIDGIN_STOCK_STATUS_AVAILABLE; - break; - } + stock = pidgin_stock_id_from_status_primitive(prim); } gtk_list_store_append(status_box->dropdown_store, &iter); diff -r 0011cd06990a -r 18543445e929 pidgin/gtkutils.c --- a/pidgin/gtkutils.c Thu Apr 23 05:08:06 2009 +0000 +++ b/pidgin/gtkutils.c Thu Apr 23 05:30:36 2009 +0000 @@ -1715,27 +1715,11 @@ { GtkIconSize icon_size = gtk_icon_size_from_name(size); GdkPixbuf *pixbuf = NULL; - - if (prim == PURPLE_STATUS_UNAVAILABLE) - pixbuf = gtk_widget_render_icon (w, PIDGIN_STOCK_STATUS_BUSY, - icon_size, "GtkWidget"); - else if (prim == PURPLE_STATUS_AWAY) - pixbuf = gtk_widget_render_icon (w, PIDGIN_STOCK_STATUS_AWAY, - icon_size, "GtkWidget"); - else if (prim == PURPLE_STATUS_EXTENDED_AWAY) - pixbuf = gtk_widget_render_icon (w, PIDGIN_STOCK_STATUS_XA, - icon_size, "GtkWidget"); - else if (prim == PURPLE_STATUS_INVISIBLE) - pixbuf = gtk_widget_render_icon (w, PIDGIN_STOCK_STATUS_INVISIBLE, - icon_size, "GtkWidget"); - else if (prim == PURPLE_STATUS_OFFLINE) - pixbuf = gtk_widget_render_icon (w, PIDGIN_STOCK_STATUS_OFFLINE, - icon_size, "GtkWidget"); - else - pixbuf = gtk_widget_render_icon (w, PIDGIN_STOCK_STATUS_AVAILABLE, - icon_size, "GtkWidget"); + const char *stock = pidgin_stock_id_from_status_primitive(prim); + + pixbuf = gtk_widget_render_icon (w, stock ? stock : PIDGIN_STOCK_STATUS_AVAILABLE, + icon_size, "GtkWidget"); return pixbuf; - } const char *