network-manager-applet r443 - in trunk: . po src
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: network-manager-applet r443 - in trunk: . po src
- Date: Sun, 13 Jan 2008 14:30:56 +0000 (GMT)
Author: dcbw
Date: Sun Jan 13 14:30:55 2008
New Revision: 443
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=443&view=rev
Log:
2008-01-11 Dan Williams <dcbw redhat com>
* src/applet-dialogs.h
src/applet-dialogs.c
- New files; move info and about dialog stuff here
* src/Makefile.am
po/POTFILES.in
- Add applet-dialogs.c, applet-dialogs.h
* src/applet.c
src/applet.h
src/wireless-dialog.c
- Updates for split out dialogs stuff
Added:
trunk/src/applet-dialogs.c
trunk/src/applet-dialogs.h
Modified:
trunk/ChangeLog
trunk/po/POTFILES.in
trunk/src/Makefile.am
trunk/src/applet.c
trunk/src/applet.h
trunk/src/wireless-dialog.c
Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in (original)
+++ trunk/po/POTFILES.in Sun Jan 13 14:30:55 2008
@@ -3,6 +3,7 @@
# Please keep this file sorted alphabetically.
src/applet-dbus-manager.c
src/applet-dbus-settings.c
+src/applet-dialogs.c
src/applet.c
src/applet.glade
src/applet.h
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Sun Jan 13 14:30:55 2008
@@ -39,6 +39,8 @@
vpn-password-dialog.h \
wireless-dialog.h \
wireless-dialog.c \
+ applet-dialogs.h \
+ applet-dialogs.c \
$(NULL)
nm_applet_LDADD = \
Added: trunk/src/applet-dialogs.c
==============================================================================
--- (empty file)
+++ trunk/src/applet-dialogs.c Sun Jan 13 14:30:55 2008
@@ -0,0 +1,342 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
+ *
+ * Dan Williams <dcbw redhat com>
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * (C) Copyright 2008 Red Hat, Inc.
+ */
+
+#include <netinet/in.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+
+#include <nm-device-802-3-ethernet.h>
+#include <nm-device-802-11-wireless.h>
+
+#include <gtk/gtk.h>
+#include <gtk/gtkwidget.h>
+#include <glade/glade.h>
+#include <glib/gi18n.h>
+
+#include "applet-dialogs.h"
+
+
+static GtkWidget *
+info_dialog_get_label (GtkWidget *info_dialog,
+ GladeXML *xml,
+ const char *name)
+{
+ GtkWidget *label;
+
+ if (xml != NULL) {
+ label = glade_xml_get_widget (xml, name);
+ g_object_set_data (G_OBJECT (info_dialog), name, label);
+ } else
+ label = g_object_get_data (G_OBJECT (info_dialog), name);
+
+ return label;
+}
+
+static void
+info_dialog_show_error (const char *err)
+{
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new_with_markup (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+ "<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s", _("Error displaying connection information:"), err);
+ gtk_window_present (GTK_WINDOW (dialog));
+ g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog);
+}
+
+static const gchar *
+ip4_address_as_string (guint32 ip)
+{
+ struct in_addr tmp_addr;
+ gchar *ip_string;
+
+ tmp_addr.s_addr = ip;
+ ip_string = inet_ntoa (tmp_addr);
+
+ return ip_string;
+}
+
+static GtkWidget *
+info_dialog_update (GladeXML *xml, NMDevice *device)
+{
+ GtkWidget *dialog;
+ GtkWidget *label;
+ NMIP4Config *cfg;
+ guint32 speed;
+ char *str;
+ char *iface_and_type;
+ GArray *dns;
+
+ g_return_val_if_fail (xml != NULL, NULL);
+ g_return_val_if_fail (device != NULL, NULL);
+
+ dialog = glade_xml_get_widget (xml, "info_dialog");
+ if (!dialog) {
+ info_dialog_show_error (_("Could not find some required resources (the glade file)!"));
+ return NULL;
+ }
+
+ cfg = nm_device_get_ip4_config (device);
+
+ speed = 0;
+ if (NM_IS_DEVICE_802_3_ETHERNET (device)) {
+ /* Wireless speed in Mb/s */
+ speed = nm_device_802_3_ethernet_get_speed (NM_DEVICE_802_3_ETHERNET (device));
+ } else if (NM_IS_DEVICE_802_11_WIRELESS (device)) {
+ /* Wireless speed in b/s */
+ speed = nm_device_802_11_wireless_get_bitrate (NM_DEVICE_802_11_WIRELESS (device));
+ speed /= 1000000;
+ }
+
+ str = nm_device_get_iface (device);
+ if (NM_IS_DEVICE_802_3_ETHERNET (device))
+ iface_and_type = g_strdup_printf (_("Wired Ethernet (%s)"), str);
+ else if (NM_IS_DEVICE_802_11_WIRELESS (device))
+ iface_and_type = g_strdup_printf (_("Wireless Ethernet (%s)"), str);
+ else
+ iface_and_type = g_strdup (str);
+
+ g_free (str);
+
+ label = info_dialog_get_label (dialog, xml, "label-interface");
+ gtk_label_set_text (GTK_LABEL (label), iface_and_type);
+ g_free (iface_and_type);
+
+ label = info_dialog_get_label (dialog, xml, "label-speed");
+ if (speed) {
+ str = g_strdup_printf (_("%u Mb/s"), speed);
+ gtk_label_set_text (GTK_LABEL (label), str);
+ g_free (str);
+ } else
+ gtk_label_set_text (GTK_LABEL (label), _("Unknown"));
+
+ str = nm_device_get_driver (device);
+ label = info_dialog_get_label (dialog, xml, "label-driver");
+ gtk_label_set_text (GTK_LABEL (label), str);
+ g_free (str);
+
+ label = info_dialog_get_label (dialog, xml, "label-ip-address");
+ gtk_label_set_text (GTK_LABEL (label),
+ ip4_address_as_string (nm_ip4_config_get_address (cfg)));
+
+ label = info_dialog_get_label (dialog, xml, "label-broadcast-address");
+ gtk_label_set_text (GTK_LABEL (label),
+ ip4_address_as_string (nm_ip4_config_get_broadcast (cfg)));
+
+ label = info_dialog_get_label (dialog, xml, "label-subnet-mask");
+ gtk_label_set_text (GTK_LABEL (label),
+ ip4_address_as_string (nm_ip4_config_get_netmask (cfg)));
+
+ label = info_dialog_get_label (dialog, xml, "label-default-route");
+ gtk_label_set_text (GTK_LABEL (label),
+ ip4_address_as_string (nm_ip4_config_get_gateway (cfg)));
+
+ dns = nm_ip4_config_get_nameservers (cfg);
+ if (dns) {
+ label = info_dialog_get_label (dialog, xml, "label-primary-dns");
+ if (dns->len > 0) {
+ gtk_label_set_text (GTK_LABEL (label),
+ ip4_address_as_string (g_array_index (dns, guint32, 0)));
+ } else {
+ gtk_label_set_text (GTK_LABEL (label), "");
+ }
+
+ label = info_dialog_get_label (dialog, xml, "label-secondary-dns");
+ if (dns->len > 1) {
+ gtk_label_set_text (GTK_LABEL (label),
+ ip4_address_as_string (g_array_index (dns, guint32, 1)));
+ } else {
+ gtk_label_set_text (GTK_LABEL (label), "");
+ }
+
+ g_array_free (dns, TRUE);
+ }
+
+ str = NULL;
+ if (NM_IS_DEVICE_802_3_ETHERNET (device))
+ str = nm_device_802_3_ethernet_get_hw_address (NM_DEVICE_802_3_ETHERNET (device));
+ else if (NM_IS_DEVICE_802_11_WIRELESS (device))
+ str = g_strdup (nm_device_802_11_wireless_get_hw_address (NM_DEVICE_802_11_WIRELESS (device)));
+
+ label = info_dialog_get_label (dialog, xml, "label-hardware-address");
+ gtk_label_set_text (GTK_LABEL (label), str ? str : "");
+ g_free (str);
+
+ return dialog;
+}
+
+void
+applet_info_dialog_show (NMApplet *applet)
+{
+ GtkWidget *dialog;
+ NMDevice *device;
+
+ device = applet_get_first_active_device (applet);
+ if (!device) {
+ info_dialog_show_error (_("No active connections!"));
+ return;
+ }
+
+ dialog = info_dialog_update (applet->info_dialog_xml, device);
+ if (!dialog)
+ return;
+
+ g_signal_connect (dialog, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), dialog);
+ g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_hide), dialog);
+ gtk_window_present (GTK_WINDOW (dialog));
+}
+
+static void
+about_dialog_handle_url_cb (GtkAboutDialog *about, const gchar *url, gpointer data)
+{
+ GError *error = NULL;
+ gboolean ret;
+ char *cmdline;
+ GdkScreen *gscreen;
+ GtkWidget *error_dialog;
+
+ gscreen = gtk_window_get_screen (GTK_WINDOW (about));
+
+ cmdline = g_strconcat ("gnome-open ", url, NULL);
+ ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
+ g_free (cmdline);
+
+ if (ret == TRUE)
+ return;
+
+ g_error_free (error);
+ error = NULL;
+
+ cmdline = g_strconcat ("xdg-open ", url, NULL);
+ ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
+ g_free (cmdline);
+
+ if (ret == FALSE) {
+ error_dialog = gtk_message_dialog_new ( NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Failed to show url %s", error->message);
+ gtk_dialog_run (GTK_DIALOG (error_dialog));
+ g_error_free (error);
+ }
+
+}
+
+/* Make email in about dialog clickable */
+static void
+about_dialog_handle_email_cb (GtkAboutDialog *about, const char *email_address, gpointer data)
+{
+ GError *error = NULL;
+ gboolean ret;
+ char *cmdline;
+ GdkScreen *gscreen;
+ GtkWidget *error_dialog;
+
+ gscreen = gtk_window_get_screen (GTK_WINDOW (about));
+
+ cmdline = g_strconcat ("gnome-open mailto:", email_address, NULL);
+ ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
+ g_free (cmdline);
+
+ if (ret == TRUE)
+ return;
+
+ g_error_free (error);
+ error = NULL;
+
+ cmdline = g_strconcat ("xdg-open mailto:", email_address, NULL);
+ ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
+ g_free (cmdline);
+
+ if (ret == FALSE) {
+ error_dialog = gtk_message_dialog_new ( NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Failed to show url %s", error->message);
+ gtk_dialog_run (GTK_DIALOG (error_dialog));
+ g_error_free (error);
+ }
+}
+
+void
+applet_about_dialog_show (NMApplet *applet)
+{
+ static const gchar *authors[] = {
+ "The Red Hat Desktop Team, including:\n",
+ "Christopher Aillon <caillon redhat com>",
+ "Jonathan Blandford <jrb redhat com>",
+ "John Palmieri <johnp redhat com>",
+ "Ray Strode <rstrode redhat com>",
+ "Colin Walters <walters redhat com>",
+ "Dan Williams <dcbw redhat com>",
+ "David Zeuthen <davidz redhat com>",
+ "\nAnd others, including:\n",
+ "Bill Moss <bmoss clemson edu>",
+ "Tom Parker",
+ "j bootlab org",
+ "Peter Jones <pjones redhat com>",
+ "Robert Love <rml novell com>",
+ "Tim Niemueller <tim niemueller de>",
+ NULL
+ };
+
+ static const gchar *artists[] = {
+ "Diana Fong <dfong redhat com>",
+ NULL
+ };
+
+
+ /* FIXME: unnecessary with libgnomeui >= 2.16.0 */
+ static gboolean been_here = FALSE;
+ if (!been_here) {
+ been_here = TRUE;
+ gtk_about_dialog_set_url_hook (about_dialog_handle_url_cb, NULL, NULL);
+ gtk_about_dialog_set_email_hook (about_dialog_handle_email_cb, NULL, NULL);
+ }
+
+ gtk_show_about_dialog (NULL,
+ "version", VERSION,
+ "copyright", _("Copyright \xc2\xa9 2004-2007 Red Hat, Inc.\n"
+ "Copyright \xc2\xa9 2005-2007 Novell, Inc."),
+ "comments", _("Notification area applet for managing your network devices and connections."),
+ "website", "http://www.gnome.org/projects/NetworkManager/",
+ "website-label", _("NetworkManager Website"),
+ "authors", authors,
+ "artists", artists,
+ "translator-credits", _("translator-credits"),
+ "logo-icon-name", GTK_STOCK_NETWORK,
+ NULL);
+}
+
+
+gboolean
+applet_warning_dialog_show (const char *message)
+{
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, message, NULL);
+
+ /* Bash focus-stealing prevention in the face */
+ gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ALWAYS);
+ gtk_widget_realize (dialog);
+ gdk_x11_window_set_user_time (dialog->window, gtk_get_current_event_time ());
+ gtk_window_present (GTK_WINDOW (dialog));
+
+ g_signal_connect_swapped (dialog, "response",
+ G_CALLBACK (gtk_widget_destroy),
+ dialog);
+ return FALSE;
+}
+
Added: trunk/src/applet-dialogs.h
==============================================================================
--- (empty file)
+++ trunk/src/applet-dialogs.h Sun Jan 13 14:30:55 2008
@@ -0,0 +1,38 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
+ *
+ * Dan Williams <dcbw redhat com>
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * (C) Copyright 2008 Red Hat, Inc.
+ */
+
+#ifndef __APPLET_DIALOGS_H__
+#define __APPLET_DIALOGS_H__
+
+#include <gtk/gtk.h>
+#include <gtk/gtkmenuitem.h>
+
+#include "applet.h"
+
+void applet_info_dialog_show (NMApplet *applet);
+
+void applet_about_dialog_show (NMApplet *applet);
+
+gboolean applet_warning_dialog_show (const char *message);
+
+
+#endif /* __APPLET_DIALOGS_H__ */
Modified: trunk/src/applet.c
==============================================================================
--- trunk/src/applet.c (original)
+++ trunk/src/applet.c Sun Jan 13 14:30:55 2008
@@ -63,6 +63,7 @@
#include "applet.h"
#include "menu-items.h"
+#include "applet-dialogs.h"
#include "vpn-password-dialog.h"
#include "nm-utils.h"
#include "gnome-keyring-md5.h"
@@ -96,8 +97,8 @@
G_DEFINE_TYPE(NMApplet, nma, G_TYPE_OBJECT)
-static NMDevice *
-get_first_active_device (NMApplet *applet)
+NMDevice *
+applet_get_first_active_device (NMApplet *applet)
{
GSList *iter;
NMDevice *dev = NULL;
@@ -136,331 +137,6 @@
gobject_class->finalize = nma_finalize;
}
-static GtkWidget * get_label (GtkWidget *info_dialog, GladeXML *xml, const char *name)
-{
- GtkWidget *label;
-
- if (xml != NULL)
- {
- label = glade_xml_get_widget (xml, name);
- g_object_set_data (G_OBJECT (info_dialog), name, label);
- }
- else
- label = g_object_get_data (G_OBJECT (info_dialog), name);
-
- return label;
-}
-
-static void nma_show_info_dialog_err (const char *err)
-{
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new_with_markup (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
- "<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s", _("Error displaying connection information:"), err);
- gtk_window_present (GTK_WINDOW (dialog));
- g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog);
-}
-
-static const gchar *
-ip4_address_as_string (guint32 ip)
-{
- struct in_addr tmp_addr;
- gchar *ip_string;
-
- tmp_addr.s_addr = ip;
- ip_string = inet_ntoa (tmp_addr);
-
- return ip_string;
-}
-
-static GtkWidget *
-nma_info_dialog_update (GladeXML *xml, NMDevice *device)
-{
- GtkWidget *dialog;
- GtkWidget *label;
- NMIP4Config *cfg;
- guint32 speed;
- char *str;
- char *iface_and_type;
- GArray *dns;
-
- g_return_val_if_fail (xml != NULL, NULL);
- g_return_val_if_fail (device != NULL, NULL);
-
- dialog = glade_xml_get_widget (xml, "info_dialog");
- if (!dialog) {
- nma_show_info_dialog_err (_("Could not find some required resources (the glade file)!"));
- return NULL;
- }
-
- cfg = nm_device_get_ip4_config (device);
-
- speed = 0;
- if (NM_IS_DEVICE_802_3_ETHERNET (device)) {
- /* Wireless speed in Mb/s */
- speed = nm_device_802_3_ethernet_get_speed (NM_DEVICE_802_3_ETHERNET (device));
- } else if (NM_IS_DEVICE_802_11_WIRELESS (device)) {
- /* Wireless speed in b/s */
- speed = nm_device_802_11_wireless_get_bitrate (NM_DEVICE_802_11_WIRELESS (device));
- speed /= 1000000;
- }
-
- str = nm_device_get_iface (device);
- if (NM_IS_DEVICE_802_3_ETHERNET (device))
- iface_and_type = g_strdup_printf (_("Wired Ethernet (%s)"), str);
- else if (NM_IS_DEVICE_802_11_WIRELESS (device))
- iface_and_type = g_strdup_printf (_("Wireless Ethernet (%s)"), str);
- else
- iface_and_type = g_strdup (str);
-
- g_free (str);
-
- label = get_label (dialog, xml, "label-interface");
- gtk_label_set_text (GTK_LABEL (label), iface_and_type);
- g_free (iface_and_type);
-
- label = get_label (dialog, xml, "label-speed");
- if (speed) {
- str = g_strdup_printf (_("%u Mb/s"), speed);
- gtk_label_set_text (GTK_LABEL (label), str);
- g_free (str);
- } else
- gtk_label_set_text (GTK_LABEL (label), _("Unknown"));
-
- str = nm_device_get_driver (device);
- label = get_label (dialog, xml, "label-driver");
- gtk_label_set_text (GTK_LABEL (label), str);
- g_free (str);
-
- label = get_label (dialog, xml, "label-ip-address");
- gtk_label_set_text (GTK_LABEL (label),
- ip4_address_as_string (nm_ip4_config_get_address (cfg)));
-
- label = get_label (dialog, xml, "label-broadcast-address");
- gtk_label_set_text (GTK_LABEL (label),
- ip4_address_as_string (nm_ip4_config_get_broadcast (cfg)));
-
- label = get_label (dialog, xml, "label-subnet-mask");
- gtk_label_set_text (GTK_LABEL (label),
- ip4_address_as_string (nm_ip4_config_get_netmask (cfg)));
-
- label = get_label (dialog, xml, "label-default-route");
- gtk_label_set_text (GTK_LABEL (label),
- ip4_address_as_string (nm_ip4_config_get_gateway (cfg)));
-
- dns = nm_ip4_config_get_nameservers (cfg);
- if (dns) {
- label = get_label (dialog, xml, "label-primary-dns");
- if (dns->len > 0) {
- gtk_label_set_text (GTK_LABEL (label),
- ip4_address_as_string (g_array_index (dns, guint32, 0)));
- } else {
- gtk_label_set_text (GTK_LABEL (label), "");
- }
-
- label = get_label (dialog, xml, "label-secondary-dns");
- if (dns->len > 1) {
- gtk_label_set_text (GTK_LABEL (label),
- ip4_address_as_string (g_array_index (dns, guint32, 1)));
- } else {
- gtk_label_set_text (GTK_LABEL (label), "");
- }
-
- g_array_free (dns, TRUE);
- }
-
- str = NULL;
- if (NM_IS_DEVICE_802_3_ETHERNET (device))
- str = nm_device_802_3_ethernet_get_hw_address (NM_DEVICE_802_3_ETHERNET (device));
- else if (NM_IS_DEVICE_802_11_WIRELESS (device))
- str = g_strdup (nm_device_802_11_wireless_get_hw_address (NM_DEVICE_802_11_WIRELESS (device)));
-
- label = get_label (dialog, xml, "label-hardware-address");
- gtk_label_set_text (GTK_LABEL (label), str ? str : "");
- g_free (str);
-
- return dialog;
-}
-
-static void
-nma_show_info_cb (GtkMenuItem *mi, NMApplet *applet)
-{
- GtkWidget *dialog;
- NMDevice *device;
-
- device = get_first_active_device (applet);
- if (!device) {
- nma_show_info_dialog_err (_("No active connections!"));
- return;
- }
-
- dialog = nma_info_dialog_update (applet->info_dialog_xml, device);
- if (!dialog)
- return;
-
- g_signal_connect (dialog, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), dialog);
- g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_hide), dialog);
- gtk_window_present (GTK_WINDOW (dialog));
-}
-
-static void
-nma_edit_connections_cb (GtkMenuItem *mi, NMApplet *applet)
-{
-}
-
-static void
-about_dialog_handle_url_cb (GtkAboutDialog *about, const gchar *url, gpointer data)
-{
- GError *error = NULL;
- gboolean ret;
- char *cmdline;
- GdkScreen *gscreen;
- GtkWidget *error_dialog;
-
- gscreen = gtk_window_get_screen (GTK_WINDOW (about));
-
- cmdline = g_strconcat ("gnome-open ", url, NULL);
- ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
- g_free (cmdline);
-
- if (ret == TRUE)
- return;
-
- g_error_free (error);
- error = NULL;
-
- cmdline = g_strconcat ("xdg-open ", url, NULL);
- ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
- g_free (cmdline);
-
- if (ret == FALSE) {
- error_dialog = gtk_message_dialog_new ( NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Failed to show url %s", error->message);
- gtk_dialog_run (GTK_DIALOG (error_dialog));
- g_error_free (error);
- }
-
-}
-
-/* Make email in about dialog clickable */
-static void
-about_dialog_handle_email_cb (GtkAboutDialog *about, const char *email_address, gpointer data)
-{
- GError *error = NULL;
- gboolean ret;
- char *cmdline;
- GdkScreen *gscreen;
- GtkWidget *error_dialog;
-
- gscreen = gtk_window_get_screen (GTK_WINDOW (about));
-
- cmdline = g_strconcat ("gnome-open mailto:", email_address, NULL);
- ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
- g_free (cmdline);
-
- if (ret == TRUE)
- return;
-
- g_error_free (error);
- error = NULL;
-
- cmdline = g_strconcat ("xdg-open mailto:", email_address, NULL);
- ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
- g_free (cmdline);
-
- if (ret == FALSE) {
- error_dialog = gtk_message_dialog_new ( NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Failed to show url %s", error->message);
- gtk_dialog_run (GTK_DIALOG (error_dialog));
- g_error_free (error);
- }
-}
-
-static void
-nma_about_cb (GtkMenuItem *mi, NMApplet *applet)
-{
- static const gchar *authors[] = {
- "The Red Hat Desktop Team, including:\n",
- "Christopher Aillon <caillon redhat com>",
- "Jonathan Blandford <jrb redhat com>",
- "John Palmieri <johnp redhat com>",
- "Ray Strode <rstrode redhat com>",
- "Colin Walters <walters redhat com>",
- "Dan Williams <dcbw redhat com>",
- "David Zeuthen <davidz redhat com>",
- "\nAnd others, including:\n",
- "Bill Moss <bmoss clemson edu>",
- "Tom Parker",
- "j bootlab org",
- "Peter Jones <pjones redhat com>",
- "Robert Love <rml novell com>",
- "Tim Niemueller <tim niemueller de>",
- NULL
- };
-
- static const gchar *artists[] = {
- "Diana Fong <dfong redhat com>",
- NULL
- };
-
-
- /* FIXME: unnecessary with libgnomeui >= 2.16.0 */
- static gboolean been_here = FALSE;
- if (!been_here) {
- been_here = TRUE;
- gtk_about_dialog_set_url_hook (about_dialog_handle_url_cb, NULL, NULL);
- gtk_about_dialog_set_email_hook (about_dialog_handle_email_cb, NULL, NULL);
- }
-
- gtk_show_about_dialog (NULL,
- "version", VERSION,
- "copyright", _("Copyright \xc2\xa9 2004-2007 Red Hat, Inc.\n"
- "Copyright \xc2\xa9 2005-2007 Novell, Inc."),
- "comments", _("Notification area applet for managing your network devices and connections."),
- "website", "http://www.gnome.org/projects/NetworkManager/",
- "website-label", _("NetworkManager Website"),
- "authors", authors,
- "artists", artists,
- "translator-credits", _("translator-credits"),
- "logo-icon-name", GTK_STOCK_NETWORK,
- NULL);
-}
-
-
-/*
- * show_warning_dialog
- *
- * pop up a warning or error dialog with certain text
- *
- */
-static gboolean
-show_warning_dialog (gpointer user_data)
-{
- char *msg = (char *) user_data;
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, msg, NULL);
- g_free (msg);
-
- /* Bash focus-stealing prevention in the face */
- gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ALWAYS);
- gtk_widget_realize (dialog);
- gdk_x11_window_set_user_time (dialog->window, gtk_get_current_event_time ());
- gtk_window_present (GTK_WINDOW (dialog));
-
- g_signal_connect_swapped (dialog, "response",
- G_CALLBACK (gtk_widget_destroy),
- dialog);
- return FALSE;
-}
-
-
-void
-nma_schedule_warning_dialog (const char *msg)
-{
- g_return_if_fail (msg != NULL);
-
- g_idle_add ((GSourceFunc) show_warning_dialog, g_strdup (msg));
-}
-
typedef struct {
NMApplet *applet;
@@ -1124,7 +800,7 @@
return;
/* Connection inactive, activate */
- device = get_first_active_device (applet);
+ device = applet_get_first_active_device (applet);
connection = nm_vpn_manager_connect (applet->vpn_manager,
NM_DBUS_SERVICE_USER_SETTINGS,
nm_connection_settings_get_dbus_object_path (connection_settings),
@@ -2018,6 +1694,11 @@
gtk_widget_hide (applet->stop_wireless_item);
}
+static void
+nma_edit_connections_cb (GtkMenuItem *mi, NMApplet *applet)
+{
+}
+
/*
* nma_context_menu_create
*
@@ -2052,10 +1733,10 @@
/* 'Connection Information' item */
applet->info_menu_item = gtk_image_menu_item_new_with_mnemonic (_("Connection _Information"));
- g_signal_connect (applet->info_menu_item,
- "activate",
- G_CALLBACK (nma_show_info_cb),
- applet);
+ g_signal_connect_swapped (applet->info_menu_item,
+ "activate",
+ G_CALLBACK (applet_info_dialog_show),
+ applet);
image = gtk_image_new_from_stock (GTK_STOCK_INFO, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (applet->info_menu_item), image);
gtk_menu_shell_append (menu, applet->info_menu_item);
@@ -2083,7 +1764,7 @@
/* About item */
menu_item = gtk_image_menu_item_new_with_mnemonic (_("_About"));
- g_signal_connect (menu_item, "activate", G_CALLBACK (nma_about_cb), applet);
+ g_signal_connect_swapped (menu_item, "activate", G_CALLBACK (applet_about_dialog_show), applet);
image = gtk_image_new_from_stock (GTK_STOCK_ABOUT, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
gtk_menu_shell_append (menu, menu_item);
@@ -3349,7 +3030,7 @@
applet->glade_file = g_build_filename (GLADEDIR, "applet.glade", NULL);
if (!applet->glade_file || !g_file_test (applet->glade_file, G_FILE_TEST_IS_REGULAR)) {
- nma_schedule_warning_dialog (_("The NetworkManager Applet could not find some required resources (the glade file was not found)."));
+ applet_warning_dialog_show (_("The NetworkManager Applet could not find some required resources (the glade file was not found)."));
goto error;
}
@@ -3551,10 +3232,8 @@
success = TRUE;
out:
- if (!success)
- {
- char *msg = g_strdup(_("The NetworkManager applet could not find some required resources. It cannot continue.\n"));
- show_warning_dialog (msg);
+ if (!success) {
+ applet_warning_dialog_show (_("The NetworkManager applet could not find some required resources. It cannot continue.\n"));
nma_icons_free (applet);
}
Modified: trunk/src/applet.h
==============================================================================
--- trunk/src/applet.h (original)
+++ trunk/src/applet.h Sun Jan 13 14:30:55 2008
@@ -135,8 +135,8 @@
GType nma_get_type (void);
-NMApplet * nm_applet_new (void);
+NMApplet *nm_applet_new (void);
-void nma_schedule_warning_dialog (const char *msg);
+NMDevice *applet_get_first_active_device (NMApplet *applet);
#endif
Modified: trunk/src/wireless-dialog.c
==============================================================================
--- trunk/src/wireless-dialog.c (original)
+++ trunk/src/wireless-dialog.c Sun Jan 13 14:30:55 2008
@@ -37,6 +37,7 @@
#include <nm-setting-wireless.h>
#include "applet.h"
+#include "applet-dialogs.h"
#include "wireless-dialog.h"
#include "wireless-security.h"
#include "utils.h"
@@ -783,7 +784,7 @@
xml = glade_xml_new (glade_file, "wireless_dialog", NULL);
if (xml == NULL) {
- nma_schedule_warning_dialog (_("The NetworkManager Applet could not find some required resources (the glade file was not found)."));
+ applet_warning_dialog_show (_("The NetworkManager Applet could not find some required resources (the glade file was not found)."));
return NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]