Commit 741f73fa authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui

properly handle init_template for composite widgets

init_template is not properly handled on pygobject side.
Along other small fixes from my the latest commit
parent f16972d7
Pipeline #56147 failed with stages
in 3 minutes and 31 seconds
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.0 -->
<interface>
<requires lib="gtk+" version="3.2"/>
<requires lib="gtk+" version="3.10"/>
<template class="AddConnectionDialog" parent="GtkDialog">
<property name="can_focus">False</property>
<property name="border_width">5</property>
......@@ -56,8 +56,8 @@
<object class="GtkComboBoxText" id="address_combo_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="active">0</property>
<property name="has_entry">True</property>
<property name="active_id">0</property>
<child internal-child="entry">
<object class="GtkEntry">
<property name="can_focus">False</property>
......
......@@ -35,6 +35,7 @@
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkListBox" id="bus_listbox">
<property name="visible">True</property>
......
......@@ -2,6 +2,13 @@
<!-- Generated with glade 3.22.0 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkAdjustment" id="adjustment1">
<property name="lower">1</property>
<property name="upper">100</property>
<property name="value">1</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<template class="ExecuteMethodDialog" parent="GtkDialog">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Execute D-Bus Method</property>
......@@ -336,9 +343,7 @@
<object class="GtkLabel" id="label_method_name">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_left">5</property>
<property name="margin_start">5</property>
<property name="halign">baseline</property>
<property name="use_markup">True</property>
<property name="wrap">True</property>
<property name="selectable">True</property>
......@@ -399,9 +404,7 @@
<object class="GtkLabel" id="label_object_path">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_left">5</property>
<property name="margin_start">5</property>
<property name="halign">baseline</property>
<property name="use_markup">True</property>
<property name="selectable">True</property>
</object>
......@@ -415,8 +418,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_left">5</property>
<property name="margin_start">5</property>
<property name="use_markup">True</property>
<property name="selectable">True</property>
</object>
......@@ -444,9 +445,7 @@
<object class="GtkLabel" id="label_bus_name">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_left">5</property>
<property name="margin_start">5</property>
<property name="halign">baseline</property>
<property name="use_markup">True</property>
<property name="selectable">True</property>
</object>
......@@ -479,11 +478,4 @@
<placeholder/>
</child>
</template>
<object class="GtkAdjustment" id="adjustment1">
<property name="lower">1</property>
<property name="upper">100</property>
<property name="value">1</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
</interface>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<!-- Generated with glade 3.22.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkMessageDialog" id="messagedialog">
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="border_width">5</property>
<property name="type_hint">dialog</property>
<property name="skip_taskbar_hint">True</property>
<property name="message_type">error</property>
<property name="buttons">close</property>
<child internal-child="vbox">
<object class="GtkBox" id="messagedialog-vbox">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="messagedialog-action_area">
<property name="can_focus">False</property>
</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>
</object>
</child>
</object>
<requires lib="gtk+" version="3.12"/>
<object class="GtkTreeStore" id="treestore">
<columns>
<!-- column-name gchararray1 -->
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.0 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<requires lib="gtk+" version="3.12" />
<object class="GtkPopoverMenu" id="popover1">
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin">6</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkModelButton">
<property name="visible">True</property>
<property name="action_name">win.connect-system-bus</property>
<property name="text" translatable="yes">Connect to System Bus</property>
</object>
</child>
<child>
<object class="GtkModelButton">
<property name="visible">True</property>
<property name="action_name">win.connect-session-bus</property>
<property name="text" translatable="yes">Connect to Session Bus</property>
</object>
</child>
<child>
<object class="GtkModelButton">
<property name="visible">True</property>
<property name="action_name">win.connect-other-bus</property>
<property name="text" translatable="yes">Connect to other Bus</property>
</object>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
</object>
</child>
<child>
<object class="GtkModelButton">
<property name="visible">True</property>
<property name="action_name">win.close-bus</property>
<property name="text" translatable="yes">Close Bus</property>
</object>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
</object>
</child>
<child>
<object class="GtkModelButton">
<property name="visible">True</property>
<property name="action_name">app.help</property>
<property name="text" translatable="yes">Help</property>
</object>
</child>
<child>
<object class="GtkModelButton">
<property name="visible">True</property>
<property name="action_name">app.about</property>
<property name="text" translatable="yes">About D-Feet</property>
</object>
</child>
</object>
</child>
</object>
<template class="DFeetWindow" parent="GtkApplicationWindow">
<property name="can_focus">False</property>
<property name="default_width">600</property>
<property name="default_height">480</property>
<signal name="delete-event" handler="window_deleted" swapped="no"/>
<signal name="destroy" handler="window_destroyed" swapped="no"/>
<property name="icon_name">org.gnome.dfeet</property>
<signal name="delete-event" handler="window_deleted" swapped="no" />
<child>
<object class="GtkStack" id="buses_stack">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="transition_duration">300</property>
<property name="transition_type">slide-left-right</property>
<signal name="add" handler="stack_child_added" swapped="no"/>
<signal name="remove" handler="stack_child_removed" swapped="no"/>
<signal name="add" handler="stack_child_added" swapped="no" />
<signal name="remove" handler="stack_child_removed" swapped="no" />
<child>
<placeholder/>
<placeholder />
</child>
</object>
</child>
......@@ -40,7 +103,7 @@
<property name="can_focus">False</property>
<property name="receives_default">False</property>
<property name="valign">center</property>
<property name="action_name">win.gear-menu</property>
<property name="popover">popover1</property>
<child>
<object class="GtkImage" id="gear_image">
<property name="visible">True</property>
......@@ -60,4 +123,4 @@
</object>
</child>
</template>
</interface>
</interface>
\ No newline at end of file
......@@ -9,6 +9,7 @@ class AddConnectionDialog(Gtk.Dialog):
address_combo_box = Gtk.Template.Child()
def __init__(self, parent, address_bus_history=[]):
super(AddConnectionDialog, self).__init__()
self.init_template('AddConnectionDialog')
self.set_transient_for(parent)
address_combo_box_store = Gtk.ListStore(str)
......@@ -16,11 +17,8 @@ class AddConnectionDialog(Gtk.Dialog):
for el in address_bus_history:
address_combo_box_store.append([el])
self.address_combo_box.set_entry_text_column(0)
self.address_combo_box.set_model(address_combo_box_store)
self.dialog.add_button('gtk-cancel', Gtk.ResponseType.CANCEL)
self.dialog.add_button('gtk-connect', Gtk.ResponseType.OK)
@property
def address(self):
......@@ -32,7 +30,7 @@ class AddConnectionDialog(Gtk.Dialog):
entry = self.address_combo_box.get_child()
return entry.get_text()
def run(self):
def start(self):
response = self.run()
if response == Gtk.ResponseType.CANCEL:
return response
......@@ -46,5 +44,5 @@ class AddConnectionDialog(Gtk.Dialog):
else:
return Gtk.ResponseType.OK
def destroy(self):
def quit(self):
self.destroy()
......@@ -19,7 +19,8 @@ class DFeetApp(Gtk.Application):
# Note that the function in C activate() becomes do_activate() in Python
def do_activate(self):
self._main_win = DFeetWindow(self, self.version)
self._main_win = DFeetWindow()
self._main_win.set_application(self)
# Note that the function in C startup() becomes do_startup() in Python
def do_startup(self):
......
......@@ -20,13 +20,13 @@ class BusNameBox(Gtk.Box):
self.__icon_table = IconTable.get_instance()
self.__icon_image = Gtk.Image.new_from_pixbuf(self.__icon_table.default_icon)
self.__hbox = Gtk.Box(orientation=Gtk.Box.Orientation.HORIZONTAL,
self.__hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL,
spacing=5, halign=Gtk.Align.START)
self.pack_start(self.__hbox, True, True, 0)
# icon
self.__hbox.pack_start(self.__icon_image, True, True, 0)
# other information
self.__vbox_right = Gtk.Box(orientation=Gtk.Box.Orientation.VERTICAL,
self.__vbox_right = Gtk.Box(orientation=Gtk.Orientation.VERTICAL,
spacing=5, expand=True)
self.__hbox.pack_start(self.__vbox_right, True, True, 0)
......@@ -123,10 +123,10 @@ class BusWatch(Gtk.Box):
"""watch for a given bus"""
def __init__(self, bus_address):
super(BusWatch, self).__init__()
self.init_template('BusWatch')
self.__bus_address = bus_address
# create a listbox for all the busnames
listbox = Gtk.Template.Child('scrolledwindow_listbox').get_children()
self.bus_listbox.set_sort_func(self.__listbox_sort_by_name, None)
self.bus_listbox.set_filter_func(self.__listbox_filter_by_name, None)
......@@ -198,7 +198,7 @@ class BusWatch(Gtk.Box):
bus_name_box.bus_name,
bus_name_box.unique_name,
connection_is_bus=True)
self.pack_end(self.__addr_info.introspect_box, True, True, 0)
self.pack_end(self.__addr_info, True, True, 0)
self.show_all()
def __name_owner_changed_cb(self, connection, sender_name,
......
......@@ -28,6 +28,7 @@ class ExecuteMethodDialog(Gtk.Dialog):
def __init__(self, connection, connection_is_bus, bus_name,
method_obj, parent_window):
super(ExecuteMethodDialog, self).__init__()
self.init_template('ExecuteMethodDialog')
self.set_transient_for(parent_window)
......@@ -124,12 +125,7 @@ class ExecuteMethodDialog(Gtk.Dialog):
# output the exception
self.source_textview.get_buffer().set_text(str(e))
self.prettyprint_textview.get_buffer().set_text(pformat(str(e)))
def run(self):
response = self.run()
if response == Gtk.ResponseType.DELETE_EVENT or response == Gtk.ResponseType.CLOSE:
self.destroy()
@Gtk.Template.Callback('execute_dialog_close_cb')
def close_cb(self, widget):
self.destroy()
......@@ -35,12 +35,13 @@ class AddressInfo(Gtk.Box):
def __init__(self, address, name, unique_name, connection_is_bus=True):
super(AddressInfo, self).__init__()
self.init_template('AddressInfo')
self.address = address # can be Gio.BusType.SYSTEM or Gio.BusType.SYSTEM or other address
self.name = name # the well-known name or None
self.unique_name = unique_name # the unique name or None
self.connection_is_bus = connection_is_bus # is it a bus or a p2p connection?
self.treemodel.set_sort_func(0, self.__sort_model)
self.treemodel.set_sort_column_id(0, Gtk.SortType.ASCENDING)
......@@ -147,7 +148,7 @@ class AddressInfo(Gtk.Box):
def introspect_start(self):
"""introspect the given bus name and update the tree model"""
# cleanup current tree model
self.__treemodel.clear()
self.treemodel.clear()
# Statistics
self.__get_stats()
......@@ -178,58 +179,58 @@ class AddressInfo(Gtk.Box):
tree_iter = None
if len(node_info.interfaces) > 0:
node_obj = DBusNode(self.name, object_path, node_info)
tree_iter = self.__treemodel.append(tree_iter, ["%s" % object_path, node_obj])
# tree_iter = self.__treemodel.append(tree_iter, ["Hallo", None])
tree_iter = self.treemodel.append(tree_iter, ["%s" % object_path, node_obj])
# tree_iter = self.treemodel.append(tree_iter, ["Hallo", None])
# append interfaces to tree model
name_iter = self.__treemodel.append(tree_iter,
name_iter = self.treemodel.append(tree_iter,
["<b>Interfaces</b>", None])
for iface in node_info.interfaces:
iface_obj = DBusInterface(node_obj, iface)
iface_iter = self.__treemodel.append(
iface_iter = self.treemodel.append(
name_iter,
["%s" % iface.name, iface_obj])
# interface methods
if len(iface.methods) > 0:
iface_methods_iter = self.__treemodel.append(
iface_methods_iter = self.treemodel.append(
iface_iter, ["<b>Methods</b>", None])
for iface_method in iface.methods:
method_obj = DBusMethod(iface_obj, iface_method)
self.__treemodel.append(
self.treemodel.append(
iface_methods_iter,
["%s" % method_obj.markup_str, method_obj])
# interface signals
if len(iface.signals) > 0:
iface_signals_iter = self.__treemodel.append(
iface_signals_iter = self.treemodel.append(
iface_iter, ["<b>Signals</b>", None])
for iface_signal in iface.signals:
signal_obj = DBusSignal(iface_obj, iface_signal)
self.__treemodel.append(
self.treemodel.append(
iface_signals_iter,
["%s" % signal_obj.markup_str, signal_obj])
# interface properties
if len(iface.properties) > 0:
iface_properties_iter = self.__treemodel.append(
iface_properties_iter = self.treemodel.append(
iface_iter, ["<b>Properties</b>", None])
for iface_property in iface.properties:
property_obj = DBusProperty(iface_obj, iface_property)
self.__treemodel.append(
self.treemodel.append(
iface_properties_iter,
["%s" % property_obj.markup_str, property_obj])
# interface annotations
if len(iface.annotations) > 0:
iface_annotations_iter = self.__treemodel.append(
iface_annotations_iter = self.treemodel.append(
iface_iter, ["<b>Annotations</b>", None])
for iface_annotation in iface.annotations:
annotation_obj = DBusAnnotation(iface_obj, iface_annotation)
self.__treemodel.append(
self.treemodel.append(
iface_annotations_iter,
["%s" % (annotation_obj.markup_str), annotation_obj])
# are more nodes left?
if len(node_info.nodes) > 0:
for node in node_info.nodes:
# node_iter = self.__treemodel.append(tree_iter, [node.path, node])
# node_iter = self.treemodel.append(tree_iter, [node.path, node])
if object_path == "/":
object_path = ""
object_path_new = object_path + "/" + node.path
......@@ -263,9 +264,9 @@ class AddressInfo(Gtk.Box):
# The stats interface might not be enabled. Ignore.
pass
else:
stats_iter = self.__treemodel.append(None, ["<b>Statistics</b>", None])
stats_iter = self.treemodel.append(None, ["<b>Statistics</b>", None])
for k, v in sorted(res[0].items()):
self.__treemodel.append(stats_iter, [k + " = " + str(v), None])
self.treemodel.append(stats_iter, [k + " = " + str(v), None])
def __get_match_rules_cb(self, connection, result_async, data):
"""callback when the GetAllMatchRules dbus function call finished"""
......@@ -278,9 +279,9 @@ class AddressInfo(Gtk.Box):
if self.unique_name not in res[0]:
return
rules_iter = self.__treemodel.append(None, ["<b>Match rules</b>", None])
rules_iter = self.treemodel.append(None, ["<b>Match rules</b>", None])
for v in res[0][self.unique_name]:
self.__treemodel.append(rules_iter, [v, None])
self.treemodel.append(rules_iter, [v, None])
def __get_stats(self):
if self.name == 'org.freedesktop.DBus':
......@@ -325,7 +326,7 @@ if __name__ == "__main__":
win = Gtk.Window()
win.connect("delete-event", Gtk.main_quit)
win.set_default_size(1024, 768)
win.add(ai.introspect_box)
win.add(ai)
win.show_all()
try:
Gtk.main()
......
......@@ -36,15 +36,12 @@ class DFeetWindow(Gtk.ApplicationWindow):
HISTORY_MAX_SIZE = 10
def __init__(self, app, version):
Gtk.ApplicationWindow.__init__(self, application=app)
self.version = version
def __init__(self):
super(DFeetWindow, self).__init__()
self.init_template('DFeetWindow')
self.session_bus = None
self.system_bus = None
# setup the window
self.set_icon_name(app.props.application_id)
# create actions
action = Gio.SimpleAction.new('connect-system-bus', None)
action.connect('activate', self.__action_connect_system_bus_cb)
......@@ -110,10 +107,6 @@ class DFeetWindow(Gtk.ApplicationWindow):
action.connect('activate', self.__action_connect_session_bus_cb)
self.add_action(action)
@Gtk.Template.Callback('window_destroyed')
def __on_destroy(self, data=None):
self.buses_stack.disconnect(None)
def __action_connect_system_bus_cb(self, action, parameter):
"""connect to system bus"""
try:
......@@ -141,7 +134,7 @@ class DFeetWindow(Gtk.ApplicationWindow):
def __action_connect_other_bus_cb(self, action, parameter):
"""connect to other bus"""
dialog = AddConnectionDialog(self, self.bus_history)
result = dialog.run()
result = dialog.start()
if result == Gtk.ResponseType.OK:
address = dialog.address
if address == 'Session Bus':
......@@ -163,7 +156,7 @@ class DFeetWindow(Gtk.ApplicationWindow):
self.bus_history = self.bus_history[0:self.HISTORY_MAX_SIZE]
except Exception as e:
print("can not connect to '%s': %s" % (address, str(e)))
dialog.destroy()
dialog.quit()
def __action_close_bus_cb(self, action, parameter):
"""close current bus"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment