font picker resurrected (or something)



Hi,

I hacked together the old semi-ported (I've been nearly mugged for
saying that I ported gcalc, when it was actually half ported already)
gnome-font-picker.

Problem is that it seems to crash quite badly, and my gdb is really
clueless about it (ie. it acts weird). Here goes the patch, also adds
the font picker to test-gnome.

I hope somebody can f1x0r it in some way.

Cheers


Index: libgnomeui/ChangeLog
===================================================================
RCS file: /cvs/gnome/libgnomeui/libgnomeui/ChangeLog,v
retrieving revision 1.1693
diff -u -r1.1693 ChangeLog
--- libgnomeui/ChangeLog	2001/10/13 18:17:31	1.1693
+++ libgnomeui/ChangeLog	2001/10/14 00:21:39
@@ -1,3 +1,12 @@
+2001-10-14  Bastien Nocera  <hadess hadess net>
+
+	* Makefile.am:
+	* gnome-font-picker.c: (gnome_font_picker_class_init),
+	(gnome_font_picker_set_property), (gnome_font_picker_get_property),
+	(gnome_font_picker_uw_get_widget),
+	(gnome_font_picker_label_use_font_in_label): fixes and
+	porting to gnome2
+
 2001-10-13  Bastien Nocera  <hadess hadess net>
 
 	* libgnomeui.h: gnome-font-picker.h was missing from the include
Index: libgnomeui/Makefile.am
===================================================================
RCS file: /cvs/gnome/libgnomeui/libgnomeui/Makefile.am,v
retrieving revision 1.309
diff -u -r1.309 Makefile.am
--- libgnomeui/Makefile.am	2001/09/19 19:17:36	1.309
+++ libgnomeui/Makefile.am	2001/10/14 00:21:39
@@ -63,6 +63,7 @@
 	gnome-druid-page-standard.c	\
 	gnome-entry.c			\
 	gnome-file-entry.c		\
+	gnome-font-picker.c		\
 	gnome-gconf-ui.c		\
 	gnome-href.c			\
 	gnome-ice.c			\
@@ -104,6 +105,7 @@
 	gnome-druid-page-standard.h	\
 	gnome-entry.h			\
 	gnome-file-entry.h		\
+	gnome-font-picker.h		\
 	gnome-href.h			\
 	gnome-ice.h			\
 	gnome-icon-entry.h		\
Index: libgnomeui/gnome-font-picker.c
===================================================================
RCS file: /cvs/gnome/libgnomeui/libgnomeui/gnome-font-picker.c,v
retrieving revision 1.41
diff -u -r1.41 gnome-font-picker.c
--- libgnomeui/gnome-font-picker.c	2001/09/28 23:03:08	1.41
+++ libgnomeui/gnome-font-picker.c	2001/10/14 00:21:39
@@ -154,8 +154,8 @@
 		 g_param_spec_enum ("mode",
 				    _("Mode"),
 				    _("The mode of operation of the font picker"),
-				    G_TYPE_ENUM /* FIXME: should have its own type -George */
-				    GNOME_FONT_PICKER_MODE_PIXMAP
+				    G_TYPE_ENUM /* FIXME: should have its own type -George */,
+				    GNOME_FONT_PICKER_MODE_PIXMAP,
 				    (G_PARAM_READABLE |
 				     G_PARAM_WRITABLE)));
 	g_object_class_install_property
