network-manager-applet r515 - in trunk: . src/connection-editor
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: network-manager-applet r515 - in trunk: . src/connection-editor
- Date: Thu, 7 Feb 2008 22:47:31 +0000 (GMT)
Author: dcbw
Date: Thu Feb 7 22:47:31 2008
New Revision: 515
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=515&view=rev
Log:
2008-02-07 Dan Williams <dcbw redhat com>
* src/connection-editor/nm-connection-list.c
src/connection-editor/nm-connection-list.h
- Add an icon column to the list view showing what connection type each
connection is
Modified:
trunk/ChangeLog
trunk/src/connection-editor/nm-connection-list.c
trunk/src/connection-editor/nm-connection-list.h
Modified: trunk/src/connection-editor/nm-connection-list.c
==============================================================================
--- trunk/src/connection-editor/nm-connection-list.c (original)
+++ trunk/src/connection-editor/nm-connection-list.c Thu Feb 7 22:47:31 2008
@@ -20,6 +20,8 @@
* (C) Copyright 2004-2005 Red Hat, Inc.
*/
+#include <string.h>
+
#include <gtk/gtkbutton.h>
#include <gtk/gtkdialog.h>
#include <gtk/gtkliststore.h>
@@ -28,6 +30,7 @@
#include <gtk/gtkcellrenderertext.h>
#include <gtk/gtkmessagedialog.h>
#include <gtk/gtkstock.h>
+#include <gtk/gtkcellrendererpixbuf.h>
#include <gconf/gconf-client.h>
#include <glib/gi18n.h>
@@ -35,6 +38,11 @@
#include <nm-setting-connection.h>
#include <nm-connection.h>
#include <nm-setting.h>
+#include <nm-setting-wired.h>
+#include <nm-setting-wireless.h>
+#include <nm-setting-vpn.h>
+#include <nm-setting-gsm.h>
+#include <nm-setting-cdma.h>
#include "nm-connection-editor.h"
#include "nm-connection-list.h"
@@ -44,6 +52,10 @@
#define CE_GCONF_PATH_TAG "ce-gconf-path"
+#define COL_ID 0
+#define COL_ICON 1
+#define COL_CONNECTION 2
+
static NMConnection *
get_connection_for_selection (NMConnectionList *list,
GtkTreeModel **model,
@@ -68,7 +80,7 @@
return NULL;
if (gtk_tree_model_get_iter (*model, iter, (GtkTreePath *) selected_rows->data))
- gtk_tree_model_get (*model, iter, 1, &connection, -1);
+ gtk_tree_model_get (*model, iter, COL_CONNECTION, &connection, -1);
/* free memory */
g_list_foreach (selected_rows, (GFunc) gtk_tree_path_free, NULL);
@@ -170,19 +182,32 @@
static void
hash_add_connection_to_list (gpointer key, gpointer value, gpointer user_data)
{
- NMSettingConnection *s_connection;
- GtkTreeIter iter;
+ NMConnectionList *list = NM_CONNECTION_LIST (user_data);
NMConnection *connection = (NMConnection *) value;
- GtkListStore *model = GTK_LIST_STORE (user_data);
+ NMSettingConnection *s_con;
+ GtkTreeIter iter;
+ GdkPixbuf *pixbuf = list->unknown_icon;
- s_connection = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- if (!s_connection)
+ s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+ if (!s_con)
return;
- gtk_list_store_append (model, &iter);
- gtk_list_store_set (model, &iter,
- 0, s_connection->id,
- 1, connection,
+ if (!strcmp (s_con->type, NM_SETTING_WIRED_SETTING_NAME))
+ pixbuf = list->wired_icon;
+ else if (!strcmp (s_con->type, NM_SETTING_WIRELESS_SETTING_NAME))
+ pixbuf = list->wireless_icon;
+ else if (!strcmp (s_con->type, NM_SETTING_VPN_SETTING_NAME))
+ pixbuf = list->vpn_icon;
+ else if (!strcmp (s_con->type, NM_SETTING_GSM_SETTING_NAME))
+ pixbuf = list->wwan_icon;
+ else if (!strcmp (s_con->type, NM_SETTING_CDMA_SETTING_NAME))
+ pixbuf = list->wwan_icon;
+
+ gtk_list_store_append (list->model, &iter);
+ gtk_list_store_set (list->model, &iter,
+ COL_ID, s_con->id,
+ COL_ICON, pixbuf,
+ COL_CONNECTION, connection,
-1);
}
@@ -237,17 +262,21 @@
}
}
+#define ICON_LOAD(x, y) \
+ { \
+ x = gtk_icon_theme_load_icon (list->icon_theme, y, 16, 0, &error); \
+ if (x == NULL) { \
+ g_warning ("Icon %s missing: %s", y, error->message); \
+ g_error_free (error); \
+ return; \
+ } \
+ }
+
static void
nm_connection_list_init (NMConnectionList *list)
{
- GtkListStore *model;
GtkTreeSelection *select;
-
- list->client = gconf_client_get_default ();
-
- /* read connections */
- list->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
- load_connections (list);
+ GError *error = NULL;
/* load GUI */
list->gui = glade_xml_new (GLADEDIR "/nm-connection-editor.glade", "NMConnectionList", NULL);
@@ -256,20 +285,42 @@
return;
}
+ list->icon_theme = gtk_icon_theme_get_for_screen (gdk_screen_get_default ());
+
+ /* Load icons */
+ ICON_LOAD(list->wired_icon, "nm-device-wired");
+ ICON_LOAD(list->wireless_icon, "nm-device-wireless");
+ ICON_LOAD(list->wwan_icon, "nm-device-wwan");
+ ICON_LOAD(list->vpn_icon, "lock");
+ ICON_LOAD(list->unknown_icon, "nm-no-connection");
+
+ list->client = gconf_client_get_default ();
+
+ /* read connections */
+ list->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
+ load_connections (list);
+
list->dialog = glade_xml_get_widget (list->gui, "NMConnectionList");
g_signal_connect (G_OBJECT (list->dialog), "response", G_CALLBACK (dialog_response_cb), list);
list->connection_list = glade_xml_get_widget (list->gui, "connection_list");
- model = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_OBJECT, G_TYPE_STRING);
+ list->model = gtk_list_store_new (3, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_OBJECT);
g_hash_table_foreach (list->connections,
(GHFunc) hash_add_connection_to_list,
- model);
- gtk_tree_view_set_model (GTK_TREE_VIEW (list->connection_list), GTK_TREE_MODEL (model));
+ list);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (list->connection_list), GTK_TREE_MODEL (list->model));
+
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (list->connection_list),
-1, "Name", gtk_cell_renderer_text_new (),
- "text", 0,
+ "text", COL_ID,
NULL);
+
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (list->connection_list),
+ -1, "Type", gtk_cell_renderer_pixbuf_new (),
+ "pixbuf", COL_ICON,
+ NULL);
+
select = gtk_tree_view_get_selection (GTK_TREE_VIEW (list->connection_list));
gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE);
g_signal_connect (G_OBJECT (select),
@@ -293,6 +344,12 @@
{
NMConnectionList *list = NM_CONNECTION_LIST (object);
+ g_object_unref (list->wired_icon);
+ g_object_unref (list->wireless_icon);
+ g_object_unref (list->wwan_icon);
+ g_object_unref (list->vpn_icon);
+ g_object_unref (list->unknown_icon);
+
gtk_widget_destroy (list->dialog);
g_object_unref (list->gui);
g_hash_table_destroy (list->connections);
Modified: trunk/src/connection-editor/nm-connection-list.h
==============================================================================
--- trunk/src/connection-editor/nm-connection-list.h (original)
+++ trunk/src/connection-editor/nm-connection-list.h Thu Feb 7 22:47:31 2008
@@ -26,6 +26,9 @@
#include <glib-object.h>
#include <glade/glade-xml.h>
#include <gconf/gconf-client.h>
+#include <gdk/gdkpixbuf.h>
+#include <gtk/gtk.h>
+#include <gtk/gtkicontheme.h>
#define NM_TYPE_CONNECTION_LIST (nm_connection_list_get_type ())
#define NM_IS_CONNECTION_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_CONNECTION_LIST))
@@ -40,11 +43,20 @@
GConfClient *client;
GladeXML *gui;
+ GtkListStore *model;
+
GtkWidget *dialog;
GtkWidget *connection_list;
GtkWidget *add_button;
GtkWidget *edit_button;
GtkWidget *delete_button;
+
+ GdkPixbuf *wired_icon;
+ GdkPixbuf *wireless_icon;
+ GdkPixbuf *wwan_icon;
+ GdkPixbuf *vpn_icon;
+ GdkPixbuf *unknown_icon;
+ GtkIconTheme *icon_theme;
} NMConnectionList;
typedef struct {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]