changeset 14190:366be2ce35a7

[gaim-migrate @ 16854] Generates the image for the about dialog on demand instead of making it a stock image which remains in memory forever. committer: Tailor Script <tailor@pidgin.im>
author Aaron Sheldon <aaronsheldon>
date Sat, 19 Aug 2006 00:24:14 +0000
parents 789d80a6b9d9
children 009db0b357b5
files src/gtkdialogs.c src/gtkstock.c src/gtkstock.h
diffstat 3 files changed, 51 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkdialogs.c	Sat Aug 19 00:07:40 2006 +0000
+++ b/src/gtkdialogs.c	Sat Aug 19 00:24:14 2006 +0000
@@ -223,6 +223,44 @@
 	about = NULL;
 }
 
+/* This function puts the version number onto the pixmap we use in the 'about' 
+ * screen in Gaim. */
+static void
+gaim_gtk_logo_versionize(GdkPixbuf **original, GtkWidget *widget) {
+	GdkPixmap *pixmap;
+	GtkStyle *style;
+	PangoContext *context;
+	PangoLayout *layout;
+	gchar *markup;
+	gint width, height;
+	gint lwidth = 0, lheight = 0;
+
+	style = gtk_widget_get_style(widget);
+
+	gdk_pixbuf_render_pixmap_and_mask(*original, &pixmap, NULL, 255);
+	width = gdk_pixbuf_get_width(*original);
+	height = gdk_pixbuf_get_height(*original);
+	g_object_unref(G_OBJECT(*original));
+
+	context = gtk_widget_get_pango_context(widget);
+	layout = pango_layout_new(context);
+
+	markup = g_strdup_printf("<span foreground=\"#FFFFFF\" size=\"larger\">%s</span>", VERSION);
+	pango_layout_set_font_description(layout, style->font_desc);
+	pango_layout_set_markup(layout, markup, strlen(markup));
+	g_free(markup);
+
+	pango_layout_get_pixel_size(layout, &lwidth, &lheight);
+	gdk_draw_layout(GDK_DRAWABLE(pixmap), style->bg_gc[GTK_STATE_NORMAL],
+					width - (lwidth + 3), height - (lheight + 1), layout);
+	g_object_unref(G_OBJECT(layout));
+
+	*original = gdk_pixbuf_get_from_drawable(NULL, pixmap, NULL,
+											 0, 0, 0, 0,
+											 width, height);
+	g_object_unref(G_OBJECT(pixmap));
+}
+
 void gaim_gtkdialogs_about()
 {
 	GtkWidget *hbox;
@@ -236,6 +274,8 @@
 	GString *str;
 	int i;
 	AtkObject *obj;
+	char* filename;
+	GdkPixbuf *pixbuf;
 
 	if (about != NULL) {
 		gtk_window_present(GTK_WINDOW(about));
@@ -256,7 +296,17 @@
 	vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER);
 	gtk_container_add(GTK_CONTAINER(hbox), vbox);
 
-	logo = gtk_image_new_from_stock(GAIM_STOCK_LOGO, gtk_icon_size_from_name(GAIM_ICON_SIZE_LOGO));
+	/* Generate a logo with a version number */
+	logo = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+	gtk_widget_realize(logo);
+	filename = g_build_filename(DATADIR, "pixmaps", "gaim", "logo.png", NULL);
+	pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
+	g_free(filename);
+	gaim_gtk_logo_versionize(&pixbuf, logo);
+	gtk_widget_destroy(logo);
+	logo = gtk_image_new_from_pixbuf(pixbuf);
+	gdk_pixbuf_unref(pixbuf);
+	/* Insert the logo */
 	obj = gtk_widget_get_accessible(logo);
 	atk_object_set_description(obj, "Gaim " VERSION);
 	gtk_box_pack_start(GTK_BOX(vbox), logo, FALSE, FALSE, 0);
--- a/src/gtkstock.c	Sat Aug 19 00:07:40 2006 +0000
+++ b/src/gtkstock.c	Sat Aug 19 00:24:14 2006 +0000
@@ -93,7 +93,6 @@
 	{ GAIM_STOCK_INVITE,          NULL,      GTK_STOCK_JUMP_TO          },
 	{ GAIM_STOCK_LINK,            "buttons", "insert-link-small.png"    },
 	{ GAIM_STOCK_LOG,             NULL,      GTK_STOCK_DND_MULTIPLE     },
-	{ GAIM_STOCK_LOGO,            "gaim",    "logo.png"                 },
 	{ GAIM_STOCK_MODIFY,          NULL,      GTK_STOCK_PREFERENCES      },
 #if GTK_CHECK_VERSION(2,6,0)
 	{ GAIM_STOCK_PAUSE,           NULL,      GTK_STOCK_MEDIA_PAUSE      },
@@ -174,42 +173,6 @@
 	return filename;
 }
 
-static void
-gaim_gtk_stock_versionize(GdkPixbuf **original, GtkWidget *widget) {
-	GdkPixmap *pixmap;
-	GtkStyle *style;
-	PangoContext *context;
-	PangoLayout *layout;
-	gchar *markup;
-	gint width, height;
-	gint lwidth = 0, lheight = 0;
-
-	style = gtk_widget_get_style(widget);
-
-	gdk_pixbuf_render_pixmap_and_mask(*original, &pixmap, NULL, 255);
-	width = gdk_pixbuf_get_width(*original);
-	height = gdk_pixbuf_get_height(*original);
-	g_object_unref(G_OBJECT(*original));
-
-	context = gtk_widget_get_pango_context(widget);
-	layout = pango_layout_new(context);
-
-	markup = g_strdup_printf("<span foreground=\"#FFFFFF\" size=\"larger\">%s</span>", VERSION);
-	pango_layout_set_font_description(layout, style->font_desc);
-	pango_layout_set_markup(layout, markup, strlen(markup));
-	g_free(markup);
-
-	pango_layout_get_pixel_size(layout, &lwidth, &lheight);
-	gdk_draw_layout(GDK_DRAWABLE(pixmap), style->bg_gc[GTK_STATE_NORMAL],
-					width - (lwidth + 3), height - (lheight + 1), layout);
-	g_object_unref(G_OBJECT(layout));
-
-	*original = gdk_pixbuf_get_from_drawable(NULL, pixmap, NULL,
-											 0, 0, 0, 0,
-											 width, height);
-	g_object_unref(G_OBJECT(pixmap));
-}
-
 void
 gaim_gtk_stock_init(void)
 {
@@ -255,9 +218,6 @@
 
 			g_free(filename);
 
-			if (!strcmp(stock_icons[i].name, GAIM_STOCK_LOGO))
-				gaim_gtk_stock_versionize(&pixbuf, win);
-
 			iconset = gtk_icon_set_new_from_pixbuf(pixbuf);
 
 			g_object_unref(G_OBJECT(pixbuf));
--- a/src/gtkstock.h	Sat Aug 19 00:07:40 2006 +0000
+++ b/src/gtkstock.h	Sat Aug 19 00:24:14 2006 +0000
@@ -67,7 +67,6 @@
 #define GAIM_STOCK_INVITE          "gaim-invite"
 #define GAIM_STOCK_LINK            "gaim-link"
 #define GAIM_STOCK_LOG             "gaim-log"
-#define GAIM_STOCK_LOGO            "gaim-logo"
 #define GAIM_STOCK_MODIFY          "gaim-modify"
 #define GAIM_STOCK_OPEN_MAIL       "gaim-stock-open-mail"
 #define GAIM_STOCK_PAUSE           "gaim-pause"