summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrbuj <[email protected]>2020-12-14 15:44:45 +0100
committerVictor Kareh <[email protected]>2020-12-18 09:30:19 -0500
commit43afa6d5de37f36c196459bb441311a65bcc386c (patch)
treed315e4bf1ca6576c228ce9cb273a710df41ac3c3
parent1b7915e471b1105368b5bd07a616c8339c6cf7dc (diff)
downloadmate-applets-43afa6d5de37f36c196459bb441311a65bcc386c.tar.bz2
mate-applets-43afa6d5de37f36c196459bb441311a65bcc386c.tar.xz
netspeed: show all IP addresses on tooltip if enabled
-rw-r--r--netspeed/data/netspeed-preferences.ui130
-rw-r--r--netspeed/data/org.mate.panel.applet.netspeed.gschema.xml.in5
-rw-r--r--netspeed/src/netspeed.c84
3 files changed, 142 insertions, 77 deletions
diff --git a/netspeed/data/netspeed-preferences.ui b/netspeed/data/netspeed-preferences.ui
index 62b0e601..9bc04f65 100644
--- a/netspeed/data/netspeed-preferences.ui
+++ b/netspeed/data/netspeed-preferences.ui
@@ -1,42 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.36.0 -->
+<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.22"/>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">help-browser</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">help-browser</property>
</object>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">window-close</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">window-close</property>
</object>
<object class="GtkDialog" id="preferences_dialog">
- <property name="can_focus">False</property>
- <property name="border_width">12</property>
+ <property name="can-focus">False</property>
+ <property name="border-width">12</property>
<property name="title" translatable="yes">MATE Netspeed Preferences</property>
- <property name="icon_name">mate-netspeed-applet</property>
- <property name="type_hint">dialog</property>
+ <property name="icon-name">mate-netspeed-applet</property>
+ <property name="type-hint">dialog</property>
<signal name="response" handler="on_preferences_dialog_response" swapped="no"/>
<child internal-child="vbox">
<object class="GtkBox">
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
- <property name="can_focus">False</property>
- <property name="layout_style">end</property>
+ <property name="can-focus">False</property>
+ <property name="layout-style">end</property>
<child>
<object class="GtkButton" id="button1">
<property name="label" translatable="yes">_Help</property>
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
<property name="image">image1</property>
- <property name="use_underline">True</property>
- <property name="always_show_image">True</property>
+ <property name="use-underline">True</property>
+ <property name="always-show-image">True</property>
</object>
<packing>
<property name="expand">True</property>
@@ -48,13 +48,13 @@
<object class="GtkButton" id="button2">
<property name="label" translatable="yes">_Close</property>
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="receives_default">True</property>
+ <property name="can-focus">True</property>
+ <property name="can-default">True</property>
+ <property name="has-default">True</property>
+ <property name="receives-default">True</property>
<property name="image">image2</property>
- <property name="use_underline">True</property>
- <property name="always_show_image">True</property>
+ <property name="use-underline">True</property>
+ <property name="always-show-image">True</property>
</object>
<packing>
<property name="expand">True</property>
@@ -72,34 +72,34 @@
<child>
<object class="GtkFrame">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">none</property>
+ <property name="can-focus">False</property>
+ <property name="label-xalign">0</property>
+ <property name="shadow-type">none</property>
<child>
<object class="GtkAlignment">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="left_padding">12</property>
+ <property name="can-focus">False</property>
+ <property name="left-padding">12</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">5</property>
+ <property name="can-focus">False</property>
+ <property name="border-width">5</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Network _device:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">network_device_combo</property>
+ <property name="use-underline">True</property>
+ <property name="mnemonic-widget">network_device_combo</property>
</object>
<packing>
<property name="expand">False</property>
@@ -110,7 +110,7 @@
<child>
<object class="GtkComboBoxText" id="network_device_combo">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<signal name="changed" handler="on_network_device_combo_changed" swapped="no"/>
</object>
<packing>
@@ -130,11 +130,11 @@
<object class="GtkCheckButton" id="show_sum_checkbutton">
<property name="label" translatable="yes">Show _sum instead of in &amp; out</property>
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">False</property>
<property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
+ <property name="use-underline">True</property>
+ <property name="draw-indicator">True</property>
<signal name="toggled" handler="on_show_sum_checkbutton_toggled" swapped="no"/>
</object>
<packing>
@@ -147,11 +147,11 @@
<object class="GtkCheckButton" id="show_bits_checkbutton">
<property name="label" translatable="yes">Show _bits instead of bytes</property>
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">False</property>
<property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
+ <property name="use-underline">True</property>
+ <property name="draw-indicator">True</property>
<signal name="toggled" handler="on_show_bits_checkbutton_toggled" swapped="no"/>
</object>
<packing>
@@ -164,11 +164,11 @@
<object class="GtkCheckButton" id="change_icon_checkbutton">
<property name="label" translatable="yes">_Change icon according to the selected device</property>
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">False</property>
<property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
+ <property name="use-underline">True</property>
+ <property name="draw-indicator">True</property>
<signal name="toggled" handler="on_change_icon_checkbutton_toggled" swapped="no"/>
</object>
<packing>
@@ -181,11 +181,11 @@
<object class="GtkCheckButton" id="show_icon_checkbutton">
<property name="label" translatable="yes">Show _icon</property>
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">False</property>
<property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
+ <property name="use-underline">True</property>
+ <property name="draw-indicator">True</property>
<signal name="toggled" handler="on_show_icon_checkbutton_toggled" swapped="no"/>
</object>
<packing>
@@ -198,11 +198,11 @@
<object class="GtkCheckButton" id="show_quality_icon_checkbutton">
<property name="label" translatable="yes">Show signal _quality icon for wireless devices</property>
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">False</property>
<property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
+ <property name="use-underline">True</property>
+ <property name="draw-indicator">True</property>
<signal name="toggled" handler="on_show_quality_icon_checkbutton_toggled" swapped="no"/>
</object>
<packing>
@@ -211,6 +211,23 @@
<property name="position">5</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="show_all_addresses_checkbutton">
+ <property name="label" translatable="yes">Show all _IP addresses on tooltip</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">False</property>
+ <property name="halign">start</property>
+ <property name="use-underline">True</property>
+ <property name="draw-indicator">True</property>
+ <signal name="toggled" handler="on_show_all_addresses_checkbutton_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">6</property>
+ </packing>
+ </child>
</object>
</child>
</object>
@@ -218,7 +235,7 @@
<child type="label">
<object class="GtkLabel">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">General Settings</property>
<attributes>
@@ -239,8 +256,5 @@
<action-widget response="-11">button1</action-widget>
<action-widget response="-3">button2</action-widget>
</action-widgets>
- <child type="titlebar">
- <placeholder/>
- </child>
</object>
</interface>
diff --git a/netspeed/data/org.mate.panel.applet.netspeed.gschema.xml.in b/netspeed/data/org.mate.panel.applet.netspeed.gschema.xml.in
index 88b6a8aa..a45dadb1 100644
--- a/netspeed/data/org.mate.panel.applet.netspeed.gschema.xml.in
+++ b/netspeed/data/org.mate.panel.applet.netspeed.gschema.xml.in
@@ -15,6 +15,11 @@
<summary>Show bits</summary>
<description>If true, show speed in bits instead of bytes.</description>
</key>
+ <key name="show-all-addresses" type="b">
+ <default>false</default>
+ <summary>Show IPv4 and IPv6 addresses on tooltip</summary>
+ <description>If true, show both IP addresses if enabled.</description>
+ </key>
<key name="show-icon" type="b">
<default>true</default>
<summary>Show icon</summary>
diff --git a/netspeed/src/netspeed.c b/netspeed/src/netspeed.c
index 7683928c..b3e88847 100644
--- a/netspeed/src/netspeed.c
+++ b/netspeed/src/netspeed.c
@@ -99,6 +99,7 @@ typedef struct
guint timeout_id;
char *up_cmd;
char *down_cmd;
+ gboolean show_all_addresses;
gboolean show_sum;
gboolean show_bits;
gboolean change_icon;
@@ -1079,7 +1080,6 @@ device_change_cb (GtkComboBox *combo,
update_applet (applet);
}
-
/* Handle preference dialog response event
*/
static void
@@ -1102,6 +1102,15 @@ pref_response_cb (GtkDialog *dialog,
applet->settings = NULL;
}
+/* Called when the showalladdresses checkbutton is toggled...
+ */
+static void
+showalladdresses_change_cb (GtkToggleButton *togglebutton,
+ MateNetspeedApplet *applet)
+{
+ applet->show_all_addresses = gtk_toggle_button_get_active (togglebutton);
+}
+
/* Called when the showsum checkbutton is toggled...
*/
static void
@@ -1183,6 +1192,10 @@ settings_cb (GtkAction *action,
gtk_dialog_set_default_response (GTK_DIALOG (applet->settings), GTK_RESPONSE_CLOSE);
+ g_settings_bind (applet->gsettings, "show-all-addresses",
+ gtk_builder_get_object (builder, "show_all_addresses_checkbutton"),
+ "active", G_SETTINGS_BIND_DEFAULT);
+
g_settings_bind (applet->gsettings, "show-sum",
gtk_builder_get_object (builder, "show_sum_checkbutton"),
"active", G_SETTINGS_BIND_DEFAULT);
@@ -1224,6 +1237,7 @@ settings_cb (GtkAction *action,
/* signals */
gtk_builder_add_callback_symbols (builder,
"on_network_device_combo_changed", G_CALLBACK (device_change_cb),
+ "on_show_all_addresses_checkbutton_toggled", G_CALLBACK (showalladdresses_change_cb),
"on_show_sum_checkbutton_toggled", G_CALLBACK (showsum_change_cb),
"on_show_bits_checkbutton_toggled", G_CALLBACK (showbits_change_cb),
"on_change_icon_checkbutton_toggled", G_CALLBACK (changeicon_change_cb),
@@ -1517,32 +1531,63 @@ update_tooltip (MateNetspeedApplet* applet)
char ipv6_text [INET6_ADDRSTRLEN];
char *ip;
- if (applet->devinfo->ip) {
- format_ipv4 (applet->devinfo->ip, ipv4_text);
- ip = ipv4_text;
- } else {
+ if (applet->show_all_addresses) {
format_ipv6 (applet->devinfo->ipv6, ipv6_text);
- if (strlen (ipv6_text) > 2) {
- ip = ipv6_text;
+ if (applet->devinfo->ip) {
+ format_ipv4 (applet->devinfo->ip, ipv4_text);
+ if (strlen (ipv6_text) > 2) {
+ g_string_printf (tooltip,
+ _("%s: %s and %s"),
+ applet->devinfo->name,
+ ipv4_text,
+ ipv6_text);
+ } else {
+ g_string_printf (tooltip,
+ _("%s: %s"),
+ applet->devinfo->name,
+ ipv4_text);
+ }
+ } else {
+ if (strlen (ipv6_text) > 2) {
+ g_string_printf (tooltip,
+ _("%s: %s"),
+ applet->devinfo->name,
+ ipv4_text);
+ } else {
+ g_string_printf (tooltip,
+ _("%s: has no ip"),
+ applet->devinfo->name);
+ }
+ }
+ } else {
+ if (applet->devinfo->ip) {
+ format_ipv4 (applet->devinfo->ip, ipv4_text);
+ ip = ipv4_text;
} else {
- ip = _("has no ip");
+ format_ipv6 (applet->devinfo->ipv6, ipv6_text);
+ if (strlen (ipv6_text) > 2) {
+ ip = ipv6_text;
+ } else {
+ ip = _("has no ip");
+ }
}
+ g_string_printf (tooltip,
+ _("%s: %s"),
+ applet->devinfo->name,
+ ip);
}
if (applet->show_sum) {
- g_string_printf (tooltip,
- _("%s: %s\nin: %s out: %s"),
- applet->devinfo->name,
- ip,
- applet->devinfo->rx_rate,
- applet->devinfo->tx_rate);
+ g_string_append_printf (tooltip,
+ _("\nin: %s out: %s"),
+ applet->devinfo->rx_rate,
+ applet->devinfo->tx_rate);
} else {
- g_string_printf (tooltip,
- _("%s: %s\nsum: %s"),
- applet->devinfo->name,
- ip,
- applet->devinfo->sum_rate);
+ g_string_append_printf (tooltip,
+ _("\nsum: %s"),
+ applet->devinfo->sum_rate);
}
+
#ifdef HAVE_NL
if (applet->devinfo->type == DEV_WIRELESS)
g_string_append_printf (tooltip,
@@ -1635,6 +1680,7 @@ mate_netspeed_applet_factory (MatePanelApplet *applet_widget,
/* Get stored settings from gsettings
*/
+ applet->show_all_addresses = g_settings_get_boolean (applet->gsettings, "show-all-addresses");
applet->show_sum = g_settings_get_boolean (applet->gsettings, "show-sum");
applet->show_bits = g_settings_get_boolean (applet->gsettings, "show-bits");
applet->show_icon = g_settings_get_boolean (applet->gsettings, "show-icon");