aboutsummaryrefslogtreecommitdiff
path: root/src/indicator-ng.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/indicator-ng.c')
-rw-r--r--src/indicator-ng.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/indicator-ng.c b/src/indicator-ng.c
index f057600..a94f57e 100644
--- a/src/indicator-ng.c
+++ b/src/indicator-ng.c
@@ -1,5 +1,6 @@
/*
* Copyright 2013 Canonical Ltd.
+ * Copyright 2021-2022 Robert Tari
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
@@ -15,6 +16,7 @@
*
* Authors:
* Lars Uebernickel <lars.uebernickel@canonical.com>
+ * Robert Tari <robert@tari.in>
*/
#include "indicator-ng.h"
@@ -39,9 +41,9 @@ struct _IndicatorNg
gchar *secondary_action;
gchar *submenu_action;
gint position;
-
+ gchar *sTooltip;
guint name_watch_id;
-
+ gboolean bMenuShown;
GDBusConnection *session_bus;
GActionGroup *actions;
GMenuModel *menu;
@@ -244,7 +246,7 @@ static gboolean indicator_ng_menu_insert_idos(IndicatorNg *self, GMenuModel *pSe
GtkWidget *pMenuItemOld = GTK_WIDGET(g_list_nth_data(lMenuItems, nMenuItem));
const gchar *sName = gtk_widget_get_name(pMenuItemOld);
- if (!g_str_equal(sName, sType))
+ if (sName != NULL && !g_str_equal(sName, sType))
{
GActionGroup *pActionGroup = (GActionGroup*)g_object_get_qdata(G_OBJECT(self->entry.menu), m_pActionMuxer);
GMenuItem *pMenuModelItem = g_menu_item_new_from_model(pSection, nModelItem);
@@ -421,10 +423,26 @@ static void indicator_ng_menu_section_changed(__attribute__((unused)) GMenuModel
}
}
+static void indicator_ng_set_tooltip(IndicatorNg *self, gchar *sTooltip)
+{
+ if (self->entry.label != NULL)
+ {
+ gtk_widget_set_tooltip_text(GTK_WIDGET(self->entry.label), sTooltip);
+ }
+
+ if (self->entry.image != NULL)
+ {
+ gtk_widget_set_tooltip_text(GTK_WIDGET(self->entry.image), sTooltip);
+ }
+}
+
static void indicator_ng_menu_shown(__attribute__((unused)) GtkWidget *pWidget, gpointer pUserData)
{
IndicatorNg *self = pUserData;
guint nSectionCount = 0;
+ self->bMenuShown = TRUE;
+
+ indicator_ng_set_tooltip(self, NULL);
if (!self->lMenuSections[0])
{
@@ -472,10 +490,13 @@ indicator_ng_menu_hidden (__attribute__((unused)) GtkWidget *widget,
gpointer user_data)
{
IndicatorNg *self = user_data;
+ self->bMenuShown = FALSE;
if (self->submenu_action)
g_action_group_change_action_state (self->actions, self->submenu_action,
g_variant_new_boolean (FALSE));
+
+ indicator_ng_set_tooltip(self, self->sTooltip);
}
static void
@@ -594,6 +615,7 @@ indicator_ng_update_entry (IndicatorNg *self)
g_variant_lookup (state, "icon", "*", &icon);
g_variant_lookup (state, "accessible-desc", "&s", &accessible_desc);
g_variant_lookup (state, "visible", "b", &visible);
+ g_variant_lookup (state, "tooltip", "&s", &self->sTooltip);
}
else
g_warning ("the action of the indicator menu item must have state with type (sssb) or a{sv}");
@@ -601,6 +623,7 @@ indicator_ng_update_entry (IndicatorNg *self)
indicator_ng_set_label (self, label);
indicator_ng_set_icon_from_variant (self, icon);
indicator_ng_set_accessible_desc (self, accessible_desc);
+ indicator_ng_set_tooltip (self, self->bMenuShown ? NULL : self->sTooltip);
indicator_object_set_visible (INDICATOR_OBJECT (self), visible);
if (icon)
@@ -954,6 +977,8 @@ indicator_ng_initable_iface_init (GInitableIface *initable)
static void
indicator_ng_init (IndicatorNg *self)
{
+ self->sTooltip = NULL;
+ self->bMenuShown = FALSE;
m_pActionMuxer = g_quark_from_static_string ("gtk-widget-action-muxer");
for (guint nMenuSection = 0; nMenuSection < MENU_SECTIONS; nMenuSection++)