Merge lp:~gber/libappindicator/fallback-tooltip into lp:libappindicator/16.10

Proposed by Guido Berhoerster
Status: Needs review
Proposed branch: lp:~gber/libappindicator/fallback-tooltip
Merge into: lp:libappindicator/16.10
Diff against target: 109 lines (+42/-0)
1 file modified
src/app-indicator.c (+42/-0)
To merge this branch: bzr merge lp:~gber/libappindicator/fallback-tooltip
Reviewer Review Type Date Requested Status
Indicator Applet Developers Pending
Review via email: mp+349501@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

289. By Guido Berhoerster

Display a tooltip in fallback mode

This replicates the behavior of KDE Plasma or the Xfce Status Notifier
Plugin in fallback mode by displaying a tooltip with the contents of the
"title" and "icon-desc" or "attention-icon-desc" properties if set.

288. By CI Train Bot Account

Releasing 12.10.1+18.04.20180322.1-0ubuntu1

287. By Unit 193

Have -dev package depend on libgtk2.0-dev or libgk-3-dev according to its pkgconfig file (LP: #1757574) (LP: #1757574)

Approved by: Jeremy Bicha

286. By CI Train Bot Account

Releasing 12.10.1+18.04.20180320-0ubuntu1

285. By Olivier Tilloy

Fix build failures on bionic,
and update Vcs-* fields in debian/control. (LP: #1757121)

Approved by: Marco Trevisan (Treviño)

284. By Didier Roche-Tolomelli

releasing package libappindicator version 12.10.1+17.04.20170215-0ubuntu2

283. By Didier Roche-Tolomelli

* debian/control:
  - Downgrade libappindicator* recommending the indicator-application
    service to suggests. Only some sessions wants it, while we still
    link against the lib in multiple apps.

282. By CI Train Bot Account

Releasing 12.10.1+17.04.20170215-0ubuntu1

281. By Marco Trevisan (Treviño)

app-indicator: don't append the snap prefix if the icon is saved in a well known readable path

280. By CI Train Bot Account

Releasing 12.10.1+17.04.20170213-0ubuntu1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/app-indicator.c'
--- src/app-indicator.c 2018-03-20 12:38:59 +0000
+++ src/app-indicator.c 2018-07-13 19:47:46 +0000
@@ -190,6 +190,7 @@
190static void status_icon_status_wrapper (AppIndicator * self, const gchar * status, gpointer data);190static void status_icon_status_wrapper (AppIndicator * self, const gchar * status, gpointer data);
191static gboolean scroll_event_wrapper(GtkWidget *status_icon, GdkEventScroll *event, gpointer user_data);191static gboolean scroll_event_wrapper(GtkWidget *status_icon, GdkEventScroll *event, gpointer user_data);
192static gboolean middle_click_wrapper(GtkWidget *status_icon, GdkEventButton *event, gpointer user_data);192static gboolean middle_click_wrapper(GtkWidget *status_icon, GdkEventButton *event, gpointer user_data);
193static void status_icon_desc_changes (GObject * gobject, GParamSpec * pspec, gpointer data);
193static void status_icon_changes (AppIndicator * self, gpointer data);194static void status_icon_changes (AppIndicator * self, gpointer data);
194static void status_icon_activate (GtkStatusIcon * icon, gpointer data);195static void status_icon_activate (GtkStatusIcon * icon, gpointer data);
195static void status_icon_menu_activate (GtkStatusIcon *status_icon, guint button, guint activate_time, gpointer user_data);196static void status_icon_menu_activate (GtkStatusIcon *status_icon, guint button, guint activate_time, gpointer user_data);
@@ -1540,6 +1541,10 @@
1540 G_CALLBACK(status_icon_changes), icon);1541 G_CALLBACK(status_icon_changes), icon);
1541 g_signal_connect(G_OBJECT(self), APP_INDICATOR_SIGNAL_NEW_ATTENTION_ICON,1542 g_signal_connect(G_OBJECT(self), APP_INDICATOR_SIGNAL_NEW_ATTENTION_ICON,
1542 G_CALLBACK(status_icon_changes), icon);1543 G_CALLBACK(status_icon_changes), icon);
1544 g_signal_connect(G_OBJECT(self), "notify::icon-desc",
1545 G_CALLBACK(status_icon_desc_changes), icon);
1546 g_signal_connect(G_OBJECT(self), "notify::attention-icon-desc",
1547 G_CALLBACK(status_icon_desc_changes), icon);
15431548
1544 status_icon_changes(self, icon);1549 status_icon_changes(self, icon);
15451550
@@ -1551,6 +1556,13 @@
1551 return icon;1556 return icon;
1552}1557}
15531558
1559static void
1560status_icon_desc_changes (GObject * gobject, GParamSpec * pspec, gpointer data)
1561{
1562 AppIndicator * self = APP_INDICATOR(gobject);
1563 status_icon_changes(self, data);
1564}
1565
1554/* A wrapper as the status update prototype is a little1566/* A wrapper as the status update prototype is a little
1555 bit different, but we want to handle it the same. */1567 bit different, but we want to handle it the same. */
1556static void1568static void
@@ -1598,6 +1610,27 @@
1598 return FALSE;1610 return FALSE;
1599}1611}
16001612
1613static gchar *
1614status_icon_tooltip_new (const gchar * title, const gchar * desc)
1615{
1616 gchar * tooltip;
1617 gchar * title_escaped;
1618 gchar * desc_escaped;
1619
1620 if (title == NULL && desc == NULL) {
1621 return (NULL);
1622 }
1623
1624 title_escaped = (title != NULL) ? g_markup_escape_text(title, -1) : g_strdup("");
1625 desc_escaped = (desc != NULL) ? g_markup_escape_text(desc, -1) : g_strdup("");
1626 tooltip = g_strdup_printf("<b>%s</b>%s%s", title_escaped,
1627 (title != NULL) && (desc != NULL) ? "\n" : "", desc_escaped);
1628 g_free(desc_escaped);
1629 g_free(title_escaped);
1630
1631 return tooltip;
1632}
1633
1601/* This tracks changes to either the status or the icons1634/* This tracks changes to either the status or the icons
1602 that are associated with the app indicator */1635 that are associated with the app indicator */
1603static void1636static void
@@ -1628,6 +1661,7 @@
1628 g_strfreev (path);1661 g_strfreev (path);
1629 }1662 }
16301663
1664 gchar * tooltip = NULL;
1631 const gchar * icon_name = NULL;1665 const gchar * icon_name = NULL;
1632 switch (app_indicator_get_status(self)) {1666 switch (app_indicator_get_status(self)) {
1633 case APP_INDICATOR_STATUS_PASSIVE:1667 case APP_INDICATOR_STATUS_PASSIVE:
@@ -1637,14 +1671,19 @@
1637 break;1671 break;
1638 case APP_INDICATOR_STATUS_ACTIVE:1672 case APP_INDICATOR_STATUS_ACTIVE:
1639 icon_name = app_indicator_get_icon(self);1673 icon_name = app_indicator_get_icon(self);
1674 tooltip = status_icon_tooltip_new(app_indicator_get_title(self),
1675 app_indicator_get_icon_desc(self));
1640 gtk_status_icon_set_visible(icon, TRUE);1676 gtk_status_icon_set_visible(icon, TRUE);
1641 break;1677 break;
1642 case APP_INDICATOR_STATUS_ATTENTION:1678 case APP_INDICATOR_STATUS_ATTENTION:
1643 /* get the _attention_ icon here */1679 /* get the _attention_ icon here */
1644 icon_name = app_indicator_get_attention_icon(self);1680 icon_name = app_indicator_get_attention_icon(self);
1681 tooltip = status_icon_tooltip_new(app_indicator_get_title(self),
1682 app_indicator_get_attention_icon_desc(self));
1645 gtk_status_icon_set_visible(icon, TRUE);1683 gtk_status_icon_set_visible(icon, TRUE);
1646 break;1684 break;
1647 };1685 };
1686 gtk_status_icon_set_tooltip_markup(icon, tooltip);
16481687
1649 if (icon_name != NULL) {1688 if (icon_name != NULL) {
1650 gchar *snapped_icon = append_snap_prefix(icon_name);1689 gchar *snapped_icon = append_snap_prefix(icon_name);
@@ -1668,6 +1707,8 @@
1668 g_free(snapped_icon);1707 g_free(snapped_icon);
1669 }1708 }
16701709
1710 g_free(tooltip);
1711
1671 return;1712 return;
1672}1713}
16731714
@@ -1706,6 +1747,7 @@
1706{1747{
1707 g_signal_handlers_disconnect_by_func(G_OBJECT(self), status_icon_status_wrapper, status_icon);1748 g_signal_handlers_disconnect_by_func(G_OBJECT(self), status_icon_status_wrapper, status_icon);
1708 g_signal_handlers_disconnect_by_func(G_OBJECT(self), status_icon_changes, status_icon);1749 g_signal_handlers_disconnect_by_func(G_OBJECT(self), status_icon_changes, status_icon);
1750 g_signal_handlers_disconnect_by_func(G_OBJECT(self), status_icon_desc_changes, status_icon);
1709 g_signal_handlers_disconnect_by_func(G_OBJECT(self), scroll_event_wrapper, status_icon);1751 g_signal_handlers_disconnect_by_func(G_OBJECT(self), scroll_event_wrapper, status_icon);
1710 g_signal_handlers_disconnect_by_func(G_OBJECT(self), middle_click_wrapper, status_icon);1752 g_signal_handlers_disconnect_by_func(G_OBJECT(self), middle_click_wrapper, status_icon);
1711 gtk_status_icon_set_visible(status_icon, FALSE);1753 gtk_status_icon_set_visible(status_icon, FALSE);

Subscribers

People subscribed via source and target branches