exchange executors
This commit is contained in:
@@ -447,7 +447,7 @@ class EditorWrapper(object):
|
|||||||
self.window.connect("key-release-event", handle_keyboard)
|
self.window.connect("key-release-event", handle_keyboard)
|
||||||
self.window.connect("show", self.hide_parent, parent)
|
self.window.connect("show", self.hide_parent, parent)
|
||||||
|
|
||||||
Gtk.Widget.set_size_request(self.window, 840, 1)
|
Gtk.Widget.set_size_request(self.window, 720, 1)
|
||||||
|
|
||||||
self.known_modules = ["clock", "playerctl", "sway-taskbar", "sway-workspaces", "scratchpad"]
|
self.known_modules = ["clock", "playerctl", "sway-taskbar", "sway-workspaces", "scratchpad"]
|
||||||
|
|
||||||
@@ -1530,12 +1530,33 @@ class EditorWrapper(object):
|
|||||||
self.executor_interval.set_value(settings["interval"])
|
self.executor_interval.set_value(settings["interval"])
|
||||||
|
|
||||||
self.executor_remove = builder.get_object("remove")
|
self.executor_remove = builder.get_object("remove")
|
||||||
self.executor_remove.set_sensitive(name in self.panel)
|
|
||||||
|
self.executor_save_to_db_btn = builder.get_object("save-to-database")
|
||||||
|
self.executor_save_to_db_btn.connect("clicked", self.check_and_save_to_db, name, settings)
|
||||||
|
if new:
|
||||||
|
self.executor_remove.set_visible(False)
|
||||||
|
self.executor_save_to_db_btn.set_visible(False)
|
||||||
|
|
||||||
for item in self.scrolled_window.get_children():
|
for item in self.scrolled_window.get_children():
|
||||||
item.destroy()
|
item.destroy()
|
||||||
self.scrolled_window.add(grid)
|
self.scrolled_window.add(grid)
|
||||||
|
|
||||||
|
def check_and_save_to_db(self, btn, name, settings):
|
||||||
|
if name not in self.executors_base:
|
||||||
|
self.save_executor_to_db(btn, name, settings)
|
||||||
|
else:
|
||||||
|
menu = Gtk.Menu()
|
||||||
|
item = Gtk.MenuItem.new_with_label("Replace '{}' in database".format(name))
|
||||||
|
item.connect("activate", self.save_executor_to_db, name, settings)
|
||||||
|
menu.append(item)
|
||||||
|
menu.set_reserve_toggle_size(False)
|
||||||
|
menu.show_all()
|
||||||
|
menu.popup_at_widget(btn, Gdk.Gravity.NORTH, Gdk.Gravity.SOUTH, None)
|
||||||
|
|
||||||
|
def save_executor_to_db(self, widget, name, settings):
|
||||||
|
self.executors_base[name] = settings
|
||||||
|
save_json(self.executors_base, self.executors_file)
|
||||||
|
|
||||||
def update_executor(self):
|
def update_executor(self):
|
||||||
config_key = "executor-{}".format(self.executor_name.get_text())
|
config_key = "executor-{}".format(self.executor_name.get_text())
|
||||||
settings = self.panel[config_key] if config_key in self.panel else {}
|
settings = self.panel[config_key] if config_key in self.panel else {}
|
||||||
@@ -1596,10 +1617,7 @@ class EditorWrapper(object):
|
|||||||
"""l = {}
|
"""l = {}
|
||||||
for item in self.panel["modules-right"]:
|
for item in self.panel["modules-right"]:
|
||||||
l[item] = self.panel[item]
|
l[item] = self.panel[item]
|
||||||
save_json(l, file)"""
|
save_json(l, self.executors_file)"""
|
||||||
|
|
||||||
for key in self.executors_base:
|
|
||||||
print(key, self.executors_base[key])
|
|
||||||
|
|
||||||
builder = Gtk.Builder.new_from_file(os.path.join(dir_name, "glade/executor_import.glade"))
|
builder = Gtk.Builder.new_from_file(os.path.join(dir_name, "glade/executor_import.glade"))
|
||||||
grid = builder.get_object("grid")
|
grid = builder.get_object("grid")
|
||||||
@@ -1628,18 +1646,25 @@ class EditorWrapper(object):
|
|||||||
self.ie_btn_delete = builder.get_object("btn-delete")
|
self.ie_btn_delete = builder.get_object("btn-delete")
|
||||||
self.ie_btn_delete.connect("clicked", self.ie_show_btn_delete_menu)
|
self.ie_btn_delete.connect("clicked", self.ie_show_btn_delete_menu)
|
||||||
self.ie_btn_import = builder.get_object("btn-import")
|
self.ie_btn_import = builder.get_object("btn-import")
|
||||||
|
self.ie_btn_import.set_label("Add to '{}'".format(self.panel["name"]))
|
||||||
self.ie_btn_import.connect("clicked", self.ie_on_import_btn)
|
self.ie_btn_import.connect("clicked", self.ie_on_import_btn)
|
||||||
|
|
||||||
def ie_on_import_btn(self, btn):
|
def ie_on_import_btn(self, btn):
|
||||||
executor = self.ie_combo.get_active_text()
|
executor = self.ie_combo.get_active_text()
|
||||||
if executor not in self.panel:
|
if executor not in self.panel:
|
||||||
print("Adding to panel")
|
self.ie_add_executor(btn, executor)
|
||||||
self.panel[executor] = self.executors_base[executor].copy()
|
|
||||||
print(self.panel)
|
|
||||||
"""for key in self.executors_base[executor]:
|
|
||||||
self.panel[executor][key] = self.executors_base[executor][key]"""
|
|
||||||
else:
|
else:
|
||||||
print("Already in panel")
|
self.ie_show_btn_import_menu(btn)
|
||||||
|
|
||||||
|
def ie_show_btn_import_menu(self, btn):
|
||||||
|
executor = self.ie_combo.get_active_text()
|
||||||
|
menu = Gtk.Menu()
|
||||||
|
item = Gtk.MenuItem.new_with_label("Replace '{}' in '{}'".format(executor, self.panel["name"]))
|
||||||
|
item.connect("activate", self.ie_add_executor, executor)
|
||||||
|
menu.append(item)
|
||||||
|
menu.set_reserve_toggle_size(False)
|
||||||
|
menu.show_all()
|
||||||
|
menu.popup_at_widget(btn, Gdk.Gravity.NORTH, Gdk.Gravity.SOUTH, None)
|
||||||
|
|
||||||
def ie_show_btn_delete_menu(self, btn):
|
def ie_show_btn_delete_menu(self, btn):
|
||||||
executor = self.ie_combo.get_active_text()
|
executor = self.ie_combo.get_active_text()
|
||||||
@@ -1651,6 +1676,10 @@ class EditorWrapper(object):
|
|||||||
menu.show_all()
|
menu.show_all()
|
||||||
menu.popup_at_widget(btn, Gdk.Gravity.NORTH, Gdk.Gravity.SOUTH, None)
|
menu.popup_at_widget(btn, Gdk.Gravity.NORTH, Gdk.Gravity.SOUTH, None)
|
||||||
|
|
||||||
|
def ie_add_executor(self, widget, executor):
|
||||||
|
self.panel[executor] = self.executors_base[executor].copy()
|
||||||
|
save_json(self.config, self.file)
|
||||||
|
|
||||||
def ie_remove_executor(self, item, executor):
|
def ie_remove_executor(self, item, executor):
|
||||||
del self.executors_base[executor]
|
del self.executors_base[executor]
|
||||||
self.ie_combo.remove_all()
|
self.ie_combo.remove_all()
|
||||||
|
@@ -2,11 +2,11 @@
|
|||||||
<!-- Generated with glade 3.38.2 -->
|
<!-- Generated with glade 3.38.2 -->
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.24"/>
|
<requires lib="gtk+" version="3.24"/>
|
||||||
<!-- n-columns=3 n-rows=14 -->
|
<!-- n-columns=3 n-rows=15 -->
|
||||||
<object class="GtkGrid" id="grid">
|
<object class="GtkGrid" id="grid">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="row-spacing">12</property>
|
<property name="row-spacing">6</property>
|
||||||
<property name="column-spacing">12</property>
|
<property name="column-spacing">12</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkEntry" id="css-name">
|
<object class="GtkEntry" id="css-name">
|
||||||
@@ -287,6 +287,9 @@ executor will create a new one.</property>
|
|||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="halign">start</property>
|
<property name="halign">start</property>
|
||||||
<property name="label" translatable="yes">Module :: Executor</property>
|
<property name="label" translatable="yes">Module :: Executor</property>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="weight" value="bold"/>
|
||||||
|
</attributes>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left-attach">0</property>
|
<property name="left-attach">0</property>
|
||||||
@@ -296,7 +299,7 @@ executor will create a new one.</property>
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCheckButton" id="remove">
|
<object class="GtkCheckButton" id="remove">
|
||||||
<property name="label" translatable="yes">Remove this executor</property>
|
<property name="label" translatable="yes">Remove executor</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">True</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="receives-default">False</property>
|
<property name="receives-default">False</property>
|
||||||
@@ -305,7 +308,6 @@ executor will create a new one.</property>
|
|||||||
<packing>
|
<packing>
|
||||||
<property name="left-attach">0</property>
|
<property name="left-attach">0</property>
|
||||||
<property name="top-attach">14</property>
|
<property name="top-attach">14</property>
|
||||||
<property name="width">2</property>
|
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@@ -378,6 +380,21 @@ executor will create a new one.</property>
|
|||||||
<property name="top-attach">11</property>
|
<property name="top-attach">11</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="save-to-database">
|
||||||
|
<property name="label" translatable="yes">Save to database</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
<property name="receives-default">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">1</property>
|
||||||
|
<property name="top-attach">14</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<placeholder/>
|
<placeholder/>
|
||||||
</child>
|
</child>
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
<requires lib="gtk+" version="3.24"/>
|
<requires lib="gtk+" version="3.24"/>
|
||||||
<object class="GtkWindow" id="main-window">
|
<object class="GtkWindow" id="main-window">
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
|
<property name="decorated">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@@ -207,7 +208,7 @@
|
|||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
<property name="padding">20</property>
|
<property name="padding">10</property>
|
||||||
<property name="position">0</property>
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
@@ -232,7 +233,7 @@
|
|||||||
<packing>
|
<packing>
|
||||||
<property name="expand">True</property>
|
<property name="expand">True</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
<property name="padding">20</property>
|
<property name="padding">10</property>
|
||||||
<property name="position">0</property>
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
@@ -276,7 +277,7 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="btn-apply">
|
<object class="GtkButton" id="btn-apply">
|
||||||
<property name="label">Save changes</property>
|
<property name="label">Apply</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">True</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="receives-default">True</property>
|
<property name="receives-default">True</property>
|
||||||
@@ -301,7 +302,7 @@
|
|||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
<property name="padding">10</property>
|
<property name="padding">6</property>
|
||||||
<property name="position">1</property>
|
<property name="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
@@ -6,14 +6,17 @@
|
|||||||
<object class="GtkGrid" id="grid">
|
<object class="GtkGrid" id="grid">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="row-spacing">10</property>
|
<property name="row-spacing">6</property>
|
||||||
<property name="column-spacing">10</property>
|
<property name="column-spacing">10</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel">
|
<object class="GtkLabel">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="halign">start</property>
|
<property name="halign">start</property>
|
||||||
<property name="label" translatable="yes">Plugins::MenuStart</property>
|
<property name="label" translatable="yes">Plugins :: MenuStart</property>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="weight" value="bold"/>
|
||||||
|
</attributes>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left-attach">0</property>
|
<property name="left-attach">0</property>
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
<object class="GtkGrid" id="grid">
|
<object class="GtkGrid" id="grid">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="row-spacing">10</property>
|
<property name="row-spacing">6</property>
|
||||||
<property name="column-spacing">10</property>
|
<property name="column-spacing">10</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel">
|
<object class="GtkLabel">
|
||||||
|
@@ -37,7 +37,7 @@
|
|||||||
<property name="homogeneous">True</property>
|
<property name="homogeneous">True</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="btn-delete">
|
<object class="GtkButton" id="btn-delete">
|
||||||
<property name="label" translatable="yes">Delete</property>
|
<property name="label" translatable="yes">Delete from database</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="sensitive">False</property>
|
<property name="sensitive">False</property>
|
||||||
<property name="can-focus">True</property>
|
<property name="can-focus">True</property>
|
||||||
|
Reference in New Issue
Block a user