Merge pull request #113 from nwg-piotr/picker

add icon picker, fix #112
This commit is contained in:
Piotr Miller
2022-05-22 23:29:08 +02:00
committed by GitHub
4 changed files with 79 additions and 34 deletions

View File

@@ -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)
@@ -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"])
@@ -2353,6 +2363,12 @@ class EditorWrapper(object):
self.scrolled_window.add(custom_items_grid)
def on_pick_btn(btn, entry):
s = cmd2string("nwg-icon-picker")
if s:
entry.set_text(s)
class ControlsCustomItems(Gtk.Frame):
def __init__(self, panel, config, file):
check_key(panel, "controls-settings", {})
@@ -2375,7 +2391,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 +2415,12 @@ class ControlsCustomItems(Gtk.Frame):
entry.connect("changed", self.update_icon, self.icons, i, "icon")
hbox.pack_start(entry, 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)
entry.set_text(item["cmd"])
@@ -2444,6 +2465,12 @@ class ControlsCustomItems(Gtk.Frame):
self.new_icon.connect("changed", update_icon, self.icons)
hbox.pack_start(self.new_icon, 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)
self.new_command.set_placeholder_text("command")

View File

@@ -179,6 +179,7 @@
<property name="can-focus">False</property>
<property name="tooltip-text" translatable="yes">Attention! Renaming an existing
button will create a new one.</property>
<property name="halign">start</property>
<property name="stock">gtk-dialog-warning</property>
</object>
<packing>
@@ -232,6 +233,23 @@ button will create a new one.</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btn-picker">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Pick an icon</property>
<property name="halign">start</property>
<property name="always-show-image">True</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
<placeholder/>
</child>

View File

@@ -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

View File

@@ -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,