Fixed chat context menu and added stuff to secondary menu
This commit is contained in:
parent
dd20ff78c4
commit
f9b3f91d3f
@ -971,16 +971,22 @@ class AlpacaWindow(Adw.ApplicationWindow):
|
|||||||
self.manage_models_dialog.close()
|
self.manage_models_dialog.close()
|
||||||
self.connection_error()
|
self.connection_error()
|
||||||
|
|
||||||
def chat_click_handler(self, gesture, n_press, x, y, chat_label, popover):
|
def chat_click_handler(self, gesture, n_press, x, y):
|
||||||
self.right_clicked_chat_label = chat_label
|
chat_row = gesture.get_widget()
|
||||||
|
popover = Gtk.PopoverMenu(
|
||||||
|
menu_model=self.right_click_menu,
|
||||||
|
has_arrow=False,
|
||||||
|
halign=1,
|
||||||
|
)
|
||||||
|
self.right_clicked_chat_row = chat_row
|
||||||
position = Gdk.Rectangle()
|
position = Gdk.Rectangle()
|
||||||
position.x = x
|
position.x = x
|
||||||
position.y = y
|
position.y = y
|
||||||
|
popover.set_parent(chat_row.get_child())
|
||||||
popover.set_pointing_to(position)
|
popover.set_pointing_to(position)
|
||||||
popover.popup()
|
popover.popup()
|
||||||
|
|
||||||
def new_chat_element(self, chat_name:str, select:bool):
|
def new_chat_element(self, chat_name:str, select:bool):
|
||||||
chat_box = Gtk.Box()
|
|
||||||
chat_label = Gtk.Label(
|
chat_label = Gtk.Label(
|
||||||
label=chat_name,
|
label=chat_name,
|
||||||
hexpand=True,
|
hexpand=True,
|
||||||
@ -990,21 +996,15 @@ class AlpacaWindow(Adw.ApplicationWindow):
|
|||||||
wrap_mode=2,
|
wrap_mode=2,
|
||||||
xalign=0
|
xalign=0
|
||||||
)
|
)
|
||||||
chat_box.append(chat_label)
|
|
||||||
popover = Gtk.PopoverMenu(
|
|
||||||
menu_model=self.right_click_menu,
|
|
||||||
has_arrow=False,
|
|
||||||
halign=1
|
|
||||||
)
|
|
||||||
chat_box.append(popover)
|
|
||||||
chat_row = Gtk.ListBoxRow(
|
chat_row = Gtk.ListBoxRow(
|
||||||
css_classes = ["chat_row"],
|
css_classes = ["chat_row"],
|
||||||
height_request = 45,
|
height_request = 45,
|
||||||
child = chat_box,
|
child = chat_label,
|
||||||
name = chat_name
|
name = chat_name
|
||||||
)
|
)
|
||||||
|
|
||||||
gesture = Gtk.GestureClick(button=3)
|
gesture = Gtk.GestureClick(button=3)
|
||||||
gesture.connect("pressed", lambda gesture, n_press, x, y, chat_label=chat_label, popover=popover : self.chat_click_handler(gesture, n_press, x, y, chat_label, popover))
|
gesture.connect("released", self.chat_click_handler)
|
||||||
chat_row.add_controller(gesture)
|
chat_row.add_controller(gesture)
|
||||||
|
|
||||||
self.chat_list_box.append(chat_row)
|
self.chat_list_box.append(chat_row)
|
||||||
@ -1219,13 +1219,16 @@ class AlpacaWindow(Adw.ApplicationWindow):
|
|||||||
|
|
||||||
def chat_actions(self, action, user_data):
|
def chat_actions(self, action, user_data):
|
||||||
action_name = action.get_name()
|
action_name = action.get_name()
|
||||||
chat_label = self.right_clicked_chat_label
|
if self.right_clicked_chat_row:
|
||||||
chat_name = chat_label.get_parent().get_parent().get_name()
|
chat_row = self.right_clicked_chat_row
|
||||||
self.right_clicked_chat_label = None
|
else:
|
||||||
|
chat_row = self.chat_list_box.get_selected_row()
|
||||||
|
chat_name = chat_row.get_name()
|
||||||
|
self.right_clicked_chat_row = None
|
||||||
if action_name == 'delete_chat':
|
if action_name == 'delete_chat':
|
||||||
dialogs.delete_chat(self, chat_name)
|
dialogs.delete_chat(self, chat_name)
|
||||||
elif action_name == 'rename_chat':
|
elif action_name == 'rename_chat':
|
||||||
dialogs.rename_chat(self, chat_name, chat_label)
|
dialogs.rename_chat(self, chat_name, chat_row.get_child())
|
||||||
elif action_name == 'export_chat':
|
elif action_name == 'export_chat':
|
||||||
self.export_chat(chat_name)
|
self.export_chat(chat_name)
|
||||||
|
|
||||||
|
@ -114,7 +114,12 @@
|
|||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
<child type="end">
|
<child type="end">
|
||||||
|
<object class="GtkMenuButton">
|
||||||
|
<property name="primary">False</property>
|
||||||
|
<property name="icon-name">open-menu-symbolic</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Chat Menu</property>
|
||||||
|
<property name="menu-model">secondary_menu</property>
|
||||||
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
@ -855,10 +860,8 @@
|
|||||||
<attribute name="label" translatable="yes">Import chat</attribute>
|
<attribute name="label" translatable="yes">Import chat</attribute>
|
||||||
<attribute name="action">app.import_chat</attribute>
|
<attribute name="action">app.import_chat</attribute>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
</section>
|
||||||
<attribute name="label" translatable="yes">Clear chat</attribute>
|
<section>
|
||||||
<attribute name="action">app.clear</attribute>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<attribute name="label" translatable="yes">Preferences</attribute>
|
<attribute name="label" translatable="yes">Preferences</attribute>
|
||||||
<attribute name="action">app.preferences</attribute>
|
<attribute name="action">app.preferences</attribute>
|
||||||
@ -873,6 +876,20 @@
|
|||||||
</item>
|
</item>
|
||||||
</section>
|
</section>
|
||||||
</menu>
|
</menu>
|
||||||
|
<menu id="secondary_menu">
|
||||||
|
<item>
|
||||||
|
<attribute name="label" translatable="yes">Rename chat</attribute>
|
||||||
|
<attribute name="action">app.rename_chat</attribute>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<attribute name="label" translatable="yes">Export chat</attribute>
|
||||||
|
<attribute name="action">app.export_chat</attribute>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<attribute name="label" translatable="yes">Clear chat</attribute>
|
||||||
|
<attribute name="action">app.clear</attribute>
|
||||||
|
</item>
|
||||||
|
</menu>
|
||||||
<menu id="right_click_menu">
|
<menu id="right_click_menu">
|
||||||
<section>
|
<section>
|
||||||
<item>
|
<item>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user