[seahorse-plugins] Migrate to GTK3



commit bfa4c26ea63bb2bda879d04f09a222d3817ce2bc
Author: Stef Walter <stef memberwebs com>
Date:   Wed Oct 6 22:26:27 2010 +0000

    Migrate to GTK3
    
    To build with GTK3 use the --with-gtk=3.0 command line argument.

 configure.in                                |   27 +++++++++++++-
 libseahorse/seahorse-passphrase.c           |    7 ++-
 libseahorse/seahorse-widget.c               |   55 +++++++++++++++++---------
 libseahorse/seahorse-widget.h               |   20 ++++++----
 plugins/nautilus/seahorse-pgp-preferences.c |    6 +-
 5 files changed, 82 insertions(+), 33 deletions(-)
---
diff --git a/configure.in b/configure.in
index 633ce1e..1f7ebc8 100644
--- a/configure.in
+++ b/configure.in
@@ -31,7 +31,31 @@ AC_CHECK_FUNCS(strsep)
 
 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
 
-PKG_CHECK_MODULES(SEAHORSE, gconf-2.0 gtk+-2.0 >= 2.18.0 gio-2.0)
+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.0
+	;;
+esac
+
+AC_SUBST(GTK_API_VERSION)
+AM_CONDITIONAL([WITH_GTK3],[test "$with_gtk" = "3.0"])
+
+PKG_CHECK_MODULES(SEAHORSE, gconf-2.0 gtk+-$GTK_API_VERSION >= $GTK_REQUIRED gio-2.0)
 
 AC_MSG_CHECKING([for some Win32 platform])
 case "$host" in
@@ -619,6 +643,7 @@ dnl  SUMMARY
 dnl ****************************************************************************
 
 echo "
+GTK+ Version:            $GTK_API_VERSION
 GnuPG Version:           $gnupg_version
 GPGME Version:           $gpgme_config_version
 Plugins:
diff --git a/libseahorse/seahorse-passphrase.c b/libseahorse/seahorse-passphrase.c
index 658d276..a33d2b9 100644
--- a/libseahorse/seahorse-passphrase.c
+++ b/libseahorse/seahorse-passphrase.c
@@ -40,6 +40,9 @@
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
+#if GTK_CHECK_VERSION (2,90,0)
+#include <gdk/gdkkeysyms-compat.h>
+#endif
 
 #include "seahorse-gpgmex.h"
 #include "seahorse-libdialogs.h"
