[gconf-editor] all: port to GTK+ 3



commit 976eca6fdc52da2991f0e5dae3ea22831331134f
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Mar 7 11:35:29 2011 -0500

    all: port to GTK+ 3
    
    Make gconf-editor a GTK+ 3 application.

 configure.in                   |   21 +--------------
 src/gconf-bookmarks-dialog.c   |   19 ++++++--------
 src/gconf-cell-renderer.c      |   52 +++++++++++++++++++++++-----------------
 src/gconf-editor-application.c |    4 +-
 src/gconf-editor-window.c      |   37 ++++++++++++----------------
 src/gconf-key-editor.c         |   23 +++++++----------
 src/gconf-search-dialog.c      |    1 -
 src/gedit-output-window.c      |   15 +----------
 8 files changed, 69 insertions(+), 103 deletions(-)
---
diff --git a/configure.in b/configure.in
index 826843a..18655fc 100644
--- a/configure.in
+++ b/configure.in
@@ -27,28 +27,11 @@ if test "x$GCC" = "xyes"; then
 fi
 changequote([,])dnl
 
-AC_MSG_CHECKING([which gtk+ version to compile against])
-AC_ARG_WITH([gtk],
-  [AS_HELP_STRING([--with-gtk=2.0|3.0],[which gtk+ version to compile against (default: 2.0)])],
-  [case "$with_gtk" in
-     2.0|3.0) ;;
-     *) AC_MSG_ERROR([invalid gtk version specified]) ;;
-   esac],
-  [with_gtk=2.0])
-AC_MSG_RESULT([$with_gtk])
-
-case "$with_gtk" in
-  2.0) GTK_API_VERSION=2.0
-       GTK_REQUIRED=2.18.0
-       ;;
-  3.0) GTK_API_VERSION=3.0
-       GTK_REQUIRED=2.90.4
-       ;;
-esac
+GTK_REQUIRED=3.0.0
 
 PKG_CHECK_MODULES(GCONF_EDITOR,
 		  gconf-2.0 >= 2.9.2
-		  gtk+-$GTK_API_VERSION >= $GTK_REQUIRED
+		  gtk+-3.0 >= GTK_REQUIRED
 		  dbus-glib-1)
 
 AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
diff --git a/src/gconf-bookmarks-dialog.c b/src/gconf-bookmarks-dialog.c
index 95d67b6..d6710d5 100644
--- a/src/gconf-bookmarks-dialog.c
+++ b/src/gconf-bookmarks-dialog.c
@@ -34,14 +34,14 @@ gconf_bookmarks_dialog_response (GtkDialog *dialog, gint response_id)
 }
 
 static void
-gconf_bookmarks_dialog_destroy (GtkObject *object)
+gconf_bookmarks_dialog_finalize (GObject *object)
 {
 	GConfClient *client;
 	GConfBookmarksDialog *dialog;
-	
+
 	client = gconf_client_get_default ();
 	dialog = GCONF_BOOKMARKS_DIALOG (object);
-	
+
 	if (dialog->notify_id != 0) {
 		gconf_client_notify_remove (client, dialog->notify_id);
 		gconf_client_remove_dir (client, BOOKMARKS_KEY, NULL);
@@ -49,22 +49,20 @@ gconf_bookmarks_dialog_destroy (GtkObject *object)
 	}
 
 	g_object_unref (client);
-	
-	if (GTK_OBJECT_CLASS (gconf_bookmarks_dialog_parent_class)->destroy) {
-		(* GTK_OBJECT_CLASS (gconf_bookmarks_dialog_parent_class)->destroy) (object);
-	}
+
+	G_OBJECT_CLASS (gconf_bookmarks_dialog_parent_class)->finalize (object);
 }
 
 static void
 gconf_bookmarks_dialog_class_init (GConfBookmarksDialogClass *klass)
 {
 	GtkDialogClass *dialog_class;
-	GtkObjectClass *object_class;
+	GObjectClass *object_class;
 
-	object_class = (GtkObjectClass *)klass;
+	object_class = (GObjectClass *)klass;
 	dialog_class = (GtkDialogClass *)klass;
 
-	object_class->destroy = gconf_bookmarks_dialog_destroy;
+	object_class->finalize = gconf_bookmarks_dialog_finalize;
 	dialog_class->response = gconf_bookmarks_dialog_response;
 }
 
