comparison src/gtkdialogs.c @ 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 eb58c6169e6c
children
comparison
equal deleted inserted replaced
14189:789d80a6b9d9 14190:366be2ce35a7
221 if (about != NULL) 221 if (about != NULL)
222 gtk_widget_destroy(about); 222 gtk_widget_destroy(about);
223 about = NULL; 223 about = NULL;
224 } 224 }
225 225
226 /* This function puts the version number onto the pixmap we use in the 'about'
227 * screen in Gaim. */
228 static void
229 gaim_gtk_logo_versionize(GdkPixbuf **original, GtkWidget *widget) {
230 GdkPixmap *pixmap;
231 GtkStyle *style;
232 PangoContext *context;
233 PangoLayout *layout;
234 gchar *markup;
235 gint width, height;
236 gint lwidth = 0, lheight = 0;
237
238 style = gtk_widget_get_style(widget);
239
240 gdk_pixbuf_render_pixmap_and_mask(*original, &pixmap, NULL, 255);
241 width = gdk_pixbuf_get_width(*original);
242 height = gdk_pixbuf_get_height(*original);
243 g_object_unref(G_OBJECT(*original));
244
245 context = gtk_widget_get_pango_context(widget);
246 layout = pango_layout_new(context);
247
248 markup = g_strdup_printf("<span foreground=\"#FFFFFF\" size=\"larger\">%s</span>", VERSION);
249 pango_layout_set_font_description(layout, style->font_desc);
250 pango_layout_set_markup(layout, markup, strlen(markup));
251 g_free(markup);
252
253 pango_layout_get_pixel_size(layout, &lwidth, &lheight);
254 gdk_draw_layout(GDK_DRAWABLE(pixmap), style->bg_gc[GTK_STATE_NORMAL],
255 width - (lwidth + 3), height - (lheight + 1), layout);
256 g_object_unref(G_OBJECT(layout));
257
258 *original = gdk_pixbuf_get_from_drawable(NULL, pixmap, NULL,
259 0, 0, 0, 0,
260 width, height);
261 g_object_unref(G_OBJECT(pixmap));
262 }
263
226 void gaim_gtkdialogs_about() 264 void gaim_gtkdialogs_about()
227 { 265 {
228 GtkWidget *hbox; 266 GtkWidget *hbox;
229 GtkWidget *vbox; 267 GtkWidget *vbox;
230 GtkWidget *logo; 268 GtkWidget *logo;
234 GtkWidget *button; 272 GtkWidget *button;
235 GtkTextIter iter; 273 GtkTextIter iter;
236 GString *str; 274 GString *str;
237 int i; 275 int i;
238 AtkObject *obj; 276 AtkObject *obj;
277 char* filename;
278 GdkPixbuf *pixbuf;
239 279
240 if (about != NULL) { 280 if (about != NULL) {
241 gtk_window_present(GTK_WINDOW(about)); 281 gtk_window_present(GTK_WINDOW(about));
242 return; 282 return;
243 } 283 }
254 gtk_container_add(GTK_CONTAINER(about), hbox); 294 gtk_container_add(GTK_CONTAINER(about), hbox);
255 295
256 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); 296 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER);
257 gtk_container_add(GTK_CONTAINER(hbox), vbox); 297 gtk_container_add(GTK_CONTAINER(hbox), vbox);
258 298
259 logo = gtk_image_new_from_stock(GAIM_STOCK_LOGO, gtk_icon_size_from_name(GAIM_ICON_SIZE_LOGO)); 299 /* Generate a logo with a version number */
300 logo = gtk_window_new(GTK_WINDOW_TOPLEVEL);
301 gtk_widget_realize(logo);
302 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "logo.png", NULL);
303 pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
304 g_free(filename);
305 gaim_gtk_logo_versionize(&pixbuf, logo);
306 gtk_widget_destroy(logo);
307 logo = gtk_image_new_from_pixbuf(pixbuf);
308 gdk_pixbuf_unref(pixbuf);
309 /* Insert the logo */
260 obj = gtk_widget_get_accessible(logo); 310 obj = gtk_widget_get_accessible(logo);
261 atk_object_set_description(obj, "Gaim " VERSION); 311 atk_object_set_description(obj, "Gaim " VERSION);
262 gtk_box_pack_start(GTK_BOX(vbox), logo, FALSE, FALSE, 0); 312 gtk_box_pack_start(GTK_BOX(vbox), logo, FALSE, FALSE, 0);
263 313
264 frame = gaim_gtk_create_imhtml(FALSE, &text, NULL, NULL); 314 frame = gaim_gtk_create_imhtml(FALSE, &text, NULL, NULL);