[gnome-flashback/gnome-3-24] Revert "bluetooth-applet: port GtkStatusIcon to SnItem"



commit 1e64b4297aed054218b1e323186941cba7943e0a
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Tue Mar 28 17:58:10 2017 +0300

    Revert "bluetooth-applet: port GtkStatusIcon to SnItem"
    
    This reverts commit 1e119e6db1c66b428d5e12eb741e2049385167e9.

 gnome-flashback/libbluetooth-applet/Makefile.am    |    1 -
 .../libbluetooth-applet/gf-bluetooth-applet.c      |   58 ++++++++++----------
 2 files changed, 29 insertions(+), 30 deletions(-)
---
diff --git a/gnome-flashback/libbluetooth-applet/Makefile.am b/gnome-flashback/libbluetooth-applet/Makefile.am
index 60d1f0e..20e2dcf 100644
--- a/gnome-flashback/libbluetooth-applet/Makefile.am
+++ b/gnome-flashback/libbluetooth-applet/Makefile.am
@@ -29,7 +29,6 @@ libbluetooth_applet_la_LDFLAGS = \
        $(NULL)
 
 libbluetooth_applet_la_LIBADD = \
-       $(top_builddir)/libstatus-notifier/libstatus-notifier.la \
        $(BLUETOOTH_APPLET_LIBS) \
        $(NULL)
 
diff --git a/gnome-flashback/libbluetooth-applet/gf-bluetooth-applet.c 
b/gnome-flashback/libbluetooth-applet/gf-bluetooth-applet.c
index 8bf9d0d..b3ec1df 100644
--- a/gnome-flashback/libbluetooth-applet/gf-bluetooth-applet.c
+++ b/gnome-flashback/libbluetooth-applet/gf-bluetooth-applet.c
@@ -18,13 +18,11 @@
 #include "config.h"
 
 #include <bluetooth-client.h>
-#include <gdk/gdkx.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
 #include "gf-bluetooth-applet.h"
 #include "gf-sd-rfkill.h"
-#include "libstatus-notifier/sn-item.h"
 
 #define GSM_DBUS_NAME "org.gnome.SettingsDaemon.Rfkill"
 #define GSM_DBUS_PATH "/org/gnome/SettingsDaemon/Rfkill"
@@ -35,7 +33,7 @@ struct _GfBluetoothApplet
 
   gint             bus_name_id;
 
-  SnItem          *status_item;
+  GtkStatusIcon   *status_icon;
   GfSdRfkill      *rfkill;
   BluetoothClient *client;
   GtkTreeModel    *model;
@@ -138,17 +136,19 @@ settings_cb (GtkMenuItem *item,
 }
 
 static void
-context_menu_cb (SnItem            *object,
-                 gint               x,
-                 gint               y,
-                 GfBluetoothApplet *applet)
+popup_menu_cb (GtkStatusIcon *status_icon,
+               guint          button,
+               guint          activate_time,
+               gpointer       user_data)
 {
+  GfBluetoothApplet *applet;
   GtkWidget *menu;
   gboolean airplane_mode;
   GtkWidget *item;
-  GdkScreen *screen;
-  GdkWindow *root;
 
+  G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
+  applet = GF_BLUETOOTH_APPLET (user_data);
   menu = gtk_menu_new ();
 
   airplane_mode = FALSE;
@@ -176,12 +176,12 @@ context_menu_cb (SnItem            *object,
   gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
   g_signal_connect (item, "activate", G_CALLBACK (settings_cb), NULL);
 
-  screen = gdk_screen_get_default ();
-  root = gdk_screen_get_root_window (screen);
-
   gtk_widget_show_all (menu);
-  gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
-                  0, gdk_x11_get_server_time (root));
+  gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
+                  gtk_status_icon_position_menu, status_icon,
+                  button, activate_time);
+
+  G_GNUC_END_IGNORE_DEPRECATIONS
 }
 
 static GtkTreeIter *
@@ -257,7 +257,8 @@ gf_bluetooth_applet_sync (GfBluetoothApplet *applet)
 
   if (devices == -1)
     {
-      g_clear_object (&applet->status_item);
+      g_clear_object (&applet->status_icon);
+
       return;
     }
 
@@ -287,23 +288,22 @@ gf_bluetooth_applet_sync (GfBluetoothApplet *applet)
       tooltip_text = g_strdup (_("Not Connected"));
     }
 
-  if (applet->status_item == NULL)
-    {
-      applet->status_item = g_object_new (SN_TYPE_ITEM,
-                                          "version", 0,
-                                          "category", SN_ITEM_CATEGORY_SYSTEM_SERVICES,
-                                          "id", "gf-bluetooth-applet",
-                                           NULL);
+  G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 
-      g_signal_connect (applet->status_item, "context-menu",
-                        G_CALLBACK (context_menu_cb), applet);
+  if (applet->status_icon == NULL)
+    {
+      applet->status_icon = gtk_status_icon_new ();
 
-      sn_item_register (applet->status_item);
+      g_signal_connect (applet->status_icon, "popup-menu",
+                        G_CALLBACK (popup_menu_cb), applet);
     }
 
-  sn_item_set_title (applet->status_item, title);
-  sn_item_set_icon_name (applet->status_item, icon_name);
-  sn_item_set_tooltip (applet->status_item, NULL, NULL, NULL, tooltip_text);
+  gtk_status_icon_set_title (applet->status_icon, title);
+  gtk_status_icon_set_from_icon_name (applet->status_icon, icon_name);
+  gtk_status_icon_set_tooltip_text (applet->status_icon, tooltip_text);
+  gtk_status_icon_set_visible (applet->status_icon, TRUE);
+
+  G_GNUC_END_IGNORE_DEPRECATIONS
 
   g_free (tooltip_text);
 }
@@ -424,7 +424,7 @@ gf_bluetooth_applet_dispose (GObject *object)
       applet->bus_name_id = 0;
     }
 
-  g_clear_object (&applet->status_item);
+  g_clear_object (&applet->status_icon);
   g_clear_object (&applet->rfkill);
   g_clear_object (&applet->client);
   g_clear_object (&applet->model);


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