building HEAD with GTK+-2.4



I decided to try to get libgnomeprintui building with HEAD GTK+.  I
started out by trying to port the deprecated widgets to the new version,
but soon discovered that there are millions of option menus.  This patch
moves a couple over, and removes -DG*_DISABLE_DEPRECATED from the
Makefile for now.  At some point we'll have to move port all the option
menus, but for now, this will at least get it compiling.

Thanks,
-Jonathan

Index: libgnomeprintui//Makefile.am
===================================================================
RCS file: /cvs/gnome/libgnomeprintui/libgnomeprintui/Makefile.am,v
retrieving revision 1.76
diff -u -r1.76 Makefile.am
--- libgnomeprintui//Makefile.am	25 Apr 2003 13:37:26 -0000	1.76
+++ libgnomeprintui//Makefile.am	14 Oct 2003 18:40:42 -0000
@@ -11,13 +11,7 @@
 	-DGNOMELOCALEDIR=\""$(datadir)/locale"\" 	\
 	-DGNOME_PRINT_LIBDIR=\"$(libdir)/gnome-print\" \
 	-DBINDIR=\""$(bindir)"\"	\
-	-DDATADIR=\""$(datadir)"\" \
-	\
-	-DG_DISABLE_DEPRECATED				\
-	-DGDK_DISABLE_DEPRECATED				\
-	-DGTK_DISABLE_DEPRECATED				\
-	-DGDK_PIXBUF_DISABLE_DEPRECATED		\
-	-DGNOME_DISABLE_DEPRECATED
+	-DDATADIR=\""$(datadir)"\"
 
 LDFLAGS = -version-info $(GNOMEPRINT_CURRENT):$(GNOMEPRINT_REVISION):$(GNOMEPRINT_AGE)
 
Index: libgnomeprintui//gnome-font-dialog.c
===================================================================
RCS file: /cvs/gnome/libgnomeprintui/libgnomeprintui/gnome-font-dialog.c,v
retrieving revision 1.33
diff -u -r1.33 gnome-font-dialog.c
--- libgnomeprintui//gnome-font-dialog.c	18 Dec 2002 01:52:54 -0000	1.33
+++ libgnomeprintui//gnome-font-dialog.c	14 Oct 2003 18:40:42 -0000
@@ -73,7 +73,7 @@
 #define MIN_PREVIEW_HEIGHT 44
 #define MAX_PREVIEW_HEIGHT 300
 