@@ -195,7 +193,6 @@ gconf_bookmarks_dialog_init (GConfBookmarksDialog *dialog)
 
 	content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
 
-	gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
 	gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
 	gtk_box_set_spacing (GTK_BOX (content_area), 2);
 	gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
diff --git a/src/gconf-cell-renderer.c b/src/gconf-cell-renderer.c
index cab9444..dc2efab 100644
--- a/src/gconf-cell-renderer.c
+++ b/src/gconf-cell-renderer.c
@@ -131,8 +131,13 @@ gconf_cell_renderer_finalize (GObject *object)
 }
 
 static void
-gconf_cell_renderer_get_size (GtkCellRenderer *cell, GtkWidget *widget, GdkRectangle *cell_area,
-			      gint *x_offset, gint *y_offset, gint *width, gint *height)
+gconf_cell_renderer_get_size (GtkCellRenderer *cell,
+			      GtkWidget *widget,
+			      const GdkRectangle *cell_area,
+			      gint *x_offset,
+			      gint *y_offset,
+			      gint *width,
+			      gint *height)
 {
 	GConfCellRenderer *cellvalue;
 	gchar *tmp_str;
@@ -255,8 +260,8 @@ gconf_cell_renderer_start_editing (GtkCellRenderer      *cell,
 				   GdkEvent             *event,
 				   GtkWidget            *widget,
 				   const gchar          *path,
-				   GdkRectangle         *background_area,
-				   GdkRectangle         *cell_area,
+				   const GdkRectangle   *background_area,
+				   const GdkRectangle   *cell_area,
 				   GtkCellRendererState  flags)
 {
 	GtkWidget *entry;
@@ -303,8 +308,8 @@ gconf_cell_renderer_activate (GtkCellRenderer      *cell,
 			      GdkEvent             *event,
 			      GtkWidget            *widget,
 			      const gchar          *path,
-			      GdkRectangle         *background_area,
-			      GdkRectangle         *cell_area,
+			      const GdkRectangle   *background_area,
+			      const GdkRectangle   *cell_area,
 			      GtkCellRendererState  flags)
 {
 	GConfCellRenderer *cellvalue;
@@ -329,8 +334,11 @@ gconf_cell_renderer_activate (GtkCellRenderer      *cell,
 }
 
 static void
-gconf_cell_renderer_render (GtkCellRenderer *cell, GdkWindow *window, GtkWidget *widget,
-			    GdkRectangle *background_area, GdkRectangle *cell_area, GdkRectangle *expose_area,
+gconf_cell_renderer_render (GtkCellRenderer *cell,
+			    cairo_t *cr,
+			    GtkWidget *widget,
+			    const GdkRectangle *background_area,
+			    const GdkRectangle *cell_area,
 			    GtkCellRendererState flags)
 {
 	GConfCellRenderer *cellvalue;
@@ -343,8 +351,8 @@ gconf_cell_renderer_render (GtkCellRenderer *cell, GdkWindow *window, GtkWidget
 			      "text", _("<no value>"),
 			      NULL);
 
-		gtk_cell_renderer_render (cellvalue->text_renderer, window, widget,
-					  background_area, cell_area, expose_area, flags);
+		gtk_cell_renderer_render (cellvalue->text_renderer, cr, widget,
+					  background_area, cell_area, flags);
 		return;
 	}
 
@@ -355,16 +363,16 @@ gconf_cell_renderer_render (GtkCellRenderer *cell, GdkWindow *window, GtkWidget
 		g_object_set (G_OBJECT (cellvalue->text_renderer),
 			      "text", tmp_str,
 			      NULL);
-		gtk_cell_renderer_render (cellvalue->text_renderer, window, widget,
-					  background_area, cell_area, expose_area, flags);
+		gtk_cell_renderer_render (cellvalue->text_renderer, cr, widget,
+					  background_area, cell_area, flags);
 		g_free (tmp_str);
 		break;
 	case GCONF_VALUE_STRING:
 		g_object_set (G_OBJECT (cellvalue->text_renderer),
 			      "text", gconf_value_get_string (cellvalue->value),
 			      NULL);
-		gtk_cell_renderer_render (cellvalue->text_renderer, window, widget,
-					  background_area, cell_area, expose_area, flags);
+		gtk_cell_renderer_render (cellvalue->text_renderer, cr, widget,
+					  background_area, cell_area, flags);
 		break;
 	case GCONF_VALUE_BOOL:
 		g_object_set (G_OBJECT (cellvalue->toggle_renderer),
@@ -372,8 +380,8 @@ gconf_cell_renderer_render (GtkCellRenderer *cell, GdkWindow *window, GtkWidget
 			      "active", gconf_value_get_bool (cellvalue->value),
 			      NULL);
 		
-		gtk_cell_renderer_render (cellvalue->toggle_renderer, window, widget,
-					  background_area, cell_area, expose_area, flags);
+		gtk_cell_renderer_render (cellvalue->toggle_renderer, cr, widget,
+					  background_area, cell_area, flags);
 		break;
 
 	case GCONF_VALUE_SCHEMA:
@@ -381,8 +389,8 @@ gconf_cell_renderer_render (GtkCellRenderer *cell, GdkWindow *window, GtkWidget
 			      "text", SCHEMA_TEXT,
 			      NULL);
 		
-		gtk_cell_renderer_render (cellvalue->text_renderer, window, widget,
-					  background_area, cell_area, expose_area, flags);
+		gtk_cell_renderer_render (cellvalue->text_renderer, cr, widget,
+					  background_area, cell_area, flags);
 		break;
 		
 	case GCONF_VALUE_LIST:
@@ -391,8 +399,8 @@ gconf_cell_renderer_render (GtkCellRenderer *cell, GdkWindow *window, GtkWidget
 			      "text", tmp_str,
 			      NULL);
 		
-		gtk_cell_renderer_render (cellvalue->text_renderer, window, widget,
-					  background_area, cell_area, expose_area, flags);
+		gtk_cell_renderer_render (cellvalue->text_renderer, cr, widget,
+					  background_area, cell_area, flags);
 		g_free (tmp_str);
 		break;
 	case GCONF_VALUE_PAIR:
@@ -400,8 +408,8 @@ gconf_cell_renderer_render (GtkCellRenderer *cell, GdkWindow *window, GtkWidget
 		g_object_set (G_OBJECT (cellvalue->text_renderer),
 			      "text", tmp_str,
 			      NULL);
-		gtk_cell_renderer_render (cellvalue->text_renderer, window, widget,
-					  background_area, cell_area, expose_area, flags);
+		gtk_cell_renderer_render (cellvalue->text_renderer, cr, widget,
+					  background_area, cell_area, flags);
 		g_free (tmp_str);
 		break;
 
diff --git a/src/gconf-editor-application.c b/src/gconf-editor-application.c
index d1c63e0..fc37105 100644
--- a/src/gconf-editor-application.c
+++ b/src/gconf-editor-application.c
@@ -29,7 +29,7 @@
 static GSList *editor_windows = NULL;
 
 static void
-gconf_editor_application_window_destroyed (GtkObject *window)
+gconf_editor_application_window_destroyed (GtkWidget *window)
 {
 	editor_windows = g_slist_remove (editor_windows, window);
 
@@ -48,7 +48,7 @@ gconf_editor_application_create_editor_window (int type)
 	gconfwindow = GCONF_EDITOR_WINDOW (window);
 
 	if (gconfwindow->client == NULL) {
-		gconf_editor_application_window_destroyed (GTK_OBJECT (window));
+		gconf_editor_application_window_destroyed (window);
 		return NULL;
 	}
 
diff --git a/src/gconf-editor-window.c b/src/gconf-editor-window.c
index 4c9210e..4f51c8b 100644
--- a/src/gconf-editor-window.c
+++ b/src/gconf-editor-window.c
@@ -85,7 +85,7 @@ static void
 gconf_editor_window_close_window (GtkAction *action G_GNUC_UNUSED,
 				  GtkWidget *window)
 {
-	gtk_object_destroy (GTK_OBJECT (window));
+	gtk_widget_destroy (window);
 }
 
 void
@@ -1288,18 +1288,6 @@ gconf_editor_window_setup_ui_prefs_handler (GConfEditorWindow *window)
 	g_object_unref (client);
 }
 
-static void
-gconf_editor_window_style_set (GtkWidget *widget, GtkStyle *prev_style, GtkWidget *text_view)
-{
-	GtkStyle *style;
-
-	style = gtk_widget_get_style (widget);
-	gtk_widget_modify_base (text_view, GTK_STATE_NORMAL,
-				&style->bg[GTK_STATE_NORMAL]);
-	gtk_widget_modify_text (text_view, GTK_STATE_NORMAL,
-				&style->fg[GTK_STATE_NORMAL]);
-}
-
 void
 gconf_editor_window_expand_first (GConfEditorWindow *window)
 {
@@ -1440,9 +1428,8 @@ gconf_editor_window_class_init (GConfEditorWindowClass *klass)
 }
 
 static void
-tree_view_style_set_cb (GtkWidget *widget,
-                        GtkStyle *previous_style,
-                        GObject *cell)
+tree_view_style_updated_cb (GtkWidget *widget,
+                            GObject *cell)
 {
         GdkPixbuf *folder_open = NULL, *folder_closed = NULL;
         int w, h;
@@ -1483,6 +1470,7 @@ gconf_editor_window_init (GConfEditorWindow *window)
 	GtkWidget *details_frame, *alignment, *table, *label, *text_view, *image;
 	gchar *markup;
 	GError *error;
+        GdkRGBA bg;
 	
 	gtk_window_set_default_size (GTK_WINDOW (window), 700, 550);
 
@@ -1568,7 +1556,8 @@ gconf_editor_window_init (GConfEditorWindow *window)
 	column = gtk_tree_view_column_new ();
 
 	cell = gtk_cell_renderer_pixbuf_new ();
-        g_signal_connect (window->tree_view, "style-set", G_CALLBACK (tree_view_style_set_cb), cell);
+        g_signal_connect (window->tree_view, "style-updated",
+                          G_CALLBACK (tree_view_style_updated_cb), cell);
 	gtk_tree_view_column_pack_start (column, cell, FALSE);
 	cell = gtk_cell_renderer_text_new ();
 	gtk_tree_view_column_pack_start (column, cell, TRUE);
@@ -1753,12 +1742,18 @@ gconf_editor_window_init (GConfEditorWindow *window)
 	window->long_desc_buffer = gtk_text_buffer_new (NULL);
 	gtk_text_buffer_set_text (window->long_desc_buffer, _("(None)"), -1);	
 	text_view = gtk_text_view_new_with_buffer (window->long_desc_buffer);
-	g_signal_connect (window, "style_set",
-			  G_CALLBACK (gconf_editor_window_style_set),
-			  text_view);
 	gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view), GTK_WRAP_WORD);
 	gtk_text_view_set_editable (GTK_TEXT_VIEW (text_view), FALSE);
-	scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+
+        gtk_style_context_get_background_color (gtk_widget_get_style_context (GTK_WIDGET (window)),
+                                                0, &bg);
+        gtk_widget_override_background_color (text_view, 0, &bg);
+
+        gtk_style_context_get_background_color (gtk_widget_get_style_context (GTK_WIDGET (window)),
+                                                GTK_STATE_FLAG_SELECTED, &bg);
+        gtk_widget_override_background_color (text_view, GTK_STATE_FLAG_SELECTED, &bg);
+
+        scrolled_window = gtk_scrolled_window_new (NULL, NULL);
 	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
 					GTK_POLICY_AUTOMATIC,
 					GTK_POLICY_AUTOMATIC);
diff --git a/src/gconf-key-editor.c b/src/gconf-key-editor.c
index c265ba5..9cd82d2 100644
--- a/src/gconf-key-editor.c
+++ b/src/gconf-key-editor.c
@@ -116,20 +116,20 @@ gconf_key_editor_create_combo_box (GConfKeyEditor *editor)
 {
 	GtkWidget *combo_box;
 
-	combo_box = gtk_combo_box_new_text ();
+	combo_box = gtk_combo_box_text_new ();
 
 	/* These have to be ordered so the EDIT_ enum matches the
 	 * menu indices
 	 */
 
-	gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), _("Integer"));
-	gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), _("Boolean"));
-	gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), _("String"));
+	gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), _("Integer"));
+	gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), _("Boolean"));
+	gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), _("String"));
 	/* Translators: this refers to "Floating point":
 	 * see http://en.wikipedia.org/wiki/Floating_point
 	 */
