Philipp Hörist pushed to branch gtk4 at gajim / gajim
Commits:
ed76908f by Philipp Hörist at 2024-10-06T16:16:10+02:00
refactor: Fix MainMenuButton
- - - - -
3 changed files:
- gajim/gtk/builder.py
- gajim/gtk/main_menu_button.py
- gajim/gtk/widgets.py
Changes:
=====================================
gajim/gtk/builder.py
=====================================
@@ -5,6 +5,7 @@
from typing import Any
import functools
+import logging
import sys
import xml.etree.ElementTree as ET
@@ -16,6 +17,9 @@
from gajim.common.i18n import _
+log = logging.getLogger('gajim.gtk')
+
+
class Builder:
filename = ''
@@ -41,6 +45,8 @@ def __init__(self,
xml_text = self._load_string_from_filename(filename, gettext_)
+ log.debug('Load ui file: %s', filename)
+
if widgets is not None:
self._builder.add_objects_from_string(xml_text, widgets)
else:
=====================================
gajim/gtk/main_menu_button.py
=====================================
@@ -2,6 +2,8 @@
#
# SPDX-License-Identifier: GPL-3.0-only
+from __future__ import annotations
+
from gi.repository import Gio
from gi.repository import GLib
from gi.repository import Gtk
@@ -12,13 +14,19 @@
class MainMenuButton(Gtk.MenuButton):
def __init__(self) -> None:
Gtk.MenuButton.__init__(
- self, halign=Gtk.Align.CENTER, visible=False, margin_top=12
+ self,
+ halign=Gtk.Align.CENTER,
+ margin_top=12,
+ icon_name='open-menu-symbolic',
)
- image = Gtk.Image.new_from_icon_name('open-menu-symbolic')
- self.set_child(image)
+ menu_model = app.app.get_menubar()
+ assert menu_model is not None
+
+ menu = Gtk.PopoverMenu.new_from_model_full(
+ menu_model, Gtk.PopoverMenuFlags.NESTED)
- self.set_menu_model(app.app.get_menubar())
+ self.set_popover(menu)
menu_toggle_action = app.window.lookup_action('toggle-menu-bar')
assert menu_toggle_action is not None
@@ -29,7 +37,4 @@ def __init__(self) -> None:
def _on_menu_toggle_action(
self, _action: Gio.SimpleAction, _param: GLib.Variant | None
) -> None:
- if app.window.get_show_menubar():
- self.hide()
- else:
- self.show()
+ self.set_visible(not app.window.get_show_menubar())
=====================================
gajim/gtk/widgets.py
=====================================
@@ -4,6 +4,8 @@
from __future__ import annotations
+import logging
+
from gi.repository import Gdk
from gi.repository import Gtk
@@ -12,6 +14,9 @@
from gajim.gtk.util import iterate_children
+log = logging.getLogger('gajim.gtk')
+
+
class GajimAppWindow(Gtk.ApplicationWindow):
def __init__(
self,
@@ -33,6 +38,9 @@ def __init__(
default_height=default_height,
transient_for=transient_for,
)
+
+ log.debug('Load Window: %s', name)
+
self.add_css_class('gajim-app-window')
if add_window_padding:
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/ed76908f87485e28838b56aa9bc36919bc7972df
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/ed76908f87485e28838b56aa9bc36919bc7972df
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]