[gthumb] oauth authorization dialog: show the loading activity



commit 6259551ef903b8ed0c2239387d03c12f9f179923
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sat Dec 22 12:25:42 2012 +0100

    oauth authorization dialog: show the loading activity

 .../oauth/data/ui/oauth-ask-authorization.ui       |  120 ++++++++++---------
 extensions/oauth/oauth-ask-authorization-dialog.c  |   49 ++++++--
 2 files changed, 101 insertions(+), 68 deletions(-)
---
diff --git a/extensions/oauth/data/ui/oauth-ask-authorization.ui b/extensions/oauth/data/ui/oauth-ask-authorization.ui
index c8d0fdf..83006cf 100644
--- a/extensions/oauth/data/ui/oauth-ask-authorization.ui
+++ b/extensions/oauth/data/ui/oauth-ask-authorization.ui
@@ -1,84 +1,90 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <requires lib="gtk+" version="2.16"/>
-  <object class="GtkImage" id="button_image">
+  <!-- interface-requires gtk+ 3.0 -->
+  <object class="GtkNotebook" id="dialog_content">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
-    <property name="stock">gtk-dialog-authentication</property>
-  </object>
-  <object class="GtkMessageDialog" id="ask_authorization_messagedialog">
-    <property name="can_focus">False</property>
     <property name="border_width">5</property>
-    <property name="resizable">False</property>
-    <property name="modal">True</property>
-    <property name="type_hint">normal</property>
-    <property name="skip_taskbar_hint">True</property>
-    <property name="message_type">other</property>
-    <property name="image">icon_image</property>
-    <child internal-child="vbox">
-      <object class="GtkBox" id="dialog-vbox1">
+    <property name="show_tabs">False</property>
+    <property name="show_border">False</property>
+    <child>
+      <object class="GtkBox" id="webkit_view_container">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="orientation">vertical</property>
-        <property name="spacing">2</property>
-        <child internal-child="action_area">
-          <object class="GtkButtonBox" id="dialog-action_area1">
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+    </child>
+    <child type="tab">
+      <placeholder/>
+    </child>
+    <child>
+      <object class="GtkBox" id="loading_container">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <child>
+          <object class="GtkBox" id="box2">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="layout_style">end</property>
             <child>
-              <object class="GtkButton" id="cancel_button">
-                <property name="label">gtk-cancel</property>
-                <property name="use_action_appearance">False</property>
+              <object class="GtkBox" id="box3">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
+                <property name="can_focus">False</property>
+                <property name="spacing">6</property>
+                <child>
+                  <object class="GtkSpinner" id="spinner1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="active">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label3">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">Loading...</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
               </object>
               <packing>
-                <property name="expand">False</property>
+                <property name="expand">True</property>
                 <property name="fill">False</property>
                 <property name="position">0</property>
               </packing>
             </child>
-            <child>
-              <object class="GtkButton" id="authorize_button">
-                <property name="label" translatable="yes">_Authorize...</property>
-                <property name="use_action_appearance">False</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="image">button_image</property>
-                <property name="use_underline">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
           </object>
           <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack_type">end</property>
+            <property name="expand">True</property>
+            <property name="fill">False</property>
             <property name="position">0</property>
           </packing>
         </child>
       </object>
+      <packing>
+        <property name="position">1</property>
+      </packing>
+    </child>
+    <child type="tab">
+      <placeholder/>
+    </child>
+    <child>
+      <placeholder/>
+    </child>
+    <child type="tab">
+      <placeholder/>
     </child>
-    <action-widgets>
-      <action-widget response="-6">cancel_button</action-widget>
-      <action-widget response="-5">authorize_button</action-widget>
-    </action-widgets>
-  </object>
-  <object class="GtkImage" id="icon_image">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="yalign">0</property>
-    <property name="stock">gtk-dialog-authentication</property>
-    <property name="icon-size">6</property>
   </object>
 </interface>
diff --git a/extensions/oauth/oauth-ask-authorization-dialog.c b/extensions/oauth/oauth-ask-authorization-dialog.c
index 099fd05..1dd4fd6 100644
--- a/extensions/oauth/oauth-ask-authorization-dialog.c
+++ b/extensions/oauth/oauth-ask-authorization-dialog.c
@@ -26,6 +26,8 @@
 
 
 #define GET_WIDGET(x) (_gtk_builder_get_widget (self->priv->builder, (x)))
+#define _LOADING_PAGE 1
+#define _WEB_VIEW_PAGE 0
 
 
 G_DEFINE_TYPE (OAuthAskAuthorizationDialog, oauth_ask_authorization_dialog, GTK_TYPE_DIALOG)
@@ -44,15 +46,37 @@ static guint oauth_ask_authorization_dialog_signals[LAST_SIGNAL] = { 0 };
 
 
 struct _OAuthAskAuthorizationDialogPrivate {
-	GtkWidget *view;
+	GtkWidget  *view;
+	GtkBuilder *builder;
+	gulong      load_changed_id;
 };
 
 
 static void
