[network-manager-netbook] Add support to show errors and warnings inline in the connection list



commit 8376bec29e6c13e38b40877dc73917dfcc8b1d67
Author: Tambet Ingo <tambet gmail com>
Date:   Thu Mar 4 11:53:25 2010 -0400

    Add support to show errors and warnings inline in the connection list

 src/nmn-gsm-pin-request-renderer.c |   15 ++++++++++-
 src/nmn-item-renderer.c            |   47 ++++++++++++++++++++++++++++++++++++
 src/nmn-item-renderer.h            |    7 +++++
 src/nmn-network-renderer.c         |    7 ++++-
 4 files changed, 72 insertions(+), 4 deletions(-)
---
diff --git a/src/nmn-gsm-pin-request-renderer.c b/src/nmn-gsm-pin-request-renderer.c
index 3d1f8fc..10c1913 100644
--- a/src/nmn-gsm-pin-request-renderer.c
+++ b/src/nmn-gsm-pin-request-renderer.c
@@ -79,9 +79,18 @@ sensitize_widgets (NmnGsmPinRequestRenderer *self)
 }
 
 static void
+pin_entry_changed (GtkEditable *editable,
+                   gpointer user_data)
+{
+    nmn_item_renderer_hide_error (NMN_ITEM_RENDERER (user_data));
+    sensitize_widgets (NMN_GSM_PIN_REQUEST_RENDERER (user_data));
+}
+
+static void
 init_widgets (NmnGsmPinRequestRenderer *self)
 {
     NmnGsmPinRequestRendererPrivate *priv = GET_PRIVATE (self);
+    GtkWidget *parent_container;
     GtkWidget *hbox;
     GtkWidget *vbox;
     GtkWidget *w;
@@ -90,9 +99,11 @@ init_widgets (NmnGsmPinRequestRenderer *self)
 
     item = nmn_item_renderer_get_item (NMN_ITEM_RENDERER (self));
 
+    parent_container = nmn_item_renderer_get_content_area (NMN_ITEM_RENDERER (self));
+
     hbox = gtk_hbox_new (FALSE, 12);
     gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
-    gtk_container_add (GTK_CONTAINER (self), hbox);
+    gtk_container_add (GTK_CONTAINER (parent_container), hbox);
 
     w = gtk_image_new_from_pixbuf (nm_icon_cache_get (nm_list_item_get_icon (item)));
     gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
@@ -117,7 +128,7 @@ init_widgets (NmnGsmPinRequestRenderer *self)
     gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
     priv->entry = w;
     g_signal_connect_swapped (w, "activate", G_CALLBACK (unlock), self);
-    g_signal_connect_swapped (w, "changed", G_CALLBACK (sensitize_widgets), self);
+    g_signal_connect (w, "changed", G_CALLBACK (pin_entry_changed), self);
 
     w = gtk_button_new_with_label (_("Unlock"));
     gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
diff --git a/src/nmn-item-renderer.c b/src/nmn-item-renderer.c
index cd8673f..1bfd794 100644
--- a/src/nmn-item-renderer.c
+++ b/src/nmn-item-renderer.c
@@ -25,6 +25,7 @@
 #include "nm-connection-item.h"
 #include "nm-device-item.h"
 #include "nmn-connection-details.h"
+#include "gtkinfobar.h"
 #include "utils.h"
 
 G_DEFINE_TYPE (NmnItemRenderer, nmn_item_renderer, GTK_TYPE_EVENT_BOX)
@@ -50,6 +51,10 @@ static guint signals[LAST_SIGNAL];
 typedef struct {
     NMListItem *item;
 
+    GtkWidget *content_area;
+    GtkWidget *info_bar;
+    GtkWidget *info_label;
+
     gboolean prelight;
     GdkColor prelight_color;
     GdkColor connection_item_color;
@@ -106,6 +111,35 @@ nmn_item_renderer_is_prelight (NmnItemRenderer *self)
     return GET_PRIVATE (self)->prelight;
 }
 
+GtkWidget *
+nmn_item_renderer_get_content_area (NmnItemRenderer *self)
+{
+    g_return_val_if_fail (NMN_IS_ITEM_RENDERER (self), NULL);
+
+    return GET_PRIVATE (self)->content_area;
+}
+
+void
+nmn_item_renderer_show_error (NmnItemRenderer *self,
+                              const char *message)
+{
+    NmnItemRendererPrivate *priv = GET_PRIVATE (self);
+
+    g_return_if_fail (NMN_IS_ITEM_RENDERER (self));
+    g_return_if_fail (message != NULL);
+
+    gtk_label_set_text (GTK_LABEL (priv->info_label), message);
+    gtk_widget_show (priv->info_bar);
+}
+
+void
+nmn_item_renderer_hide_error (NmnItemRenderer *self)
+{
+    g_return_if_fail (NMN_IS_ITEM_RENDERER (self));
+
+    gtk_widget_hide (GET_PRIVATE (self)->info_bar);
+}
+
 static gboolean
 enter_notify_event (GtkWidget *widget,
                     GdkEventCrossing *event)
@@ -136,9 +170,22 @@ static void
 nmn_item_renderer_init (NmnItemRenderer *item)
 {
     NmnItemRendererPrivate *priv = GET_PRIVATE (item);
+    GtkWidget *w;
 
     gdk_color_parse ("#cbcbcb", &priv->prelight_color);
     gdk_color_parse ("#e8e8e8", &priv->connection_item_color);
+
+    priv->content_area = gtk_vbox_new (FALSE, 6);
+    gtk_container_add (GTK_CONTAINER (item), priv->content_area);
+
+    priv->info_bar = egg_info_bar_new ();
+    gtk_widget_set_no_show_all (priv->info_bar, TRUE);
+    gtk_box_pack_end (GTK_BOX (priv->content_area), priv->info_bar, FALSE, FALSE, 0);
+
+    priv->info_label = gtk_label_new (NULL);
+    w = egg_info_bar_get_content_area (EGG_INFO_BAR (priv->info_bar));
+    gtk_container_add (GTK_CONTAINER (w), priv->info_label);
+    gtk_widget_show (priv->info_label);
 }
 
 static void
diff --git a/src/nmn-item-renderer.h b/src/nmn-item-renderer.h
index 6278155..875028e 100644
--- a/src/nmn-item-renderer.h
+++ b/src/nmn-item-renderer.h
@@ -55,4 +55,11 @@ void        nmn_item_renderer_set_item (NmnItemRenderer *self,
 
 gboolean    nmn_item_renderer_is_prelight (NmnItemRenderer *self);
 
+GtkWidget  *nmn_item_renderer_get_content_area (NmnItemRenderer *self);
+
+void nmn_item_renderer_show_error (NmnItemRenderer *self,
+                                   const char *message);
+
+void nmn_item_renderer_hide_error (NmnItemRenderer *self);
+
 #endif /* NMN_ITEM_RENDERER_H */
diff --git a/src/nmn-network-renderer.c b/src/nmn-network-renderer.c
index 220bc21..1085645 100644
--- a/src/nmn-network-renderer.c
+++ b/src/nmn-network-renderer.c
@@ -324,13 +324,16 @@ static void
 init_widgets (NmnNetworkRenderer *self)
 {
     NmnNetworkRendererPrivate *priv = GET_PRIVATE (self);
+    GtkWidget *parent_container;
     GtkWidget *vbox;
     GtkWidget *hbox;
     GtkWidget *w;
 
+    parent_container = nmn_item_renderer_get_content_area (NMN_ITEM_RENDERER (self));
+
     priv->vbox = GTK_BOX (gtk_vbox_new (FALSE, 6));
     gtk_container_set_border_width (GTK_CONTAINER (priv->vbox), 6);
-    gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (priv->vbox));
+    gtk_container_add (GTK_CONTAINER (parent_container), GTK_WIDGET (priv->vbox));
 
     priv->hbox = GTK_BOX (gtk_hbox_new (FALSE, 6));
     gtk_container_set_border_width (GTK_CONTAINER (priv->hbox), 6);
@@ -381,7 +384,7 @@ init_widgets (NmnNetworkRenderer *self)
     priv->remove_button = w;
     g_signal_connect (w, "clicked", G_CALLBACK (remove_button_clicked), self);
 
-    gtk_widget_show_all (GTK_WIDGET (priv->vbox));
+    gtk_widget_show_all (GTK_WIDGET (self));
 }
 
 static void



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