[arch-commits] Commit in modem-manager-gui/repos (4 files)

Felix Yan felixonmars at archlinux.org
Tue Jul 7 14:01:03 UTC 2020


    Date: Tuesday, July 7, 2020 @ 14:01:03
  Author: felixonmars
Revision: 658680

archrelease: copy trunk to community-staging-x86_64

Added:
  modem-manager-gui/repos/community-staging-x86_64/
  modem-manager-gui/repos/community-staging-x86_64/PKGBUILD
    (from rev 658679, modem-manager-gui/trunk/PKGBUILD)
  modem-manager-gui/repos/community-staging-x86_64/fix-crash.patch
    (from rev 658679, modem-manager-gui/trunk/fix-crash.patch)
  modem-manager-gui/repos/community-staging-x86_64/no-indicator.patch
    (from rev 658679, modem-manager-gui/trunk/no-indicator.patch)

--------------------+
 PKGBUILD           |   42 +++++
 fix-crash.patch    |  140 +++++++++++++++++++
 no-indicator.patch |  363 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 545 insertions(+)

Copied: modem-manager-gui/repos/community-staging-x86_64/PKGBUILD (from rev 658679, modem-manager-gui/trunk/PKGBUILD)
===================================================================
--- community-staging-x86_64/PKGBUILD	                        (rev 0)
+++ community-staging-x86_64/PKGBUILD	2020-07-07 14:01:03 UTC (rev 658680)
@@ -0,0 +1,42 @@
+# Maintainer: Balló György <ballogyor+arch at gmail dot com>
+# Contributor: Ilya Medvedev <medved55rus [at] gmail [dot] com>
+
+pkgname=modem-manager-gui
+pkgver=0.0.19.1
+pkgrel=5
+pkgdesc="Frontend for ModemManager daemon able to control specific modem functions"
+arch=('x86_64')
+url="https://linuxonly.ru/page/modem-manager-gui"
+license=('GPL3')
+depends=('gdbm' 'gtk3' 'gtkspell3' 'libnotify' 'modemmanager')
+makedepends=('po4a' 'itstool')
+optdepends=('networkmanager: monitor network traffic')
+options=(!emptydirs)
+source=("https://download.tuxfamily.org/gsf/source/$pkgname-$pkgver.tar.gz"
+        fix-crash.patch
+        no-indicator.patch)
+sha256sums=('0b9bae29f3cd3d99b3a61d5530097d576a5fa67d3215d54f3570cb20c6ca0bc2'
+            'bcc451c1db096ea1b76907616fecfd14f73baf88b774827b2d1dc6065798ed03'
+            '04f85c3d6e7dbf89f5767446a1884f1f45aaea4023a8d07981b819be181849b3')
+
+prepare() {
+  cd $pkgname-$pkgver
+
+  # Fix memory corruption because of wrong strsep() usage (FS#61622, FS#61823)
+  # Fix segfault in strftime_l() because of timestamps from future (FS#62584)
+  patch -Np1 -i ../fix-crash.patch
+
+  # Revert to GTK+ status icon
+  patch -Np1 -i ../no-indicator.patch
+}
+
+build() {
+  cd $pkgname-$pkgver
+  ./configure --prefix=/usr
+  make
+}
+ 
+package() {
+  cd $pkgname-$pkgver
+  make DESTDIR="$pkgdir" install
+}

