[gtk+] GtkApplication: adjust to GApplication changes



commit af71917015fc93c0dce5423b6f29e602d8fe751d
Author: Ryan Lortie <desrt desrt ca>
Date:   Mon Apr 30 12:34:47 2012 -0400

    GtkApplication: adjust to GApplication changes
    
    GApplication now makes the session bus and object path available as a
    public API on the application instance.  Use that instead of trying to
    guess values for ourselves.
    
    This causes this version of Gtk+ to depend on GLib 2.32.2, so bumping
    version dependency accordingly.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=671249

 configure.ac                |    2 +-
 gtk/gtkapplication.c        |   36 ++++--------------------------------
 gtk/gtkapplicationprivate.h |    2 --
 gtk/gtkapplicationwindow.c  |    2 +-
 4 files changed, 6 insertions(+), 36 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 440176c..7901e1e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,7 +39,7 @@ AC_CONFIG_AUX_DIR([build-aux])
 m4_define([gtk_binary_version], [3.0.0])
 
 # required versions of other packages
-m4_define([glib_required_version], [2.32.0])
+m4_define([glib_required_version], [2.33.1])
 m4_define([pango_required_version], [1.30.0])
 m4_define([atk_required_version], [2.2.0])
 m4_define([cairo_required_version], [1.10.0])
diff --git a/gtk/gtkapplication.c b/gtk/gtkapplication.c
index 945e333..06403d3 100644
--- a/gtk/gtkapplication.c
+++ b/gtk/gtkapplication.c
@@ -149,7 +149,7 @@ struct _GtkApplicationPrivate
 #ifdef GDK_WINDOWING_X11
   GDBusConnection *session_bus;
   const gchar     *application_id;
-  gchar           *object_path;
+  const gchar     *object_path;
 
   gchar           *app_menu_path;
   guint            app_menu_id;
@@ -274,34 +274,13 @@ gtk_application_window_removed_x11 (GtkApplication *application,
     gtk_application_window_unpublish (GTK_APPLICATION_WINDOW (window));
 }
 
-static gchar *
-object_path_from_appid (const gchar *appid)
-{
-  gchar *appid_path, *iter;
-
-  appid_path = g_strconcat ("/", appid, NULL);
-  for (iter = appid_path; *iter; iter++)
-    {
-      if (*iter == '.')
-        *iter = '/';
-
-      if (*iter == '-')
-        *iter = '_';
-    }
-
-  return appid_path;
-}
-
 static void gtk_application_startup_session_dbus (GtkApplication *app);
 
 static void
 gtk_application_startup_x11 (GtkApplication *application)
 {
-  const gchar *application_id;
-
-  application_id = g_application_get_application_id (G_APPLICATION (application));
-  application->priv->session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
-  application->priv->object_path = object_path_from_appid (application_id);
+  application->priv->session_bus = g_application_get_dbus_connection (G_APPLICATION (application));
+  application->priv->object_path = g_application_get_dbus_object_path (G_APPLICATION (application));
 
   gtk_application_startup_session_dbus (GTK_APPLICATION (application));
 }
@@ -309,9 +288,8 @@ gtk_application_startup_x11 (GtkApplication *application)
 static void
 gtk_application_shutdown_x11 (GtkApplication *application)
 {
-  g_free (application->priv->object_path);
+  application->priv->session_bus = NULL;
   application->priv->object_path = NULL;
-  g_clear_object (&application->priv->session_bus);
 
   g_clear_object (&application->priv->sm_proxy);
   g_clear_object (&application->priv->client_proxy);
@@ -320,12 +298,6 @@ gtk_application_shutdown_x11 (GtkApplication *application)
 }
 
 const gchar *
-gtk_application_get_dbus_object_path (GtkApplication *application)
-{
-  return application->priv->object_path;
-}
-
-const gchar *
 gtk_application_get_app_menu_object_path (GtkApplication *application)
 {
   return application->priv->app_menu_path;
diff --git a/gtk/gtkapplicationprivate.h b/gtk/gtkapplicationprivate.h
index a68015d..e838e88 100644
--- a/gtk/gtkapplicationprivate.h
+++ b/gtk/gtkapplicationprivate.h
@@ -44,8 +44,6 @@ G_GNUC_INTERNAL
 GtkAccelGroup         * gtk_application_window_get_accel_group          (GtkApplicationWindow *window);
 
 G_GNUC_INTERNAL
-const gchar *           gtk_application_get_dbus_object_path            (GtkApplication       *application);
-G_GNUC_INTERNAL
 const gchar *           gtk_application_get_app_menu_object_path        (GtkApplication       *application);
 G_GNUC_INTERNAL
 const gchar *           gtk_application_get_menubar_object_path         (GtkApplication       *application);
diff --git a/gtk/gtkapplicationwindow.c b/gtk/gtkapplicationwindow.c
index 1f045ca..495897e 100644
--- a/gtk/gtkapplicationwindow.c
+++ b/gtk/gtkapplicationwindow.c
@@ -777,7 +777,7 @@ gtk_application_window_real_realize (GtkWidget *widget)
                                           g_dbus_connection_get_unique_name (window->priv->session));
 
         gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_APPLICATION_OBJECT_PATH",
-                                          gtk_application_get_dbus_object_path (application));
+                                          g_application_get_dbus_object_path (G_APPLICATION (application)));
 
         gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_WINDOW_OBJECT_PATH",
                                           window->priv->object_path);



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