Changed export/import buttons for a secundary menu button

This commit is contained in:
jeffser 2024-05-29 15:00:19 -06:00
parent a180f7a46c
commit 3a5dc568c5
2 changed files with 16 additions and 24 deletions

View File

@ -87,8 +87,6 @@ class AlpacaWindow(Adw.ApplicationWindow):
chat_list_box = Gtk.Template.Child() chat_list_box = Gtk.Template.Child()
add_chat_button = Gtk.Template.Child() add_chat_button = Gtk.Template.Child()
export_chat_button = Gtk.Template.Child()
import_chat_button = Gtk.Template.Child()
loading_spinner = None loading_spinner = None
@ -542,7 +540,7 @@ class AlpacaWindow(Adw.ApplicationWindow):
self.chats["chats"][self.chats["selected_chat"]]["messages"][-1]['content'] += data['message']['content'] self.chats["chats"][self.chats["selected_chat"]]["messages"][-1]['content'] += data['message']['content']
def toggle_ui_sensitive(self, status): def toggle_ui_sensitive(self, status):
for element in [self.chat_list_box, self.export_chat_button, self.import_chat_button, self.add_chat_button]: for element in [self.chat_list_box, self.add_chat_button]:
element.set_sensitive(status) element.set_sensitive(status)
def switch_send_stop_button(self): def switch_send_stop_button(self):
@ -882,11 +880,10 @@ class AlpacaWindow(Adw.ApplicationWindow):
self.get_application().create_action('new_chat', lambda *_: self.new_chat(), ['<primary>n']) self.get_application().create_action('new_chat', lambda *_: self.new_chat(), ['<primary>n'])
self.get_application().create_action('clear', lambda *_: dialogs.clear_chat(self), ['<primary>e']) self.get_application().create_action('clear', lambda *_: dialogs.clear_chat(self), ['<primary>e'])
self.get_application().create_action('send', lambda *_: self.send_message(self), ['Return']) self.get_application().create_action('send', lambda *_: self.send_message(self), ['Return'])
self.get_application().create_action('export_current_chat', lambda *_: self.export_current_chat())
self.get_application().create_action('import_chat', lambda *_: self.import_chat())
self.add_chat_button.connect("clicked", lambda button : self.new_chat()) self.add_chat_button.connect("clicked", lambda button : self.new_chat())
self.export_chat_button.connect("clicked", lambda button : self.export_current_chat())
self.import_chat_button.connect("clicked", lambda button : self.import_chat())
self.remote_connection_entry.connect("entry-activated", lambda entry : entry.set_css_classes([])) self.remote_connection_entry.connect("entry-activated", lambda entry : entry.set_css_classes([]))
self.remote_connection_switch.connect("notify", lambda pspec, user_data : self.connection_switched()) self.remote_connection_switch.connect("notify", lambda pspec, user_data : self.connection_switched())
self.background_switch.connect("notify", lambda pspec, user_data : self.switch_run_on_background()) self.background_switch.connect("notify", lambda pspec, user_data : self.switch_run_on_background())

View File

@ -44,21 +44,11 @@
</object> </object>
</child> </child>
<child type="end"> <child type="end">
<object class="GtkButton" id="import_chat_button"> <object class="GtkMenuButton" id="chats_menu_button">
<property name="tooltip-text" translatable="yes">Import chat</property> <property name="direction">1</property>
<property name="icon-name">document-open-symbolic</property> <property name="halign">3</property>
<style> <property name="menu-model">chats_button_menu</property>
<class name="flat"/> <property name="icon-name">view-more-symbolic</property>
</style>
</object>
</child>
<child type="end">
<object class="GtkButton" id="export_chat_button">
<property name="tooltip-text" translatable="yes">Export chat</property>
<property name="icon-name">folder-download-symbolic</property>
<style>
<class name="flat"/>
</style>
</object> </object>
</child> </child>
</object> </object>
@ -113,7 +103,7 @@
<property name="tooltip-text" translatable="yes">Manage models</property> <property name="tooltip-text" translatable="yes">Manage models</property>
<child> <child>
<object class="AdwButtonContent"> <object class="AdwButtonContent">
<property name="icon-name">package-x-generic-symbolic</property> <property name="icon-name">view-more-horizontal-symbolic</property>
</object> </object>
</child> </child>
</object> </object>
@ -632,10 +622,15 @@
</item> </item>
</section> </section>
</menu> </menu>
<menu id="chat_context_menu"> <menu id="chats_button_menu">
<section> <section>
<item> <item>
<attribute name="label" translatable="yes">Remove</attribute> <attribute name="label" translatable="yes">Export current chat</attribute>
<attribute name="action">app.export_current_chat</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Import chat</attribute>
<attribute name="action">app.import_chat</attribute>
</item> </item>
</section> </section>
</menu> </menu>