Copied: modem-manager-gui/repos/community-staging-x86_64/fix-crash.patch (from rev 658679, modem-manager-gui/trunk/fix-crash.patch)
===================================================================
--- community-staging-x86_64/fix-crash.patch	                        (rev 0)
+++ community-staging-x86_64/fix-crash.patch	2020-07-07 14:01:03 UTC (rev 658680)
@@ -0,0 +1,140 @@
+# HG changeset patch
+# User Alex <alex at linuxonly.ru>
+# Date 1550936745 -10800
+# Node ID 6710bf86869852bb8a9946b628eff5bc1019b5aa
+# Parent  e8a146d4d2ea8525301670fb48b1accfdde13ac9
+Fix memory corruption because of wrong strsep() usage (Thanks to Persmule)
+
+diff --git a/src/modules/mm06.c b/src/modules/mm06.c
+--- a/src/modules/mm06.c
++++ b/src/modules/mm06.c
+@@ -1552,10 +1552,12 @@
+ 	GVariantIter *iter;
+ 	guint32 locationtype;
+ 	GVariant *locationdata;
+-	gchar *locationstring;
+ 	gsize strlength;
++	gchar **fragments;
++	gint i;
+ 	GError *error;
+-			
++	const gint numbases[4] = {10, 10, 16, 16};
++	
+ 	if ((mmguicore == NULL) || (device == NULL)) return FALSE;
+ 	mmguicorelc = (mmguicore_t)mmguicore;
+ 	
+@@ -1578,14 +1580,17 @@
+ 		g_variant_get(data, "(a{uv})", &iter);
+ 		while (g_variant_iter_next(iter, "{uv}", &locationtype, &locationdata)) {
+ 			if ((locationtype == MODULE_INT_MODEM_LOCATION_CAPABILITY_GSM_LAC_CI) && (locationdata != NULL)) {
+-				//3GPP location
++				/*3GPP location*/
+ 				strlength = 256;
+-				locationstring = g_strdup(g_variant_get_string(locationdata, &strlength));
+-				device->loc3gppdata[0] = (guint)strtol(strsep(&locationstring, ","), NULL, 10);
+-				device->loc3gppdata[1] = (guint)strtol(strsep(&locationstring, ","), NULL, 10);
+-				device->loc3gppdata[2] = (guint)strtol(strsep(&locationstring, ","), NULL, 16);
+-				device->loc3gppdata[3] = (guint)strtol(strsep(&locationstring, ","), NULL, 16);
+-				g_free(locationstring);
++				fragments = g_strsplit(g_variant_get_string(locationdata, &strlength), ",", 4);
++				if (fragments != NULL) {
++					i = 0;
++					while ((fragments[i] != NULL) && (i < 4)) {
++						device->loc3gppdata[i] = (guint)strtoul(fragments[i], NULL, numbases[i]);
++						i++;
++					}
++					g_strfreev(fragments);
++				}
+ 				g_variant_unref(locationdata);
+ 				g_debug("3GPP location: %u, %u, %4x, %4x", device->loc3gppdata[0], device->loc3gppdata[1], device->loc3gppdata[2], device->loc3gppdata[3]);
+ 			}
+diff --git a/src/modules/mm07.c b/src/modules/mm07.c
+--- a/src/modules/mm07.c
++++ b/src/modules/mm07.c
+@@ -1659,8 +1659,11 @@
+ 	GVariant *locationdata;
+ 	gchar *locationstring;
+ 	gsize strlength;
++	gchar **fragments;
++	gint i;
+ 	GError *error;
+-			
++	const gint numbases[4] = {10, 10, 16, 16};
++	
+ 	if ((mmguicore == NULL) || (device == NULL)) return FALSE;
+ 	mmguicorelc = (mmguicore_t)mmguicore;
+ 	
+@@ -1684,12 +1687,15 @@
+ 			if ((locationtype == MODULE_INT_MODEM_LOCATION_SOURCE_3GPP_LAC_CI) && (locationdata != NULL)) {
+ 				/*3GPP location*/
+ 				strlength = 256;
+-				locationstring = g_strdup(g_variant_get_string(locationdata, &strlength));
+-				device->loc3gppdata[0] = (guint)strtol(strsep(&locationstring, ","), NULL, 10);
+-				device->loc3gppdata[1] = (guint)strtol(strsep(&locationstring, ","), NULL, 10);
+-				device->loc3gppdata[2] = (guint)strtol(strsep(&locationstring, ","), NULL, 16);
+-				device->loc3gppdata[3] = (guint)strtol(strsep(&locationstring, ","), NULL, 16);
+-				g_free(locationstring);
++				fragments = g_strsplit(g_variant_get_string(locationdata, &strlength), ",", 4);
++				if (fragments != NULL) {
++					i = 0;
++					while ((fragments[i] != NULL) && (i < 4)) {
++						device->loc3gppdata[i] = (guint)strtoul(fragments[i], NULL, numbases[i]);
++						i++;
++					}
++					g_strfreev(fragments);
++				}
+ 				g_variant_unref(locationdata);
+ 				g_debug("3GPP location: %u, %u, %4x, %4x\n", device->loc3gppdata[0], device->loc3gppdata[1], device->loc3gppdata[2], device->loc3gppdata[3]);
+ 			} else if ((locationtype == MODULE_INT_MODEM_LOCATION_SOURCE_GPS_RAW) && (locationdata != NULL)) {
+# HG changeset patch
+# User Alex <alex at linuxonly.ru>
+# Date 1558782045 -10800
+# Node ID 83553d042443c71be71533b6b91ee10f228d935f
+# Parent  de113e8953ae708043823578b64882cfc5a45ca2
+Fix segfault in strftime_l() because of timestamps from future
+
+diff --git a/src/strformat.c b/src/strformat.c
+--- a/src/strformat.c
++++ b/src/strformat.c
+@@ -1,7 +1,7 @@
+ /*
+  *      strformat.c
+  *      
+- *      Copyright 2013-2014 Alex <alex at linuxonly.ru>
++ *      Copyright 2013-2019 Alex <alex at linuxonly.ru>
+  *      
+  *      This program is free software: you can redistribute it and/or modify
+  *      it under the terms of the GNU General Public License as published by
+@@ -182,18 +182,22 @@
+ 		
+ 	memset(buffer, 0, bufsize);
+ 	
+-	if (delta <= 0.0) {
+-		if (strftime(buffer, bufsize, _("Today, %T"), ftime) == 0) {
+-			g_snprintf(buffer, bufsize, _("Unknown"));
+-		}
+-	} else if ((delta > 0.0) && (delta < 86400.0)) {
+-		if (strftime(buffer, bufsize, _("Yesterday, %T"), ftime) == 0) {
+-			g_snprintf(buffer, bufsize, _("Unknown"));
++	if (ftime != NULL) {
++		if (delta <= 0.0) {
++			if (strftime(buffer, bufsize, _("Today, %T"), ftime) == 0) {
++				g_snprintf(buffer, bufsize, _("Unknown"));
++			}
++		} else if ((delta > 0.0) && (delta < 86400.0)) {
++			if (strftime(buffer, bufsize, _("Yesterday, %T"), ftime) == 0) {
++				g_snprintf(buffer, bufsize, _("Unknown"));
++			}
++		} else {
++			if (strftime(buffer, bufsize, _("%d %B %Y, %T"), ftime) == 0) {
++				g_snprintf(buffer, bufsize, _("Unknown"));
++			}
+ 		}
+ 	} else {
+-		if (strftime(buffer, bufsize, _("%d %B %Y, %T"), ftime) == 0) {
+-			g_snprintf(buffer, bufsize, _("Unknown"));
+-		}
++		g_snprintf(buffer, bufsize, _("Unknown"));
+ 	}
+ 	
+ 	return buffer;

Copied: modem-manager-gui/repos/community-staging-x86_64/no-indicator.patch (from rev 658679, modem-manager-gui/trunk/no-indicator.patch)
===================================================================
--- community-staging-x86_64/no-indicator.patch	                        (rev 0)
+++ community-staging-x86_64/no-indicator.patch	2020-07-07 14:01:03 UTC (rev 658680)
@@ -0,0 +1,363 @@
+diff -Naur modem-manager-gui-0.0.19.orig/src/main.c modem-manager-gui-0.0.19/src/main.c
+--- modem-manager-gui-0.0.19.orig/src/main.c	2018-03-17 16:35:08.000000000 +0100
++++ modem-manager-gui-0.0.19/src/main.c	2018-03-22 14:10:34.762564755 +0100
+@@ -138,11 +138,9 @@
+ static void mmgui_main_ui_about_menu_item_activate_signal(GSimpleAction *action, GVariant *parameter, gpointer data);
+ static void mmgui_main_ui_section_menu_item_activate_signal(GSimpleAction *action, GVariant *parameter, gpointer data);
+ /*Tray*/
+-static gboolean mmgui_main_tray_handle_state_change_from_thread(gpointer data);
+ static void mmgui_main_tray_icon_window_show_signal(GtkCheckMenuItem *checkmenuitem, gpointer data);
+ static void mmgui_main_tray_icon_new_sms_signal(GtkMenuItem *menuitem, gpointer data);
+ static void mmgui_main_tray_icon_exit_signal(GtkMenuItem *menuitem, gpointer data);
+-static void mmgui_main_tray_icon_build(mmgui_application_t mmguiapp);
+ static void mmgui_main_tray_icon_init(mmgui_application_t mmguiapp);
+ /*Ayatana*/
+ static void mmgui_main_ayatana_event_callback(enum _mmgui_ayatana_event event, gpointer ayatana, gpointer data, gpointer userdata);
+@@ -217,7 +215,6 @@
+ 			mmgui_main_contacts_list_fill(mmguiapp);
+ 			/*Show network name*/
+ 			g_idle_add(mmgui_main_ui_update_statusbar_from_thread, mmguiapp);
+-			g_idle_add(mmgui_main_tray_handle_state_change_from_thread, mmguiapp);
+ 			break;
+ 		case MMGUI_EVENT_DEVICE_CLOSING:
+ 			mmgui_modem_settings_close(mmguiapp->modemsettings);
+@@ -235,21 +232,18 @@
+ 			appdata->mmguiapp = mmguiapp;
+ 			appdata->data = data;
+ 			g_idle_add(mmgui_main_device_handle_enabled_status_from_thread, appdata);
+-			g_idle_add(mmgui_main_tray_handle_state_change_from_thread, mmguiapp);
+ 			break;
+ 		case MMGUI_EVENT_DEVICE_BLOCKED_STATUS:
+ 			appdata = g_new0(struct _mmgui_application_data, 1);
+ 			appdata->mmguiapp = mmguiapp;
+ 			appdata->data = data;
+ 			g_idle_add(mmgui_main_device_handle_blocked_status_from_thread, appdata);
+-			g_idle_add(mmgui_main_tray_handle_state_change_from_thread, mmguiapp);
+ 			break;
+ 		case MMGUI_EVENT_DEVICE_PREPARED_STATUS:
+ 			appdata = g_new0(struct _mmgui_application_data, 1);
+ 			appdata->mmguiapp = mmguiapp;
+ 			appdata->data = data;
+ 			g_idle_add(mmgui_main_device_handle_prepared_status_from_thread, appdata);
+-			g_idle_add(mmgui_main_tray_handle_state_change_from_thread, mmguiapp);
+ 			break;
+ 		case MMGUI_EVENT_DEVICE_CONNECTION_STATUS:
+ 			appdata = g_new0(struct _mmgui_application_data, 1);
+@@ -272,7 +266,6 @@
+ 			mmgui_main_info_handle_network_registration_change(mmguiapp, device);
+ 			/*Show new network name*/
+ 			g_idle_add(mmgui_main_ui_update_statusbar_from_thread, mmguiapp);
+-			g_idle_add(mmgui_main_tray_handle_state_change_from_thread, mmguiapp);
+ 			break;
+ 		case MMGUI_EVENT_LOCATION_CHANGE:
+ 			device = (mmguidevice_t)data;
+@@ -1660,9 +1653,9 @@
+ 				gmm_settings_set_boolean(mmguiapp->settings, "window_hide_notify_shown", mmguiapp->options->hidenotifyshown);
+ 			}
+ 			/*Set tray menu mark*/
+-			g_signal_handler_block(G_OBJECT(mmguiapp->window->showwin_ind), mmguiapp->window->traysigid);
+-			gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mmguiapp->window->showwin_ind), FALSE);
+-			g_signal_handler_unblock(G_OBJECT(mmguiapp->window->showwin_ind), mmguiapp->window->traysigid);
++			g_signal_handler_block(G_OBJECT(mmguiapp->window->showwin_tm), mmguiapp->window->traysigid);
++			gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mmguiapp->window->showwin_tm), FALSE);
++			g_signal_handler_unblock(G_OBJECT(mmguiapp->window->showwin_tm), mmguiapp->window->traysigid);
+ 			/*Save window state*/
+ 			mmguiapp->options->minimized = TRUE;
+ 			gmm_settings_set_boolean(mmguiapp->settings, "window_state_minimized", mmguiapp->options->minimized);
+@@ -1691,9 +1684,9 @@
+ 				gmm_settings_set_boolean(mmguiapp->settings, "window_hide_notify_shown", mmguiapp->options->hidenotifyshown);
+ 			}
+ 			/*Set tray menu mark*/
+-			g_signal_handler_block(G_OBJECT(mmguiapp->window->showwin_ind), mmguiapp->window->traysigid);
+-			gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mmguiapp->window->showwin_ind), FALSE);
+-			g_signal_handler_unblock(G_OBJECT(mmguiapp->window->showwin_ind), mmguiapp->window->traysigid);
++			g_signal_handler_block(G_OBJECT(mmguiapp->window->showwin_tm), mmguiapp->window->traysigid);
++			gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mmguiapp->window->showwin_tm), FALSE);
++			g_signal_handler_unblock(G_OBJECT(mmguiapp->window->showwin_tm), mmguiapp->window->traysigid);
+ 			/*Save window state*/
+ 			mmguiapp->options->minimized = TRUE;
+ 			gmm_settings_set_boolean(mmguiapp->settings, "window_state_minimized", mmguiapp->options->minimized);
+@@ -1910,32 +1903,7 @@
+ }
+ 
+ /*TRAY*/
+-#if RESOURCE_INDICATOR_ENABLED
+-
+-static gboolean mmgui_main_tray_handle_state_change_from_thread(gpointer data)
+-{
+-	mmgui_application_t mmguiapp;
+-	mmguidevice_t device;
+-	guint caps;
+-	
+-	mmguiapp = (mmgui_application_t)data;
+-	
+-	if (mmguiapp == NULL) return FALSE;
+-	if (mmguiapp->core == NULL) return FALSE;
+-	
+-	device = mmguicore_devices_get_current(mmguiapp->core);
+-	
+-	if (device != NULL) {
+-		caps = mmguicore_sms_get_capabilities(mmguiapp->core);
+-		gtk_widget_set_sensitive(mmguiapp->window->newsms_ind, caps & MMGUI_SMS_CAPS_SEND);
+-	} else {
+-		gtk_widget_set_sensitive(mmguiapp->window->newsms_ind, FALSE);
+-	}
+-	
+-	return FALSE;
+-}
+-
+-static void mmgui_main_tray_icon_window_show_signal(GtkCheckMenuItem *checkmenuitem, gpointer data)
++static void mmgui_main_tray_icon_activation_signal(GtkStatusIcon *status_icon, gpointer data)
+ {
+ 	mmgui_application_t mmguiapp;
+ 	
+@@ -1952,9 +1920,9 @@
+ 		/*Hide window*/
+ 		gtk_widget_hide(mmguiapp->window->window);
+ 		mmguiapp->options->minimized = TRUE;
+-		g_signal_handler_block(G_OBJECT(mmguiapp->window->showwin_ind), mmguiapp->window->traysigid);
+-		gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mmguiapp->window->showwin_ind), FALSE);
+-		g_signal_handler_unblock(G_OBJECT(mmguiapp->window->showwin_ind), mmguiapp->window->traysigid);
++		g_signal_handler_block(G_OBJECT(mmguiapp->window->showwin_tm), mmguiapp->window->traysigid);
++		gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mmguiapp->window->showwin_tm), FALSE);
++		g_signal_handler_unblock(G_OBJECT(mmguiapp->window->showwin_tm), mmguiapp->window->traysigid);
+ 	} else {
+ 		/*Restore window position*/
+ 		if (mmguiapp->options->savegeometry) {
+@@ -1963,14 +1931,26 @@
+ 		/*Show window*/
+ 		gtk_widget_show(mmguiapp->window->window);
+ 		mmguiapp->options->minimized = FALSE;
+-		g_signal_handler_block(G_OBJECT(mmguiapp->window->showwin_ind), mmguiapp->window->traysigid);
+-		gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mmguiapp->window->showwin_ind), TRUE);
+-		g_signal_handler_unblock(G_OBJECT(mmguiapp->window->showwin_ind), mmguiapp->window->traysigid);
++		g_signal_handler_block(G_OBJECT(mmguiapp->window->showwin_tm), mmguiapp->window->traysigid);
++		gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mmguiapp->window->showwin_tm), TRUE);
++		g_signal_handler_unblock(G_OBJECT(mmguiapp->window->showwin_tm), mmguiapp->window->traysigid);
+ 	}
+ 	/*Save window state*/
+ 	gmm_settings_set_boolean(mmguiapp->settings, "window_state_minimized", mmguiapp->options->minimized);
+ }
+ 
++static void mmgui_main_tray_icon_window_show_signal(GtkCheckMenuItem *checkmenuitem, gpointer data)
++{
++	mmgui_application_t mmguiapp;
++	
++	mmguiapp = (mmgui_application_t)data;
++	
++	if (mmguiapp == NULL) return;
++	if ((mmguiapp->core == NULL) || (mmguiapp->window == NULL)) return;
++	
++	mmgui_main_tray_icon_activation_signal(GTK_STATUS_ICON(mmguiapp->window->statusicon), mmguiapp);
++}
++
+ static void mmgui_main_tray_icon_new_sms_signal(GtkMenuItem *menuitem, gpointer data)
+ {
+ 	mmgui_application_t mmguiapp;
+@@ -1983,9 +1963,9 @@
+ 	
+ 	if (!gtk_widget_get_visible(mmguiapp->window->window)) {
+ 		gtk_widget_show(mmguiapp->window->window);
+-		g_signal_handler_block(G_OBJECT(mmguiapp->window->showwin_ind), mmguiapp->window->traysigid);
+-		gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mmguiapp->window->showwin_ind), TRUE);
+-		g_signal_handler_unblock(G_OBJECT(mmguiapp->window->showwin_ind), mmguiapp->window->traysigid);
++		g_signal_handler_block(G_OBJECT(mmguiapp->window->showwin_tm), mmguiapp->window->traysigid);
++		gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mmguiapp->window->showwin_tm), TRUE);
++		g_signal_handler_unblock(G_OBJECT(mmguiapp->window->showwin_tm), mmguiapp->window->traysigid);
+ 	} else {
+ 		gtk_window_present(GTK_WINDOW(mmguiapp->window->window));
+ 	}
+@@ -2013,59 +1993,98 @@
+ 	mmgui_main_application_terminate(mmguiapp);
+ }
+ 
+-static void mmgui_main_tray_icon_build(mmgui_application_t mmguiapp)
++static void mmgui_main_tray_popup_menu_show_signal(GtkStatusIcon *status_icon, guint button, guint activate_time, gpointer data)
+ {
+-	gchar *iconfilepath;
++	mmgui_application_t mmguiapp;
++	guint smscaps;
++	
++	mmguiapp = (mmgui_application_t)data;
++	
++	if (mmguiapp == NULL) return;
++	if ((mmguiapp->core == NULL) || (mmguiapp->window == NULL)) return;
++	
++	if (mmguicore_devices_get_enabled(mmguiapp->core)) {
++		smscaps = mmguicore_sms_get_capabilities(mmguiapp->core);
++		if (smscaps & MMGUI_SMS_CAPS_SEND) {
++			gtk_widget_set_sensitive(mmguiapp->window->newsms_tm, TRUE);
++		} else {
++			gtk_widget_set_sensitive(mmguiapp->window->newsms_tm, FALSE);
++		}
++	} else {
++		gtk_widget_set_sensitive(mmguiapp->window->newsms_tm, FALSE);
++	}
++
++	gtk_menu_popup(GTK_MENU(mmguiapp->window->traymenu), NULL, NULL, gtk_status_icon_position_menu, status_icon, button, activate_time);
++}
++
++static gboolean mmgui_main_tray_tooltip_show_signal(GtkStatusIcon *status_icon, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip, gpointer data)
++{
++	mmgui_application_t mmguiapp;
++	guint unreadmessages;
++	gchar strbuf[64];
+ 	
++	mmguiapp = (mmgui_application_t)data;
++	
++	if (mmguiapp == NULL) return FALSE;
++	
++	if (mmguicore_devices_get_current(mmguiapp->core) != NULL) {
++		unreadmessages = mmgui_smsdb_get_unread_messages(mmguicore_devices_get_sms_db(mmguiapp->core));
++		if (unreadmessages > 0) {
++			memset(strbuf, 0, sizeof(strbuf));
++			g_snprintf(strbuf, sizeof(strbuf), _("Unread messages: %u"), unreadmessages);
++			gtk_tooltip_set_text(tooltip, strbuf);
++		} else {
++			gtk_tooltip_set_text(tooltip, _("No unread messages"));
++		}
++	} else {
++		gtk_tooltip_set_text(tooltip, _("No unread messages"));
++	}
++	
++	return TRUE;
++}
++
++static void mmgui_main_tray_icon_init(mmgui_application_t mmguiapp)
++{
++	gchar *iconfilepath;
++
+ 	if (mmguiapp == NULL) return;
+ 	
+-	/*Indicator*/
+-	iconfilepath = g_build_filename(RESOURCE_SYMBOLIC_ICONS_DIR, "modem-manager-gui-symbolic.svg", NULL);
+-	mmguiapp->window->indicator = app_indicator_new(RESOURCE_LOCALE_DOMAIN, iconfilepath, APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
+-	g_free(iconfilepath);
+-	/*Indicator menu*/
+-	mmguiapp->window->indmenu = gtk_menu_new();
++	/*Tray icon*/
++ 	iconfilepath = g_build_filename(RESOURCE_SCALABLE_ICONS_DIR, "modem-manager-gui.svg", NULL);
++	mmguiapp->window->statusicon = gtk_status_icon_new_from_file(iconfilepath);
++	g_signal_connect(G_OBJECT(mmguiapp->window->statusicon), "activate", G_CALLBACK(mmgui_main_tray_icon_activation_signal), mmguiapp);
++	gtk_status_icon_set_tooltip_text(mmguiapp->window->statusicon, _("No unread messages"));
++	/*Tray menu*/
++	mmguiapp->window->traymenu = gtk_menu_new();
+ 	/*Show window entry*/
+-	mmguiapp->window->showwin_ind = gtk_check_menu_item_new_with_label(_("Show window"));
+-	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mmguiapp->window->showwin_ind), FALSE);
+-	mmguiapp->window->traysigid = g_signal_connect(G_OBJECT(mmguiapp->window->showwin_ind), "toggled", G_CALLBACK(mmgui_main_tray_icon_window_show_signal), mmguiapp);
++	mmguiapp->window->showwin_tm = gtk_check_menu_item_new_with_label(_("Show window"));
++	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mmguiapp->window->showwin_tm), gtk_widget_get_visible(mmguiapp->window->window));
++	mmguiapp->window->traysigid = g_signal_connect(G_OBJECT(mmguiapp->window->showwin_tm), "toggled", G_CALLBACK(mmgui_main_tray_icon_window_show_signal), mmguiapp);
+ 	/*Separator*/
+-	mmguiapp->window->sep1_ind = gtk_separator_menu_item_new();
++	mmguiapp->window->sep1_tm = gtk_separator_menu_item_new();
+ 	/*New SMS entry*/
+-	mmguiapp->window->newsms_ind = gtk_menu_item_new_with_label(_("New SMS"));
+-	gtk_widget_set_sensitive(mmguiapp->window->newsms_ind, FALSE);
+-	g_signal_connect(G_OBJECT(mmguiapp->window->newsms_ind), "activate", G_CALLBACK(mmgui_main_tray_icon_new_sms_signal), mmguiapp);
++	mmguiapp->window->newsms_tm = gtk_menu_item_new_with_label(_("New SMS"));
++	gtk_widget_set_sensitive(mmguiapp->window->newsms_tm, FALSE);
++	g_signal_connect(G_OBJECT(mmguiapp->window->newsms_tm), "activate", G_CALLBACK(mmgui_main_tray_icon_new_sms_signal), mmguiapp);
+ 	/*Separator 2*/
+-	mmguiapp->window->sep2_ind = gtk_separator_menu_item_new();
++	mmguiapp->window->sep2_tm = gtk_separator_menu_item_new();
+ 	/*Quit entry*/
+-	mmguiapp->window->quit_ind = gtk_menu_item_new_with_label(_("Quit"));
+-	g_signal_connect(G_OBJECT(mmguiapp->window->quit_ind), "activate", G_CALLBACK(mmgui_main_tray_icon_exit_signal), mmguiapp);
++	mmguiapp->window->quit_tm = gtk_menu_item_new_with_label(_("Quit"));
++	g_signal_connect(G_OBJECT(mmguiapp->window->quit_tm), "activate", G_CALLBACK(mmgui_main_tray_icon_exit_signal), mmguiapp);
+ 	/*Packaging*/
+-	gtk_menu_shell_append(GTK_MENU_SHELL(mmguiapp->window->indmenu), mmguiapp->window->showwin_ind);
+-	gtk_menu_shell_append(GTK_MENU_SHELL(mmguiapp->window->indmenu), mmguiapp->window->sep1_ind);
+-	gtk_menu_shell_append(GTK_MENU_SHELL(mmguiapp->window->indmenu), mmguiapp->window->newsms_ind);
+-	gtk_menu_shell_append(GTK_MENU_SHELL(mmguiapp->window->indmenu), mmguiapp->window->sep2_ind);
+-	gtk_menu_shell_append(GTK_MENU_SHELL(mmguiapp->window->indmenu), mmguiapp->window->quit_ind);
+-	gtk_widget_show_all(mmguiapp->window->indmenu);
+-	/*Set status*/
+-	app_indicator_set_status(mmguiapp->window->indicator, APP_INDICATOR_STATUS_ACTIVE);
+-	app_indicator_set_attention_icon(mmguiapp->window->indicator, "indicator-messages-new");
+-	/*Set menu*/
+-	app_indicator_set_menu(mmguiapp->window->indicator, GTK_MENU(mmguiapp->window->indmenu));
+-}
+-
+-static void mmgui_main_tray_icon_init(mmgui_application_t mmguiapp)
+-{
+-	if (mmguiapp == NULL) return;
+-	
+-	/*Window state*/
+-	g_signal_handler_block(G_OBJECT(mmguiapp->window->showwin_ind), mmguiapp->window->traysigid);
+-	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mmguiapp->window->showwin_ind), ((!mmguiapp->options->invisible) && (!mmguiapp->options->minimized)));
+-	g_signal_handler_unblock(G_OBJECT(mmguiapp->window->showwin_ind), mmguiapp->window->traysigid);
++	gtk_menu_shell_append(GTK_MENU_SHELL(mmguiapp->window->traymenu), mmguiapp->window->showwin_tm);
++	gtk_menu_shell_append(GTK_MENU_SHELL(mmguiapp->window->traymenu), mmguiapp->window->sep1_tm);
++	gtk_menu_shell_append(GTK_MENU_SHELL(mmguiapp->window->traymenu), mmguiapp->window->newsms_tm);
++	gtk_menu_shell_append(GTK_MENU_SHELL(mmguiapp->window->traymenu), mmguiapp->window->sep2_tm);
++	gtk_menu_shell_append(GTK_MENU_SHELL(mmguiapp->window->traymenu), mmguiapp->window->quit_tm);
++	gtk_widget_show_all(mmguiapp->window->traymenu);
++	/*Tray menu signal*/
++	g_signal_connect(G_OBJECT(mmguiapp->window->statusicon), "popup-menu", G_CALLBACK(mmgui_main_tray_popup_menu_show_signal), mmguiapp);
++	/*Tray tooltip signal*/
++	g_signal_connect(G_OBJECT(mmguiapp->window->statusicon), "query-tooltip", G_CALLBACK(mmgui_main_tray_tooltip_show_signal), mmguiapp);
++	gtk_status_icon_set_has_tooltip(mmguiapp->window->statusicon, TRUE);
+ }
+ 
+-#endif
+-
+ /*Ayatana*/
+ static void mmgui_main_ayatana_event_callback(enum _mmgui_ayatana_event event, gpointer ayatana, gpointer data, gpointer userdata)
+ {
+@@ -2657,10 +2676,8 @@
+ 	/*Builder object is not needed anymore*/
+ 	g_object_unref(G_OBJECT(builder));
+ 	
+-	#if RESOURCE_INDICATOR_ENABLED
+-		mmgui_main_tray_icon_build(mmguiapp);
+-	#endif
+-		
++	mmgui_main_tray_icon_init(mmguiapp);
++	
+ 	return TRUE;
+ }
+ 
+@@ -2800,11 +2817,6 @@
+ 	#if RESOURCE_SPELLCHECKER_ENABLED
+ 		mmgui_main_sms_spellcheck_init(mmguiapp);
+ 	#endif
+-	
+-	#if RESOURCE_INDICATOR_ENABLED
+-		mmgui_main_tray_icon_init(mmguiapp);
+-	#endif
+-	
+ 	/*Restore window geometry*/
+ 	if (mmguiapp->options->savegeometry) {
+ 		if ((mmguiapp->options->wgwidth >= 1) && (mmguiapp->options->wgheight >= 1)) {
+diff -Naur modem-manager-gui-0.0.19.orig/src/main.h modem-manager-gui-0.0.19/src/main.h
+--- modem-manager-gui-0.0.19.orig/src/main.h	2018-03-17 16:35:08.000000000 +0100
++++ modem-manager-gui-0.0.19/src/main.h	2018-03-22 13:43:48.508435052 +0100
+@@ -34,10 +34,6 @@
+ 	#include <gtkspell/gtkspell.h>
+ #endif
+ 
+-#if RESOURCE_INDICATOR_ENABLED
+-	#include <libappindicator/app-indicator.h>
+-#endif
+-
+ #define MMGUI_MAIN_DEFAULT_DEVICE_IDENTIFIER  "00000000000000000000000"
+ #define MMGUI_MAIN_DEFAULT_CONNECTION_UUID    "00000000-0000-4000-0000-000000000000"
+ 
+@@ -323,10 +319,10 @@
+ 	GClosure *newcontactclosure;
+ 	GClosure *removecontactclosure;
+ 	GClosure *smstocontactclosure;
+-	/*Indicator*/
+-	AppIndicator *indicator;
+-	GtkWidget *indmenu;
+-	GtkWidget *showwin_ind, *sep1_ind, *newsms_ind, *sep2_ind, *quit_ind;
++	/*Tray icon*/
++	GtkStatusIcon *statusicon;
++	GtkWidget *traymenu;
++	GtkWidget *showwin_tm, *sep1_tm, *newsms_tm, *sep2_tm, *quit_tm;
+ 	gulong traysigid;
+ };
+ 



More information about the arch-commits mailing list