aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/app-indicator.c354
1 files changed, 0 insertions, 354 deletions
diff --git a/src/app-indicator.c b/src/app-indicator.c
index 35ac818..039b980 100644
--- a/src/app-indicator.c
+++ b/src/app-indicator.c
@@ -176,7 +176,6 @@ static void unfallback (AppIndicator * self, GtkStatusIcon * status_icon);
static gchar * append_panel_icon_suffix (const gchar * icon_name);
static void watcher_owner_changed (GObject * obj, GParamSpec * pspec, gpointer user_data);
static void client_menu_changed (GtkWidget *widget, GtkWidget *child, AppIndicator *indicator);
-static void submenu_changed (GtkWidget *widget, GtkWidget *child, gpointer data);
static void theme_changed_cb (GtkIconTheme * theme, gpointer user_data);
static GVariant * bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * property, GError ** error, gpointer user_data);
static void bus_creation (GObject * obj, GAsyncResult * res, gpointer user_data);
@@ -1680,359 +1679,6 @@ app_indicator_set_icon_theme_path (AppIndicator *self, const gchar *icon_theme_p
return;
}
-static void
-activate_menuitem (DbusmenuMenuitem *mi, guint timestamp, gpointer user_data)
-{
- GtkWidget *widget = (GtkWidget *)user_data;
-
- gtk_menu_item_activate (GTK_MENU_ITEM (widget));
-}
-
-static void
-widget_toggled (GtkWidget *widget, DbusmenuMenuitem *mi)
-{
- dbusmenu_menuitem_property_set_int (mi,
- DBUSMENU_MENUITEM_PROP_TOGGLE_STATE,
- gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)) ? DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED : DBUSMENU_MENUITEM_TOGGLE_STATE_UNCHECKED);
-}
-
-static void
-menuitem_iterate (GtkWidget *widget,
- gpointer data)
-{
- if (GTK_IS_LABEL (widget))
- {
- DbusmenuMenuitem *child = (DbusmenuMenuitem *)data;
-
- dbusmenu_menuitem_property_set (child,
- DBUSMENU_MENUITEM_PROP_LABEL,
- gtk_label_get_text (GTK_LABEL (widget)));
- }
-}
-
-static gboolean
-should_show_image (GtkImage *image)
-{
- GtkWidget *item;
-
- item = gtk_widget_get_ancestor (GTK_WIDGET (image),
- GTK_TYPE_IMAGE_MENU_ITEM);
-
- if (item)
- {
- GtkSettings *settings;
- gboolean gtk_menu_images;
-
- settings = gtk_widget_get_settings (item);
-
- g_object_get (settings, "gtk-menu-images", &gtk_menu_images, NULL);
-
- if (gtk_menu_images)
- return TRUE;
-
- return gtk_image_menu_item_get_always_show_image (GTK_IMAGE_MENU_ITEM (item));
- }
-
- return FALSE;
-}
-
-static void
-update_icon_name (DbusmenuMenuitem *menuitem,
- GtkImage *image)
-{
- const gchar *icon_name = NULL;
-
- if (gtk_image_get_storage_type (image) != GTK_IMAGE_ICON_NAME)
- return;
-
- gtk_image_get_icon_name (image, &icon_name, NULL);
-
- if (should_show_image (image))
- dbusmenu_menuitem_property_set (menuitem,
- DBUSMENU_MENUITEM_PROP_ICON_NAME,
- icon_name);
- else
- dbusmenu_menuitem_property_remove (menuitem,
- DBUSMENU_MENUITEM_PROP_ICON_NAME);
-}
-
-/* return value specifies whether the label is set or not */
-static gboolean
-update_stock_item (DbusmenuMenuitem *menuitem,
- GtkImage *image)
-{
- GtkStockItem stock;
- gchar *stock_id = NULL;
-
- if (gtk_image_get_storage_type (image) != GTK_IMAGE_STOCK)
- return FALSE;
-
- gtk_image_get_stock (image, &stock_id, NULL);
- gtk_stock_lookup (stock_id, &stock);
-
- if (should_show_image (image))
- dbusmenu_menuitem_property_set (menuitem,
- DBUSMENU_MENUITEM_PROP_ICON_NAME,
- stock_id);
- else
- dbusmenu_menuitem_property_remove (menuitem,
- DBUSMENU_MENUITEM_PROP_ICON_NAME);
-
- const gchar * label = dbusmenu_menuitem_property_get (menuitem,
- DBUSMENU_MENUITEM_PROP_LABEL);
-
- if (stock.label != NULL && label != NULL)
- {
- dbusmenu_menuitem_property_set (menuitem,
- DBUSMENU_MENUITEM_PROP_LABEL,
- stock.label);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-image_notify_cb (GtkWidget *widget,
- GParamSpec *pspec,
- gpointer data)
-{
- DbusmenuMenuitem *child = (DbusmenuMenuitem *)data;
- GtkImage *image = GTK_IMAGE (widget);
-
- if (pspec->name == g_intern_static_string ("stock"))
- {
- update_stock_item (child, image);
- }
- else if (pspec->name == g_intern_static_string ("icon-name"))
- {
- update_icon_name (child, image);
- }
-}
-
-static void
-widget_notify_cb (GtkWidget *widget,
- GParamSpec *pspec,
- gpointer data)
-{
- DbusmenuMenuitem *child = (DbusmenuMenuitem *)data;
-
- if (pspec->name == g_intern_static_string ("sensitive"))
- {
- dbusmenu_menuitem_property_set_bool (child,
- DBUSMENU_MENUITEM_PROP_ENABLED,
- gtk_widget_is_sensitive (widget));
- }
- else if (pspec->name == g_intern_static_string ("label"))
- {
- dbusmenu_menuitem_property_set (child,
- DBUSMENU_MENUITEM_PROP_LABEL,
- gtk_menu_item_get_label (GTK_MENU_ITEM (widget)));
- }
- else if (pspec->name == g_intern_static_string ("visible"))
- {
- dbusmenu_menuitem_property_set_bool (child,
- DBUSMENU_MENUITEM_PROP_VISIBLE,
- gtk_widget_get_visible (widget));
- }
-}
-
-static void
-action_notify_cb (GtkAction *action,
- GParamSpec *pspec,
- gpointer data)
-{
- DbusmenuMenuitem *child = (DbusmenuMenuitem *)data;
-
- if (pspec->name == g_intern_static_string ("active"))
- {
- dbusmenu_menuitem_property_set_bool (child,
- DBUSMENU_MENUITEM_PROP_TOGGLE_STATE,
- gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
- }
-
- if (pspec->name == g_intern_static_string ("label"))
- {
- dbusmenu_menuitem_property_set (child,
- DBUSMENU_MENUITEM_PROP_LABEL,
- gtk_action_get_label (action));
- }
-}
-
-static void
-container_iterate (GtkWidget *widget,
- gpointer data)
-{
- DbusmenuMenuitem *root = (DbusmenuMenuitem *)data;
- DbusmenuMenuitem *child;
- GtkWidget *submenu = NULL;
- const gchar *label = NULL;
- gboolean label_set = FALSE;
-
- if (GTK_IS_TEAROFF_MENU_ITEM(widget)) {
- return;
- }
-
- child = dbusmenu_menuitem_new ();
-
- if (GTK_IS_SEPARATOR_MENU_ITEM (widget))
- {
- dbusmenu_menuitem_property_set (child,
- "type",
- DBUSMENU_CLIENT_TYPES_SEPARATOR);
- }
- else
- {
- if (GTK_IS_CHECK_MENU_ITEM (widget))
- {
- GtkCheckMenuItem *check;
-
- check = GTK_CHECK_MENU_ITEM (widget);
- label = gtk_menu_item_get_label (GTK_MENU_ITEM (widget));
-
- dbusmenu_menuitem_property_set (child,
- DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE,
- GTK_IS_RADIO_MENU_ITEM (widget) ? DBUSMENU_MENUITEM_TOGGLE_RADIO : DBUSMENU_MENUITEM_TOGGLE_CHECK);
-
- dbusmenu_menuitem_property_set (child,
- DBUSMENU_MENUITEM_PROP_LABEL,
- label);
-
- label_set = TRUE;
-
- dbusmenu_menuitem_property_set_int (child,
- DBUSMENU_MENUITEM_PROP_TOGGLE_STATE,
- gtk_check_menu_item_get_active (check) ? DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED : DBUSMENU_MENUITEM_TOGGLE_STATE_UNCHECKED);
-
- g_signal_connect (widget,
- "toggled",
- G_CALLBACK (widget_toggled),
- child);
- }
- else if (GTK_IS_IMAGE_MENU_ITEM (widget))
- {
- GtkWidget *image;
- GtkImageType image_type;
-
- image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (widget));
- image_type = gtk_image_get_storage_type (GTK_IMAGE (image));
-
- g_signal_connect (image,
- "notify",
- G_CALLBACK (image_notify_cb),
- child);
-
- if (image_type == GTK_IMAGE_STOCK)
- {
- label_set = update_stock_item (child, GTK_IMAGE (image));
- }
- else if (image_type == GTK_IMAGE_ICON_NAME)
- {
- update_icon_name (child, GTK_IMAGE (image));
- }
- }
- }
-
- if (!label_set)
- {
- if (label != NULL)
- {
- dbusmenu_menuitem_property_set (child,
- DBUSMENU_MENUITEM_PROP_LABEL,
- label);
- }
- else
- {
- /* find label child widget */
- gtk_container_forall (GTK_CONTAINER (widget),
- menuitem_iterate,
- child);
- }
- }
-
- if (GTK_IS_MENU_ITEM (widget))
- {
- submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget));
- if (submenu != NULL)
- {
- gtk_container_foreach (GTK_CONTAINER (submenu),
- container_iterate,
- child);
- g_signal_connect_object (submenu,
- "child-added",
- G_CALLBACK (submenu_changed),
- child,
- 0);
- g_signal_connect_object (submenu,
- "child-removed",
- G_CALLBACK (submenu_changed),
- child,
- 0);
- }
- }
-
- dbusmenu_menuitem_property_set_bool (child,
- DBUSMENU_MENUITEM_PROP_ENABLED,
- gtk_widget_is_sensitive (widget));
- dbusmenu_menuitem_property_set_bool (child,
- DBUSMENU_MENUITEM_PROP_VISIBLE,
- gtk_widget_get_visible (widget));
-
- g_signal_connect (widget, "notify",
- G_CALLBACK (widget_notify_cb), child);
-
- if (GTK_IS_ACTIVATABLE (widget))
- {
- GtkActivatable *activatable = GTK_ACTIVATABLE (widget);
-
- if (gtk_activatable_get_use_action_appearance (activatable))
- {
- GtkAction *action = gtk_activatable_get_related_action (activatable);
-
- if (action)
- {
- g_signal_connect_object (action, "notify",
- G_CALLBACK (action_notify_cb),
- child,
- G_CONNECT_AFTER);
- }
- }
- }
-
- g_signal_connect (G_OBJECT (child),
- DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
- G_CALLBACK (activate_menuitem), widget);
- dbusmenu_menuitem_child_append (root, child);
-
- /* Get rid of initial ref now that the root is
- holding the object */
- g_object_unref(child);
-
- return;
-}
-
-static void
-submenu_changed (GtkWidget *widget,
- GtkWidget *child,
- gpointer data)
-{
- DbusmenuMenuitem *root = (DbusmenuMenuitem *)data;
- GList *children, *l;
- children = dbusmenu_menuitem_get_children (root);
-
- for (l = children; l;)
- {
- DbusmenuMenuitem *c = (DbusmenuMenuitem *)l->data;
- l = l->next;
- dbusmenu_menuitem_child_delete (root, c);
- }
-
- gtk_container_foreach (GTK_CONTAINER (widget),
- container_iterate,
- root);
-}
-
/* Does the dbusmenu related work. If there isn't a server, it builds
one and if there are menus it runs the parse to put those menus into
the server. */