@@ -201,8 +204,8 @@ seahorse_passphrase_prompt_show (const gchar *title, const gchar *description,
 
     if (!prompt)
         prompt = _("Password:"); 
-    
-    w = gtk_dialog_new_with_buttons (title, NULL, GTK_DIALOG_NO_SEPARATOR, NULL);
+
+    w = gtk_dialog_new_with_buttons (title, NULL, 0, NULL);
     gtk_window_set_icon_name (GTK_WINDOW (w), GTK_STOCK_DIALOG_AUTHENTICATION);
 
     dialog = GTK_DIALOG (w);
diff --git a/libseahorse/seahorse-widget.c b/libseahorse/seahorse-widget.c
index 3fb9e5a..7bdaad7 100644
--- a/libseahorse/seahorse-widget.c
+++ b/libseahorse/seahorse-widget.c
@@ -37,9 +37,17 @@ enum {
 	PROP_NAME
 };
 
+enum {
+	DESTROY,
+	LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
 static void     class_init          (SeahorseWidgetClass    *klass);
 static void     object_init         (SeahorseWidget         *swidget);
 
+static void     object_dispose      (GObject                *object);
 static void     object_finalize     (GObject                *gobject);
 
 static void     object_set_property (GObject                *object,
@@ -67,7 +75,7 @@ G_MODULE_EXPORT gboolean on_widget_delete_event  (GtkWidget             *widget,
                                                        GdkEvent              *event,
                                                        SeahorseWidget        *swidget);
 
-static GtkObjectClass *parent_class = NULL;
+static GObjectClass *parent_class = NULL;
 
 /* Hash of widgets with name as key */
 static GHashTable *widgets = NULL;
@@ -84,8 +92,8 @@ seahorse_widget_get_type (void)
 			NULL, NULL, sizeof (SeahorseWidget), 0, (GInstanceInitFunc) object_init
 		};
 		
-        widget_type = g_type_register_static (GTK_TYPE_OBJECT, "SeahorseWidget", 
-                                              &widget_info, 0);
+		widget_type = g_type_register_static (G_TYPE_OBJECT, "SeahorseWidget",
+		                                      &widget_info, 0);
 	}
 	
 	return widget_type;
@@ -98,15 +106,20 @@ class_init (SeahorseWidgetClass *klass)
 	
 	parent_class = g_type_class_peek_parent (klass);
 	gobject_class = G_OBJECT_CLASS (klass);
-	
+
 	gobject_class->constructor = seahorse_widget_constructor;
+	gobject_class->dispose = object_dispose;
 	gobject_class->finalize = object_finalize;
 	gobject_class->set_property = object_set_property;
 	gobject_class->get_property = object_get_property;
-	
-    g_object_class_install_property (gobject_class, PROP_NAME,
-        g_param_spec_string ("name", "Widget name", "Name of gtkbuilder file and main widget",
-                             NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+	g_object_class_install_property (gobject_class, PROP_NAME,
+	         g_param_spec_string ("name", "Widget name", "Name of gtkbuilder file and main widget",
+	                              NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+	signals[DESTROY] = g_signal_new ("destroy", SEAHORSE_TYPE_WIDGET,
+	                                 G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (SeahorseWidgetClass, destroy),
+	                                 NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
 }
 
 static void
@@ -147,6 +160,20 @@ seahorse_widget_constructor (GType type, guint n_props, GObjectConstructParam* p
     return obj;
 }
 
+static void
+object_dispose (GObject *object)
+{
+	SeahorseWidget *swidget = SEAHORSE_WIDGET (object);
+
+	if (!swidget->in_destruction) {
+		swidget->in_destruction = TRUE;
+		g_signal_emit (swidget, signals[DESTROY], 0);
+		swidget->in_destruction = FALSE;
+	}
+
+	G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
 /* Disconnects callbacks, destroys main window widget,
  * and frees the xml definition and any other data */
 static void
@@ -276,11 +303,6 @@ seahorse_widget_new (const gchar *name, GtkWindow *parent)
         gtk_window_set_transient_for (window, parent);
     }
 
-    /* We don't care about this floating business */
-    g_object_ref (GTK_OBJECT (swidget));
-    g_object_ref_sink (GTK_OBJECT (swidget));
-    g_object_unref (GTK_OBJECT (swidget));
-
     return swidget;
 }
 
@@ -305,13 +327,8 @@ seahorse_widget_new_allow_multiple (const gchar *name, GtkWindow *parent)
     }
 
 	gtk_builder_connect_signals (swidget->gtkbuilder, NULL);
-    
-    /* We don't care about this floating business */
-    g_object_ref (GTK_OBJECT (swidget));
-    g_object_ref_sink (GTK_OBJECT (swidget));
-    g_object_unref (GTK_OBJECT (swidget));
 
-    return swidget;
+	return swidget;
 }
 
 SeahorseWidget*
diff --git a/libseahorse/seahorse-widget.h b/libseahorse/seahorse-widget.h
index b5929c1..a753ab5 100644
--- a/libseahorse/seahorse-widget.h
+++ b/libseahorse/seahorse-widget.h
@@ -56,18 +56,22 @@ typedef struct _SeahorseWidgetClass SeahorseWidgetClass;
  */
 
 struct _SeahorseWidget {
-    GtkObject parent;
-
-    /*< public >*/
-    GtkBuilder *gtkbuilder;
-    gchar *name;
-    
-    /*< private >*/
-    gboolean destroying;
+	GObject parent;
+
+	/*< public >*/
+	GtkBuilder *gtkbuilder;
+	gchar *name;
+
+	/*< private >*/
+	gboolean destroying;
+	gboolean in_destruction;
 };
 
 struct _SeahorseWidgetClass {
-    GtkObjectClass parent_class;
+	GObjectClass parent_class;
+
+	/*< signals >*/
+	void (*destroy) (SeahorseWidget *swidget);
 };
 
 GType            seahorse_widget_get_type ();
diff --git a/plugins/nautilus/seahorse-pgp-preferences.c b/plugins/nautilus/seahorse-pgp-preferences.c
index 9b9b076..cc8bae9 100644
--- a/plugins/nautilus/seahorse-pgp-preferences.c
+++ b/plugins/nautilus/seahorse-pgp-preferences.c
@@ -42,15 +42,15 @@ static const GOptionEntry options[] = {
 };
 
 G_MODULE_EXPORT static void
-destroyed (GtkObject *object, gpointer data)
+destroyed (gpointer widget, gpointer data)
 {
 	exit (0);
 }
 
 G_MODULE_EXPORT static void
-help_clicked (GtkObject *object, SeahorseWidget *swidget)
+help_clicked (GtkWidget *widget, SeahorseWidget *swidget)
 {
-    seahorse_widget_show_help (swidget);
+	seahorse_widget_show_help (swidget);
 }
 
 int



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