From 8e04fc11ff799bf369c59f7f2fc29916b7b6b9f5 Mon Sep 17 00:00:00 2001 From: Seth Nickell Date: Mon, 9 Aug 2004 19:47:21 +0000 Subject: [PATCH] * panel-applet/NMWirelessApplet.c: (nmwa_timeout_handler), (nmwa_button_clicked), (nmwa_populate_menu), (nmwa_setup_widgets), (nmwa_new): * src/NetworkManagerDbus.c: (nm_dbus_nmi_filter): Don't load the menus until clicked on (also removes a call outside normal code paths at first load). Hide applet when NM is not present. Improve printf debugging stuff. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@45 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 14 +++++++++ panel-applet/NMWirelessApplet.c | 54 +++++++++++++++++---------------- src/NetworkManagerDbus.c | 2 ++ 3 files changed, 44 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4903a212b5..a5f9cd0c72 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2004-08-09 Seth Nickell + + * panel-applet/NMWirelessApplet.c: (nmwa_timeout_handler), + (nmwa_button_clicked), (nmwa_populate_menu), (nmwa_setup_widgets), + (nmwa_new): + * src/NetworkManagerDbus.c: (nm_dbus_nmi_filter): + + Don't load the menus until clicked on (also removes a call outside + normal code paths at first load). + + Hide applet when NM is not present. + + Improve printf debugging stuff. + 2004-08-09 Dan Williams * dispatcher-daemon/NetworkManagerDispatcher.c: diff --git a/panel-applet/NMWirelessApplet.c b/panel-applet/NMWirelessApplet.c index 064048c95a..c959a5898e 100644 --- a/panel-applet/NMWirelessApplet.c +++ b/panel-applet/NMWirelessApplet.c @@ -162,23 +162,22 @@ static int nmwa_timeout_handler (NMWirelessApplet *applet) if (!applet->connection) applet->connection = nmwa_dbus_init (applet); - if (applet->nm_active) - { - if ((active_device = nmwa_dbus_get_active_wireless_device (applet->connection))) - { -fprintf( stderr, "showing\n"); - applet->have_active_device = TRUE; - nmwa_update_state (applet); - gtk_widget_show (GTK_WIDGET (applet)); - dbus_free (active_device); - } - else - fprintf( stderr, "timeout_handler(): active_device was nULL\n"); - } - else - { -fprintf( stderr, "hiding\n"); - gtk_widget_hide (GTK_WIDGET (applet)); + if (applet->nm_active) { + fprintf( stderr, "NM is present {\n"); + if ((active_device = nmwa_dbus_get_active_wireless_device (applet->connection))) { + applet->have_active_device = TRUE; + nmwa_update_state (applet); + fprintf( stderr, " A wireless device was active, showing applet\n"); + gtk_widget_show (GTK_WIDGET (applet)); + dbus_free (active_device); + } else { + fprintf( stderr, " A wireless device was not active, hiding applet\n"); + gtk_widget_hide (GTK_WIDGET (applet)); + } + fprintf( stderr, "}\n\n"); + } else { + fprintf( stderr, "NM is *not* present\n"); + gtk_widget_hide (GTK_WIDGET (applet)); } return (TRUE); @@ -316,8 +315,12 @@ static void nmwa_get_menu_pos (GtkMenu *menu, gint *x, gint *y, gboolean *push_i static void nmwa_button_clicked (GtkWidget *button, NMWirelessApplet *applet) { - if (GTK_WIDGET_VISIBLE (applet->menu)) - gtk_menu_popdown (GTK_MENU (applet->menu)); + if (applet->menu != NULL) + { + gtk_menu_popdown (GTK_MENU (applet->menu)); + g_object_unref(G_OBJECT(applet->menu)); + applet->menu = NULL; + } else { applet->menu = nmwa_populate_menu (applet); @@ -361,13 +364,12 @@ static GtkWidget * nmwa_populate_menu (NMWirelessApplet *applet) int num_networks; char **networks; + g_assert(applet->nm_active); g_return_if_fail (applet != NULL); menu = gtk_menu_new (); - if (applet->nm_active) - nmwa_dbus_add_networks_to_menu (applet->connection, menu); - else - nmwa_add_menu_item ("No Wireless Networks found...", FALSE, menu); + + nmwa_dbus_add_networks_to_menu (applet->connection, menu); return (menu); } @@ -431,9 +433,7 @@ static void nmwa_setup_widgets (NMWirelessApplet *applet) applet->current_pixbuf = NULL; applet->about_dialog = NULL; - if (applet->menu) - gtk_widget_destroy (applet->menu); - applet->menu = nmwa_populate_menu (applet); + applet->menu = NULL; } static void change_size_cb(PanelApplet *pa, gint s, NMWirelessApplet *applet) @@ -487,6 +487,8 @@ static GtkWidget * nmwa_new (NMWirelessApplet *applet) { panel_applet_set_flags (PANEL_APPLET (applet), PANEL_APPLET_EXPAND_MINOR); + gtk_widget_hide(GTK_WIDGET(applet)); + applet->connection = nmwa_dbus_init(applet); applet->have_active_device = FALSE; applet->nm_active = nmwa_dbus_nm_is_running(applet->connection); diff --git a/src/NetworkManagerDbus.c b/src/NetworkManagerDbus.c index 40f78d42ca..1ed2a5bcce 100644 --- a/src/NetworkManagerDbus.c +++ b/src/NetworkManagerDbus.c @@ -889,6 +889,8 @@ static DBusHandlerResult nm_dbus_nmi_filter (DBusConnection *connection, DBusMes g_return_val_if_fail (connection != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED); g_return_val_if_fail (message != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED); + printf ("NMI Filter called\n"); + if (!(object_path = dbus_message_get_path (message))) return (DBUS_HANDLER_RESULT_NOT_YET_HANDLED);