[gedit-plugins/sessionsaver] Need a name to save



commit 7a0212b17d8d9566888ee691c1a3f5db4c6db248
Author: Jordi Mas <jmas softcatala org>
Date:   Fri Jun 28 16:50:45 2019 +0200

    Need a name to save

 plugins/sessionsaver/sessionsaver/dialogs.py         | 14 ++++++++++----
 plugins/sessionsaver/sessionsaver/ui/sessionsaver.ui |  4 ++--
 2 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/plugins/sessionsaver/sessionsaver/dialogs.py b/plugins/sessionsaver/sessionsaver/dialogs.py
index 1b51460..7df7be8 100644
--- a/plugins/sessionsaver/sessionsaver/dialogs.py
+++ b/plugins/sessionsaver/sessionsaver/dialogs.py
@@ -95,18 +95,24 @@ class SaveSessionDialog(Dialog):
 
         model = SessionModel(sessions)
 
-        combobox = self['session-name']
-        combobox.set_model(model)
-        combobox.set_entry_text_column(1)
+        self.combobox = self['session-name']
+        self.combobox.set_model(model)
+        self.combobox.set_entry_text_column(1)
+        self.combobox.connect("changed", self.on_name_combo_changed)
 
         self.dialog.connect('response', self.on_response)
+        self['save_button'].set_sensitive(False)
+
+    def on_name_combo_changed(self, combo):
+        name = self.combobox.get_child().get_text()
+        self['save_button'].set_sensitive(len(name) > 0)
 
     def on_response(self, dialog, response_id):
         if response_id == Gtk.ResponseType.OK:
             files = [doc.get_location()
                         for doc in self.parent.get_documents()
                         if doc.get_location() is not None]
-            name = self['session-name'].get_child().get_text()
+            name = self.combobox.get_child().get_text()
             self.sessions.add(Session(name, files))
             self.sessions.save()
             self.on_updated_sessions()
diff --git a/plugins/sessionsaver/sessionsaver/ui/sessionsaver.ui 
b/plugins/sessionsaver/sessionsaver/ui/sessionsaver.ui
index 7e333df..9c5b9db 100644
--- a/plugins/sessionsaver/sessionsaver/ui/sessionsaver.ui
+++ b/plugins/sessionsaver/sessionsaver/ui/sessionsaver.ui
@@ -34,7 +34,7 @@
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="button1">
+              <object class="GtkButton" id="save_button">
                 <property name="label">gtk-save</property>
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
@@ -106,7 +106,7 @@
     </child>
     <action-widgets>
       <action-widget response="-6">button2</action-widget>
-      <action-widget response="-5">button1</action-widget>
+      <action-widget response="-5">save_button</action-widget>
     </action-widgets>
   </object>
   <object class="GtkWindow" id="session-manager-dialog">


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