@@ -301,17 +301,17 @@
 	self = GNOME_FONT_PICKER (object);
 
 	switch (param_id) {
-	case PARAM_TITLE:
+	case PROP_TITLE:
 		gnome_font_picker_set_title (self, g_value_get_string (value));
 		break;
-	case PARAM_MODE:
+	case PROP_MODE:
 		gnome_font_picker_set_mode (self, g_value_get_enum (value));
 		break;
-	case PARAM_FONT_NAME:
+	case PROP_FONT_NAME:
 		gnome_font_picker_set_font_name (self,
 						 g_value_get_string (value));
 		break;
-	case PARAM_PREVIEW_TEXT:
+	case PROP_PREVIEW_TEXT:
 		gnome_font_picker_set_preview_text
 			(self, g_value_get_string (value));
 		break;
@@ -335,20 +335,20 @@
 	self = GNOME_FONT_PICKER (object);
 
 	switch (param_id) {
-	case PARAM_TITLE:
+	case PROP_TITLE:
 		g_value_set_string (value, gnome_font_picker_get_title (self));
 		break;
-	case PARAM_MODE:
-		g_value_set_enum (value, gnome_font_picker_get_title (self));
+	case PROP_MODE:
+		g_value_set_string (value, gnome_font_picker_get_title (self));
 		break;
-	case PARAM_FONT_NAME:
+	case PROP_FONT_NAME:
 		g_value_set_string (value,
 				    gnome_font_picker_get_font_name (self));
 		break;
-	case PARAM_FONT:
+	case PROP_FONT:
 		g_value_set_pointer (value, gnome_font_picker_get_font (self));
 		break;
-	case PARAM_PREVIEW_TEXT:
+	case PROP_PREVIEW_TEXT:
 		g_value_set_string (value,
 				    gnome_font_picker_get_preview_text (self));
 		break;
@@ -600,8 +600,8 @@
 GtkWidget *
 gnome_font_picker_uw_get_widget (GnomeFontPicker *gfp)
 {
-    g_return_val_if_fail (gfp != NULL);
-    g_return_val_if_fail (GNOME_IS_FONT_PICKER (gfp));
+    g_return_val_if_fail (gfp != NULL, NULL);
+    g_return_val_if_fail (GNOME_IS_FONT_PICKER (gfp), NULL);
 
     if (gfp->_priv->mode == GNOME_FONT_PICKER_MODE_USER_WIDGET) {
 	    return gfp->_priv->inside;
@@ -998,8 +998,13 @@
     /* Change label style */
     gtk_widget_ensure_style(gfp->_priv->font_label);
     style=gtk_style_copy(gfp->_priv->font_label->style);
-    gdk_font_unref(style->font);
-    style->font=font;
+    {
+	    GdkFont *style_font;
+	    
+	    style_font = gtk_style_get_font(style);
+	    gdk_font_unref(style_font);
+	    gtk_style_set_font(style, font);
+    }
     gtk_widget_set_style(gfp->_priv->font_label,style);
     gtk_style_unref(style);
 
Index: test-gnome/ChangeLog
===================================================================
RCS file: /cvs/gnome/libgnomeui/test-gnome/ChangeLog,v
retrieving revision 1.20
diff -u -r1.20 ChangeLog
--- test-gnome/ChangeLog	2001/10/12 01:59:44	1.20
+++ test-gnome/ChangeLog	2001/10/14 00:21:40
@@ -1,3 +1,8 @@
+2001-10-14  Bastien Nocera  <hadess hadess net>
+
+	* testgnome.c: (create_font_picker), (main):
+	included font picker test, use new API
+
 2001-10-11  Michael Meeks  <michael ximian com>
 
 	* testgnome.c (create_newwin): use bonobo_ui_util_set_ui
Index: test-gnome/testgnome.c
===================================================================
RCS file: /cvs/gnome/libgnomeui/test-gnome/testgnome.c,v
retrieving revision 1.19
diff -u -r1.19 testgnome.c
--- test-gnome/testgnome.c	2001/10/12 01:59:44	1.19
+++ test-gnome/testgnome.c	2001/10/14 00:21:40
@@ -667,10 +667,11 @@
 }
 #endif
 
-#if 0
+
 /*
  * FontPicker
  */
+#if 0
 static void
 cfp_ck_UseFont(GtkWidget *widget,GnomeFontPicker *gfp)
 {
@@ -706,7 +707,7 @@
 
 	gnome_font_picker_fi_set_show_size(gfp,tb->active);
 }
-
+#endif
 static void
 cfp_set_font(GnomeFontPicker *gfp, gchar *font_name, GtkLabel *label)
 {
@@ -735,7 +736,7 @@
 	bonobo_window_set_contents(BONOBO_WINDOW(app->app),vbox);
 
 	/* Pixmap */
-	frPixmap=gtk_frame_new(_("Default Pixmap"));
+	frPixmap=gtk_frame_new("Default Pixmap");
 	gtk_box_pack_start(GTK_BOX(vbox),frPixmap,TRUE,TRUE,0);
 	vbox1=gtk_vbox_new(FALSE,FALSE);
 	gtk_container_add(GTK_CONTAINER(frPixmap),vbox1);
@@ -744,7 +745,7 @@
 	fontpicker1 = gnome_font_picker_new();
 	gtk_container_set_border_width(GTK_CONTAINER(fontpicker1),5);
 	gtk_box_pack_start(GTK_BOX(vbox1),fontpicker1,TRUE,TRUE,0);
-	lbPixmap=gtk_label_new(_("If you choose a font it will appear here"));
+	lbPixmap=gtk_label_new("If you choose a font it will appear here");
 	gtk_box_pack_start(GTK_BOX(vbox1),lbPixmap,TRUE,TRUE,5);
 
 	gtk_signal_connect(GTK_OBJECT(fontpicker1),"font_set",
@@ -760,14 +761,14 @@
 	/* GnomeFontPicker with fontinfo */
 	hbox1=gtk_hbox_new(FALSE,5);
 	gtk_box_pack_start(GTK_BOX(vbox2),hbox1,FALSE,FALSE,0);
-	ckUseFont=gtk_check_button_new_with_label(_("Use Font in button with size"));
+	ckUseFont=gtk_check_button_new_with_label("Use Font in button with size");
 	gtk_box_pack_start(GTK_BOX(hbox1),ckUseFont,TRUE,TRUE,0);
 
 	adj=GTK_ADJUSTMENT(gtk_adjustment_new(14,5,150,1,1,1));
 	spUseFont=gtk_spin_button_new(adj,1,0);
 	gtk_box_pack_start(GTK_BOX(hbox1),spUseFont,FALSE,FALSE,0);
 
-	ckShowSize=gtk_check_button_new_with_label(_("Show font size"));
+	ckShowSize=gtk_check_button_new_with_label("Show font size");
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ckShowSize),TRUE);
 	gtk_box_pack_start(GTK_BOX(vbox2),ckShowSize,FALSE,FALSE,5);
 
@@ -775,16 +776,7 @@
 	gnome_font_picker_set_mode(GNOME_FONT_PICKER(fontpicker2),GNOME_FONT_PICKER_MODE_FONT_INFO);
 	gtk_box_pack_start(GTK_BOX(vbox2),fontpicker2,TRUE,TRUE,0);
 
-	gtk_signal_connect(GTK_OBJECT(ckUseFont),"toggled",
-			   (GtkSignalFunc)cfp_ck_UseFont,fontpicker2);
-
-	gtk_signal_connect(GTK_OBJECT(ckShowSize),"toggled",
-			   (GtkSignalFunc)cfp_ck_ShowSize,fontpicker2);
-
-	gtk_signal_connect(GTK_OBJECT(adj),"value_changed",
-			   (GtkSignalFunc)cfp_sp_value_changed,fontpicker2);
-
-	lbFontInfo=gtk_label_new(_("If you choose a font it will appear here"));
+	lbFontInfo=gtk_label_new("If you choose a font it will appear here");
 	gtk_box_pack_start(GTK_BOX(vbox2),lbFontInfo,TRUE,TRUE,5);
 
 
@@ -803,15 +795,16 @@
 	gnome_font_picker_set_mode(GNOME_FONT_PICKER(fontpicker3),GNOME_FONT_PICKER_MODE_USER_WIDGET);
 
 	hbox3=gtk_hbox_new(FALSE,0);
-	gtk_box_pack_start(GTK_BOX(hbox3),gnome_stock_new_with_icon(GNOME_STOCK_PIXMAP_SPELLCHECK),
+	gtk_box_pack_start(GTK_BOX(hbox3),gtk_image_new_from_stock
+                           (GNOME_STOCK_PIXMAP_SPELLCHECK, 32),
 			   FALSE,FALSE,5);
-	gtk_box_pack_start(GTK_BOX(hbox3),gtk_label_new(_("This is an hbox with pixmap and text")),
+	gtk_box_pack_start(GTK_BOX(hbox3),gtk_label_new("This is an hbox with pixmap and text"),
 			   FALSE,FALSE,5);
 	gnome_font_picker_uw_set_widget(GNOME_FONT_PICKER(fontpicker3),hbox3);
 	gtk_container_set_border_width(GTK_CONTAINER(fontpicker3),5);
 	gtk_box_pack_start(GTK_BOX(vbox3),fontpicker3,TRUE,TRUE,0);
 
-	lbUser=gtk_label_new(_("If you choose a font it will appear here"));
+	lbUser=gtk_label_new("If you choose a font it will appear here");
 	gtk_box_pack_start(GTK_BOX(vbox3),lbUser,TRUE,TRUE,5);
 
 	gtk_signal_connect(GTK_OBJECT(fontpicker3),"font_set",
@@ -820,7 +813,7 @@
 	gtk_widget_show_all(app->app);
 
 }
-#endif
+
 
 /*
  * HRef
@@ -1049,7 +1042,7 @@
 		{ "pixmap entry", create_pixmap_entry },
 		{ "icon entry", create_icon_entry },
 /*		{ "font selector", create_font_selector }, */
-/*		{ "font picker", create_font_picker },*/
+		{ "font picker", create_font_picker },
 		{ "href", create_href },
 		{ "icon list", create_icon_list },
 /*		{ "image entry", create_image_entry }, */


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