diff options
author | Dan Williams <dcbw@redhat.com> | 2017-07-19 23:24:21 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2018-01-09 10:33:51 -0600 |
commit | 28d0023c28504193c07bfe06d54cb79ee3212849 (patch) | |
tree | 034549bfc5cb86971e9c8342298b6ff5c40f99b5 | |
parent | ad47c44afc60265e19d518bd70c550ebe0fda10a (diff) | |
download | network-manager-applet-28d0023c28504193c07bfe06d54cb79ee3212849.tar.gz |
adsfasdf
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | src/applet-device-broadband.c | 3 | ||||
-rw-r--r-- | src/applet-device-bt.c | 3 | ||||
-rw-r--r-- | src/applet-device-ethernet.c | 3 | ||||
-rw-r--r-- | src/applet-device-wifi.c | 3 | ||||
-rw-r--r-- | src/applet.c | 74 | ||||
-rw-r--r-- | src/context-menu.c | 11 | ||||
-rw-r--r-- | src/menu-utils.c | 84 |
8 files changed, 96 insertions, 87 deletions
diff --git a/Makefile.am b/Makefile.am index 5b582128..d4774b31 100644 --- a/Makefile.am +++ b/Makefile.am @@ -785,6 +785,8 @@ nm_applet_hc_real = \ src/applet-vpn-request.h \ src/context-menu.c \ src/context-menu.h \ + src/menu-utils.c \ + src/menu-utils.h \ src/ethernet-dialog.h \ src/ethernet-dialog.c \ src/applet-dialogs.h \ diff --git a/src/applet-device-broadband.c b/src/applet-device-broadband.c index da1790ed..c6a4e5fd 100644 --- a/src/applet-device-broadband.c +++ b/src/applet-device-broadband.c @@ -29,6 +29,7 @@ #include "applet-dialogs.h" #include "mobile-helpers.h" #include "mb-menu-item.h" +#include "menu-utils.h" #define BROADBAND_INFO_TAG "devinfo" @@ -789,7 +790,7 @@ add_menu_item (NMDevice *device, /* Add the default / inactive connection items */ if (!nma_menu_device_check_unusable (device)) { if ((!active && connections->len) || (active && connections->len > 1)) - applet_menu_item_add_complex_separator_helper (menu, applet, _("Available")); + nma_menu_item_add_complex_separator_helper (menu, !!INDICATOR_ENABLED (applet), _("Available")); if (connections->len) { for (i = 0; i < connections->len; i++) { diff --git a/src/applet-device-bt.c b/src/applet-device-bt.c index 099c8c5a..5fc3b1d4 100644 --- a/src/applet-device-bt.c +++ b/src/applet-device-bt.c @@ -26,6 +26,7 @@ #include "applet.h" #include "applet-device-bt.h" #include "applet-dialogs.h" +#include "menu-utils.h" static gboolean bt_new_auto_connection (NMDevice *device, @@ -72,7 +73,7 @@ bt_add_menu_item (NMDevice *device, if (!nma_menu_device_check_unusable (device)) { /* Add menu items for existing bluetooth connections for this device */ if (connections->len) { - applet_menu_item_add_complex_separator_helper (menu, applet, _("Available")); + nma_menu_item_add_complex_separator_helper (menu, !!INDICATOR_ENABLED (applet), _("Available")); applet_add_connection_items (device, connections, TRUE, active, NMA_ADD_INACTIVE, menu, applet); } } diff --git a/src/applet-device-ethernet.c b/src/applet-device-ethernet.c index caac52d0..f69d5725 100644 --- a/src/applet-device-ethernet.c +++ b/src/applet-device-ethernet.c @@ -26,6 +26,7 @@ #include "applet.h" #include "applet-device-ethernet.h" #include "ethernet-dialog.h" +#include "menu-utils.h" #define DEFAULT_ETHERNET_NAME _("Auto Ethernet") @@ -114,7 +115,7 @@ ethernet_add_menu_item (NMDevice *device, if (!nma_menu_device_check_unusable (device)) { if ((!active && connections->len) || (active && connections->len > 1)) - applet_menu_item_add_complex_separator_helper (menu, applet, _("Available")); + nma_menu_item_add_complex_separator_helper (menu, !!INDICATOR_ENABLED (applet), _("Available")); if (connections->len) applet_add_connection_items (device, connections, carrier, active, NMA_ADD_INACTIVE, menu, applet); diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c index 08ecef19..232be830 100644 --- a/src/applet-device-wifi.c +++ b/src/applet-device-wifi.c @@ -33,6 +33,7 @@ #include "utils.h" #include "nma-wifi-dialog.h" #include "mobile-helpers.h" +#include "menu-utils.h" #define ACTIVE_AP_TAG "active-ap" @@ -904,7 +905,7 @@ wifi_add_menu_item (NMDevice *device, GSList *topmenu_items = NULL; guint32 num_for_toplevel = 5; - applet_menu_item_add_complex_separator_helper (menu, applet, _("Available")); + nma_menu_item_add_complex_separator_helper (menu, !!INDICATOR_ENABLED (applet), _("Available")); if (g_slist_length (menu_items) == (num_for_toplevel + 1)) num_for_toplevel++; diff --git a/src/applet.c b/src/applet.c index f33384dd..858d2fe6 100644 --- a/src/applet.c +++ b/src/applet.c @@ -44,6 +44,7 @@ #include "context-menu.h" #include "nma-wifi-dialog.h" #include "applet-vpn-request.h" +#include "menu-utils.h" #include "utils.h" #if WITH_WWAN @@ -529,44 +530,6 @@ applet_menu_item_activate_helper (NMDevice *device, applet_item_activate_info_destroy (info); } -void -applet_menu_item_add_complex_separator_helper (GtkWidget *menu, - NMApplet *applet, - const gchar *label) -{ - GtkWidget *menu_item, *box, *xlabel, *separator; - - if (INDICATOR_ENABLED (applet)) { - /* Indicator doesn't draw complex separators */ - return; - } - - menu_item = gtk_menu_item_new (); - box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); - - if (label) { - xlabel = gtk_label_new (NULL); - gtk_label_set_markup (GTK_LABEL (xlabel), label); - - separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); - g_object_set (G_OBJECT (separator), "valign", GTK_ALIGN_CENTER, NULL); - gtk_box_pack_start (GTK_BOX (box), separator, TRUE, TRUE, 0); - - gtk_box_pack_start (GTK_BOX (box), xlabel, FALSE, FALSE, 2); - } - - separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); - g_object_set (G_OBJECT (separator), "valign", GTK_ALIGN_CENTER, NULL); - gtk_box_pack_start (GTK_BOX (box), separator, TRUE, TRUE, 0); - - g_object_set (G_OBJECT (menu_item), - "child", box, - "sensitive", FALSE, - NULL); - - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); -} - GtkWidget * applet_new_menu_item_helper (NMConnection *connection, NMConnection *active, @@ -1134,41 +1097,6 @@ applet_get_active_vpn_connection (NMApplet *applet, return ret; } -/* - * nma_menu_add_separator_item - * - */ -static void -nma_menu_add_separator_item (GtkWidget *menu) -{ - GtkWidget *menu_item; - - menu_item = gtk_separator_menu_item_new (); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); - gtk_widget_show (menu_item); -} - - -/* - * nma_menu_add_text_item - * - * Add a non-clickable text item to a menu - * - */ -static void nma_menu_add_text_item (GtkWidget *menu, char *text) -{ - GtkWidget *menu_item; - - g_return_if_fail (text != NULL); - g_return_if_fail (menu != NULL); - - menu_item = gtk_menu_item_new_with_label (text); - gtk_widget_set_sensitive (menu_item, FALSE); - - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); - gtk_widget_show (menu_item); -} - static gint sort_devices_by_description (gconstpointer a, gconstpointer b) { diff --git a/src/context-menu.c b/src/context-menu.c index 257751f7..29ec1a7f 100644 --- a/src/context-menu.c +++ b/src/context-menu.c @@ -32,19 +32,10 @@ #include "applet.h" #include "context-menu.h" #include "applet-dialogs.h" +#include "menu-utils.h" #include "utils.h" static void -nma_menu_add_separator_item (GtkWidget *menu) -{ - GtkWidget *menu_item; - - menu_item = gtk_separator_menu_item_new (); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); - gtk_widget_show (menu_item); -} - -static void nma_set_wifi_enabled_cb (GtkWidget *widget, NMApplet *applet) { gboolean state; diff --git a/src/menu-utils.c b/src/menu-utils.c new file mode 100644 index 00000000..38176c77 --- /dev/null +++ b/src/menu-utils.c @@ -0,0 +1,84 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager Applet -- allow user control over networking + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2004 - 2017 Red Hat, Inc. + */ + +#include "menu-utils.h" + +void +nma_menu_add_separator_item (GtkWidget *menu) +{ + GtkWidget *menu_item; + + menu_item = gtk_separator_menu_item_new (); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); + gtk_widget_show (menu_item); +} + +void +nma_menu_add_text_item (GtkWidget *menu, char *text) +{ + GtkWidget *menu_item; + + g_return_if_fail (text != NULL); + g_return_if_fail (menu != NULL); + + menu_item = gtk_menu_item_new_with_label (text); + gtk_widget_set_sensitive (menu_item, FALSE); + + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); + gtk_widget_show (menu_item); +} + +void +applet_menu_item_add_complex_separator_helper (GtkWidget *menu, + gboolean indicator_enabled, + const gchar *label) +{ + GtkWidget *menu_item, *box, *xlabel, *separator; + + if (indicator_enabled) { + /* Indicator doesn't draw complex separators */ + return; + } + + menu_item = gtk_menu_item_new (); + box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); + + if (label) { + xlabel = gtk_label_new (NULL); + gtk_label_set_markup (GTK_LABEL (xlabel), label); + + separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); + g_object_set (G_OBJECT (separator), "valign", GTK_ALIGN_CENTER, NULL); + gtk_box_pack_start (GTK_BOX (box), separator, TRUE, TRUE, 0); + + gtk_box_pack_start (GTK_BOX (box), xlabel, FALSE, FALSE, 2); + } + + separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); + g_object_set (G_OBJECT (separator), "valign", GTK_ALIGN_CENTER, NULL); + gtk_box_pack_start (GTK_BOX (box), separator, TRUE, TRUE, 0); + + g_object_set (G_OBJECT (menu_item), + "child", box, + "sensitive", FALSE, + NULL); + + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); +} |