GApplication: drop support for appmenu/menubars
authorRyan Lortie <desrt@desrt.ca>
Mon, 16 Jan 2012 19:47:08 +0000 (14:47 -0500)
committerRyan Lortie <desrt@desrt.ca>
Wed, 18 Jan 2012 18:39:22 +0000 (13:39 -0500)
This has been moved over to GtkApplication now.

https://bugzilla.gnome.org/show_bug.cgi?id=668118

gio/gapplication.c
gio/gapplicationimpl-dbus.c

index 5e228497abe581f34d330c60de0bd65246aa4554..7644ceb186da8faa0c9faf016d3d38d0a8e835f1 100644 (file)
@@ -226,9 +226,7 @@ enum
   PROP_IS_REGISTERED,
   PROP_IS_REMOTE,
   PROP_INACTIVITY_TIMEOUT,
-  PROP_ACTION_GROUP,
-  PROP_APP_MENU,
-  PROP_MENUBAR
+  PROP_ACTION_GROUP
 };
 
 enum
@@ -508,13 +506,6 @@ g_application_real_add_platform_data (GApplication    *application,
 }
 
 /* GObject implementation stuff {{{1 */
-static void         g_application_set_app_menu (GApplication *application,
-                                                GMenuModel   *app_menu);
-static GMenuModel * g_application_get_app_menu (GApplication *application);
-static void         g_application_set_menubar  (GApplication *application,
-                                                GMenuModel   *menubar);
-static GMenuModel * g_application_get_menubar  (GApplication *application);
-
 static void
 g_application_set_property (GObject      *object,
                             guint         prop_id,
@@ -544,14 +535,6 @@ g_application_set_property (GObject      *object,
       application->priv->actions = g_value_dup_object (value);
       break;
 
-    case PROP_APP_MENU:
-      g_application_set_app_menu (application, g_value_get_object (value));
-      break;
-
-    case PROP_MENUBAR:
-      g_application_set_menubar (application, g_value_get_object (value));
-      break;
-
     default:
       g_assert_not_reached ();
     }
@@ -589,62 +572,6 @@ g_application_set_action_group (GApplication *application,
     g_object_ref (application->priv->actions);
 }
 
-static void
-g_application_set_app_menu (GApplication *application,
-                            GMenuModel   *app_menu)
-{
-  g_return_if_fail (G_IS_APPLICATION (application));
-
-  if (app_menu != application->priv->app_menu)
-    {
-      if (application->priv->app_menu != NULL)
-        g_object_unref (application->priv->app_menu);
-
-      application->priv->app_menu = app_menu;
-
-      if (application->priv->app_menu != NULL)
-        g_object_ref (application->priv->app_menu);
-
-      g_object_notify (G_OBJECT (application), "app-menu");
-    }
-}
-
-static GMenuModel *
-g_application_get_app_menu (GApplication *application)
-{
-  g_return_val_if_fail (G_IS_APPLICATION (application), NULL);
-
-  return application->priv->app_menu;
-}
-
-static void
-g_application_set_menubar (GApplication *application,
-                            GMenuModel   *menubar)
-{
-  g_return_if_fail (G_IS_APPLICATION (application));
-
-  if (menubar != application->priv->menubar)
-    {
-      if (application->priv->menubar != NULL)
-        g_object_unref (application->priv->menubar);
-
-      application->priv->menubar = menubar;
-
-      if (application->priv->menubar != NULL)
-        g_object_ref (application->priv->menubar);
-
-      g_object_notify (G_OBJECT (application), "menubar");
-    }
-}
-
-static GMenuModel *
-g_application_get_menubar (GApplication *application)
-{
-  g_return_val_if_fail (G_IS_APPLICATION (application), NULL);
-
-  return application->priv->menubar;
-}
-
 static void
 g_application_get_property (GObject    *object,
                             guint       prop_id,
@@ -680,16 +607,6 @@ g_application_get_property (GObject    *object,
                         g_application_get_inactivity_timeout (application));
       break;
 
-    case PROP_APP_MENU:
-      g_value_set_object (value,
-                          g_application_get_app_menu (application));
-      break;
-
-    case PROP_MENUBAR:
-      g_value_set_object (value,
-                          g_application_get_menubar (application));
-      break;
-
     default:
       g_assert_not_reached ();
     }
@@ -718,12 +635,6 @@ g_application_finalize (GObject *object)
   if (g_application_get_default () == application)
     g_application_set_default (NULL);
 
-  if (application->priv->app_menu)
-    g_object_unref (application->priv->app_menu);
-
-  if (application->priv->menubar)
-    g_object_unref (application->priv->menubar);
-
   if (application->priv->actions)
     g_object_unref (application->priv->actions);
 
@@ -813,20 +724,6 @@ g_application_class_init (GApplicationClass *class)
                          G_TYPE_ACTION_GROUP,
                          G_PARAM_DEPRECATED | G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
 
-  g_object_class_install_property (object_class, PROP_APP_MENU,
-    g_param_spec_object ("app-menu",
-                         P_("Application menu"),
-                         P_("The GMenuModel for the application menu"),
-                         G_TYPE_MENU_MODEL,
-                         G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
-  g_object_class_install_property (object_class, PROP_MENUBAR,
-    g_param_spec_object ("menubar",
-                         P_("Menubar"),
-                         P_("The GMenuModel for the menubar"),
-                         G_TYPE_MENU_MODEL,
-                         G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
   /**
    * GApplication::startup:
    * @application: the application
index d307f2a49090067f28b3a88ffa0dcec894c3a902..2dfc153c461110b35f4171c88ac543547c1753b2 100644 (file)
@@ -30,7 +30,6 @@
 #include "gdbusconnection.h"
 #include "gdbusintrospection.h"
 #include "gdbuserror.h"
-#include "gmenuexporter.h"
 
 #include <string.h>
 #include <stdio.h>
@@ -66,8 +65,6 @@ static const gchar org_gtk_Application_xml[] =
   "      <arg type='a{sv}' name='platform-data' direction='in'/>"
   "      <arg type='i' name='exit-status' direction='out'/>"
   "    </method>"
-  "    <property name='AppMenu' type='ao' access='read'/>"
-  "    <property name='MenuBar' type='ao' access='read'/>"
   "  </interface>"
   "</node>";
 
@@ -98,12 +95,6 @@ struct _GApplicationImpl
   guint            object_id;
   guint            actions_id;
 
-  gchar           *app_menu_path;
-  guint            app_menu_id;
-
-  gchar           *menubar_path;
-  guint            menubar_id;
-
   gboolean         properties_live;
   gboolean         primary;
   gpointer         app;
@@ -198,44 +189,6 @@ g_application_impl_method_call (GDBusConnection       *connection,
     g_assert_not_reached ();
 }
 
-static GVariant *
-g_application_impl_get_property (GDBusConnection  *connection,
-                                 const gchar      *sender,
-                                 const gchar      *object_path,
-                                 const gchar      *interface_name,
-                                 const gchar      *property_name,
-                                 GError          **error,
-                                 gpointer          user_data)
-{
-  GApplicationImpl *impl = user_data;
-  GVariantBuilder builder;
-
-  /* We use this boolean to detect if the properties have ever been
-   * queried before.  If they have not been queried, then there is no
-   * point emitting change signals since nobody is watching anyway.
-   */
-  impl->properties_live = TRUE;
-
-  g_variant_builder_init (&builder, G_VARIANT_TYPE_OBJECT_PATH_ARRAY);
-
-  if (g_str_equal (property_name, "AppMenu"))
-    {
-      if (impl->app_menu_path != NULL)
-        g_variant_builder_add (&builder, "o", impl->app_menu_path);
-    }
-
-  else if (g_str_equal (property_name, "MenuBar"))
-    {
-      if (impl->menubar_path != NULL)
-        g_variant_builder_add (&builder, "o", impl->menubar_path);
-    }
-
-  else
-    g_assert_not_reached ();
-
-  return g_variant_builder_end (&builder);
-}
-
 static gchar *
 application_path_from_appid (const gchar *appid)
 {
@@ -254,85 +207,6 @@ application_path_from_appid (const gchar *appid)
   return appid_path;
 }
 
-static void
-g_application_impl_publish_menu (GApplicationImpl  *impl,
-                                 const gchar       *type,
-                                 GMenuModel        *model,
-                                 guint             *id,
-                                 gchar            **path)
-{
-  gint i;
-
-  /* unexport any existing menu */
-  if (*id)
-    {
-      g_dbus_connection_unexport_menu_model (impl->session_bus, *id);
-      g_free (*path);
-      *path = NULL;
-      *id = 0;
-    }
-
-  /* export the new menu, if there is one */
-  if (model != NULL)
-    {
-      /* try getting the preferred name */
-      *path = g_strconcat (impl->object_path, "/menus/", type, NULL);
-      *id = g_dbus_connection_export_menu_model (impl->session_bus, *path, model, NULL);
-
-      /* keep trying until we get a working name... */
-      for (i = 0; *id == 0; i++)
-        {
-          g_free (*path);
-          *path = g_strdup_printf ("%s/menus/%s%d", impl->object_path, type, i);
-          *id = g_dbus_connection_export_menu_model (impl->session_bus, *path, model, NULL);
-        }
-    }
-
-  /* notify for changes, if needed */
-  if (impl->properties_live)
-    {
-      GVariantBuilder builder;
-
-      g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
-      g_variant_builder_add (&builder, "{sv}", type, g_variant_new_objv ((const gchar **) path, *path != NULL));
-      g_dbus_connection_emit_signal (impl->session_bus, NULL, impl->object_path,
-                                     "org.freedesktop.DBus.Properties", "PropertiesChanged",
-                                     g_variant_new ("(sa{sv}as)", "org.gtk.Actions", &builder, NULL), NULL);
-    }
-}
-
-static void
-g_application_impl_app_menu_changed (GObject    *source,
-                                     GParamSpec *pspec,
-                                     gpointer    user_data)
-{
-  GApplicationImpl *impl = user_data;
-  GMenuModel *app_menu;
-
-  g_assert (source == impl->app);
-
-  g_object_get (impl->app, "app-menu", &app_menu, NULL);
-
-  g_application_impl_publish_menu (impl, "AppMenu", app_menu, &impl->app_menu_id, &impl->app_menu_path);
-  g_clear_object (&app_menu);
-}
-
-static void
-g_application_impl_menubar_changed (GObject    *source,
-                                    GParamSpec *pspec,
-                                    gpointer    user_data)
-{
-  GApplicationImpl *impl = user_data;
-  GMenuModel *menubar;
-
-  g_assert (source == impl->app);
-
-  g_object_get (impl->app, "menubar", &menubar, NULL);
-
-  g_application_impl_publish_menu (impl, "MenuBar", menubar, &impl->menubar_id, &impl->menubar_path);
-  g_clear_object (&menubar);
-}
-
 /* Attempt to become the primary instance.
  *
  * Returns %TRUE if everything went OK, regardless of if we became the
@@ -349,7 +223,6 @@ g_application_impl_attempt_primary (GApplicationImpl  *impl,
 {
   const static GDBusInterfaceVTable vtable = {
     g_application_impl_method_call,
-    g_application_impl_get_property
   };
   GVariant *reply;
   guint32 rval;
@@ -409,14 +282,6 @@ g_application_impl_attempt_primary (GApplicationImpl  *impl,
   /* DBUS_REQUEST_NAME_REPLY_EXISTS: 3 */
   impl->primary = (rval != 3);
 
-  if (impl->primary)
-    {
-      g_signal_connect (impl->app, "notify::app-menu", G_CALLBACK (g_application_impl_app_menu_changed), impl);
-      g_signal_connect (impl->app, "notify::menubar", G_CALLBACK (g_application_impl_menubar_changed), impl);
-      g_application_impl_app_menu_changed (impl->app, NULL, impl);
-      g_application_impl_menubar_changed (impl->app, NULL, impl);
-    }
-
   return TRUE;
 }
 
@@ -445,31 +310,12 @@ g_application_impl_stop_primary (GApplicationImpl *impl)
 
   if (impl->primary)
     {
-      g_signal_handlers_disconnect_by_func (impl->app, g_application_impl_app_menu_changed, impl);
-      g_signal_handlers_disconnect_by_func (impl->app, g_application_impl_menubar_changed, impl);
-
       g_dbus_connection_call (impl->session_bus, "org.freedesktop.DBus",
                               "/org/freedesktop/DBus", "org.freedesktop.DBus",
                               "ReleaseName", g_variant_new ("(s)", impl->bus_name),
                               NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
       impl->primary = FALSE;
     }
-
-  if (impl->app_menu_id)
-    {
-      g_dbus_connection_unexport_menu_model (impl->session_bus, impl->app_menu_id);
-      g_free (impl->app_menu_path);
-      impl->app_menu_path = NULL;
-      impl->app_menu_id = 0;
-    }
-
-  if (impl->menubar_id)
-    {
-      g_dbus_connection_unexport_menu_model (impl->session_bus, impl->menubar_id);
-      g_free (impl->menubar_path);
-      impl->menubar_path = NULL;
-      impl->menubar_id = 0;
-    }
 }
 
 void