[polari/wip/send] Add send button



commit bb13da9c4102bc3bc7b9aae6804b0b2ec4c40784
Author: Ignacio Casal Quinteiro <ignacio casal nice-software com>
Date:   Fri Aug 9 08:50:25 2013 +0200

    Add send button

 data/resources/main-window.ui |   70 +++++++++++++++++++++++++++--------------
 src/mainWindow.js             |    8 ++++-
 2 files changed, 53 insertions(+), 25 deletions(-)
---
diff --git a/data/resources/main-window.ui b/data/resources/main-window.ui
index 27d003f..920a1db 100644
--- a/data/resources/main-window.ui
+++ b/data/resources/main-window.ui
@@ -329,42 +329,64 @@
                   <class name="polari-input-area"/>
                 </style>
                 <child>
-                  <object class="GtkBox" id="box4">
+                  <object class="GtkBox" id="box5">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="margin_left">6</property>
-                    <property name="margin_right">6</property>
-                    <property name="margin_top">6</property>
-                    <property name="margin_bottom">6</property>
-                    <style>
-                      <class name="linked"/>
-                    </style>
                     <child>
-                      <object class="GtkEntry" id="nick_entry">
+                      <object class="GtkBox" id="box4">
                         <property name="visible">True</property>
-                        <property name="can_focus">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="margin_left">6</property>
+                        <property name="margin_right">6</property>
+                        <property name="margin_top">6</property>
+                        <property name="margin_bottom">6</property>
                         <style>
-                          <class name="dim-label"/>
+                          <class name="linked"/>
                         </style>
+                        <child>
+                          <object class="GtkEntry" id="nick_entry">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <style>
+                              <class name="dim-label"/>
+                            </style>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkEntry" id="message_entry">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="hexpand">True</property>
+                            <property name="activates_default">True</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="fill">True</property>
-                        <property name="position">0</property>
-                      </packing>
                     </child>
                     <child>
-                      <object class="GtkEntry" id="message_entry">
+                      <object class="GtkButton" id="send_message_button">
                         <property name="visible">True</property>
+                        <property name="sensitive">False</property>
                         <property name="can_focus">True</property>
-                        <property name="hexpand">True</property>
-                        <property name="activates_default">True</property>
+                        <property name="can_default">True</property>
+                        <property name="has_default">True</property>
+                        <property name="valign">center</property>
+                        <property name="halign">center</property>
+                        <property name="margin_right">6</property>
+                        <property name="label" translatable="yes">Send</property>
+                        <style>
+                          <class name="suggested-action"/>
+                        </style>
                       </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">1</property>
-                      </packing>
                     </child>
                   </object>
                 </child>
diff --git a/src/mainWindow.js b/src/mainWindow.js
index d784922..d01466c 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -69,6 +69,7 @@ const MainWindow = new Lang.Class({
         this._inputArea = builder.get_object('main_input_area');
         this._nickEntry = builder.get_object('nick_entry');
         this._entry = builder.get_object('message_entry');
+        this._send_message = builder.get_object('send_message_button');
 
         this._nickEntry.width_chars = ChatView.MAX_NICK_CHARS
 
@@ -88,7 +89,12 @@ const MainWindow = new Lang.Class({
         this._selectionModeAction.connect('notify::state',
                     Lang.bind(this, this._onSelectionModeChanged));
 
-        this._entry.connect('activate', Lang.bind(this,
+        this._entry.connect('changed', Lang.bind(this,
+            function() {
+                this._send_message.sensitive = this._entry.text != '';
+            }));
+
+        this._send_message.connect('clicked', Lang.bind(this,
             function() {
                 this._ircParser.process(this._entry.text);
                 this._entry.text = '';


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