-	gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), _("Float"));
-	gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), _("List"));
+	gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), _("Float"));
+	gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), _("List"));
 
 	gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), 0);
 
@@ -146,15 +146,15 @@ gconf_key_editor_create_list_type_menu (GConfKeyEditor *editor)
 {
 	GtkWidget *combo_box;
 
-	combo_box = gtk_combo_box_new_text ();
+	combo_box = gtk_combo_box_text_new ();
 
 	/* These have to be ordered so the EDIT_ enum matches the
 	 * combobox indices
 	 */
 
-	gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), _("Integer"));
-	gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), _("Boolean"));
-	gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), _("String"));
+	gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), _("Integer"));
+	gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), _("Boolean"));
+	gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), _("String"));
 
 	gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), 0);
 	
@@ -227,7 +227,6 @@ list_add_clicked (GtkButton *button,
 	gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
 
 	gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
-	gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
 	gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
 	gtk_box_set_spacing (GTK_BOX (content_area), 2);
 	
@@ -332,7 +331,6 @@ list_edit_element (GConfKeyEditor *editor)
 	gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
 
 	gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
-	gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
 	gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
 	gtk_box_set_spacing (GTK_BOX (content_area), 2);
 	
@@ -551,7 +549,6 @@ gconf_key_editor_init (GConfKeyEditor *editor)
 	gtk_dialog_set_default_response (GTK_DIALOG (editor), GTK_RESPONSE_OK);
 
 	gtk_container_set_border_width (GTK_CONTAINER (editor), 5);
-	gtk_dialog_set_has_separator (GTK_DIALOG (editor), FALSE);
 	gtk_window_set_resizable (GTK_WINDOW (editor), FALSE);
 	gtk_box_set_spacing (GTK_BOX (content_area), 2);
 
diff --git a/src/gconf-search-dialog.c b/src/gconf-search-dialog.c
index 8c67022..cc51ac8 100644
--- a/src/gconf-search-dialog.c
+++ b/src/gconf-search-dialog.c
@@ -128,7 +128,6 @@ gconf_search_dialog_init (GConfSearchDialog *dialog)
 	content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
 	action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
 
-	gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
 	gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
 	gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
 	gtk_box_set_spacing (GTK_BOX (content_area), 2);
diff --git a/src/gedit-output-window.c b/src/gedit-output-window.c
index 18b6dc9..b14b6c6 100644
--- a/src/gedit-output-window.c
+++ b/src/gedit-output-window.c
@@ -68,7 +68,6 @@ enum
 
 
 static void gedit_output_window_finalize 	(GObject 	*object);
-static void gedit_output_window_destroy	 	(GtkObject 	*object);
 
 G_DEFINE_TYPE(GeditOutputWindow, gedit_output_window, GTK_TYPE_HBOX)
 
@@ -78,8 +77,6 @@ gedit_output_window_class_init (GeditOutputWindowClass *klass)
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
    	object_class->finalize = gedit_output_window_finalize;
-	
-	GTK_OBJECT_CLASS (klass)->destroy = gedit_output_window_destroy;
 
 	signals[CLOSE_REQUESTED] = 
 		g_signal_new ("close_requested",
@@ -192,7 +189,7 @@ static gboolean
 gedit_output_window_key_press_event_cb (GtkTreeView *widget, GdkEventKey *event, 
 		GeditOutputWindow *ow)
 {
-	if (event->keyval == GDK_Delete)
+	if (event->keyval == GDK_KEY_Delete)
 	{
 		gedit_output_window_clear (ow);
 		return TRUE;
@@ -302,10 +299,6 @@ gedit_output_window_treeview_selection_changed (GtkTreeSelection *selection,
 static void
 gedit_output_window_format_button (GtkButton* button, gint w, gint h)
 {
-	GtkRcStyle* rc = gtk_widget_get_modifier_style (GTK_WIDGET (button));
-	rc->xthickness = 0;
-	rc->ythickness = 0;
-        gtk_widget_modify_style (GTK_WIDGET (button), rc);
 	gtk_button_set_relief (button, GTK_RELIEF_NONE);
 	gtk_button_set_focus_on_click (button, FALSE);
 }
@@ -493,12 +486,6 @@ gedit_output_window_finalize (GObject *object)
 	G_OBJECT_CLASS (gedit_output_window_parent_class)->finalize (object);
 }
 
-static void 
-gedit_output_window_destroy (GtkObject *object)
-{
-	GTK_OBJECT_CLASS (gedit_output_window_parent_class)->destroy (object);
-}
-
 GtkWidget *
 gedit_output_window_new	(void)
 {



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