diff options
author | wurstsalat <mailtrash@posteo.de> | 2022-07-27 22:30:36 +0300 |
---|---|---|
committer | wurstsalat <mailtrash@posteo.de> | 2022-07-27 22:30:40 +0300 |
commit | 8409ae2848f70fb752c60acfdc8c9e7e4e0e71c3 (patch) | |
tree | 560ae950cb30d2e356699ba4d65ab2f6f92655f0 | |
parent | 8166209581a8c3a9544b87f96352e81b8feb0997 (diff) |
imprv: Add button for toggling chat list
Fixes #11035
-rw-r--r-- | gajim/data/gui/main.ui | 118 | ||||
-rw-r--r-- | gajim/gtk/builder.pyi | 4 | ||||
-rw-r--r-- | gajim/gtk/chat_list.py | 4 | ||||
-rw-r--r-- | gajim/gtk/main.py | 18 |
4 files changed, 91 insertions, 53 deletions
diff --git a/gajim/data/gui/main.ui b/gajim/data/gui/main.ui index b693465ed..6a4609f49 100644 --- a/gajim/data/gui/main.ui +++ b/gajim/data/gui/main.ui @@ -9,7 +9,7 @@ <property name="hexpand">True</property> <property name="vexpand">True</property> <child> - <!-- n-columns=3 n-rows=3 --> + <!-- n-columns=1 n-rows=3 --> <object class="GtkGrid" id="left_grid"> <property name="visible">True</property> <property name="can-focus">False</property> @@ -17,36 +17,6 @@ <property name="orientation">vertical</property> <property name="row-spacing">12</property> <child> - <object class="GtkBox" id="account_box"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="valign">end</property> - <property name="orientation">vertical</property> - <property name="spacing">6</property> - <child> - <object class="GtkSeparator"> - <property name="visible">True</property> - <property name="can-focus">False</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <placeholder/> - </child> - <style> - <class name="account-box"/> - </style> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">2</property> - </packing> - </child> - <child> <object class="GtkScrolledWindow" id="workspace_scrolled"> <property name="visible">True</property> <property name="can-focus">True</property> @@ -98,22 +68,76 @@ </packing> </child> <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="valign">end</property> + <property name="orientation">vertical</property> + <property name="spacing">12</property> + <child> + <object class="GtkBox" id="account_box"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="valign">end</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkSeparator"> + <property name="visible">True</property> + <property name="can-focus">False</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <placeholder/> + </child> + <style> + <class name="account-box"/> + </style> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack-type">end</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="toggle_chat_list_button"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="tooltip-text" translatable="yes">Hide chat list</property> + <property name="halign">center</property> + <property name="action-name">win.toggle-chat-list</property> + <property name="relief">none</property> + <child> + <object class="GtkImage" id="toggle_chat_list_icon"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="icon-name">go-previous-symbolic</property> + </object> + </child> + <style> + <class name="flat"/> + </style> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack-type">end</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">2</property> + </packing> </child> <style> <class name="chatlist-left-grid"/> diff --git a/gajim/gtk/builder.pyi b/gajim/gtk/builder.pyi index bc86eb839..690e78b7d 100644 --- a/gajim/gtk/builder.pyi +++ b/gajim/gtk/builder.pyi @@ -600,9 +600,11 @@ class HistoryExportBuilder(Builder): class MainBuilder(Builder): main_grid: Gtk.Grid left_grid: Gtk.Grid - account_box: Gtk.Box workspace_scrolled: Gtk.ScrolledWindow app_box: Gtk.Box + account_box: Gtk.Box + toggle_chat_list_button: Gtk.Button + toggle_chat_list_icon: Gtk.Image class MamPreferencesBuilder(Builder): diff --git a/gajim/gtk/chat_list.py b/gajim/gtk/chat_list.py index 4f88d9e9c..f7e764f46 100644 --- a/gajim/gtk/chat_list.py +++ b/gajim/gtk/chat_list.py @@ -143,10 +143,6 @@ class ChatList(Gtk.ListBox, EventHelper): self._workspace_id, count) - def is_visible(self) -> bool: - chat_list = cast(ChatList, self.get_parent()) - return chat_list.get_property('child-widget') == self - def _on_destroy(self, _widget: Gtk.Widget) -> None: GLib.source_remove(self._timer_id) diff --git a/gajim/gtk/main.py b/gajim/gtk/main.py index 11a8d192a..40038c90b 100644 --- a/gajim/gtk/main.py +++ b/gajim/gtk/main.py @@ -405,10 +405,26 @@ class MainWindow(Gtk.ApplicationWindow, EventHelper): self.select_chat_number(number) elif action_name == 'toggle-chat-list': - self._chat_page.toggle_chat_list() + self._toggle_chat_list() return None + def _toggle_chat_list(self) -> None: + chat_list_stack = self._chat_page.get_chat_list_stack() + chat_list = chat_list_stack.get_current_chat_list() + if chat_list is not None: + if chat_list.is_visible(): + self._ui.toggle_chat_list_button.set_tooltip_text( + _('Show chat list')) + self._ui.toggle_chat_list_icon.set_from_icon_name( + 'go-next-symbolic', Gtk.IconSize.BUTTON) + else: + self._ui.toggle_chat_list_button.set_tooltip_text( + _('Hide chat list')) + self._ui.toggle_chat_list_icon.set_from_icon_name( + 'go-previous-symbolic', Gtk.IconSize.BUTTON) + self._chat_page.toggle_chat_list() + def _on_window_motion_notify(self, _widget: Gtk.ApplicationWindow, _event: Gdk.EventMotion |