[meld/deprecation-cleanup] newdifftab: Migrate to template and resource loading
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld/deprecation-cleanup] newdifftab: Migrate to template and resource loading
- Date: Sun, 9 Dec 2018 21:31:30 +0000 (UTC)
commit 83605562dfa968bacf1d72daa26b3113196c3dd4
Author: Kai Willadsen <kai willadsen gmail com>
Date: Tue Dec 4 06:14:16 2018 +1000
newdifftab: Migrate to template and resource loading
data/ui/tab-placeholder.ui | 612 --------------------------------------
meld/newdifftab.py | 58 +++-
meld/resources/ui/new-diff-tab.ui | 607 +++++++++++++++++++++++++++++++++++++
meld/ui/util.py | 27 ++
4 files changed, 679 insertions(+), 625 deletions(-)
---
diff --git a/meld/newdifftab.py b/meld/newdifftab.py
index 8ea16d91..944da646 100644
--- a/meld/newdifftab.py
+++ b/meld/newdifftab.py
@@ -23,7 +23,8 @@ from gi.repository import Gtk
from meld.conf import _
from meld.melddoc import LabeledObjectMixin
from meld.recent import recent_comparisons
-from meld.ui import gnomeglade
+from meld.ui._gtktemplate import Template
+from meld.ui.util import map_widgets_into_lists
class DiffType(enum.IntEnum):
@@ -37,29 +38,47 @@ class DiffType(enum.IntEnum):
return self in (self.File, self.Folder)
-class NewDiffTab(LabeledObjectMixin, GObject.GObject, gnomeglade.Component):
+@Template(resource_path='/org/gnome/meld/ui/new-diff-tab.ui')
+class NewDiffTab(Gtk.Alignment, LabeledObjectMixin):
__gtype_name__ = "NewDiffTab"
__gsignals__ = {
+ 'label-changed': (
+ GObject.SignalFlags.RUN_FIRST, None,
+ (GObject.TYPE_STRING, GObject.TYPE_STRING)),
'close': (GObject.SignalFlags.RUN_FIRST, None, (bool,)),
'diff-created': (GObject.SignalFlags.RUN_FIRST, None, (object,)),
}
label_text = _("New comparison")
+ button_compare = Template.Child()
+ button_new_blank = Template.Child()
+ button_type_dir = Template.Child()
+ button_type_file = Template.Child()
+ button_type_vc = Template.Child()
+ choosers_notebook = Template.Child()
+ dir_chooser0 = Template.Child()
+ dir_chooser1 = Template.Child()
+ dir_chooser2 = Template.Child()
+ dir_three_way_checkbutton = Template.Child()
+ file_chooser0 = Template.Child()
+ file_chooser1 = Template.Child()
+ file_chooser2 = Template.Child()
+ file_three_way_checkbutton = Template.Child()
+ filechooserdialog0 = Template.Child()
+ filechooserdialog1 = Template.Child()
+ filechooserdialog2 = Template.Child()
+ vc_chooser0 = Template.Child()
+
def __init__(self, parentapp):
- GObject.GObject.__init__(self)
- gnomeglade.Component.__init__(
- self, "tab-placeholder.ui", "new_comparison_tab",
- [
- "filechooserdialog0",
- "filechooserdialog1",
- "filechooserdialog2",
- ]
+ super().__init__()
+ self.init_template()
+ map_widgets_into_lists(
+ self,
+ ["file_chooser", "dir_chooser", "vc_chooser", "filechooserdialog"]
)
- self.map_widgets_into_lists(
- ["file_chooser", "dir_chooser", "vc_chooser", "filechooserdialog"])
self.button_types = [
self.button_type_file,
self.button_type_dir,
@@ -76,8 +95,13 @@ class NewDiffTab(LabeledObjectMixin, GObject.GObject, gnomeglade.Component):
for chooser in self.file_chooser:
chooser.set_current_folder(default_path)
- self.widget.show()
+ self.show()
+
+ # FIXME: Awful migration hack; this means that we don't have to
+ # address `.pyobject` access before all tab types are updated.
+ self.pyobject = self
+ @Template.Callback()
def on_button_type_toggled(self, button, *args):
if not button.get_active():
if not any([b.get_active() for b in self.button_types]):
@@ -95,12 +119,14 @@ class NewDiffTab(LabeledObjectMixin, GObject.GObject, gnomeglade.Component):
self.diff_type.supports_blank())
self.button_compare.set_sensitive(True)
+ @Template.Callback()
def on_three_way_checkbutton_toggled(self, button, *args):
if button is self.file_three_way_checkbutton:
self.file_chooser2.set_sensitive(button.get_active())
else: # button is self.dir_three_way_checkbutton
self.dir_chooser2.set_sensitive(button.get_active())
+ @Template.Callback()
def on_file_set(self, filechooser, *args):
gfile = filechooser.get_file()
if not gfile:
@@ -132,6 +158,7 @@ class NewDiffTab(LabeledObjectMixin, GObject.GObject, gnomeglade.Component):
num_paths = 1
return num_paths
+ @Template.Callback()
def on_button_compare_clicked(self, *args):
type_choosers = (self.file_chooser, self.dir_chooser, self.vc_chooser)
choosers = type_choosers[self.diff_type][:self._get_num_paths()]
@@ -148,6 +175,7 @@ class NewDiffTab(LabeledObjectMixin, GObject.GObject, gnomeglade.Component):
recent_comparisons.add(tab)
self.emit('diff-created', tab)
+ @Template.Callback()
def on_button_new_blank_clicked(self, *args):
# TODO: This doesn't work the way I'd like for DirDiff and VCView.
# It should do something similar to FileDiff; give a tab with empty
@@ -171,3 +199,7 @@ class NewDiffTab(LabeledObjectMixin, GObject.GObject, gnomeglade.Component):
def on_delete_event(self, *args):
self.emit('close', 0)
return Gtk.ResponseType.OK
+
+from gi._signalhelper import install_signals
+
+install_signals(NewDiffTab)
diff --git a/meld/resources/ui/new-diff-tab.ui b/meld/resources/ui/new-diff-tab.ui
new file mode 100644
index 00000000..f307daee
--- /dev/null
+++ b/meld/resources/ui/new-diff-tab.ui
@@ -0,0 +1,607 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <!-- interface-naming-policy toplevel-contextual -->
+ <object class="MeldFileChooserDialog" id="filechooserdialog0">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="role">GtkFileChooserDialog</property>
+ <property name="type_hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="filechooserdialog-vbox0">
+ <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="filechooserdialog-action_area0">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </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>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ </object>
+ <object class="MeldFileChooserDialog" id="filechooserdialog1">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="role">GtkFileChooserDialog</property>
+ <property name="type_hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="filechooserdialog-vbox1">
+ <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="filechooserdialog-action_area1">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </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>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ </object>
+ <object class="MeldFileChooserDialog" id="filechooserdialog2">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="role">GtkFileChooserDialog</property>
+ <property name="type_hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="filechooserdialog-vbox2">
+ <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="filechooserdialog-action_area2">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </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>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ </object>
+ <template class="NewDiffTab" parent="GtkAlignment">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="yalign">0.25</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <child>
+ <object class="GtkVBox" id="vbox6">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">New comparison</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkVBox" id="vbox7">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <object class="GtkToggleButton" id="button_type_file">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <signal name="toggled" handler="on_button_type_toggled" swapped="no"/>
+ <child>
+ <object class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-new</property>
+ <property name="icon-size">6</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">File comparison</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="button_type_dir">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <signal name="toggled" handler="on_button_type_toggled" swapped="no"/>
+ <child>
+ <object class="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkImage" id="image2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-directory</property>
+ <property name="icon-size">6</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Directory comparison</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="button_type_vc">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <signal name="toggled" handler="on_button_type_toggled" swapped="no"/>
+ <child>
+ <object class="GtkVBox" id="vbox3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkImage" id="image3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">meld-version-control</property>
+ <property name="icon-size">6</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Version control view</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkNotebook" id="choosers_notebook">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="show_tabs">False</property>
+ <property name="show_border">False</property>
+ <child>
+ <object class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <placeholder/>
+ </child>
+ <child>
+ <object class="GtkGrid" id="grid1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
+ <property name="column_homogeneous">True</property>
+ <child>
+ <object class="GtkCheckButton" id="file_three_way_checkbutton">
+ <property name="label" translatable="yes">_3-way comparison</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="on_three_way_checkbutton_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFileChooserButton" id="file_chooser2">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">False</property>
+ <property name="create_folders">False</property>
+ <property name="title" translatable="yes">Select Third File</property>
+ <property name="dialog">filechooserdialog2</property>
+ <signal name="file-set" handler="on_file_set" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFileChooserButton" id="file_chooser1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="create_folders">False</property>
+ <property name="title" translatable="yes">Select Second File</property>
+ <property name="dialog">filechooserdialog1</property>
+ <signal name="file-set" handler="on_file_set" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFileChooserButton" id="file_chooser0">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="create_folders">False</property>
+ <property name="title" translatable="yes">Select First File</property>
+ <property name="dialog">filechooserdialog0</property>
+ <signal name="file-set" handler="on_file_set" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <placeholder/>
+ </child>
+ <child>
+ <object class="GtkGrid" id="grid2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
+ <property name="column_homogeneous">True</property>
+ <child>
+ <object class="GtkFileChooserButton" id="dir_chooser0">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="create_folders">False</property>
+ <property name="action">select-folder</property>
+ <property name="title" translatable="yes">Select First Folder</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFileChooserButton" id="dir_chooser1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="create_folders">False</property>
+ <property name="action">select-folder</property>
+ <property name="title" translatable="yes">Select Second Folder</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFileChooserButton" id="dir_chooser2">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">False</property>
+ <property name="create_folders">False</property>
+ <property name="action">select-folder</property>
+ <property name="title" translatable="yes">Select Third Folder</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="dir_three_way_checkbutton">
+ <property name="label" translatable="yes">_3-way comparison</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="on_three_way_checkbutton_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <placeholder/>
+ </child>
+ <child>
+ <object class="GtkGrid" id="grid3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
+ <property name="column_homogeneous">True</property>
+ <child>
+ <object class="GtkFileChooserButton" id="vc_chooser0">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="create_folders">False</property>
+ <property name="action">select-folder</property>
+ <property name="title" translatable="yes">Select A Version-Controlled
Folder</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHButtonBox" id="hbuttonbox2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="button_help">
+ <property name="label">gtk-help</property>
+ <!-- FIXME: Enable help -->
+ <property name="visible">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ <property name="secondary">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_new_blank">
+ <property name="label" translatable="yes">_Blank comparison</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <signal name="clicked" handler="on_button_new_blank_clicked" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_compare">
+ <property name="label" translatable="yes">C_ompare</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <signal name="clicked" handler="on_button_compare_clicked" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/meld/ui/util.py b/meld/ui/util.py
index 50d08e86..1f38773a 100644
--- a/meld/ui/util.py
+++ b/meld/ui/util.py
@@ -13,12 +13,16 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import logging
+
from gi.repository import Gio, Gtk
import meld.conf
# Import support module to get all builder-constructed widgets in the namespace
from meld.ui import gladesupport # noqa: F401
+log = logging.getLogger(__name__)
+
def get_widget(filename, widget):
builder = Gtk.Builder()
@@ -36,6 +40,29 @@ def get_builder(filename):
return builder
+def map_widgets_into_lists(widget, widgetnames):
+ """Put sequentially numbered widgets into lists.
+
+ Given an object with widgets self.button0, self.button1, ...,
+ after a call to object.map_widgets_into_lists(["button"])
+ object.button == [self.button0, self.button1, ...]
+ """
+ for item in widgetnames:
+ i, lst = 0, []
+ while 1:
+ key = "%s%i" % (item, i)
+ try:
+ val = getattr(widget, key)
+ except AttributeError:
+ if i == 0:
+ log.critical(
+ f"Tried to map missing attribute {key}")
+ break
+ lst.append(val)
+ i += 1
+ setattr(widget, item, lst)
+
+
# The functions `extract_accel_from_menu_item` and `extract_accels_from_menu`
# are converted straight from GTK+'s GtkApplication handling. I don't
# understand why these aren't public API, but here we are.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]