From e357cd6b9bb4e6163eba4aa28d7c7cf67b900c49 Mon Sep 17 00:00:00 2001 From: piotr Date: Tue, 17 May 2022 03:46:00 +0200 Subject: [PATCH 1/8] add picker btn --- nwg_panel/config.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/nwg_panel/config.py b/nwg_panel/config.py index 344e6fc..88787be 100644 --- a/nwg_panel/config.py +++ b/nwg_panel/config.py @@ -444,7 +444,7 @@ class EditorWrapper(object): builder.add_from_file(os.path.join(dir_name, "glade/config_main.glade")) self.window = builder.get_object("main-window") - self.window.set_transient_for(parent) + #self.window.set_transient_for(parent) self.window.set_keep_above(True) self.window.set_type_hint(Gdk.WindowTypeHint.DIALOG) self.window.connect('destroy', self.show_parent, parent) @@ -2375,7 +2375,6 @@ class ControlsCustomItems(Gtk.Frame): self.refresh() def refresh(self): - listbox = Gtk.ListBox() listbox.set_selection_mode(Gtk.SelectionMode.NONE) for i in range(len(self.items)): @@ -2400,6 +2399,11 @@ class ControlsCustomItems(Gtk.Frame): entry.connect("changed", self.update_icon, self.icons, i, "icon") hbox.pack_start(entry, False, False, 0) + btn = Gtk.Button.new_from_icon_name("edit-find-replace", Gtk.IconSize.MENU) + btn.set_tooltip_text("Pick an icon") + btn.connect("clicked", self.on_pick_btn, entry) + hbox.pack_start(btn, False, False, 0) + entry = Gtk.Entry() entry.set_width_chars(15) entry.set_text(item["cmd"]) @@ -2463,6 +2467,10 @@ class ControlsCustomItems(Gtk.Frame): self.show_all() + def on_pick_btn(self, btn, entry): + s = cmd2string("zenity --entry") + print(entry.set_text(s)) + def update_value_from_entry(self, gtk_entry, i, key): self.items[i][key] = gtk_entry.get_text() From de6ba908cd4038a7cb9568a01c945c2528fd2882 Mon Sep 17 00:00:00 2001 From: piotr Date: Thu, 19 May 2022 03:31:03 +0200 Subject: [PATCH 2/8] connect nwg-icon-picker --- nwg_panel/config.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nwg_panel/config.py b/nwg_panel/config.py index 88787be..30c13a3 100644 --- a/nwg_panel/config.py +++ b/nwg_panel/config.py @@ -2399,7 +2399,7 @@ class ControlsCustomItems(Gtk.Frame): entry.connect("changed", self.update_icon, self.icons, i, "icon") hbox.pack_start(entry, False, False, 0) - btn = Gtk.Button.new_from_icon_name("edit-find-replace", Gtk.IconSize.MENU) + btn = Gtk.Button.new_from_icon_name("nwg-icon-picker", Gtk.IconSize.MENU) btn.set_tooltip_text("Pick an icon") btn.connect("clicked", self.on_pick_btn, entry) hbox.pack_start(btn, False, False, 0) @@ -2448,6 +2448,11 @@ class ControlsCustomItems(Gtk.Frame): self.new_icon.connect("changed", update_icon, self.icons) hbox.pack_start(self.new_icon, False, False, 0) + btn = Gtk.Button.new_from_icon_name("nwg-icon-picker", Gtk.IconSize.MENU) + btn.set_tooltip_text("Pick an icon") + btn.connect("clicked", self.on_pick_btn, self.new_icon) + hbox.pack_start(btn, False, False, 0) + self.new_command = Gtk.Entry() self.new_command.set_width_chars(15) self.new_command.set_placeholder_text("command") @@ -2468,7 +2473,7 @@ class ControlsCustomItems(Gtk.Frame): self.show_all() def on_pick_btn(self, btn, entry): - s = cmd2string("zenity --entry") + s = cmd2string("nwg-icon-picker") print(entry.set_text(s)) def update_value_from_entry(self, gtk_entry, i, key): From a4d4345a3a408f9da7db82c53a36f9f16559eba7 Mon Sep 17 00:00:00 2001 From: piotr Date: Sun, 22 May 2022 01:44:18 +0200 Subject: [PATCH 3/8] remove useless print --- nwg_panel/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nwg_panel/config.py b/nwg_panel/config.py index 30c13a3..41a3183 100644 --- a/nwg_panel/config.py +++ b/nwg_panel/config.py @@ -2474,7 +2474,7 @@ class ControlsCustomItems(Gtk.Frame): def on_pick_btn(self, btn, entry): s = cmd2string("nwg-icon-picker") - print(entry.set_text(s)) + entry.set_text(s) def update_value_from_entry(self, gtk_entry, i, key): self.items[i][key] = gtk_entry.get_text() From 522392e6de5cf5ec44ffb16d1f1a751312dc5069 Mon Sep 17 00:00:00 2001 From: piotr Date: Sun, 22 May 2022 01:45:18 +0200 Subject: [PATCH 4/8] bump to 0.6.5 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 40d5db0..5418e39 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ def read(f_name): setup( name='nwg-panel', - version='0.6.4', + version='0.6.5', description='GTK3-based panel for sway window manager', packages=find_packages(), include_package_data=True, From 2cbbc6e6f80b91a47cc9ba5961a032a63f7ccd31 Mon Sep 17 00:00:00 2001 From: piotr Date: Sun, 22 May 2022 01:52:17 +0200 Subject: [PATCH 5/8] check if icon picker available --- nwg_panel/config.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/nwg_panel/config.py b/nwg_panel/config.py index 41a3183..7f7b195 100644 --- a/nwg_panel/config.py +++ b/nwg_panel/config.py @@ -2353,6 +2353,11 @@ class EditorWrapper(object): self.scrolled_window.add(custom_items_grid) +def on_pick_btn(btn, entry): + s = cmd2string("nwg-icon-picker") + entry.set_text(s) + + class ControlsCustomItems(Gtk.Frame): def __init__(self, panel, config, file): check_key(panel, "controls-settings", {}) @@ -2399,10 +2404,11 @@ class ControlsCustomItems(Gtk.Frame): entry.connect("changed", self.update_icon, self.icons, i, "icon") hbox.pack_start(entry, False, False, 0) - btn = Gtk.Button.new_from_icon_name("nwg-icon-picker", Gtk.IconSize.MENU) - btn.set_tooltip_text("Pick an icon") - btn.connect("clicked", self.on_pick_btn, entry) - hbox.pack_start(btn, False, False, 0) + if is_command("nwg-icon-picker"): + btn = Gtk.Button.new_from_icon_name("nwg-icon-picker", Gtk.IconSize.MENU) + btn.set_tooltip_text("Pick an icon") + btn.connect("clicked", on_pick_btn, entry) + hbox.pack_start(btn, False, False, 0) entry = Gtk.Entry() entry.set_width_chars(15) @@ -2448,10 +2454,11 @@ class ControlsCustomItems(Gtk.Frame): self.new_icon.connect("changed", update_icon, self.icons) hbox.pack_start(self.new_icon, False, False, 0) - btn = Gtk.Button.new_from_icon_name("nwg-icon-picker", Gtk.IconSize.MENU) - btn.set_tooltip_text("Pick an icon") - btn.connect("clicked", self.on_pick_btn, self.new_icon) - hbox.pack_start(btn, False, False, 0) + if is_command("nwg-icon-picker"): + btn = Gtk.Button.new_from_icon_name("nwg-icon-picker", Gtk.IconSize.MENU) + btn.set_tooltip_text("Pick an icon") + btn.connect("clicked", on_pick_btn, self.new_icon) + hbox.pack_start(btn, False, False, 0) self.new_command = Gtk.Entry() self.new_command.set_width_chars(15) @@ -2472,10 +2479,6 @@ class ControlsCustomItems(Gtk.Frame): self.show_all() - def on_pick_btn(self, btn, entry): - s = cmd2string("nwg-icon-picker") - entry.set_text(s) - def update_value_from_entry(self, gtk_entry, i, key): self.items[i][key] = gtk_entry.get_text() From 83b395703b3de564756b0b69e111586b22552c05 Mon Sep 17 00:00:00 2001 From: piotr Date: Sun, 22 May 2022 13:11:05 +0200 Subject: [PATCH 6/8] fix #112 --- nwg_panel/main.py | 62 +++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/nwg_panel/main.py b/nwg_panel/main.py index b89fe2a..1b056eb 100644 --- a/nwg_panel/main.py +++ b/nwg_panel/main.py @@ -240,6 +240,37 @@ def instantiate_content(panel, container, content_list, icons_path=""): def main(): + parser = argparse.ArgumentParser() + parser.add_argument("-c", + "--config", + type=str, + default="config", + help="config filename (in {}/)".format(common.config_dir)) + + parser.add_argument("-s", + "--style", + type=str, + default="style.css", + help="css filename (in {}/)".format(common.config_dir)) + + parser.add_argument("-sigdwl", + type=int, + default=10, + help="signal to refresh dwl-tags module; default: 10 (SIGUSR1)") + + parser.add_argument("-r", + "--restore", + action="store_true", + help="restore default config files") + + parser.add_argument("-v", + "--version", + action="version", + version="%(prog)s version {}".format(__version__), + help="display version information") + + args = parser.parse_args() + # Kill running instances, if any own_pid = os.getpid() # We should never have more that 1, but just in case @@ -285,37 +316,6 @@ def main(): else: print("Couldn't determine cache directory", file=sys.stderr) - parser = argparse.ArgumentParser() - parser.add_argument("-c", - "--config", - type=str, - default="config", - help="config filename (in {}/)".format(common.config_dir)) - - parser.add_argument("-s", - "--style", - type=str, - default="style.css", - help="css filename (in {}/)".format(common.config_dir)) - - parser.add_argument("-sigdwl", - type=int, - default=10, - help="signal to refresh dwl-tags module; default: 10 (SIGUSR1)") - - parser.add_argument("-r", - "--restore", - action="store_true", - help="restore default config files") - - parser.add_argument("-v", - "--version", - action="version", - version="%(prog)s version {}".format(__version__), - help="display version information") - - args = parser.parse_args() - global sig_dwl sig_dwl = args.sigdwl From 8601b41800fde89854a5eac5ed14badc7daad581 Mon Sep 17 00:00:00 2001 From: piotr Date: Sun, 22 May 2022 14:01:54 +0200 Subject: [PATCH 7/8] add icon-picker to the button form --- nwg_panel/config.py | 10 ++++++++++ nwg_panel/glade/config_button.glade | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/nwg_panel/config.py b/nwg_panel/config.py index 7f7b195..b24d887 100644 --- a/nwg_panel/config.py +++ b/nwg_panel/config.py @@ -1932,6 +1932,16 @@ class EditorWrapper(object): update_icon(self.button_icon, self.panel["icons"]) self.button_icon.connect("changed", update_icon, self.panel["icons"]) + self.button_picker = builder.get_object("btn-picker") + img = Gtk.Image.new_from_icon_name("nwg-icon-picker", Gtk.IconSize.BUTTON) + self.button_picker.set_image(img) + + if is_command("nwg-icon-picker"): + self.button_picker.set_tooltip_text("Pick an icon") + self.button_picker.connect("clicked", on_pick_btn, self.button_icon) + else: + self.button_picker.hide() + self.button_label = builder.get_object("label") self.button_label.set_text(settings["label"]) diff --git a/nwg_panel/glade/config_button.glade b/nwg_panel/glade/config_button.glade index cbfd3d9..1edd130 100644 --- a/nwg_panel/glade/config_button.glade +++ b/nwg_panel/glade/config_button.glade @@ -179,6 +179,7 @@ False Attention! Renaming an existing button will create a new one. + start gtk-dialog-warning @@ -232,6 +233,23 @@ button will create a new one. 1 + + + True + True + True + Pick an icon + start + True + + + + + + 2 + 3 + + From ad0c154f835a21ad9c2fe11c5874501428021c12 Mon Sep 17 00:00:00 2001 From: piotr Date: Sun, 22 May 2022 14:57:37 +0200 Subject: [PATCH 8/8] set value if not empty --- nwg_panel/config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nwg_panel/config.py b/nwg_panel/config.py index b24d887..6307784 100644 --- a/nwg_panel/config.py +++ b/nwg_panel/config.py @@ -2365,7 +2365,8 @@ class EditorWrapper(object): def on_pick_btn(btn, entry): s = cmd2string("nwg-icon-picker") - entry.set_text(s) + if s: + entry.set_text(s) class ControlsCustomItems(Gtk.Frame):