Philipp Hörist pushed to branch gtk4 at gajim / gajim


Commits:
3f2ba779 by Philipp Hörist at 2024-10-25T17:10:06+02:00
asd

- - - - -
df763b39 by Philipp Hörist at 2024-10-25T17:59:55+02:00
fix: Simplify key handling on main window

- - - - -


2 changed files:

- gajim/gtk/main.py
- gajim/gtk/util.py


Changes:

=====================================
gajim/gtk/main.py
=====================================
@@ -122,7 +122,7 @@ def __init__(self) -> None:
         self.add_controller(controller)
 
         controller = Gtk.EventControllerKey(
-            propagation_phase=Gtk.PropagationPhase.CAPTURE
+            propagation_phase=Gtk.PropagationPhase.BUBBLE
         )
         controller.connect('key-pressed', self._on_key_pressed)
         self.add_controller(controller)
@@ -275,41 +275,12 @@ def _on_key_pressed(
         _keycode: int,
         state: Gdk.ModifierType
     ) -> bool:
-        # event.get_state() behaves different on Linux and Windows.
-        # On Linux its not set in the case that only a modifier key
-        # is pressed.
-        # Filter out modifier not used for shortcuts like Numlock (MOD2)
-        modifier = state & Gtk.accelerator_get_default_mod_mask()
-        accel_name = Gtk.accelerator_name(keyval, modifier)
-
-        log.info('Captured key pressed: %s', accel_name)
-
-        if keyval in (
-            Gdk.KEY_Control_L,
-            Gdk.KEY_Control_R,
-            Gdk.KEY_Alt_L,
-            Gdk.KEY_Alt_R,
-            Gdk.KEY_Shift_L,
-            Gdk.KEY_Shift_R,
-        ):
-            return Gdk.EVENT_PROPAGATE
-
-        focused_widget = self.get_focus()
-        if (isinstance(focused_widget, Gtk.TextView)
-            and focused_widget.props.editable):
-                return Gdk.EVENT_PROPAGATE
-
-        if isinstance(focused_widget, Gtk.Entry | Gtk.SearchEntry):
-            return Gdk.EVENT_PROPAGATE
-
-        message_input = self.get_chat_stack().get_message_input()
-        if not message_input.get_mapped() or not message_input.is_sensitive():
-            return Gdk.EVENT_PROPAGATE
-
-        message_input.grab_focus()
-        # TODO GTK4
-        # return self.propagate_key_event(event)
-        return Gdk.EVENT_STOP
+
+        if keyval == Gdk.KEY_space:
+            self.get_chat_stack().get_message_input().grab_focus()
+            return Gdk.EVENT_STOP
+
+        return Gdk.EVENT_PROPAGATE
 
     def _on_client_state_changed(self,
                                  client: Client,


=====================================
gajim/gtk/util.py
=====================================
@@ -1009,6 +1009,13 @@ def convert_surface_to_texture(surface: 
cairo.ImageSurface) -> Gdk.Texture:
     )
 
 
+def draw_icon_to_context(context: cairo.Context, icon: Gtk.IconPaintable, 
size: int) -> Any:
+    snapshot = Gtk.Snapshot()
+    icon.snapshot(snapshot, size, size)
+    node = snapshot.to_node()
+    node.draw(context)
+
+
 def convert_glib_to_py_datetime(dt: datetime.datetime | datetime.date) -> 
GLib.DateTime:
     iso = dt.isoformat()
     g_dt = GLib.DateTime.new_from_iso8601(iso)



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/e872b979e6d7735c9d6cac973ac2fbaa4bea9ef9...df763b39ec84a1a49fccf123dd236149ad8faccf

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/e872b979e6d7735c9d6cac973ac2fbaa4bea9ef9...df763b39ec84a1a49fccf123dd236149ad8faccf
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