XMLConsole: Use glade file for building widgets

This commit is contained in:
Philipp Hörist 2017-08-16 17:12:42 +02:00
parent 21e144d89d
commit 1211a1bc59
3 changed files with 135 additions and 401 deletions

View File

@ -1,368 +1,155 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 --> <!-- Generated with glade 3.20.0 -->
<interface> <interface>
<requires lib="gtk+" version="3.12"/> <requires lib="gtk+" version="3.20"/>
<object class="GtkImage" id="image1"> <object class="GtkBox" id="box">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="stock">gtk-apply</property> <property name="orientation">vertical</property>
</object>
<object class="GtkWindow" id="xml_console_window">
<property name="can_focus">False</property>
<property name="border_width">12</property>
<property name="default_width">550</property>
<property name="default_height">450</property>
<signal name="destroy" handler="on_xml_console_window_destroy" swapped="no"/>
<signal name="key-press-event" handler="on_key_press_event" swapped="no"/>
<child> <child>
<object class="GtkBox" id="vbox"> <object class="GtkPaned" id="paned">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">6</property>
<child> <child>
<object class="GtkLabel" id="label342"> <object class="GtkScrolledWindow" id="scrolled">
<property name="visible">True</property> <property name="height_request">400</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;Jabber Traffic&lt;/b&gt;</property>
<property name="use_markup">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow43">
<property name="height_request">100</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="shadow_type">in</property> <property name="shadow_type">in</property>
<child> <child>
<object class="GtkTextView" id="stanzas_log_textview"> <object class="GtkTextView" id="textview">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="editable">False</property> <property name="editable">False</property>
<property name="wrap_mode">char</property> <property name="cursor_visible">False</property>
</object> </object>
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="resize">True</property>
<property name="fill">True</property> <property name="shrink">False</property>
<property name="position">1</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkBox" id="hbox2988"> <object class="GtkScrolledWindow" id="scrolled_input">
<property name="visible">True</property> <property name="height_request">150</property>
<property name="can_focus">False</property>
<child>
<object class="GtkCheckButton" id="enable_checkbutton">
<property name="label" translatable="yes" comments="XML Console enable checkbutton">_Enable</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_enable_checkbutton_toggled" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="clear_button">
<property name="label">gtk-clear</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="on_clear_button_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkExpander" id="expander1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="spacing">6</property> <property name="shadow_type">in</property>
<child> <child>
<object class="GtkBox" id="input_vbox1"> <object class="GtkTextView" id="input">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkBox" id="hbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkCheckButton" id="in_stanza_checkbutton">
<property name="label" translatable="yes">Hide IN stanzas</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0.5</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_in_stanza_checkbutton_toggled" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="out_stanza_checkbutton">
<property name="label" translatable="yes">Hide OUT stanzas</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0.5</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_out_stanza_checkbutton_toggled" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="presence_stanza_checkbutton">
<property name="label" translatable="yes">Hide Presence stanzas</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0.5</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_presence_stanza_checkbutton_toggled" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="iq_stanza_checkbutton">
<property name="label" translatable="yes">Hide IQ stanzas</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0.5</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_iq_stanza_checkbutton_toggled" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="message_stanza_checkbutton">
<property name="label" translatable="yes">Hide Message stanzas</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0.5</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_message_stanza_checkbutton_toggled" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">4</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="GtkBox" id="hbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;Filter&lt;/b&gt;</property>
<property name="use_markup">True</property>
<property name="xalign">0</property>
</object> </object>
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="resize">False</property>
<property name="fill">True</property> <property name="shrink">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkExpander" id="expander">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="spacing">6</property>
<signal name="activate" handler="on_expander_activate" swapped="no"/>
<child>
<object class="GtkBox" id="input_vbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow42">
<property name="height_request">150</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTextView" id="input_textview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="wrap_mode">char</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButtonBox" id="hbuttonbox31">
<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="iq_button">
<property name="label" translatable="yes" comments="Info/Query: all(?) jabber xml start with &lt;iq Leaving it _IQ is not a bad idea unless you are sure your lang has this somehow else translated (NOTE: xml still will still say &lt;iq in your language (of course))">_IQ</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Info/Query</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="on_iq_button_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="presence_button">
<property name="label" translatable="yes">_Presence</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="on_presence_button_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="message_button">
<property name="label" translatable="yes">_Message</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="on_message_button_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="send_button">
<property name="label" translatable="yes">_Send</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="image">image1</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="on_send_button_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label343">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;XML Input&lt;/b&gt;</property>
<property name="use_markup">True</property>
<property name="xalign">0</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing> </packing>
</child> </child>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkActionBar" id="actionbar">
<property name="name">actionbar</property>
<property name="visible">True</property>
<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">1</property>
</packing>
</child>
</object>
<object class="GtkHeaderBar" id="headerbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title">XML Console</property>
<property name="has_subtitle">False</property>
<property name="show_close_button">True</property>
<child>
<object class="GtkSwitch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="active">True</property>
<signal name="notify::active" handler="on_enable" swapped="no"/>
</object>
</child>
</object>
<object class="GtkPopover" id="popover">
<property name="can_focus">False</property>
<property name="valign">start</property>
<child>
<object class="GtkListBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selection_mode">none</property>
<signal name="row-activated" handler="on_row_activated" swapped="no"/>
<child>
<object class="GtkListBoxRow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Message</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Presence</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Iq</property>
</object>
</child>
</object>
</child>
</object>
</child>
<style>
<class name="PopoverButtonListbox"/>
</style>
</object>
<object class="GtkMenuButton" id="menubutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Presets</property>
<property name="popover">popover</property>
<child>
<placeholder/>
</child> </child>
</object> </object>
</interface> </interface>