+oauth_ask_authorization_dialog_finalize (GObject *obj)
+{
+	OAuthAskAuthorizationDialog *self;
+
+	self = OAUTH_ASK_AUTHORIZATION_DIALOG (obj);
+	if (g_signal_handler_is_connected (self->priv->view, self->priv->load_changed_id))
+		g_signal_handler_disconnect (self->priv->view, self->priv->load_changed_id);
+	webkit_web_view_stop_loading (WEBKIT_WEB_VIEW (self->priv->view));
+	_g_object_unref (self->priv->builder);
+
+	G_OBJECT_CLASS (oauth_ask_authorization_dialog_parent_class)->finalize (obj);
+}
+
+
+static void
 oauth_ask_authorization_dialog_class_init (OAuthAskAuthorizationDialogClass *klass)
 {
+	GObjectClass *object_class;
+
 	g_type_class_add_private (klass, sizeof (OAuthAskAuthorizationDialogPrivate));
 
+	object_class = G_OBJECT_CLASS (klass);
+	object_class->finalize = oauth_ask_authorization_dialog_finalize;
+
 	oauth_ask_authorization_dialog_signals[LOAD_REQUEST] =
 		g_signal_new ("load-request",
 			      G_TYPE_FROM_CLASS (klass),
@@ -93,12 +117,14 @@ webkit_view_load_changed_cb (WebKitWebView   *web_view,
 	switch (load_event) {
 	case WEBKIT_LOAD_STARTED:
 	case WEBKIT_LOAD_COMMITTED:
+		gtk_notebook_set_current_page (GTK_NOTEBOOK(GET_WIDGET ("dialog_content")), _LOADING_PAGE);
 		g_signal_emit (self, oauth_ask_authorization_dialog_signals[LOAD_REQUEST], 0);
 		break;
 	case WEBKIT_LOAD_REDIRECTED:
 		g_signal_emit (self, oauth_ask_authorization_dialog_signals[REDIRECTED], 0);
 		break;
 	case WEBKIT_LOAD_FINISHED:
+		gtk_notebook_set_current_page (GTK_NOTEBOOK(GET_WIDGET ("dialog_content")), _WEB_VIEW_PAGE);
 		g_signal_emit (self, oauth_ask_authorization_dialog_signals[LOADED], 0);
 		break;
 	default:
@@ -110,20 +136,21 @@ webkit_view_load_changed_cb (WebKitWebView   *web_view,
 static void
 oauth_ask_authorization_dialog_init (OAuthAskAuthorizationDialog *self)
 {
-	GtkWidget        *box;
+	GtkWidget        *dialog_content;
 	WebKitWebContext *context;
 
 	self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, OAUTH_TYPE_ASK_AUTHORIZATION_DIALOG, OAuthAskAuthorizationDialogPrivate);
+	self->priv->builder = _gtk_builder_new_from_file ("oauth-ask-authorization.ui", "oauth");
 
 	gtk_window_set_default_size (GTK_WINDOW (self), 500, 500);
 	gtk_window_set_resizable (GTK_WINDOW (self), TRUE);
 	gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), 5);
 	gtk_container_set_border_width (GTK_CONTAINER (self), 5);
 
-	box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
-	gtk_widget_show (box);
-	gtk_container_set_border_width (GTK_CONTAINER (box), 5);
-	gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), box, TRUE, TRUE, 0);
+	dialog_content = GET_WIDGET ("dialog_content");
+	gtk_widget_show (dialog_content);
+	gtk_container_set_border_width (GTK_CONTAINER (dialog_content), 5);
+	gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), dialog_content, TRUE, TRUE, 0);
 
 	self->priv->view = webkit_web_view_new ();
 	context = webkit_web_view_get_context (WEBKIT_WEB_VIEW (self->priv->view));
@@ -144,12 +171,12 @@ oauth_ask_authorization_dialog_init (OAuthAskAuthorizationDialog *self)
 		g_object_unref (file);
 	}
 	gtk_widget_show (self->priv->view);
-	gtk_box_pack_start (GTK_BOX (box), self->priv->view, TRUE, TRUE, 0);
+	gtk_box_pack_start (GTK_BOX (GET_WIDGET ("webkit_view_container")), self->priv->view, TRUE, TRUE, 0);
 
-	g_signal_connect (self->priv->view,
-			  "load-changed",
-			  G_CALLBACK (webkit_view_load_changed_cb),
-			  self);
+	self->priv->load_changed_id = g_signal_connect (self->priv->view,
+			  	  	  	  	"load-changed",
+			  	  	  	  	G_CALLBACK (webkit_view_load_changed_cb),
+			  	  	  	  	self);
 
 	gtk_dialog_add_button (GTK_DIALOG (self),
 			       GTK_STOCK_CANCEL,



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