sadrul.gtkblist-theme: 227a6f68: Reduce code duplication.

sadrul at pidgin.im sadrul at pidgin.im
Thu Apr 23 01:30:40 EDT 2009


-----------------------------------------------------------------
Revision: 227a6f68a6e4adac5c7972fcb11bbdd1fc95daea
Ancestor: daaa0f9cfbd6151bc6580adc608ad1a0d8223f16
Author: sadrul at pidgin.im
Date: 2009-04-23T05:30:36
Branch: im.pidgin.sadrul.gtkblist-theme
URL: http://d.pidgin.im/viewmtn/revision/info/227a6f68a6e4adac5c7972fcb11bbdd1fc95daea

Modified files:
        pidgin/gtksavedstatuses.c pidgin/gtkstatusbox.c
        pidgin/gtkutils.c

ChangeLog: 

Reduce code duplication.

-------------- next part --------------
============================================================
--- pidgin/gtksavedstatuses.c	9f925d89cc34991badad93f2bd8376d9f2738c57
+++ pidgin/gtksavedstatuses.c	78adf400bf44727c228e61eae98e7a0f4e349bda
@@ -398,23 +398,7 @@ get_stock_icon_from_primitive(PurpleStat
 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
============================================================
--- pidgin/gtkstatusbox.c	5137130d12461fca19cabc578d7546b7d777c88f
+++ pidgin/gtkstatusbox.c	e1dd3b9bae367d95014264456bf09e261f54991c
@@ -2145,29 +2145,7 @@ pidgin_status_box_add(PidginStatusBox *s
 			}
 		}
 
-		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);
============================================================
--- pidgin/gtkutils.c	ec9736a1977e922a0478a5485e5b1016f6f201e4
+++ pidgin/gtkutils.c	c86379bd27d9ab5b4f8aa6f140a2abbf7db4cf87
@@ -1715,27 +1715,11 @@ GdkPixbuf * pidgin_create_status_icon(Pu
 {
 	GtkIconSize icon_size = gtk_icon_size_from_name(size);
 	GdkPixbuf *pixbuf = NULL;
+	const char *stock = pidgin_stock_id_from_status_primitive(prim);
 
-	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");
+	pixbuf = gtk_widget_render_icon (w, stock ? stock : PIDGIN_STOCK_STATUS_AVAILABLE,
+			icon_size, "GtkWidget");
 	return pixbuf;
-
 }
 
 const char *


More information about the Commits mailing list