[chirp_devel] [PATCH] Updated Memory Edit View (Part 3)

Kosta Arvanitis
Sun Feb 1 00:05:05 PST 2015


# HG changeset patch
# User K. Arvanitis <kosta at alumni.uvic.ca>
# Date 1422776304 28800
# Parent  511bcfb8df4f6ab9d182ad58d7cdf32a3193a0d8
[PATCH] Updated Memory Edit View #3
Updated column picker dialog to utilize treeview.  Updated spacing on
generic yesno dialogs.  Provides overall better readability.

Feature #2273
diff -r 511bcfb8df4f -r 692c2f783c89 chirpui/mainapp.py
--- a/chirpui/mainapp.py Sat Jan 31 12:27:19 2015 -0800
+++ b/chirpui/mainapp.py Sat Jan 31 23:38:24 2015 -0800
@@ -725,12 +725,13 @@
             return False
 
         if eset.is_modified():
-            dlg = miscwidgets.YesNoDialog(title=_("Save Changes?"),
+            dlg = miscwidgets.YesNoDialog(title=_("Save Changes"),
                                           parent=self,
                                           buttons=(gtk.STOCK_YES, gtk.RESPONSE_YES,
                                                    gtk.STOCK_NO, gtk.RESPONSE_NO,
                                                    gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
-            dlg.set_text(_("File is modified, save changes before closing?"))
+            dlg.set_text(_("Save changes to %s?") % eset.filename)
+ 
             res = dlg.run()
             dlg.destroy()
 
@@ -1220,27 +1221,38 @@
         radio_name = "%s %s %s" % (eset.rthread.radio.VENDOR,
                                    eset.rthread.radio.MODEL,
                                    eset.rthread.radio.VARIANT)
-        d = gtk.Dialog(title=_("Select Columns"),
-                       parent=self,
-                       buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,
-                                gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
+        dlg = gtk.Dialog(title=_("Choose Columns"),
+                            parent=self,
+                            buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,
+                                    gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
+        dlg.set_size_request(-1, 300)
+        dlg.set_resizable(False)
 
-        vbox = gtk.VBox()
-        vbox.show()
+        store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_BOOLEAN, gobject.TYPE_INT)
+        view = gtk.TreeView(store)
+        view.set_headers_visible(False)
+        rend = gtk.CellRendererToggle()
+        def toggle(render, path, column):
+            store[path][column] = not store[path][column]
+        rend.connect("toggled", toggle, 1)
+        col = gtk.TreeViewColumn(None, rend, active=1)
+        view.append_column(col)
+        rend = gtk.CellRendererText()
+        col = gtk.TreeViewColumn(None, rend, text=0)
+        view.append_column(col)
+        view.show()
+
         sw = gtk.ScrolledWindow()
         sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
-        sw.add_with_viewport(vbox)
+        sw.add_with_viewport(view)
         sw.show()
-        d.vbox.pack_start(sw, 1, 1, 1)
-        d.set_size_request(-1, 300)
-        d.set_resizable(False)
+        dlg.vbox.pack_start(sw, 1, 1, 1)
 
-        label = gtk.Label(_("Visible columns for {radio}").format(radio=radio_name))
+        label = gtk.Label(_("Select the visible columns for {radio}").format(radio=radio_name))
         label.show()
-        vbox.pack_start(label)
+        dlg.vbox.pack_start(label, 0, 0, 6)
 
-        fields = []
-        memedit = eset.get_current_editor() #.editors["memedit"]
+        memedit = eset.get_current_editor()
         unsupported = memedit.get_unsupported_columns()
         for colspec in memedit.cols:
             if colspec[0].startswith("_"):
@@ -1248,25 +1260,25 @@
             elif colspec[0] in unsupported:
                 continue
             label = colspec[0]
-            visible = memedit.get_column_visible(memedit.col(label))
-            widget = gtk.CheckButton(label)
-            widget.set_active(visible)
-            fields.append(widget)
-            vbox.pack_start(widget, 1, 1, 1)
-            widget.show()
+            colnum = memedit.col(label)
+            visible = memedit.get_column_visible(colnum)
+            iter = store.append()
+            store.set(iter, 0, label, 1, visible, 2, colnum)
 
-        res = d.run()
-        selected_columns = []
+        res = dlg.run()
+
+        lst = []
         if res == gtk.RESPONSE_OK:
-            for widget in fields:
-                colnum = memedit.col(widget.get_label())
-                memedit.set_column_visible(colnum, widget.get_active())
-                if widget.get_active():
-                    selected_columns.append(widget.get_label())
+            def func(_store, path, iter):
+                label, visible, colnum = _store.get(iter, 0, 1, 2)
+                memedit.set_column_visible(colnum, visible)
+                if visible:
+                    lst.append(label)
+            store.foreach(func)
                                                 
-        d.destroy()
+        dlg.destroy()
 
-        CONF.set(driver, ",".join(selected_columns), "memedit_columns")
+        CONF.set(driver, ",".join(lst), "memedit_columns")
 
     def do_hide_unused(self, action):
         eset = self.get_current_editorset()
@@ -1469,6 +1481,7 @@
     </menu>
     <menu action="view">
       <menuitem action="columns"/>
+      <separator/>
       <menuitem action="hide_unused"/>
       <menuitem action="no_smart_tmode"/>
       <menu action="viewdeveloper">
@@ -1476,6 +1489,7 @@
         <menuitem action="devdiffraw"/>
         <menuitem action="devdifftab"/>
       </menu>
+      <separator/>
       <menuitem action="language"/>
     </menu>
     <menu action="radio" name="radio">
@@ -1532,7 +1546,7 @@
             ('exchange', None, _("E_xchange"), "<Control><Shift>x", None, self.mh),
             ('properties', None, _("P_roperties"), None, None, self.mh),
             ('view', None, _("_View"), None, None, self.mh),
-            ('columns', None, _("Columns"), None, None, self.mh),
+            ('columns', None, _("C_hoose Columns..."), None, None, self.mh),
             ('viewdeveloper', None, _("Developer"), None, None, self.mh),
             ('devshowraw', None, _('Show raw memory'), "<Control><Shift>r", None, self.mh),
             ('devdiffraw', None, _("Diff raw memories"), "<Control><Shift>d", None, self.mh),
diff -r 511bcfb8df4f -r 692c2f783c89 chirpui/memedit.py
--- a/chirpui/memedit.py Sat Jan 31 12:27:19 2015 -0800
+++ b/chirpui/memedit.py Sat Jan 31 23:38:24 2015 -0800
@@ -1448,7 +1448,7 @@
             loc, filled = store.get(iter,
                                     self.col(_("Loc")), self.col("_filled"))
             if filled and not always:
-                d = miscwidgets.YesNoDialog(title=_("Overwrite?"),
+                d = miscwidgets.YesNoDialog(title=_("Overwrite"),
                                             buttons=(gtk.STOCK_YES, 1,
                                                      gtk.STOCK_NO, 2,
                                                      gtk.STOCK_CANCEL, 3,
diff -r 511bcfb8df4f -r 692c2f783c89 chirpui/miscwidgets.py
--- a/chirpui/miscwidgets.py Sat Jan 31 12:27:19 2015 -0800
+++ b/chirpui/miscwidgets.py Sat Jan 31 23:38:24 2015 -0800
@@ -599,7 +599,7 @@
         self._label.show()
 
         # pylint: disable-msg=E1101
-        self.vbox.pack_start(self._label, 1, 1, 1)
+        self.vbox.pack_start(self._label, 1, 1, 6)
 
     def set_text(self, text):
         self._label.set_text(text)

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://intrepid.danplanet.com/pipermail/chirp_devel/attachments/20150201/3ac73457/attachment-0001.html 


More information about the chirp_devel mailing list