[chirp_devel] [PATCH] Memory editor controls to use Gtk.Toolbar with collapsable overflow menu. Fixes 8259

Kosta A.
Fri Sep 18 00:37:32 PDT 2020


# HG changeset patch
# User Kosta A. <ve7kcy at gmail.com>
# Date 1600414573 25200
#      Fri Sep 18 00:36:13 2020 -0700
# Node ID 1a49ad2e84e305b56a3bdeb823266e1219f34e02
# Parent  2d7b5508d8950df775754f0587b7c7856e1c2302
Memory editor controls to use Gtk.Toolbar with collapsable overflow menu. Fixes 8259.

diff --git a/chirp/ui/memedit.py b/chirp/ui/memedit.py
--- a/chirp/ui/memedit.py
+++ b/chirp/ui/memedit.py
@@ -1178,11 +1178,16 @@
         self._config.set_int(self._limit_key(which), int(sb.get_value()))
 
     def make_controls(self, min, max):
+        vbox = gtk.VBox(False, 2)
+
+        toolbar = gtk.Toolbar()
+        toolbar.set_style(gtk.TOOLBAR_BOTH_HORIZ)
+        toolbar.set_show_arrow(True)
+
         hbox = gtk.HBox(False, 2)
 
         lab = gtk.Label(_("Memory Range:"))
-        lab.show()
-        hbox.pack_start(lab, 0, 0, 0)
+        hbox.pack_start(lab, False, False, 2)
 
         lokey = self._limit_key("lo")
         hikey = self._limit_key("hi")
@@ -1194,24 +1199,23 @@
         self.lo_limit_adj = gtk.Adjustment(lostart, min, max-1, 1, 10)
         lo = gtk.SpinButton(self.lo_limit_adj)
         lo.connect("value-changed", self._store_limit, "lo")
-        lo.show()
-        hbox.pack_start(lo, 0, 0, 0)
-
-        lab = gtk.Label(" - ")
-        lab.show()
-        hbox.pack_start(lab, 0, 0, 0)
+        hbox.pack_start(lo, False, False, 2)
 
         self.hi_limit_adj = gtk.Adjustment(histart, min+1, max, 1, 10)
         hi = gtk.SpinButton(self.hi_limit_adj)
         hi.connect("value-changed", self._store_limit, "hi")
-        hi.show()
-        hbox.pack_start(hi, 0, 0, 0)
+        hbox.pack_start(hi, False, False, 2)
+
+        item = gtk.ToolItem()
+        item.add(hbox)
+        toolbar.add(item)
 
-        refresh = gtk.Button(_("Refresh"))
-        refresh.set_relief(gtk.RELIEF_NONE)
+        sep = gtk.SeparatorToolItem()
+        toolbar.add(sep)
+
+        refresh = gtk.ToolButton(gtk.STOCK_REFRESH)
         refresh.connect("clicked", lambda x: self.prefill())
-        refresh.show()
-        hbox.pack_start(refresh, 0, 0, 0)
+        toolbar.add(refresh)
 
         def activate_go(widget):
             refresh.clicked()
@@ -1226,41 +1230,43 @@
         lo.connect_after("activate", activate_go)
         hi.connect_after("activate", activate_go)
 
-        sep = gtk.VSeparator()
-        sep.show()
-        hbox.pack_start(sep, 0, 0, 2)
+        sep = gtk.SeparatorToolItem()
+        toolbar.add(sep)
 
-        showspecial = gtk.ToggleButton(_("Special Channels"))
-        showspecial.set_relief(gtk.RELIEF_NONE)
+        showspecial = gtk.ToggleToolButton()
+        showspecial.set_label(_("Special Channels"))
+        showspecial.set_stock_id(gtk.STOCK_ABOUT)
+        showspecial.set_is_important(True)
         showspecial.set_active(self.show_special)
         showspecial.connect("toggled",
                             lambda x: self.set_show_special(x.get_active()))
-        showspecial.show()
-        hbox.pack_start(showspecial, 0, 0, 0)
+        toolbar.add(showspecial)
 
-        showempty = gtk.ToggleButton(_("Show Empty"))
-        showempty.set_relief(gtk.RELIEF_NONE)
+        showempty = gtk.ToggleToolButton()
+        showempty.set_label(_("Empty Channels"))
+        showempty.set_stock_id(gtk.STOCK_SELECT_ALL)
+        showempty.set_is_important(True)
         showempty.set_active(self.show_empty)
         showempty.connect("toggled",
                           lambda x: self.set_show_empty(x.get_active()))
-        showempty.show()
-        hbox.pack_start(showempty, 0, 0, 0)
+        toolbar.add(showempty)
+
+        sep = gtk.SeparatorToolItem()
+        toolbar.add(sep)
 
-        sep = gtk.VSeparator()
-        sep.show()
-        hbox.pack_start(sep, 0, 0, 2)
-
-        props = gtk.Button(_("Properties"))
-        props.set_relief(gtk.RELIEF_NONE)
-        props.connect("clicked",
+        properties = gtk.ToolButton()
+        properties.set_stock_id(gtk.STOCK_PROPERTIES)
+        properties.set_label(_("Properties"))
+        properties.set_is_important(True)
+        properties.connect("clicked",
                       lambda x: self.hotkey(
                             gtk.Action("properties", "", "", 0)))
-        props.show()
-        hbox.pack_start(props, 0, 0, 0)
+        toolbar.add(properties)
 
-        hbox.show()
+        vbox.pack_start(toolbar, False, False, 0)
+        vbox.show_all()
 
-        return hbox
+        return vbox
 
     def set_show_special(self, show):
         self.show_special = show



More information about the chirp_devel mailing list