-/* These are what we use as the standard font sizes, for the size clist.
+/* These are what we use as the standard font sizes, for the size combo.
    Note that when using points we still show these integer point values but
    we work internally in decipoints (and decipoint values can be typed in). */
 static gchar * font_sizes[] = {
@@ -85,11 +85,11 @@
 static void gnome_font_selection_init (GnomeFontSelection *fontsel);
 static void gnome_font_selection_destroy (GtkObject *object);
 
-static void gnome_font_selection_select_family (GtkTreeSelection *selection, gpointer data);
-static void gnome_font_selection_select_style  (GtkTreeSelection *selection, gpointer data);
-static void gnome_font_selection_select_size   (GtkEditable * editable, gpointer data);
-static void gnome_font_selection_fill_families (GnomeFontSelection * fontsel);
-static void gnome_font_selection_fill_styles   (GnomeFontSelection * fontsel);
+static void gnome_font_selection_select_family (GtkTreeSelection   *selection, gpointer data);
+static void gnome_font_selection_select_style  (GtkTreeSelection   *selection, gpointer data);
+static void gnome_font_selection_select_size   (GtkWidget          *combo,     gpointer data);
+static void gnome_font_selection_fill_families (GnomeFontSelection *fontsel);
+static void gnome_font_selection_fill_styles   (GnomeFontSelection *fontsel);
 static gboolean find_row_to_select_cb (GtkTreeModel *model,
 				       GtkTreePath *path,
 				       GtkTreeIter *iter,
@@ -145,7 +145,6 @@
 static void
 gnome_font_selection_init (GnomeFontSelection * fontsel)
 {
-	static GList * sizelist = NULL;
 	GtkWidget * f, * sw, * tv, * vb, * hb, * c, * l;
 	GtkListStore *store;
 	GtkTreeSelection *selection;
@@ -155,7 +154,8 @@
 	AtkRelation *relation;
 	AtkObject *relation_targets[1];
 	AtkObject *atko;
-
+	gint i;
+	GtkTreeModel *model;
 	gtk_box_set_homogeneous ((GtkBox *) fontsel, TRUE);
 	gtk_box_set_spacing ((GtkBox *) fontsel, 4);
 
@@ -257,35 +257,31 @@
 	gtk_box_pack_start ((GtkBox *) vb, hb, FALSE, FALSE, 0);
 	fontsel->sizebox = hb;
 
-	c = gtk_combo_new ();
+	model = (GtkTreeModel *) gtk_list_store_new (1, G_TYPE_STRING);
+	c = gtk_combo_box_entry_new (model, 0);
 	gtk_widget_set_size_request (c, 64, -1);
-	gtk_combo_set_value_in_list ((GtkCombo *) c, FALSE, FALSE);
-	gtk_combo_set_use_arrows ((GtkCombo *) c, TRUE);
-	gtk_combo_set_use_arrows_always ((GtkCombo *) c, TRUE);
 	gtk_widget_show (c);
-	g_signal_connect (G_OBJECT (((GtkCombo *) c)->entry), "changed",
+	g_signal_connect (G_OBJECT (c), "changed",
 			  (GCallback) gnome_font_selection_select_size, fontsel);
 	gtk_box_pack_end ((GtkBox *) hb, c, FALSE, FALSE, 0);
 	fontsel->size = c;
 
-	if (!sizelist) {
-		gint i;
-		for (i = 0; i < (sizeof (font_sizes) / sizeof (font_sizes[0])); i++) {
-			sizelist = g_list_prepend (sizelist, font_sizes[i]);
-		}
-		sizelist = g_list_reverse (sizelist);
-	}
-
-	gtk_combo_set_popdown_strings ((GtkCombo *) c, sizelist);
+	for (i = 0; i < G_N_ELEMENTS (font_sizes); i++) {
+		GtkTreeIter iter;
 
-	gtk_entry_set_text ((GtkEntry *) ((GtkCombo *) c)->entry, "12");
+		gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+		gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+				    0, font_sizes[i],
+				    -1);
+		if (! strcmp (font_sizes[i], "12"))
+			gtk_combo_box_set_active (GTK_COMBO_BOX (c), i);
+	}
 	fontsel->selectedsize = 12.0;
 
 	l = gtk_label_new_with_mnemonic (_("Font _size:"));
 	gtk_widget_show (l);
 	gtk_box_pack_end ((GtkBox *) hb, l, FALSE, FALSE, 0);
-	gtk_label_set_mnemonic_widget ((GtkLabel *) l,
-				       ((GtkCombo *) c)->entry);
+	gtk_label_set_mnemonic_widget ((GtkLabel *) l, c);
 
 	/* Add a LABELLED_BY relation from the combo to the label. */
 	atko = gtk_widget_get_accessible (c);
@@ -420,9 +416,10 @@
 }
 
 static void
-gnome_font_selection_select_size (GtkEditable * editable, gpointer data)
+gnome_font_selection_select_size (GtkWidget *combo, gpointer data)
 {
 	GnomeFontSelection * fontsel;
+	GtkWidget *entry;
 	gchar * sizestr;
 
 	fontsel = GNOME_FONT_SELECTION (data);
@@ -430,7 +427,8 @@
 	if (!fontsel->selectedface)
 		return;
 
-	sizestr = gtk_editable_get_chars (GTK_EDITABLE (GTK_COMBO (fontsel->size)->entry), 0, -1);
+	entry = gtk_bin_get_child (GTK_BIN (combo));
+	sizestr = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
 
 	fontsel->selectedsize = MAX (atoi (sizestr), 1.0);
 
@@ -572,7 +570,7 @@
 
 	g_snprintf (b, 32, "%2.1f", size);
 	b[31] = '\0';
-	gtk_entry_set_text ((GtkEntry *) ((GtkCombo *) fontsel->size)->entry, b);
+	gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fontsel->size))), b);
 	fontsel->selectedsize = size;
 }
 
Index: libgnomeprintui//gnome-print-unit-selector.c
===================================================================
RCS file: /cvs/gnome/libgnomeprintui/libgnomeprintui/gnome-print-unit-selector.c,v
retrieving revision 1.3
diff -u -r1.3 gnome-print-unit-selector.c
--- libgnomeprintui//gnome-print-unit-selector.c	27 Feb 2003 16:59:45 -0000	1.3
+++ libgnomeprintui//gnome-print-unit-selector.c	14 Oct 2003 18:40:42 -0000
@@ -34,10 +34,16 @@
 
 #define noGPP_VERBOSE
 