View File

@ -37,6 +37,7 @@ popover#EmoticonPopover flowboxchild { padding-top: 5px; padding-bottom: 5px; }
#OptionsDialog list > row.activatable:active { box-shadow: none; } #OptionsDialog list > row.activatable:active { box-shadow: none; }
/* Generic Popover Menu with Buttons */ /* Generic Popover Menu with Buttons */
.PopoverButtonListbox { margin-top: 10px; margin-bottom: 10px; } .PopoverButtonListbox { padding-left: 0px; padding-right: 0px; }
.PopoverButtonListbox > row { padding: 10px 20px 10px 20px; } .PopoverButtonListbox > list { margin-top: 10px; margin-bottom: 10px; }
.PopoverButtonListbox row.activatable:active { box-shadow: none; background-color: @theme_selected_bg_color } .PopoverButtonListbox > list > row { padding: 10px 20px 10px 20px; }
.PopoverButtonListbox > list > row.activatable:active { box-shadow: none; background-color: @theme_selected_bg_color }

View File

@ -3352,19 +3352,6 @@ class XMLConsoleWindow(Gtk.Window):
def __init__(self, account): def __init__(self, account):
Gtk.Window.__init__(self) Gtk.Window.__init__(self)
self.account = account self.account = account
self.set_default_size(600, 600)
self.connect("destroy", self.on_destroy)
headerbar = Gtk.HeaderBar()
headerbar.set_title(_('XML Console'))
headerbar.set_show_close_button(True)
self.set_titlebar(headerbar)
switch = Gtk.Switch()
switch.set_active(True)
switch.connect("notify::active", self.on_enable)
headerbar.pack_start(switch)
self.enabled = True self.enabled = True
self.presence = True self.presence = True
self.message = True self.message = True
@ -3373,31 +3360,18 @@ class XMLConsoleWindow(Gtk.Window):
self.incoming = True self.incoming = True
self.outgoing = True self.outgoing = True
self.textview = Gtk.TextView() glade_objects = ['textview', 'input', 'scrolled_input', 'headerbar',
self.textview.set_size_request(-1, 400) 'scrolled', 'actionbar', 'paned', 'box', 'menubutton']
self.textview.set_editable(False) self.builder = gtkgui_helpers.get_gtk_builder('xml_console_window.ui')
self.textview.set_cursor_visible(False) for obj in glade_objects:
self.textview.set_hexpand(True) setattr(self, obj, self.builder.get_object(obj))
self.scrolled = Gtk.ScrolledWindow() self.set_titlebar(self.headerbar)
self.scrolled.add(self.textview) self.set_default_size(600, 600)
self.add(self.box)
self.input = Gtk.TextView()
self.input.show()
self.input.set_vexpand(True)
self.scrolled_input = Gtk.ScrolledWindow()
self.scrolled_input.set_size_request(-1, 150)
self.scrolled_input.add(self.input)
self.paned = Gtk.VPaned()
self.paned.set_vexpand(True)
self.paned.pack1(self.scrolled, True, False)
self.paned.pack2(self.scrolled_input, False, False)
self.paned.set_position(self.paned.get_property('max-position')) self.paned.set_position(self.paned.get_property('max-position'))
self.actionbar = Gtk.ActionBar()
button = gtkgui_helpers.get_image_button( button = gtkgui_helpers.get_image_button(
'edit-clear-all-symbolic', 'Clear') 'edit-clear-all-symbolic', 'Clear')
button.connect('clicked', self.on_clear) button.connect('clicked', self.on_clear)
@ -3417,45 +3391,17 @@ class XMLConsoleWindow(Gtk.Window):
button.connect('clicked', self.on_send) button.connect('clicked', self.on_send)
self.actionbar.pack_end(button) self.actionbar.pack_end(button)
listbox = Gtk.ListBox()
context = listbox.get_style_context()
context.add_class('PopoverButtonListbox')
label = Gtk.Label(label='Message')
listbox.add(label)
label = Gtk.Label(label='Presence')
listbox.add(label)
label = Gtk.Label(label='Iq')
listbox.add(label)
listbox.show_all()
listbox.set_selection_mode(Gtk.SelectionMode.NONE)
listbox.connect('row-activated', self.on_row_activated)
popover = Gtk.Popover()
popover.add(listbox)
self.menubutton = Gtk.MenuButton()
self.menubutton.set_direction(Gtk.ArrowType.UP)
self.menubutton.set_popover(popover)
self.menubutton.set_tooltip_text(_('Presets'))
self.menubutton.set_no_show_all(True)
self.actionbar.pack_start(self.menubutton) self.actionbar.pack_start(self.menubutton)
box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
box.add(self.paned)
box.add(self.actionbar)
self.add(box)
self.connect('key_press_event', self.on_key_press_event)
self.create_tags() self.create_tags()
self.show_all() self.show_all()
self.scrolled_input.hide() self.scrolled_input.hide()
self.menubutton.hide()
self.connect("destroy", self.on_destroy)
self.connect('key_press_event', self.on_key_press_event)
self.builder.connect_signals(self)
gajim.ged.register_event_handler('stanza-received', ged.GUI1, gajim.ged.register_event_handler('stanza-received', ged.GUI1,
self._nec_stanza_received) self._nec_stanza_received)