diff options
author | Gary Kramlich <grim@reaperworld.com> | 2019-09-04 03:48:47 +0000 |
---|---|---|
committer | Gary Kramlich <grim@reaperworld.com> | 2019-09-04 03:48:47 +0000 |
commit | e38beb2adaa05fad6626cfabec9aabb0b4c7bab7 (patch) | |
tree | 012e47f4471b9cd026ada3ff0eeb65a554c99db5 /pidgin/plugins | |
parent | fe657df497bc4f1c1d5f505639836b1a66470966 (diff) | |
parent | 0b7b121d07ab5ebae0f1a77443f1bb413adcd411 (diff) | |
download | pidgin-e38beb2adaa05fad6626cfabec9aabb0b4c7bab7.tar.gz |
Merged in default (pull request #546)
Convert XMPP Console plugin to Glade
Approved-by: Gary Kramlich
Diffstat (limited to 'pidgin/plugins')
-rw-r--r-- | pidgin/plugins/meson.build | 6 | ||||
-rw-r--r-- | pidgin/plugins/xmppconsole/console.ui | 597 | ||||
-rw-r--r-- | pidgin/plugins/xmppconsole/meson.build | 11 | ||||
-rw-r--r-- | pidgin/plugins/xmppconsole/xmppconsole.c (renamed from pidgin/plugins/xmppconsole.c) | 572 | ||||
-rw-r--r-- | pidgin/plugins/xmppconsole/xmppconsole.gresource.xml | 6 |
5 files changed, 807 insertions, 385 deletions
diff --git a/pidgin/plugins/meson.build b/pidgin/plugins/meson.build index d19392778c..cdacacece0 100644 --- a/pidgin/plugins/meson.build +++ b/pidgin/plugins/meson.build @@ -16,6 +16,7 @@ endif subdir('disco') subdir('ticker') +subdir('xmppconsole') if IS_WIN32 subdir('win32/winprefs') @@ -80,11 +81,6 @@ if PLUGINS build_by_default: false, install : false, install_dir : PIDGIN_PLUGINDIR) - xmppconsole = library('xmppconsole', 'xmppconsole.c', - dependencies : [libpurple_dep, libpidgin_dep, glib], - name_prefix : '', - install : true, install_dir : PIDGIN_PLUGINDIR) - if enable_unity unity = library('unity', 'unity.c', dependencies : [UNITY, libpurple_dep, libpidgin_dep, glib], diff --git a/pidgin/plugins/xmppconsole/console.ui b/pidgin/plugins/xmppconsole/console.ui new file mode 100644 index 0000000000..d5ac0a10c4 --- /dev/null +++ b/pidgin/plugins/xmppconsole/console.ui @@ -0,0 +1,597 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.22.1 --> +<interface> + <requires lib="gtk+" version="3.18"/> + <object class="GtkTextBuffer" id="entry_buffer"> + <signal name="changed" handler="entry_changed_cb" swapped="no"/> + </object> + <object class="GtkAdjustment" id="presence.priority_adjustment"> + <property name="lower">-128</property> + <property name="upper">127</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkTextTagTable" id="tags.table"> + <child type="tag"> + <object class="GtkTextTag" id="tags.info"> + <property name="foreground_rgba">rgb(119,119,119)</property> + </object> + </child> + <child type="tag"> + <object class="GtkTextTag" id="tags.incoming"> + <property name="paragraph_background_rgba">rgb(255,206,206)</property> + </object> + </child> + <child type="tag"> + <object class="GtkTextTag" id="tags.outgoing"> + <property name="paragraph_background_rgba">rgb(220,236,196)</property> + </object> + </child> + <child type="tag"> + <object class="GtkTextTag" id="tags.bracket"> + <property name="foreground_rgba">rgb(148,15,140)</property> + </object> + </child> + <child type="tag"> + <object class="GtkTextTag" id="tags.tag"> + <property name="foreground_rgba">rgb(139,29,171)</property> + <property name="weight">700</property> + </object> + </child> + <child type="tag"> + <object class="GtkTextTag" id="tags.attr"> + <property name="foreground_rgba">rgb(160,41,97)</property> + <property name="weight">700</property> + </object> + </child> + <child type="tag"> + <object class="GtkTextTag" id="tags.value"> + <property name="foreground_rgba">rgb(50,74,164)</property> + </object> + </child> + <child type="tag"> + <object class="GtkTextTag" id="tags.xmlns"> + <property name="foreground_rgba">rgb(44,177,47)</property> + <property name="weight">700</property> + </object> + </child> + </object> + <object class="GtkTextBuffer" id="buffer"> + <property name="tag_table">tags.table</property> + </object> + <object class="GtkWindow" id="PidginXmppConsole"> + <property name="can_focus">False</property> + <property name="title" translatable="yes">XMPP Console</property> + <property name="default_width">580</property> + <property name="default_height">400</property> + <signal name="destroy" handler="console_destroy" swapped="no"/> + <child> + <placeholder/> + </child> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkBox" id="hbox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_left">6</property> + <property name="spacing">6</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Account:</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="dropdown"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <signal name="changed" handler="dropdown_changed_cb" swapped="no"/> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkScrolledWindow"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="shadow_type">etched-in</property> + <child> + <object class="GtkTextView"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">False</property> + <property name="wrap_mode">word</property> + <property name="buffer">buffer</property> + </object> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkToolbar"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="toolbar_style">text</property> + <child> + <object class="GtkToggleToolButton" id="iq"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label"><iq/></property> + <signal name="toggled" handler="toggle_button_toggled_cb" object="iq.popover" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">False</property> + </packing> + </child> + <child> + <object class="GtkToggleToolButton" id="presence"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label"><presence/></property> + <signal name="toggled" handler="toggle_button_toggled_cb" object="presence.popover" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">False</property> + </packing> + </child> + <child> + <object class="GtkToggleToolButton" id="message"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label"><message/></property> + <signal name="toggled" handler="toggle_button_toggled_cb" object="message.popover" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">False</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="GtkScrolledWindow" id="sw"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="shadow_type">etched-in</property> + <child> + <object class="GtkTextView" id="entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="wrap_mode">word</property> + <property name="buffer">entry_buffer</property> + <signal name="key-press-event" handler="message_send_cb" object="PidginXmppConsole" swapped="no"/> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">3</property> + </packing> + </child> + </object> + </child> + </object> + <object class="GtkPopover" id="iq.popover"> + <property name="can_focus">False</property> + <property name="relative_to">iq</property> + <property name="position">right</property> + <signal name="closed" handler="popover_closed_cb" object="iq" swapped="no"/> + <child> + <object class="GtkGrid"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="column_spacing">6</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">To:</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Type:</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="iq.to"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="activates_default">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="iq.type"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="active">0</property> + <items> + <item>get</item> + <item>set</item> + <item>result</item> + <item>error</item> + </items> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkButton"> + <property name="label" translatable="yes">Insert</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="can_default">True</property> + <property name="has_default">True</property> + <property name="receives_default">True</property> + <signal name="clicked" handler="iq_clicked_cb" swapped="no"/> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + <property name="width">2</property> + </packing> + </child> + </object> + </child> + </object> + <object class="GtkPopover" id="message.popover"> + <property name="can_focus">False</property> + <property name="relative_to">message</property> + <property name="position">right</property> + <signal name="closed" handler="popover_closed_cb" object="message" swapped="no"/> + <child> + <object class="GtkGrid"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="column_spacing">6</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">To:</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Type:</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Body:</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Subject:</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">3</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Thread:</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">4</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="message.to"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="activates_default">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="message.body"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="activates_default">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="message.subject"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="activates_default">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">3</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="message.thread"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="activates_default">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">4</property> + </packing> + </child> + <child> + <object class="GtkButton"> + <property name="label" translatable="yes">Insert</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="can_default">True</property> + <property name="has_default">True</property> + <property name="receives_default">True</property> + <signal name="clicked" handler="message_clicked_cb" swapped="no"/> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">5</property> + <property name="width">2</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="message.type"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="active">0</property> + <items> + <item>chat</item> + <item>headline</item> + <item>groupchat</item> + <item>normal</item> + <item>error</item> + </items> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + </packing> + </child> + </object> + </child> + </object> + <object class="GtkPopover" id="presence.popover"> + <property name="can_focus">False</property> + <property name="relative_to">presence</property> + <property name="position">right</property> + <signal name="closed" handler="popover_closed_cb" object="presence" swapped="no"/> + <child> + <object class="GtkGrid"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="column_spacing">6</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">To:</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Type:</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Show:</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Status:</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">3</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Priority:</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">4</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="presence.to"> + <property name="visible">True</property> + <property name="can_focus">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="presence.type"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="active">0</property> + <items> + <item>default</item> + <item>unavailable</item> + <item>subscribe</item> + <item>unsubscribe</item> + <item>subscribed</item> + <item>unsubscribed</item> + <item>probe</item> + <item>error</item> + </items> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="presence.show"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="active">0</property> + <items> + <item>default</item> + <item>away</item> + <item>dnd</item> + <item>xa</item> + <item>chat</item> + </items> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="presence.status"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="activates_default">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">3</property> + </packing> + </child> + <child> + <object class="GtkButton"> + <property name="label" translatable="yes">Insert</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="can_default">True</property> + <property name="has_default">True</property> + <property name="receives_default">True</property> + <signal name="clicked" handler="presence_clicked_cb" swapped="no"/> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">5</property> + <property name="width">2</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="presence.priority"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="adjustment">presence.priority_adjustment</property> + <property name="numeric">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">4</property> + </packing> + </child> + </object> + </child> + </object> +</interface> diff --git a/pidgin/plugins/xmppconsole/meson.build b/pidgin/plugins/xmppconsole/meson.build new file mode 100644 index 0000000000..a2ac8ec07d --- /dev/null +++ b/pidgin/plugins/xmppconsole/meson.build @@ -0,0 +1,11 @@ +if PLUGINS + xmppconsole_resource = gnome.compile_resources('xmppconsoleresources', + 'xmppconsole.gresource.xml', + c_name : 'xmppconsole') + + library('xmppconsole', + 'xmppconsole.c', xmppconsole_resource, + dependencies : [libpurple_dep, libpidgin_dep, glib], + name_prefix : '', + install : true, install_dir : PIDGIN_PLUGINDIR) +endif # PLUGINS diff --git a/pidgin/plugins/xmppconsole.c b/pidgin/plugins/xmppconsole/xmppconsole.c index 7b11893bda..3a21a0960f 100644 --- a/pidgin/plugins/xmppconsole.c +++ b/pidgin/plugins/xmppconsole/xmppconsole.c @@ -1,7 +1,9 @@ /* * Purple - XMPP debugging tool * - * Copyright (C) 2002-2003, Sean Egan + * Pidgin is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * */ @@ -39,7 +41,6 @@ typedef struct { GtkWidget *window; GtkWidget *hbox; GtkWidget *dropdown; - GtkWidget *view; GtkTextBuffer *buffer; struct { GtkTextTag *info; @@ -56,6 +57,30 @@ typedef struct { GtkWidget *sw; int count; GList *accounts; + + struct { + GtkPopover *popover; + GtkEntry *to; + GtkComboBoxText *type; + } iq; + + struct { + GtkPopover *popover; + GtkEntry *to; + GtkComboBoxText *type; + GtkComboBoxText *show; + GtkEntry *status; + GtkEntry *priority; + } presence; + + struct { + GtkPopover *popover; + GtkEntry *to; + GtkComboBoxText *type; + GtkEntry *body; + GtkEntry *subject; + GtkEntry *thread; + } message; } XmppConsole; XmppConsole *console = NULL; @@ -65,20 +90,6 @@ static const gchar *xmpp_prpls[] = { "prpl-jabber", "prpl-gtalk", NULL }; -#define EMPTY_HTML \ -"<html><head><style type='text/css'>" \ - "body { word-wrap: break-word; margin: 0; }" \ - "div.tab { padding-left: 1em; }" \ - "div.info { color: #777777; }" \ - "div.incoming { background-color: #ffcece; }" \ - "div.outgoing { background-color: #dcecc4; }" \ - "span.bracket { color: #940f8c; }" \ - "span.tag { color: #8b1dab; font-weight: bold; }" \ - "span.attr { color: #a02961; font-weight: bold; }" \ - "span.value { color: #324aa4; }" \ - "span.xmlns { color: #2cb12f; font-weight: bold;}" \ -"</style></head></html>" - static gboolean xmppconsole_is_xmpp_account(PurpleAccount *account) { @@ -259,23 +270,22 @@ entry_changed_cb(GtkTextBuffer *buffer, void *data) { GtkTextIter start, end; char *xmlstr, *str; -#if 0 + GtkTextIter iter; int wrapped_lines; int lines; GdkRectangle oneline; int height; int pad_top, pad_inside, pad_bottom; -#endif PurpleXmlNode *node; GtkStyleContext *style; -#if 0 - /* TODO WebKit: Do entry auto-sizing... */ wrapped_lines = 1; gtk_text_buffer_get_start_iter(buffer, &iter); gtk_text_view_get_iter_location(GTK_TEXT_VIEW(console->entry), &iter, &oneline); - while (gtk_text_view_forward_display_line(GTK_TEXT_VIEW(console->entry), &iter)) + while (gtk_text_view_forward_display_line(GTK_TEXT_VIEW(console->entry), + &iter)) { wrapped_lines++; + } lines = gtk_text_buffer_get_line_count(buffer); @@ -291,12 +301,13 @@ entry_changed_cb(GtkTextBuffer *buffer, void *data) height += (oneline.height + pad_inside) * (wrapped_lines - lines); gtk_widget_set_size_request(console->sw, -1, height + 6); -#endif gtk_text_buffer_get_bounds(buffer, &start, &end); str = gtk_text_buffer_get_text(buffer, &start, &end, FALSE); - if (!str) + if (!str) { return; + } + xmlstr = g_strdup_printf("<xml>%s</xml>", str); node = purple_xmlnode_from_str(xmlstr, -1); style = gtk_widget_get_style_context(console->entry); @@ -333,195 +344,65 @@ load_text_and_set_caret(const gchar *pre_text, const gchar *post_text) gtk_text_buffer_end_user_action(console->entry_buffer); } -static void iq_clicked_cb(GtkWidget *w, gpointer nul) +static void +popover_closed_cb(GtkPopover *popover, gpointer data) +{ + GtkToggleToolButton *button = GTK_TOGGLE_TOOL_BUTTON(data); + + gtk_toggle_tool_button_set_active(button, FALSE); +} + +static void +toggle_button_toggled_cb(GtkToolButton *button, gpointer data) { - GtkWidget *vbox, *hbox, *to_entry, *label, *type_combo; - GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); + GtkPopover *popover = GTK_POPOVER(data); + + gtk_popover_popup(popover); +} + +static void +iq_clicked_cb(GtkWidget *w, gpointer data) +{ + XmppConsole *console = (XmppConsole *)data; const gchar *to; - int result; char *stanza; - GtkWidget *dialog = gtk_dialog_new_with_buttons("<iq/>", - GTK_WINDOW(console->window), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - _("_Cancel"), - GTK_RESPONSE_REJECT, - _("_OK"), - GTK_RESPONSE_ACCEPT, - NULL); - gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); - gtk_container_set_border_width(GTK_CONTAINER(dialog), 12); - vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); - - hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - - label = gtk_label_new("To:"); - gtk_label_set_xalign(GTK_LABEL(label), 0); - gtk_size_group_add_widget(sg, label); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - - to_entry = gtk_entry_new(); - gtk_entry_set_activates_default (GTK_ENTRY (to_entry), TRUE); - gtk_box_pack_start(GTK_BOX(hbox), to_entry, FALSE, FALSE, 0); - - hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - label = gtk_label_new("Type:"); - gtk_label_set_xalign(GTK_LABEL(label), 0); - - gtk_size_group_add_widget(sg, label); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - type_combo = gtk_combo_box_text_new(); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type_combo), "get"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type_combo), "set"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type_combo), "result"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type_combo), "error"); - gtk_combo_box_set_active(GTK_COMBO_BOX(type_combo), 0); - gtk_box_pack_start(GTK_BOX(hbox), type_combo, FALSE, FALSE, 0); - - gtk_widget_show_all(vbox); - - result = gtk_dialog_run(GTK_DIALOG(dialog)); - if (result != GTK_RESPONSE_ACCEPT) { - gtk_widget_destroy(dialog); - return; - } - - to = gtk_entry_get_text(GTK_ENTRY(to_entry)); - stanza = g_strdup_printf("<iq %s%s%s id='console%x' type='%s'>", - to && *to ? "to='" : "", - to && *to ? to : "", - to && *to ? "'" : "", - g_random_int(), - gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(type_combo))); + to = gtk_entry_get_text(console->iq.to); + stanza = g_strdup_printf( + "<iq %s%s%s id='console%x' type='%s'>", to && *to ? "to='" : "", + to && *to ? to : "", to && *to ? "'" : "", g_random_int(), + gtk_combo_box_text_get_active_text(console->iq.type)); load_text_and_set_caret(stanza, "</iq>"); gtk_widget_grab_focus(console->entry); g_free(stanza); - gtk_widget_destroy(dialog); - g_object_unref(sg); + /* Reset everything. */ + gtk_entry_set_text(console->iq.to, ""); + gtk_combo_box_set_active(GTK_COMBO_BOX(console->iq.type), 0); + gtk_popover_popdown(console->iq.popover); } -static void presence_clicked_cb(GtkWidget *w, gpointer nul) +static void +presence_clicked_cb(GtkWidget *w, gpointer data) { - GtkWidget *vbox; - GtkWidget *hbox; - GtkWidget *to_entry; - GtkWidget *status_entry; - GtkWidget *priority_entry; - GtkWidget *label; - GtkWidget *show_combo; - GtkWidget *type_combo; - GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); + XmppConsole *console = (XmppConsole *)data; const gchar *to, *status, *priority; gchar *type, *show; - int result; char *stanza; - GtkWidget *dialog = gtk_dialog_new_with_buttons("<presence/>", - GTK_WINDOW(console->window), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - _("_Cancel"), - GTK_RESPONSE_REJECT, - _("_OK"), - GTK_RESPONSE_ACCEPT, - NULL); - gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); - gtk_container_set_border_width(GTK_CONTAINER(dialog), 12); - vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); - - hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - - label = gtk_label_new("To:"); - gtk_size_group_add_widget(sg, label); - gtk_label_set_xalign(GTK_LABEL(label), 0); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - - to_entry = gtk_entry_new(); - gtk_entry_set_activates_default (GTK_ENTRY (to_entry), TRUE); - gtk_box_pack_start(GTK_BOX(hbox), to_entry, FALSE, FALSE, 0); - - hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - label = gtk_label_new("Type:"); - gtk_label_set_xalign(GTK_LABEL(label), 0); - gtk_size_group_add_widget(sg, label); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - type_combo = gtk_combo_box_text_new(); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type_combo), "default"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type_combo), "unavailable"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type_combo), "subscribe"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type_combo), "unsubscribe"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type_combo), "subscribed"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type_combo), "unsubscribed"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type_combo), "probe"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type_combo), "error"); - gtk_combo_box_set_active(GTK_COMBO_BOX(type_combo), 0); - gtk_box_pack_start(GTK_BOX(hbox), type_combo, FALSE, FALSE, 0); - - hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - label = gtk_label_new("Show:"); - gtk_label_set_xalign(GTK_LABEL(label), 0); - gtk_size_group_add_widget(sg, label); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - show_combo = gtk_combo_box_text_new(); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(show_combo), "default"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(show_combo), "away"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(show_combo), "dnd"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(show_combo), "xa"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(show_combo), "chat"); - - gtk_combo_box_set_active(GTK_COMBO_BOX(show_combo), 0); - gtk_box_pack_start(GTK_BOX(hbox), show_combo, FALSE, FALSE, 0); - - hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - - label = gtk_label_new("Status:"); - gtk_label_set_xalign(GTK_LABEL(label), 0); - gtk_size_group_add_widget(sg, label); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - - status_entry = gtk_entry_new(); - gtk_entry_set_activates_default (GTK_ENTRY (status_entry), TRUE); - gtk_box_pack_start(GTK_BOX(hbox), status_entry, FALSE, FALSE, 0); - - hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - - label = gtk_label_new("Priority:"); - gtk_label_set_xalign(GTK_LABEL(label), 0); - gtk_size_group_add_widget(sg, label); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - - priority_entry = gtk_spin_button_new_with_range(-128, 127, 1); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(priority_entry), 0); - gtk_box_pack_start(GTK_BOX(hbox), priority_entry, FALSE, FALSE, 0); - - gtk_widget_show_all(vbox); - - result = gtk_dialog_run(GTK_DIALOG(dialog)); - if (result != GTK_RESPONSE_ACCEPT) { - gtk_widget_destroy(dialog); - return; - } - - to = gtk_entry_get_text(GTK_ENTRY(to_entry)); - type = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(type_combo)); + to = gtk_entry_get_text(console->presence.to); + type = gtk_combo_box_text_get_active_text(console->presence.type); if (purple_strequal(type, "default")) { g_free(type); type = g_strdup(""); } - show = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(show_combo)); + show = gtk_combo_box_text_get_active_text(console->presence.show); if (purple_strequal(show, "default")) { g_free(show); show = g_strdup(""); } - status = gtk_entry_get_text(GTK_ENTRY(status_entry)); - priority = gtk_entry_get_text(GTK_ENTRY(priority_entry)); + status = gtk_entry_get_text(console->presence.status); + priority = gtk_entry_get_text(console->presence.priority); if (purple_strequal(priority, "0")) priority = ""; @@ -554,141 +435,55 @@ static void presence_clicked_cb(GtkWidget *w, gpointer nul) g_free(type); g_free(show); - gtk_widget_destroy(dialog); - g_object_unref(sg); + /* Reset everything. */ + gtk_entry_set_text(console->presence.to, ""); + gtk_combo_box_set_active(GTK_COMBO_BOX(console->presence.type), 0); + gtk_combo_box_set_active(GTK_COMBO_BOX(console->presence.show), 0); + gtk_entry_set_text(console->presence.status, ""); + gtk_entry_set_text(console->presence.priority, "0"); + gtk_popover_popdown(console->presence.popover); } -static void message_clicked_cb(GtkWidget *w, gpointer nul) +static void +message_clicked_cb(GtkWidget *w, gpointer data) { - GtkWidget *vbox; - GtkWidget *hbox; - GtkWidget *to_entry; - GtkWidget *body_entry; - GtkWidget *thread_entry; - GtkWidget *subject_entry; - GtkWidget *label; - GtkWidget *type_combo; - GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); + XmppConsole *console = (XmppConsole *)data; const gchar *to, *body, *thread, *subject; char *stanza; - int result; - - GtkWidget *dialog = gtk_dialog_new_with_buttons("<message/>", - GTK_WINDOW(console->window), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - _("_Cancel"), - GTK_RESPONSE_REJECT, - _("_OK"), - GTK_RESPONSE_ACCEPT, - NULL); - gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); - gtk_container_set_border_width(GTK_CONTAINER(dialog), 12); - vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); - - hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - - label = gtk_label_new("To:"); - gtk_label_set_xalign(GTK_LABEL(label), 0); - gtk_size_group_add_widget(sg, label); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - - to_entry = gtk_entry_new(); - gtk_entry_set_activates_default (GTK_ENTRY (to_entry), TRUE); - gtk_box_pack_start(GTK_BOX(hbox), to_entry, FALSE, FALSE, 0); - - hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - label = gtk_label_new("Type:"); - gtk_label_set_xalign(GTK_LABEL(label), 0); - gtk_size_group_add_widget(sg, label); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - type_combo = gtk_combo_box_text_new(); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type_combo), "chat"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type_combo), "headline"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type_combo), "groupchat"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type_combo), "normal"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type_combo), "error"); - gtk_combo_box_set_active(GTK_COMBO_BOX(type_combo), 0); - gtk_box_pack_start(GTK_BOX(hbox), type_combo, FALSE, FALSE, 0); - - hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - - label = gtk_label_new("Body:"); - gtk_label_set_xalign(GTK_LABEL(label), 0); - gtk_size_group_add_widget(sg, label); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - - body_entry = gtk_entry_new(); - gtk_entry_set_activates_default (GTK_ENTRY (body_entry), TRUE); - gtk_box_pack_start(GTK_BOX(hbox), body_entry, FALSE, FALSE, 0); - - hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - - label = gtk_label_new("Subject:"); - gtk_label_set_xalign(GTK_LABEL(label), 0); - gtk_size_group_add_widget(sg, label); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - - subject_entry = gtk_entry_new(); - gtk_entry_set_activates_default (GTK_ENTRY (subject_entry), TRUE); - gtk_box_pack_start(GTK_BOX(hbox), subject_entry, FALSE, FALSE, 0); - - hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - - label = gtk_label_new("Thread:"); - gtk_label_set_xalign(GTK_LABEL(label), 0); - gtk_size_group_add_widget(sg, label); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - - thread_entry = gtk_entry_new(); - gtk_entry_set_activates_default (GTK_ENTRY (thread_entry), TRUE); - gtk_box_pack_start(GTK_BOX(hbox), thread_entry, FALSE, FALSE, 0); - - gtk_widget_show_all(vbox); - - result = gtk_dialog_run(GTK_DIALOG(dialog)); - if (result != GTK_RESPONSE_ACCEPT) { - gtk_widget_destroy(dialog); - return; - } - to = gtk_entry_get_text(GTK_ENTRY(to_entry)); - body = gtk_entry_get_text(GTK_ENTRY(body_entry)); - thread = gtk_entry_get_text(GTK_ENTRY(thread_entry)); - subject = gtk_entry_get_text(GTK_ENTRY(subject_entry)); + to = gtk_entry_get_text(console->message.to); + body = gtk_entry_get_text(console->message.body); + thread = gtk_entry_get_text(console->message.thread); + subject = gtk_entry_get_text(console->message.subject); - stanza = g_strdup_printf("<message %s%s%s id='console%x' type='%s'>" - "%s%s%s%s%s%s%s%s%s", + stanza = g_strdup_printf( + "<message %s%s%s id='console%x' type='%s'>" + "%s%s%s%s%s%s%s%s%s", - *to ? "to='" : "", - *to ? to : "", - *to ? "'" : "", - g_random_int(), - gtk_combo_box_text_get_active_text( - GTK_COMBO_BOX_TEXT(type_combo)), + *to ? "to='" : "", *to ? to : "", *to ? "'" : "", + g_random_int(), + gtk_combo_box_text_get_active_text(console->message.type), - *body ? "<body>" : "", - *body ? body : "", - *body ? "</body>" : "", + *body ? "<body>" : "", *body ? body : "", + *body ? "</body>" : "", - *subject ? "<subject>" : "", - *subject ? subject : "", - *subject ? "</subject>" : "", + *subject ? "<subject>" : "", *subject ? subject : "", + *subject ? "</subject>" : "", - *thread ? "<thread>" : "", - *thread ? thread : "", - *thread ? "</thread>" : ""); + *thread ? "<thread>" : "", *thread ? thread : "", + *thread ? "</thread>" : ""); load_text_and_set_caret(stanza, "</message>"); gtk_widget_grab_focus(console->entry); g_free(stanza); - gtk_widget_destroy(dialog); - g_object_unref(sg); + /* Reset everything. */ + gtk_entry_set_text(console->message.to, ""); + gtk_combo_box_set_active(GTK_COMBO_BOX(console->message.type), 0); + gtk_entry_set_text(console->message.body, ""); + gtk_entry_set_text(console->message.subject, "0"); + gtk_entry_set_text(console->message.thread, "0"); + gtk_popover_popdown(console->message.popover); } static void @@ -771,11 +566,8 @@ dropdown_changed_cb(GtkComboBox *widget, gpointer nul) static void create_console(PurplePluginAction *action) { - GtkWidget *vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6); - GtkWidget *label; - GtkWidget *toolbar; + GtkBuilder *builder; GList *connections; - GtkToolItem *button; GtkCssProvider *entry_css; GtkStyleContext *context; @@ -786,17 +578,17 @@ create_console(PurplePluginAction *action) console = g_new0(XmppConsole, 1); - console->window = pidgin_create_window(_("XMPP Console"), PIDGIN_HIG_BORDER, NULL, TRUE); - g_signal_connect(G_OBJECT(console->window), "destroy", G_CALLBACK(console_destroy), NULL); - gtk_window_set_default_size(GTK_WINDOW(console->window), 580, 400); - gtk_container_add(GTK_CONTAINER(console->window), vbox); - - console->hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3); - gtk_box_pack_start(GTK_BOX(vbox), console->hbox, FALSE, FALSE, 0); - label = gtk_label_new(_("Account: ")); - gtk_label_set_xalign(GTK_LABEL(label), 0.0); - gtk_box_pack_start(GTK_BOX(console->hbox), label, FALSE, FALSE, 0); - console->dropdown = gtk_combo_box_text_new(); + builder = gtk_builder_new_from_resource( + "/im/pidgin/Pidgin/Plugin/XMPPConsole/console.ui"); + gtk_builder_set_translation_domain(builder, PACKAGE); + console->window = GTK_WIDGET( + gtk_builder_get_object(builder, "PidginXmppConsole")); + gtk_builder_add_callback_symbol(builder, "console_destroy", + G_CALLBACK(console_destroy)); + + console->hbox = GTK_WIDGET(gtk_builder_get_object(builder, "hbox")); + console->dropdown = + GTK_WIDGET(gtk_builder_get_object(builder, "dropdown")); for (connections = purple_connections_get_all(); connections; connections = connections->next) { PurpleConnection *gc = connections->data; if (xmppconsole_is_xmpp_account(purple_connection_get_account(gc))) { @@ -809,33 +601,27 @@ create_console(PurplePluginAction *action) } } gtk_combo_box_set_active(GTK_COMBO_BOX(console->dropdown), 0); - gtk_box_pack_start(GTK_BOX(console->hbox), console->dropdown, TRUE, TRUE, 0); - g_signal_connect(G_OBJECT(console->dropdown), "changed", G_CALLBACK(dropdown_changed_cb), NULL); - - console->view = gtk_text_view_new(); - gtk_text_view_set_editable(GTK_TEXT_VIEW(console->view), FALSE); - gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(console->view), GTK_WRAP_WORD); - - console->buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->view)); - console->tags.info = gtk_text_buffer_create_tag(console->buffer, "info", - "foreground", "#777777", NULL); - console->tags.incoming = gtk_text_buffer_create_tag(console->buffer, "incoming", - "paragraph-background", "#ffcece", NULL); - console->tags.outgoing = gtk_text_buffer_create_tag(console->buffer, "outgoing", - "paragraph-background", "#dcecc4", NULL); - console->tags.bracket = gtk_text_buffer_create_tag(console->buffer, "bracket", - "foreground", "#940f8c", NULL); - console->tags.tag = gtk_text_buffer_create_tag(console->buffer, "tag", - "foreground", "#8b1dab", - "weight", PANGO_WEIGHT_BOLD, NULL); - console->tags.attr = gtk_text_buffer_create_tag(console->buffer, "attr", - "foreground", "#a02961", - "weight", PANGO_WEIGHT_BOLD, NULL); - console->tags.value = gtk_text_buffer_create_tag(console->buffer, "value", - "foreground", "#324aa4", NULL); - console->tags.xmlns = gtk_text_buffer_create_tag(console->buffer, "xmlns", - "foreground", "#2cb12f", - "weight", PANGO_WEIGHT_BOLD, NULL); + gtk_builder_add_callback_symbol(builder, "dropdown_changed_cb", + G_CALLBACK(dropdown_changed_cb)); + + console->buffer = + GTK_TEXT_BUFFER(gtk_builder_get_object(builder, "buffer")); + console->tags.info = + GTK_TEXT_TAG(gtk_builder_get_object(builder, "tags.info")); + console->tags.incoming = + GTK_TEXT_TAG(gtk_builder_get_object(builder, "tags.incoming")); + console->tags.outgoing = + GTK_TEXT_TAG(gtk_builder_get_object(builder, "tags.outgoing")); + console->tags.bracket = + GTK_TEXT_TAG(gtk_builder_get_object(builder, "tags.bracket")); + console->tags.tag = + GTK_TEXT_TAG(gtk_builder_get_object(builder, "tags.tag")); + console->tags.attr = + GTK_TEXT_TAG(gtk_builder_get_object(builder, "tags.attr")); + console->tags.value = + GTK_TEXT_TAG(gtk_builder_get_object(builder, "tags.value")); + console->tags.xmlns = + GTK_TEXT_TAG(gtk_builder_get_object(builder, "tags.xmlns")); if (console->count == 0) { GtkTextIter start, end; @@ -843,30 +629,51 @@ create_console(PurplePluginAction *action) gtk_text_buffer_get_bounds(console->buffer, &start, &end); gtk_text_buffer_apply_tag(console->buffer, console->tags.info, &start, &end); } - gtk_box_pack_start(GTK_BOX(vbox), - pidgin_make_scrollable(console->view, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC, GTK_SHADOW_ETCHED_IN, -1, -1), - TRUE, TRUE, 0); - - toolbar = gtk_toolbar_new(); - button = gtk_tool_button_new(NULL, "<iq/>"); - gtk_tool_item_set_is_important(button, TRUE); - g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(iq_clicked_cb), NULL); - gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); - - button = gtk_tool_button_new(NULL, "<presence/>"); - gtk_tool_item_set_is_important(button, TRUE); - g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(presence_clicked_cb), NULL); - gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); - - button = gtk_tool_button_new(NULL, "<message/>"); - gtk_tool_item_set_is_important(button, TRUE); - g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(message_clicked_cb), NULL); - gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); - - gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0); - - console->entry = gtk_text_view_new(); - gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(console->entry), GTK_WRAP_WORD); + + /* Popover for <iq/> button. */ + console->iq.popover = + GTK_POPOVER(gtk_builder_get_object(builder, "iq.popover")); + console->iq.to = GTK_ENTRY(gtk_builder_get_object(builder, "iq.to")); + console->iq.type = + GTK_COMBO_BOX_TEXT(gtk_builder_get_object(builder, "iq.type")); + + /* Popover for <presence/> button. */ + console->presence.popover = GTK_POPOVER( + gtk_builder_get_object(builder, "presence.popover")); + console->presence.to = + GTK_ENTRY(gtk_builder_get_object(builder, "presence.to")); + console->presence.type = GTK_COMBO_BOX_TEXT( + gtk_builder_get_object(builder, "presence.type")); + console->presence.show = GTK_COMBO_BOX_TEXT( + gtk_builder_get_object(builder, "presence.show")); + console->presence.status = + GTK_ENTRY(gtk_builder_get_object(builder, "presence.status")); + console->presence.priority = + GTK_ENTRY(gtk_builder_get_object(builder, "presence.priority")); + + /* Popover for <message/> button. */ + console->message.popover = + GTK_POPOVER(gtk_builder_get_object(builder, "message.popover")); + console->message.to = + GTK_ENTRY(gtk_builder_get_object(builder, "message.to")); + console->message.type = GTK_COMBO_BOX_TEXT( + gtk_builder_get_object(builder, "message.type")); + console->message.body = + GTK_ENTRY(gtk_builder_get_object(builder, "message.body")); + console->message.subject = + GTK_ENTRY(gtk_builder_get_object(builder, "message.subject")); + console->message.thread = + GTK_ENTRY(gtk_builder_get_object(builder, "message.thread")); + + gtk_builder_add_callback_symbols( + builder, "toggle_button_toggled_cb", + G_CALLBACK(toggle_button_toggled_cb), "popover_closed_cb", + G_CALLBACK(popover_closed_cb), "iq_clicked_cb", + G_CALLBACK(iq_clicked_cb), "presence_clicked_cb", + G_CALLBACK(presence_clicked_cb), "message_clicked_cb", + G_CALLBACK(message_clicked_cb), NULL); + + console->entry = GTK_WIDGET(gtk_builder_get_object(builder, "entry")); entry_css = gtk_css_provider_new(); gtk_css_provider_load_from_data(entry_css, "textview." GTK_STYLE_CLASS_ERROR " text {background-color:#ffcece;}", @@ -874,18 +681,23 @@ create_console(PurplePluginAction *action) context = gtk_widget_get_style_context(console->entry); gtk_style_context_add_provider(context, GTK_STYLE_PROVIDER(entry_css), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); - console->entry_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); - g_signal_connect(G_OBJECT(console->entry),"key-press-event", G_CALLBACK(message_send_cb), console); + console->entry_buffer = GTK_TEXT_BUFFER( + gtk_builder_get_object(builder, "entry_buffer")); + gtk_builder_add_callback_symbol(builder, "message_send_cb", + G_CALLBACK(message_send_cb)); - console->sw = pidgin_make_scrollable(console->entry, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC, GTK_SHADOW_ETCHED_IN, -1, -1); - gtk_box_pack_start(GTK_BOX(vbox), console->sw, FALSE, FALSE, 0); - g_signal_connect(G_OBJECT(console->entry_buffer), "changed", G_CALLBACK(entry_changed_cb), NULL); + console->sw = GTK_WIDGET(gtk_builder_get_object(builder, "sw")); + gtk_builder_add_callback_symbol(builder, "entry_changed_cb", + G_CALLBACK(entry_changed_cb)); entry_changed_cb(console->entry_buffer, NULL); gtk_widget_show_all(console->window); if (console->count < 2) gtk_widget_hide(console->hbox); + + gtk_builder_connect_signals(builder, console); + g_object_unref(builder); } static GList * diff --git a/pidgin/plugins/xmppconsole/xmppconsole.gresource.xml b/pidgin/plugins/xmppconsole/xmppconsole.gresource.xml new file mode 100644 index 0000000000..16d59c10f9 --- /dev/null +++ b/pidgin/plugins/xmppconsole/xmppconsole.gresource.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<gresources> + <gresource prefix="/im/pidgin/Pidgin/Plugin/XMPPConsole/"> + <file compressed="true">console.ui</file> + </gresource> +</gresources> |