+enum
+{
+	COL_NAME,
+	COL_UNIT,
+	N_COLUMNS,
+};
 struct _GnomePrintUnitSelector {
 	GtkHBox box;
 
-	GtkWidget *menu;
+	GtkWidget *combo;
 
 	guint bases;
 	GList *units;
@@ -59,6 +65,9 @@
 static void gnome_print_unit_selector_init (GnomePrintUnitSelector *selector);
 static void gnome_print_unit_selector_finalize (GObject *object);
 
+static void gnome_print_unit_selector_recalculate_adjustments (GnomePrintUnitSelector *us,
+							       const GnomePrintUnit *unit);
+
 static GtkHBoxClass *unit_selector_parent_class;
 
 enum {
@@ -112,8 +121,33 @@
 }
 
 static void
-cb_gpus_opt_menu_changed (GtkOptionMenu *menu, GnomePrintUnitSelector *us)
+cb_gpus_combo_changed (GtkWidget *combo, GnomePrintUnitSelector *us)
 {
+	const GnomePrintUnit *unit;
+	GtkTreeModel *model;
+	GtkTreePath *path;
+	GtkTreeIter iter;
+
+	model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
+	path = gtk_tree_path_new_from_indices (gtk_combo_box_get_active (GTK_COMBO_BOX (combo)),
+					       -1);
+	gtk_tree_model_get_iter (model, &iter, path);
+	gtk_tree_path_free (path);
+
+	gtk_tree_model_get (model, &iter,
+			    COL_UNIT, &unit,
+			    -1);
+
+	g_return_if_fail (unit != NULL);
+
+#ifdef GPP_VERBOSE
+	g_print ("Old unit %s new unit %s\n", us->unit->name, unit->name);
+#endif
+	if (us->unit == unit)
+		return;
+
+	gnome_print_unit_selector_recalculate_adjustments (us, unit);
+
 	g_signal_emit (G_OBJECT (us),
 		       gnome_print_unit_selector_signals[GNOME_PRINT_UNIT_SELECTOR_MODIFIED],
 		       0);
@@ -122,16 +156,23 @@
 static void
 gnome_print_unit_selector_init (GnomePrintUnitSelector *us)
 {
+	GtkCellRenderer *cell;
+
 	us->ctmscale = 1.0;
 	us->devicescale = 1.0;
 	us->abbr = FALSE;
 	us->plural = TRUE;
 
-	us->menu = gtk_option_menu_new ();
-	g_signal_connect (G_OBJECT (us->menu),
-			  "changed", G_CALLBACK (cb_gpus_opt_menu_changed), us);
-	gtk_widget_show (us->menu);
-	gtk_box_pack_start (GTK_BOX (us), us->menu, TRUE, TRUE, 0);
+	us->combo = gtk_combo_box_new ((GtkTreeModel *)gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER));
+	cell = gtk_cell_renderer_text_new ();
+	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (us->combo), cell, TRUE);
+	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (us->combo), cell,
+					"text", 0,
+					NULL);
+	g_signal_connect (G_OBJECT (us->combo),
+			  "changed", G_CALLBACK (cb_gpus_combo_changed), us);
+	gtk_widget_show (us->combo);
+	gtk_box_pack_start (GTK_BOX (us), us->combo, TRUE, TRUE, 0);
 }
 
 static void
@@ -141,8 +182,8 @@
 	
 	selector = GNOME_PRINT_UNIT_SELECTOR (object);
 
