[Xfce4-commits] [apps/xfce4-panel-profiles] 02/162: Usability improvements

noreply at xfce.org noreply at xfce.org
Fri Jul 13 13:08:21 CEST 2018


This is an automated email from the git hooks/post-receive script.

o   c   h   o   s   i       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/xfce4-panel-profiles.

commit 8166a61cc84ebc0ea09bebda67ce99e7e875c12c
Author: Sean Davis <smd.seandavis at gmail.com>
Date:   Sun Jan 18 08:12:24 2015 -0500

    Usability improvements
---
 xfpanel-switch/xfpanel-switch.glade | 117 +++++++++++++++++++++++++++++++++++-
 xfpanel-switch/xfpanel-switch.py    |  43 +++++++++----
 2 files changed, 146 insertions(+), 14 deletions(-)

diff --git a/xfpanel-switch/xfpanel-switch.glade b/xfpanel-switch/xfpanel-switch.glade
index b8468d5..11cece1 100644
--- a/xfpanel-switch/xfpanel-switch.glade
+++ b/xfpanel-switch/xfpanel-switch.glade
@@ -14,6 +14,7 @@
   </object>
   <object class="GtkWindow" id="xfpanel_switch_window">
     <property name="can_focus">False</property>
+    <property name="default_height">400</property>
     <signal name="delete-event" handler="on_window_destroy" swapped="no"/>
     <child>
       <object class="GtkBox" id="box1">
@@ -123,6 +124,7 @@ Backup and restore your panel configuration</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="model">liststore1</property>
+                        <property name="tooltip_column">0</property>
                         <child internal-child="selection">
                           <object class="GtkTreeSelection" id="treeview-selection1"/>
                         </child>
@@ -131,7 +133,9 @@ Backup and restore your panel configuration</property>
                             <property name="title" translatable="yes">Filename</property>
                             <property name="expand">True</property>
                             <child>
-                              <object class="GtkCellRendererText" id="cellrenderertext1"/>
+                              <object class="GtkCellRendererText" id="cellrenderertext1">
+                                <property name="ellipsize">end</property>
+                              </object>
                               <attributes>
                                 <attribute name="text">1</attribute>
                               </attributes>
@@ -271,4 +275,115 @@ Backup and restore your panel configuration</property>
       </object>
     </child>
   </object>
+  <object class="GtkDialog" id="save_dialog">
+    <property name="can_focus">False</property>
+    <property name="title" translatable="yes">Save panel configuration as...</property>
+    <property name="resizable">False</property>
+    <property name="default_height">200</property>
+    <property name="type_hint">dialog</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="dialog-vbox1">
+        <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">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="button3">
+                <property name="label" translatable="yes">Cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+                <property name="non_homogeneous">True</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="button4">
+                <property name="label" translatable="yes">Save Configuration</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkAlignment" id="alignment2">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="border_width">6</property>
+            <child>
+              <object class="GtkGrid" id="grid1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="row_spacing">6</property>
+                <property name="column_spacing">12</property>
+                <child>
+                  <object class="GtkImage" id="image1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="icon_name">dialog-question-symbolic</property>
+                    <property name="icon_size">6</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
+                    <property name="height">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes"><b>Name the new panel configuration</b></property>
+                    <property name="use_markup">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="name_entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">1</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-6">button3</action-widget>
+      <action-widget response="-5">button4</action-widget>
+    </action-widgets>
+  </object>
 </interface>
diff --git a/xfpanel-switch/xfpanel-switch.py b/xfpanel-switch/xfpanel-switch.py
index 16012e4..f7d3662 100644
--- a/xfpanel-switch/xfpanel-switch.py
+++ b/xfpanel-switch/xfpanel-switch.py
@@ -120,19 +120,28 @@ class XfpanelSwitch:
         values = model[treeiter][:]
         return (model, treeiter, values)
 
-    def get_save_dialog(self):
-        dialog = Gtk.Dialog.new()
-        dialog.set_title("Save configuration name as...")
-        dialog.set_size_request(300,100)
-        dialog.add_buttons("Cancel", Gtk.ResponseType.CANCEL,
-                           "Save", Gtk.ResponseType.OK)
-        content_area = dialog.get_content_area()
-        self.name_entry = Gtk.Entry.new()
-        content_area.add(self.name_entry)
-        content_area.show_all()
+    def get_save_dialog(self, default_name=None):
+        dialog = self.builder.get_object("save_dialog")
+        self.name_entry = self.builder.get_object("name_entry")
+        if default_name is None:
+            date = datetime.datetime.now().strftime("%x %X")
+            date = date.replace(":", "-").replace("/", "-").replace(" ", "_")
+            default_name = _("Backup_%s") % date
+        self.name_entry.set_text(default_name)
 
         return dialog
 
+    def copy_configuration(self, row, new_name):
+        model, treeiter, values = row
+        filename = values[0]
+        old_name = values[1]
+        created = values[2]
+        new_filename = new_name + ".tar.bz2"
+        new_filename = os.path.join(self.save_location, new_filename)
+        PanelConfig.from_file(filename).to_file(new_filename)
+        name = _("%s (Copy of %s)") % (new_name, old_name)
+        self.tree_model.append([new_filename, name, created])
+
     def save_configuration(self, name):
         filename = name + ".tar.bz2"
         filename = os.path.join(self.save_location, filename)
@@ -141,12 +150,17 @@ class XfpanelSwitch:
         self.tree_model.append([filename, name, created])
 
     def on_save_clicked(self, widget):
+        model, treeiter, values = self.get_selected()
+        filename = values[0]
         dialog = self.get_save_dialog()
         if dialog.run() == Gtk.ResponseType.OK:
             name = self.name_entry.get_text().strip()
             if len(name) > 0:
-                self.save_configuration(name)
-        dialog.destroy()
+                if filename == "":
+                    self.save_configuration(name)
+                else:
+                    self.copy_configuration(self.get_selected(), name)
+        dialog.hide()
 
     def load_configuration(self, filename):
         if os.path.isfile(filename):
@@ -158,11 +172,14 @@ class XfpanelSwitch:
         self.load_configuration(filename)
 
     def delete_configuration(self, filename):
-        os.remove(filename)
+        if os.path.isfile(filename):
+            os.remove(filename)
 
     def on_delete_clicked(self, widget):
         model, treeiter, values = self.get_selected()
         filename = values[0]
+        if filename == "":
+            return
         self.delete_configuration(filename)
         model.remove(treeiter)
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list