[hotssh/wip/libssh] Move the Disconnect action from tab button to gears menu



commit 23f730fbe950d6eb7c8d8a5fd21e37dc58fb493e
Author: Colin Walters <walters verbum org>
Date:   Thu Nov 7 08:21:12 2013 -0500

    Move the Disconnect action from tab button to gears menu
    
    It's just more logical, and preserves screen real estate.

 src/gears-menu.ui |    4 ++++
 src/hotssh-tab.c  |   18 +++++++-----------
 src/hotssh-tab.h  |    2 ++
 src/hotssh-win.c  |   19 ++++++++++++++++++-
 src/tab.ui        |   15 ---------------
 5 files changed, 31 insertions(+), 27 deletions(-)
---
diff --git a/src/gears-menu.ui b/src/gears-menu.ui
index 91bf7be..62b5c55 100644
--- a/src/gears-menu.ui
+++ b/src/gears-menu.ui
@@ -7,6 +7,10 @@
         <attribute name="label" translatable="yes">_New Tab</attribute>
         <attribute name="action">win.new-channel</attribute>
       </item>
+      <item>
+        <attribute name="label" translatable="yes">_Disconnect</attribute>
+        <attribute name="action">win.disconnect</attribute>
+      </item>
     </section>
   </menu>
 </interface>
diff --git a/src/hotssh-tab.c b/src/hotssh-tab.c
index 936f968..73332d8 100644
--- a/src/hotssh-tab.c
+++ b/src/hotssh-tab.c
@@ -64,7 +64,6 @@ struct _HotSshTabPrivate
   GtkWidget *hostkey_container;
   GtkWidget *hostkey_fingerprint_label;
   GtkWidget *approve_hostkey_button;
-  GtkWidget *disconnect_button;
   GtkWidget *terminal_box;
 
   /* State */
@@ -386,14 +385,6 @@ on_connect (GtkButton     *button,
 }
 
 static void
-on_disconnect (GtkButton     *button,
-              HotSshTab     *self)
-{
-  page_transition (self, HOTSSH_TAB_PAGE_NEW_CONNECTION);
-  gtk_notebook_set_current_page ((GtkNotebook*)self, 0);
-}
-
-static void
 process_write_queue (HotSshTab        *self);
 
 static void
@@ -565,7 +556,6 @@ hotssh_tab_init (HotSshTab *self)
   g_signal_connect (priv->connect_cancel_button, "clicked", G_CALLBACK (on_connect_cancel), self);
   g_signal_connect (priv->auth_cancel_button, "clicked", G_CALLBACK (on_connect_cancel), self);
   g_signal_connect (priv->approve_hostkey_button, "clicked", G_CALLBACK (on_approve_hostkey_clicked), self);
-  g_signal_connect (priv->disconnect_button, "clicked", G_CALLBACK (on_disconnect), self);
   g_signal_connect_swapped (priv->password_entry, "activate", G_CALLBACK (submit_password), self);
   g_signal_connect_swapped (priv->password_submit, "clicked", G_CALLBACK (submit_password), self);
 
@@ -609,7 +599,6 @@ hotssh_tab_class_init (HotSshTabClass *class)
   gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), HotSshTab, hostkey_container);
   gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), HotSshTab, 
hostkey_fingerprint_label);
   gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), HotSshTab, approve_hostkey_button);
-  gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), HotSshTab, disconnect_button);
   gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), HotSshTab, terminal_box);
 
   GTK_WIDGET_CLASS (class)->grab_focus = hotssh_tab_grab_focus;
@@ -634,3 +623,10 @@ hotssh_tab_new_channel  (HotSshTab *source)
 
   return tab;
 }
+
+void
+hotssh_tab_disconnect  (HotSshTab *self)
+{
+  page_transition (self, HOTSSH_TAB_PAGE_NEW_CONNECTION);
+  gtk_notebook_set_current_page ((GtkNotebook*)self, 0);
+}
diff --git a/src/hotssh-tab.h b/src/hotssh-tab.h
index ab1a4f0..4a5634c 100644
--- a/src/hotssh-tab.h
+++ b/src/hotssh-tab.h
@@ -32,3 +32,5 @@ typedef struct _HotSshTabClass    HotSshTabClass;
 GType                   hotssh_tab_get_type     (void);
 HotSshTab              *hotssh_tab_new          (void);
 HotSshTab              *hotssh_tab_new_channel  (HotSshTab *source);
+
+void                    hotssh_tab_disconnect  (HotSshTab *source);
diff --git a/src/hotssh-win.c b/src/hotssh-win.c
index 248c222..6af6ead 100644
--- a/src/hotssh-win.c
+++ b/src/hotssh-win.c
@@ -30,10 +30,14 @@ static void new_tab_activated (GSimpleAction    *action,
 static void new_channel_activated (GSimpleAction    *action,
                                    GVariant         *parameter,
                                    gpointer          user_data);
+static void disconnect_activated (GSimpleAction    *action,
+                                  GVariant         *parameter,
+                                  gpointer          user_data);
 
 static GActionEntry win_entries[] = {
   { "new-tab", new_tab_activated, NULL, NULL, NULL },
-  { "new-channel", new_channel_activated, NULL, NULL, NULL }
+  { "new-channel", new_channel_activated, NULL, NULL, NULL },
+  { "disconnect", disconnect_activated, NULL, NULL, NULL }
 };
 
 struct _HotSshWindow
@@ -166,6 +170,19 @@ new_tab_activated (GSimpleAction    *action,
 }
 
 static void
+disconnect_activated (GSimpleAction    *action,
+                      GVariant         *parameter,
+                      gpointer          user_data)
+{
+  HotSshWindow *self = user_data;
+  HotSshWindowPrivate *priv = hotssh_window_get_instance_private (self);
+  guint i = gtk_notebook_get_current_page ((GtkNotebook*)priv->main_notebook);
+  HotSshTab *current_tab = (HotSshTab*)gtk_notebook_get_nth_page ((GtkNotebook*)priv->main_notebook, i);
+
+  hotssh_tab_disconnect (current_tab);
+}
+
+static void
 new_channel_activated (GSimpleAction    *action,
                        GVariant         *parameter,
                        gpointer          user_data)
diff --git a/src/tab.ui b/src/tab.ui
index edcd289..50cd0de 100644
--- a/src/tab.ui
+++ b/src/tab.ui
@@ -376,21 +376,6 @@
                 <property name="position">0</property>
               </packing>
             </child>
-            <child>
-              <object class="GtkButton" id="disconnect_button">
-                <property name="label">gtk-disconnect</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_stock">True</property>
-                <property name="yalign">0.64999997615814209</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>


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