Daniel Brötzmann pushed to branch gtk4 at gajim / gajim


Commits:
f28c38b1 by wurstsalat at 2024-10-06T12:46:39+02:00
refactor: Use GajimAppWindow in WorkspaceDialog

- - - - -


2 changed files:

- gajim/data/gui/workspace_dialog.ui
- gajim/gtk/workspace_dialog.py


Changes:

=====================================
gajim/data/gui/workspace_dialog.ui
=====================================
@@ -3,6 +3,7 @@
   <requires lib="gtk" version="4.0"/>
   <object class="GtkBox" id="box">
     <property name="orientation">vertical</property>
+    <property name="hexpand">1</property>
     <property name="spacing">12</property>
     <child>
       <object class="GtkImage" id="preview"/>
@@ -118,6 +119,9 @@
     </child>
     <child>
       <object class="GtkBox">
+        <property name="spacing">12</property>
+        <property name="homogeneous">1</property>
+        <property name="halign">end</property>
         <child>
           <object class="GtkButton">
             <property name="label" translatable="1">_Cancel</property>
@@ -140,8 +144,5 @@
         </child>
       </object>
     </child>
-    <style>
-      <class name="padding-18"/>
-    </style>
   </object>
 </interface>


=====================================
gajim/gtk/workspace_dialog.py
=====================================
@@ -4,7 +4,6 @@
 
 from typing import Any
 
-from gi.repository import Gdk
 from gi.repository import Gtk
 
 from gajim.common import app
@@ -17,16 +16,18 @@
 from gajim.gtk.const import DEFAULT_WORKSPACE_COLOR
 from gajim.gtk.util import make_rgba
 from gajim.gtk.util import rgba_to_float
+from gajim.gtk.widgets import GajimAppWindow
 
 
-class WorkspaceDialog(Gtk.ApplicationWindow):
+class WorkspaceDialog(GajimAppWindow):
     def __init__(self, workspace_id: str | None = None) -> None:
-        Gtk.ApplicationWindow.__init__(self)
-        self.set_name('WorkspaceDialog')
-        self.set_application(app.app)
-        self.set_show_menubar(False)
-        self.set_title(_('Workspace Settings'))
-        self.set_size_request(500, 600)
+        GajimAppWindow.__init__(
+            self,
+            name='WorkspaceDialog',
+            title=_('Workspace Settings'),
+            default_width=500,
+            default_height=600,
+        )
 
         self._workspace_id = workspace_id
 
@@ -66,14 +67,8 @@ def __init__(self, workspace_id: str | None = None) -> None:
         self._ui.entry.set_text(name)
         self._ui.color_chooser.set_rgba(rgba)
         self._update_avatar()
-        # self._ui.save_button.grab_default() GTK4 TODO
 
-        # self.connect('key-press-event', self._on_key_press)
-        self.show()
-
-    def _on_key_press(self, _widget: Gtk.Widget, event: Any) -> None:
-        if event.keyval == Gdk.KEY_Escape:
-            self.destroy()
+        self.set_default_widget(self._ui.save_button)
 
     def _on_remove_workspace(self, _button: Gtk.Button) -> None:
         assert self._workspace_id is not None



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/f28c38b1d38f9a007e88031049a36608fdf4a0ff

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/f28c38b1d38f9a007e88031049a36608fdf4a0ff
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to