Re: tiny messagebox patch




On Tue, 24 Mar 1998, Federico Mena wrote:
> 
> The message box widget should use the GnomePixmap widget for its
> pixmaps instead of creating them "by hand" with Gdk.  Could you please
> look into this?  It should be a simple matter of

OK, here's a patch that does this. It also changes the button box layout
to GTK_BUTTONBOX_DEFAULT_STYLE because the right-justified buttons looked
kinda weird to me. But if this was a feature, ignore that part of the
patch.

I also changed it to have a default title of "Message" if no stock
messagebox type is matched, and if there is no stock messagebox type
matched or the stock pixmap fails to load it loads a default pixmap.  If
the default pixmap fails to load it just uses the 0 x 0 empty GnomePixmap
widget. 

I think better behavior might be to add GNOME_MESSAGE_BOX_GENERIC and have 
a warning if no stock messagebox types are matched - that would really be
a bug in the user program. I can do this if people want.

Of course, all the pixmaps fail to load, because the pixmaps haven't been
drawn yet AFAICT, and even if they had there's no mechanism in
gnome-messagebox to figure out where they are installed. I am not sure how
to fix this. gchar * gnome_get_pixmap_path() ? $ICON_PATH? Something like
that would be useful.

Havoc Pennington
http://pobox.com/~hp

Index: gnome-libs/libgnomeui/gnome-messagebox.c
===================================================================
RCS file: /debian/home/gnomecvs/gnome-libs/libgnomeui/gnome-messagebox.c,v
retrieving revision 1.10
diff -u -r1.10 gnome-messagebox.c
--- gnome-messagebox.c	1998/03/24 08:55:16	1.10
+++ gnome-messagebox.c	1998/03/24 20:54:43
@@ -150,12 +150,8 @@
 	GtkWidget *vbox;
 	GtkWidget *label;
 	GtkWidget *separator;
+	GtkWidget *pixmap;
 
-	GtkWidget *pixmapwid;
-	GdkPixmap *pixmap;
-	GdkBitmap *mask;                 
-	GtkStyle *style;
-
 	va_start (ap, message_box_type);
 	
 	message_box = gtk_type_new (gnome_message_box_get_type ());
@@ -166,46 +162,40 @@
 	gtk_container_border_width (GTK_CONTAINER (message_box), 
 				    GNOME_MESSAGE_BOX_BORDER_WIDTH);
 
-	style = gtk_widget_get_style (GTK_WIDGET (message_box));
-
 	if (strcmp(GNOME_MESSAGE_BOX_INFO, message_box_type) == 0)
 	{
 		gtk_window_set_title (GTK_WINDOW (message_box), _("Information"));
-		pixmap = gdk_pixmap_create_from_xpm (GTK_WIDGET (message_box)->window, 
-						     &mask, 
-						     &style->bg[GTK_STATE_NORMAL],
-						     "bomb.xpm");
+		pixmap = gnome_pixmap_new_from_file("bomb.xpm");
 	}
 	else if (strcmp(GNOME_MESSAGE_BOX_WARNING, message_box_type) == 0)
 	{
 		gtk_window_set_title (GTK_WINDOW (message_box), _("Warning"));
-		pixmap = gdk_pixmap_create_from_xpm (GTK_WIDGET (message_box)->window,
-						     &mask, 
-						     &style->bg[GTK_STATE_NORMAL],
-						     "bomb.xpm");
+		pixmap = gnome_pixmap_new_from_file("bomb.xpm");
 	}
 	else if (strcmp(GNOME_MESSAGE_BOX_ERROR, message_box_type) == 0)
 	{
 		gtk_window_set_title (GTK_WINDOW (message_box), _("Error"));
-		pixmap = gdk_pixmap_create_from_xpm (GTK_WIDGET (message_box)->window, 
-						     &mask, 
-						     &style->bg[GTK_STATE_NORMAL],
-						     "bomb.xpm");
+		pixmap = gnome_pixmap_new_from_file("bomb.xpm");
 	}
 	else if (strcmp(GNOME_MESSAGE_BOX_QUESTION, message_box_type) == 0)
 	{
 		gtk_window_set_title (GTK_WINDOW (message_box), _("Question"));
-		pixmap = gdk_pixmap_create_from_xpm (GTK_WIDGET (message_box)->window, 
-						     &mask, 
-						     &style->bg[GTK_STATE_NORMAL],
-						     "bomb.xpm");
+		pixmap = gnome_pixmap_new_from_file("bomb.xpm");
 	}
-	else
+	else 
 	{
-		gtk_window_set_title (GTK_WINDOW (message_box), "");
+		gtk_window_set_title (GTK_WINDOW (message_box), _("Message"));
 		pixmap = NULL;
 	}
 
+	if ( (pixmap == NULL) || 
+	     (GNOME_PIXMAP(pixmap)->pixmap == NULL) ) {
+	  if (pixmap) {
+	    gtk_widget_destroy(pixmap);
+	  }
+	  pixmap = gnome_pixmap_new_from_file("gnome-default.png");
+	}
+
 	vbox = gtk_vbox_new (FALSE, 0);
 	gtk_container_add (GTK_CONTAINER (message_box), vbox);
 	gtk_widget_show (vbox);
@@ -214,12 +204,9 @@
 	gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 10);
 	gtk_widget_show (hbox);
 
-	if (pixmap)
-	{
-		pixmapwid = gtk_pixmap_new (pixmap, mask);
-		gtk_box_pack_start (GTK_BOX (hbox), pixmapwid, FALSE, TRUE, 0);
-		gtk_widget_show (pixmapwid);
-	}
+	gtk_box_pack_start (GTK_BOX (hbox), 
+			    pixmap, FALSE, TRUE, 0);
+	gtk_widget_show (pixmap);
 
 	label = gtk_label_new (message);
 	gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
@@ -232,7 +219,7 @@
 
 	hbox = gtk_hbutton_box_new ();
 	gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox),
-				   GTK_BUTTONBOX_END);
+				   GTK_BUTTONBOX_DEFAULT_STYLE);
 	gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbox), GNOME_PAD);
 	gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
 	gtk_widget_show (hbox);




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]