-	if (selector->menu) {
-		selector->menu = NULL;
+	if (selector->combo) {
+		selector->combo = NULL;
 	}
 
 	while (selector->adjustments) {
@@ -212,54 +253,37 @@
 }
 
 static void
-gpus_unit_activate (GtkWidget *widget, GnomePrintUnitSelector *us)
-{
-	const GnomePrintUnit *unit;
-
-	unit = g_object_get_data (G_OBJECT (widget), "unit");
-	g_return_if_fail (unit != NULL);
-
-#ifdef GPP_VERBOSE
-	g_print ("Old unit %s new unit %s\n", us->unit->name, unit->name);
-#endif
-	if (us->unit == unit)
-		return;
-
-	gnome_print_unit_selector_recalculate_adjustments (us, unit);
-}
-
-static void
 gpus_rebuild_menu (GnomePrintUnitSelector *us)
 {
-	GtkWidget *m, *i;
 	GList *l;
 	gint pos, p;
+	GtkTreeModel *model;
 
-	m = gtk_menu_new ();
-	gtk_widget_show (m);
-
+	model = gtk_combo_box_get_model (GTK_COMBO_BOX (us->combo));
+	gtk_list_store_clear (GTK_LIST_STORE (model));
+	
 	pos = p = 0;
 	for (l = us->units; l != NULL; l = l->next) {
 		const GnomePrintUnit *u;
+		GtkTreeIter iter;
 		gchar *name;
 		
 		u = l->data;
 
 		name = gnome_print_unit_get_name (u, us->plural, us->abbr, 0);
-		i = gtk_menu_item_new_with_label (name);
+		gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+		gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+				    COL_NAME, name,
+				    COL_UNIT, u,
+				    -1);
 		g_free (name);
 
-		g_object_set_data (G_OBJECT (i), "unit", (gpointer) u);
-		g_signal_connect (G_OBJECT (i), "activate", (GCallback) gpus_unit_activate, us);
-		gtk_widget_show (i);
-		gtk_menu_shell_append (GTK_MENU_SHELL (m), i);
 		if (u == us->unit)
 			pos = p;
 		p += 1;
 	}
 
-	gtk_option_menu_set_menu (GTK_OPTION_MENU (us->menu), m);
-	gtk_option_menu_set_history (GTK_OPTION_MENU (us->menu), pos);
+	gtk_combo_box_set_active (GTK_COMBO_BOX (us->combo), pos);
 }
 
 void
@@ -298,7 +322,7 @@
 	g_return_if_fail (pos >= 0);
 
 	gnome_print_unit_selector_recalculate_adjustments (us,  unit);
-	gtk_option_menu_set_history (GTK_OPTION_MENU (us->menu), pos);
+	gtk_combo_box_set_active (GTK_COMBO_BOX (us->combo), pos);
 }
 
 void
Index: libgnomeprintui//gpaui/Makefile.am
===================================================================
RCS file: /cvs/gnome/libgnomeprintui/libgnomeprintui/gpaui/Makefile.am,v
retrieving revision 1.14
diff -u -r1.14 Makefile.am
--- libgnomeprintui//gpaui/Makefile.am	12 Feb 2003 03:58:54 -0000	1.14
+++ libgnomeprintui//gpaui/Makefile.am	14 Oct 2003 18:40:42 -0000
@@ -5,13 +5,8 @@
 	-I$(top_srcdir)/intl \
 	-I$(top_srcdir)/libgnomeprintui \
 	-DWE_ARE_LIBGNOMEPRINT_INTERNALS \
-	$(LIBGNOMEPRINTUI_CFLAGS) \
-	\
-	-DG_DISABLE_DEPRECATED				\
-	-DGDK_DISABLE_DEPRECATED				\
-	-DGTK_DISABLE_DEPRECATED				\
-	-DGDK_PIXBUF_DISABLE_DEPRECATED		\
-	-DGNOME_DISABLE_DEPRECATED
+	$(LIBGNOMEPRINTUI_CFLAGS)
+
 
 
 CPPFLAGS = \
Index: tests//Makefile.am
===================================================================
RCS file: /cvs/gnome/libgnomeprintui/tests/Makefile.am,v
retrieving revision 1.25
diff -u -r1.25 Makefile.am
--- tests//Makefile.am	17 Dec 2002 01:16:11 -0000	1.25
+++ tests//Makefile.am	14 Oct 2003 18:40:42 -0000
@@ -6,13 +6,7 @@
      -DWE_ARE_LIBGNOMEPRINT_INTERNALS \
 	-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
 	-DBINDIR=\""$(bindir)"\" \
-	-DDATADIR=\""$(datadir)"\" \
-	\
-	-DG_DISABLE_DEPRECATED				\
-	-DGDK_DISABLE_DEPRECATED				\
-	-DGTK_DISABLE_DEPRECATED				\
-	-DGDK_PIXBUF_DISABLE_DEPRECATED		\
-	-DGNOME_DISABLE_DEPRECATED
+	-DDATADIR=\""$(datadir)"\"
 
 if EXAMPLES_USE_LOCAL_LIBGNOMEPRINT
 libgnomeprint_local=$(top_builddir)/../libgnomeprint/libgnomeprint/libgnomeprint-2-2.la
@@ -41,4 +35,4 @@
 simple_SOURCES = simple.c
 simple_LDFLAGS =
 simple_DEPENDENCIES = $(DEPS)
-simple_LDADD = $(printui_libs);
\ No newline at end of file
+simple_LDADD = $(printui_libs);


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