[network-manager-netbook] Add support for regular status icon



commit 4506a5e6c0f9fff3e06fd6de5700daebeec3c66f
Author: Tambet Ingo <tambet gmail com>
Date:   Fri Dec 18 11:44:59 2009 +0200

    Add support for regular status icon
    
    Now it's possible to use network-manager-netbook in regular GNOME/KDE desktop,
    yay! Just pass the --desktop flag to it.

 libnm-gtk/nm-status-icon.c |    4 ++-
 src/main.c                 |   46 +++++++++++++++++++++++++++++++++----------
 2 files changed, 38 insertions(+), 12 deletions(-)
---
diff --git a/libnm-gtk/nm-status-icon.c b/libnm-gtk/nm-status-icon.c
index 3385624..c83ec55 100644
--- a/libnm-gtk/nm-status-icon.c
+++ b/libnm-gtk/nm-status-icon.c
@@ -136,7 +136,9 @@ model_changed (NMStatusModel *model,
     if (active_item == priv->item)
         return;
 
-    g_signal_handlers_disconnect_by_func (priv->item, item_status_changed, self);
+    if (priv->item)
+        g_signal_handlers_disconnect_by_func (priv->item, item_status_changed, self);
+
     priv->item = active_item;
 
     if (active_item) {
diff --git a/src/main.c b/src/main.c
index a8c00f4..162dd66 100644
--- a/src/main.c
+++ b/src/main.c
@@ -26,6 +26,7 @@
 #include "nmn-applet.h"
 #include "nm-status-model.h"
 #include "nm-icon-cache.h"
+#include "nm-status-icon.h"
 #include "nmn-panel-client.h"
 
 static void
@@ -48,6 +49,13 @@ dialog_done_cb (gpointer user_data)
     mpl_panel_client_request_focus (MPL_PANEL_CLIENT (user_data));
 }
 
+static void
+status_icon_activated (GtkStatusIcon *status_icon,
+                       gpointer user_data)
+{
+    gtk_widget_show (GTK_WIDGET (user_data));
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -55,9 +63,12 @@ main (int argc, char *argv[])
     NmnApplet *applet;
     GtkWidget *container;
     gboolean standalone = FALSE;
+    gboolean desktop = FALSE;
     GError *error = NULL;
-    GOptionEntry    entries[] = {
-        { "standalone", 's', 0, G_OPTION_ARG_NONE, &standalone, _("Run in standalone mode"), NULL }, { NULL }
+    GOptionEntry entries[] = {
+        { "standalone", 's', 0, G_OPTION_ARG_NONE, &standalone, _("Run in standalone mode"), NULL },
+        { "desktop", 'd', 0, G_OPTION_ARG_NONE, &desktop, _("Run in desktop mode"), NULL },
+        { NULL }
     };
 
     bindtextdomain (GETTEXT_PACKAGE, NMNLOCALEDIR);
@@ -74,23 +85,36 @@ main (int argc, char *argv[])
         return 1;
     }
 
-    /* Force to the moblin theme */
-    gtk_settings_set_string_property (gtk_settings_get_default (),
-                                      "gtk-theme-name",
-                                      "Moblin-Netbook",
-                                      NULL);
-
     model = nmn_model_new ();
     applet = nmn_applet_new (model);
 
     if (standalone) {
         container = gtk_window_new (GTK_WINDOW_TOPLEVEL);
         g_signal_connect (container, "delete-event", (GCallback) gtk_main_quit, NULL);
-        gtk_widget_set_size_request (container, 1000, -1);
+        gtk_widget_set_size_request (container, 800, -1);
+        gtk_widget_show (container);
+    } else if (desktop) {
+        NMStatusModel *status_model;
+        GtkStatusIcon *status_icon;
+
+        status_model = NM_STATUS_MODEL (nm_status_model_new (GTK_TREE_MODEL (model)));
+        status_icon = nm_status_icon_new (status_model);
+        g_object_unref (status_model);
+        
+        container = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+        g_signal_connect (status_icon, "activate", G_CALLBACK (status_icon_activated), container);
+        g_signal_connect (container, "delete-event", (GCallback) gtk_widget_hide, NULL);
+        gtk_widget_set_size_request (container, 800, -1);
     } else {
         NMStatusModel *status_model;
         NmnPanelClient *panel_client;
 
+        /* Force to the moblin theme */
+        gtk_settings_set_string_property (gtk_settings_get_default (),
+                                          "gtk-theme-name",
+                                          "Moblin-Netbook",
+                                          NULL);
+
         status_model = NM_STATUS_MODEL (nm_status_model_new (GTK_TREE_MODEL (model)));
         panel_client = nmn_panel_client_new (status_model);
         g_object_unref (status_model);
@@ -103,12 +127,12 @@ main (int argc, char *argv[])
         nm_utils_set_dialog_done_cb (dialog_done_cb, panel_client);
 
         container = mpl_panel_gtk_get_window (MPL_PANEL_GTK (panel_client));
+        gtk_widget_modify_bg (container, GTK_STATE_NORMAL, &gtk_widget_get_style (container)->white);
+        gtk_widget_show (container);
     }
 
     gtk_widget_show (GTK_WIDGET (applet));
     gtk_container_add (GTK_CONTAINER (container), GTK_WIDGET (applet));
-    gtk_widget_modify_bg (container, GTK_STATE_NORMAL, &gtk_widget_get_style (container)->white);
-    gtk_widget_show (container);
 
     gtk_main ();
     g_object_unref (model);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]