Sat, 08 Jan 2011 03:45:42 +0000
Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
committer: John Bailey <rekkanoryo@rekkanoryo.org>
| 15412 | 1 | /* |
| 15884 | 2 | * Purple - XMPP debugging tool |
| 15412 | 3 | * |
| 4 | * Copyright (C) 2002-2003, Sean Egan | |
| 5 | * | |
| 6 | * This program is free software; you can redistribute it and/or modify | |
| 7 | * it under the terms of the GNU General Public License as published by | |
| 8 | * the Free Software Foundation; either version 2 of the License, or | |
| 9 | * (at your option) any later version. | |
| 10 | * | |
| 11 | * This program is distributed in the hope that it will be useful, | |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | * GNU General Public License for more details. | |
| 15 | * | |
| 16 | * You should have received a copy of the GNU General Public License | |
| 17 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18122
diff
changeset
|
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 15412 | 19 | * |
| 20 | */ | |
| 21 | ||
| 22 | #include "internal.h" | |
| 23 | #include "gtkplugin.h" | |
| 24 | #include "version.h" | |
| 25 | #include "prpl.h" | |
| 26 | #include "xmlnode.h" | |
| 27 | ||
| 28 | #include "gtkimhtml.h" | |
| 17242 | 29 | #include "gtkutils.h" |
| 15412 | 30 | |
| 31 | typedef struct { | |
| 15884 | 32 | PurpleConnection *gc; |
| 15412 | 33 | GtkWidget *window; |
| 34 | GtkWidget *hbox; | |
| 35 | GtkWidget *dropdown; | |
| 36 | GtkWidget *imhtml; | |
| 37 | GtkWidget *entry; | |
| 38 | GtkWidget *sw; | |
| 39 | int count; | |
| 40 | GList *accounts; | |
| 41 | } XmppConsole; | |
| 42 | ||
| 43 | XmppConsole *console = NULL; | |
| 44 | static void *xmpp_console_handle = NULL; | |
| 45 | ||
| 46 | #define BRACKET_COLOR "#940f8c" | |
| 47 | #define TAG_COLOR "#8b1dab" | |
| 48 | #define ATTR_NAME_COLOR "#a02961" | |
| 49 | #define ATTR_VALUE_COLOR "#324aa4" | |
| 50 | #define XMLNS_COLOR "#2cb12f" | |
| 51 | ||
| 52 | static char * | |
| 53 | xmlnode_to_pretty_str(xmlnode *node, int *len, int depth) | |
| 54 | { | |
| 55 | GString *text = g_string_new(""); | |
| 56 | xmlnode *c; | |
| 57 | char *node_name, *esc, *esc2, *tab = NULL; | |
| 58 | gboolean need_end = FALSE, pretty = TRUE; | |
| 59 | ||
| 60 | g_return_val_if_fail(node != NULL, NULL); | |
| 61 | ||
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
62 | if (pretty && depth) { |
| 15412 | 63 | tab = g_strnfill(depth, '\t'); |
| 64 | text = g_string_append(text, tab); | |
| 65 | } | |
| 66 | ||
| 67 | node_name = g_markup_escape_text(node->name, -1); | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
68 | g_string_append_printf(text, |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
69 | "<font color='" BRACKET_COLOR "'><</font>" |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
70 | "<font color='" TAG_COLOR "'><b>%s</b></font>", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
71 | node_name); |
| 15412 | 72 | |
| 73 | if (node->xmlns) { | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
74 | if ((!node->parent || |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
75 | !node->parent->xmlns || |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
76 | strcmp(node->xmlns, node->parent->xmlns)) && |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
77 | strcmp(node->xmlns, "jabber:client")) |
| 15412 | 78 | { |
| 79 | char *xmlns = g_markup_escape_text(node->xmlns, -1); | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
80 | g_string_append_printf(text, |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
81 | " <font color='" ATTR_NAME_COLOR "'><b>xmlns</b></font>=" |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
82 | "'<font color='" XMLNS_COLOR "'><b>%s</b></font>'", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
83 | xmlns); |
| 15412 | 84 | g_free(xmlns); |
| 85 | } | |
| 86 | } | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
87 | for (c = node->child; c; c = c->next) |
| 15412 | 88 | { |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
89 | if (c->type == XMLNODE_TYPE_ATTRIB) { |
| 15412 | 90 | esc = g_markup_escape_text(c->name, -1); |
| 91 | esc2 = g_markup_escape_text(c->data, -1); | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
92 | g_string_append_printf(text, |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
93 | " <font color='" ATTR_NAME_COLOR "'><b>%s</b></font>=" |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
94 | "'<font color='" ATTR_VALUE_COLOR "'>%s</font>'", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
95 | esc, esc2); |
| 15412 | 96 | g_free(esc); |
| 97 | g_free(esc2); | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
98 | } else if (c->type == XMLNODE_TYPE_TAG || c->type == XMLNODE_TYPE_DATA) { |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
99 | if (c->type == XMLNODE_TYPE_DATA) |
| 15412 | 100 | pretty = FALSE; |
| 101 | need_end = TRUE; | |
| 102 | } | |
| 103 | } | |
| 104 | ||
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
105 | if (need_end) { |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
106 | g_string_append_printf(text, |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
107 | "<font color='"BRACKET_COLOR"'>></font>%s", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
108 | pretty ? "<br>" : ""); |
| 15412 | 109 | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
110 | for (c = node->child; c; c = c->next) |
| 15412 | 111 | { |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
112 | if (c->type == XMLNODE_TYPE_TAG) { |
| 15412 | 113 | int esc_len; |
| 114 | esc = xmlnode_to_pretty_str(c, &esc_len, depth+1); | |
| 115 | text = g_string_append_len(text, esc, esc_len); | |
| 116 | g_free(esc); | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
117 | } else if (c->type == XMLNODE_TYPE_DATA && c->data_sz > 0) { |
| 15412 | 118 | esc = g_markup_escape_text(c->data, c->data_sz); |
| 119 | text = g_string_append(text, esc); | |
| 120 | g_free(esc); | |
| 121 | } | |
| 122 | } | |
| 123 | ||
| 124 | if(tab && pretty) | |
| 125 | text = g_string_append(text, tab); | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
126 | g_string_append_printf(text, |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
127 | "<font color='" BRACKET_COLOR "'><</font>/" |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
128 | "<font color='" TAG_COLOR "'><b>%s</b></font>" |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
129 | "<font color='" BRACKET_COLOR "'>></font><br>", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
130 | node_name); |
| 15412 | 131 | } else { |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
132 | g_string_append_printf(text, |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
133 | "/<font color='" BRACKET_COLOR "'>></font><br>"); |
| 15412 | 134 | } |
| 135 | ||
| 136 | g_free(node_name); | |
| 137 | ||
| 138 | g_free(tab); | |
| 139 | ||
| 140 | if(len) | |
| 141 | *len = text->len; | |
| 142 | ||
| 143 | return g_string_free(text, FALSE); | |
| 144 | } | |
| 145 | ||
| 146 | static void | |
| 15884 | 147 | xmlnode_received_cb(PurpleConnection *gc, xmlnode **packet, gpointer null) |
| 15412 | 148 | { |
| 149 | char *str, *formatted; | |
| 150 | ||
| 151 | if (!console || console->gc != gc) | |
| 152 | return; | |
| 153 | str = xmlnode_to_pretty_str(*packet, NULL, 0); | |
| 154 | formatted = g_strdup_printf("<body bgcolor='#ffcece'><pre>%s</pre></body>", str); | |
| 155 | gtk_imhtml_append_text(GTK_IMHTML(console->imhtml), formatted, 0); | |
| 156 | g_free(formatted); | |
| 157 | g_free(str); | |
| 158 | } | |
| 159 | ||
| 160 | static void | |
| 15884 | 161 | xmlnode_sent_cb(PurpleConnection *gc, char **packet, gpointer null) |
| 15412 | 162 | { |
| 163 | char *str; | |
| 164 | char *formatted; | |
| 165 | xmlnode *node; | |
| 166 | ||
| 167 | if (!console || console->gc != gc) | |
| 168 | return; | |
| 169 | node = xmlnode_from_str(*packet, -1); | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
170 | |
| 15412 | 171 | if (!node) |
| 172 | return; | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
173 | |
| 15412 | 174 | str = xmlnode_to_pretty_str(node, NULL, 0); |
| 175 | formatted = g_strdup_printf("<body bgcolor='#dcecc4'><pre>%s</pre></body>", str); | |
| 176 | gtk_imhtml_append_text(GTK_IMHTML(console->imhtml), formatted, 0); | |
| 177 | g_free(formatted); | |
| 178 | g_free(str); | |
| 179 | xmlnode_free(node); | |
| 180 | } | |
| 181 | ||
| 182 | static void message_send_cb(GtkWidget *widget, gpointer p) | |
| 183 | { | |
| 184 | GtkTextIter start, end; | |
| 15884 | 185 | PurplePluginProtocolInfo *prpl_info = NULL; |
|
30626
bec413ce77c7
Fix some "Dead nested assignment"s and then kill off some useless
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30010
diff
changeset
|
186 | PurpleConnection *gc; |
| 15412 | 187 | GtkTextBuffer *buffer; |
| 188 | char *text; | |
| 189 | ||
| 190 | gc = console->gc; | |
|
17529
5fd44f61d007
Fix a crash when trying to use XMPP console with no XMPP accounts connected
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16749
diff
changeset
|
191 | |
|
5fd44f61d007
Fix a crash when trying to use XMPP console with no XMPP accounts connected
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16749
diff
changeset
|
192 | if (gc) |
|
5fd44f61d007
Fix a crash when trying to use XMPP console with no XMPP accounts connected
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16749
diff
changeset
|
193 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); |
|
5fd44f61d007
Fix a crash when trying to use XMPP console with no XMPP accounts connected
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16749
diff
changeset
|
194 | |
| 15412 | 195 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); |
| 196 | gtk_text_buffer_get_start_iter(buffer, &start); | |
| 197 | gtk_text_buffer_get_end_iter(buffer, &end); | |
|
17529
5fd44f61d007
Fix a crash when trying to use XMPP console with no XMPP accounts connected
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16749
diff
changeset
|
198 | |
| 15412 | 199 | text = gtk_imhtml_get_text(GTK_IMHTML(console->entry), &start, &end); |
|
17529
5fd44f61d007
Fix a crash when trying to use XMPP console with no XMPP accounts connected
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16749
diff
changeset
|
200 | |
|
5fd44f61d007
Fix a crash when trying to use XMPP console with no XMPP accounts connected
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16749
diff
changeset
|
201 | if (prpl_info && prpl_info->send_raw != NULL) |
| 15412 | 202 | prpl_info->send_raw(gc, text, strlen(text)); |
| 203 | ||
| 204 | g_free(text); | |
| 205 | gtk_imhtml_clear(GTK_IMHTML(console->entry)); | |
| 206 | } | |
| 207 | ||
| 208 | static void entry_changed_cb(GtkTextBuffer *buffer, void *data) | |
| 209 | { | |
| 210 | char *xmlstr, *str; | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
211 | GtkTextIter iter; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
212 | int wrapped_lines; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
213 | int lines; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
214 | GdkRectangle oneline; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
215 | int height; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
216 | int pad_top, pad_inside, pad_bottom; |
| 15412 | 217 | GtkTextIter start, end; |
| 218 | xmlnode *node; | |
| 219 | ||
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
220 | wrapped_lines = 1; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
221 | gtk_text_buffer_get_start_iter(buffer, &iter); |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
222 | gtk_text_view_get_iter_location(GTK_TEXT_VIEW(console->entry), &iter, &oneline); |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
223 | while (gtk_text_view_forward_display_line(GTK_TEXT_VIEW(console->entry), &iter)) |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
224 | wrapped_lines++; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
225 | |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
226 | lines = gtk_text_buffer_get_line_count(buffer); |
| 15412 | 227 | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
228 | /* Show a maximum of 64 lines */ |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
229 | lines = MIN(lines, 6); |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
230 | wrapped_lines = MIN(wrapped_lines, 6); |
| 15412 | 231 | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
232 | pad_top = gtk_text_view_get_pixels_above_lines(GTK_TEXT_VIEW(console->entry)); |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
233 | pad_bottom = gtk_text_view_get_pixels_below_lines(GTK_TEXT_VIEW(console->entry)); |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
234 | pad_inside = gtk_text_view_get_pixels_inside_wrap(GTK_TEXT_VIEW(console->entry)); |
| 15412 | 235 | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
236 | height = (oneline.height + pad_top + pad_bottom) * lines; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
237 | height += (oneline.height + pad_inside) * (wrapped_lines - lines); |
| 15412 | 238 | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
239 | gtk_widget_set_size_request(console->sw, -1, height + 6); |
| 15412 | 240 | |
| 241 | gtk_text_buffer_get_start_iter(buffer, &start); | |
| 242 | gtk_text_buffer_get_end_iter(buffer, &end); | |
| 243 | str = gtk_text_buffer_get_text(buffer, &start, &end, FALSE); | |
| 244 | if (!str) | |
| 245 | return; | |
| 246 | xmlstr = g_strdup_printf("<xml>%s</xml>", str); | |
| 247 | node = xmlnode_from_str(xmlstr, -1); | |
| 248 | if (node) { | |
| 249 | gtk_imhtml_clear_formatting(GTK_IMHTML(console->entry)); | |
| 250 | } else { | |
| 251 | gtk_imhtml_toggle_background(GTK_IMHTML(console->entry), "#ffcece"); | |
| 252 | } | |
| 253 | g_free(str); | |
| 254 | g_free(xmlstr); | |
| 255 | if (node) | |
| 256 | xmlnode_free(node); | |
| 257 | } | |
| 258 | ||
| 259 | static void iq_clicked_cb(GtkWidget *w, gpointer nul) | |
| 260 | { | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
261 | GtkWidget *vbox, *hbox, *to_entry, *label, *type_combo; |
| 15412 | 262 | GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
| 263 | GtkTextIter iter; | |
| 264 | GtkTextBuffer *buffer; | |
| 265 | const char *to; | |
| 266 | int result; | |
| 267 | char *stanza; | |
| 268 | ||
| 269 | GtkWidget *dialog = gtk_dialog_new_with_buttons("<iq/>", | |
| 270 | GTK_WINDOW(console->window), | |
| 271 | GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 272 | GTK_STOCK_CANCEL, | |
| 273 | GTK_RESPONSE_REJECT, | |
| 274 | GTK_STOCK_OK, | |
| 275 | GTK_RESPONSE_ACCEPT, | |
| 276 | NULL); | |
| 277 | gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | |
| 278 | gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); | |
| 279 | gtk_container_set_border_width(GTK_CONTAINER(dialog), 12); | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
280 | #if GTK_CHECK_VERSION(2,14,0) |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
281 | vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
282 | #else |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
283 | vbox = GTK_DIALOG(dialog)->vbox; |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
284 | #endif |
| 15412 | 285 | |
| 286 | hbox = gtk_hbox_new(FALSE, 3); | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
287 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| 15412 | 288 | |
| 289 | label = gtk_label_new("To:"); | |
| 290 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 291 | gtk_size_group_add_widget(sg, label); | |
| 292 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 293 | ||
| 294 | to_entry = gtk_entry_new(); | |
| 295 | gtk_entry_set_activates_default (GTK_ENTRY (to_entry), TRUE); | |
| 296 | gtk_box_pack_start(GTK_BOX(hbox), to_entry, FALSE, FALSE, 0); | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
297 | |
| 15412 | 298 | hbox = gtk_hbox_new(FALSE, 3); |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
299 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| 15412 | 300 | label = gtk_label_new("Type:"); |
| 301 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 302 | ||
| 303 | gtk_size_group_add_widget(sg, label); | |
| 304 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 305 | type_combo = gtk_combo_box_new_text(); | |
| 306 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "get"); | |
| 307 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "set"); | |
| 308 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "result"); | |
| 309 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "error"); | |
| 310 | gtk_combo_box_set_active(GTK_COMBO_BOX(type_combo), 0); | |
| 311 | gtk_box_pack_start(GTK_BOX(hbox), type_combo, FALSE, FALSE, 0); | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
312 | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
313 | gtk_widget_show_all(vbox); |
| 15412 | 314 | |
| 315 | result = gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 316 | if (result != GTK_RESPONSE_ACCEPT) { | |
| 317 | gtk_widget_destroy(dialog); | |
| 318 | return; | |
| 319 | } | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
320 | |
| 15412 | 321 | to = gtk_entry_get_text(GTK_ENTRY(to_entry)); |
| 322 | ||
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
323 | stanza = g_strdup_printf("<iq %s%s%s id='console%x' type='%s'></iq>", |
| 15412 | 324 | to && *to ? "to='" : "", |
| 325 | to && *to ? to : "", | |
| 326 | to && *to ? "'" : "", | |
| 327 | g_random_int(), | |
| 328 | gtk_combo_box_get_active_text(GTK_COMBO_BOX(type_combo))); | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
329 | |
| 15412 | 330 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); |
| 331 | gtk_text_buffer_set_text(buffer, stanza, -1); | |
| 332 | gtk_text_buffer_get_iter_at_offset(buffer, &iter, strstr(stanza, "</iq>") - stanza); | |
| 333 | gtk_text_buffer_place_cursor(buffer, &iter); | |
| 334 | g_free(stanza); | |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
335 | |
| 15412 | 336 | gtk_widget_destroy(dialog); |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
337 | g_object_unref(sg); |
| 15412 | 338 | } |
| 339 | ||
| 340 | static void presence_clicked_cb(GtkWidget *w, gpointer nul) | |
| 341 | { | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
342 | GtkWidget *vbox; |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
343 | GtkWidget *hbox; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
344 | GtkWidget *to_entry; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
345 | GtkWidget *status_entry; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
346 | GtkWidget *priority_entry; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
347 | GtkWidget *label; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
348 | GtkWidget *show_combo; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
349 | GtkWidget *type_combo; |
| 15412 | 350 | GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
| 351 | GtkTextIter iter; | |
| 352 | GtkTextBuffer *buffer; | |
| 353 | const char *to, *type, *status, *show, *priority; | |
| 354 | int result; | |
| 355 | char *stanza; | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
356 | |
| 15412 | 357 | GtkWidget *dialog = gtk_dialog_new_with_buttons("<presence/>", |
| 358 | GTK_WINDOW(console->window), | |
| 359 | GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 360 | GTK_STOCK_CANCEL, | |
| 361 | GTK_RESPONSE_REJECT, | |
| 362 | GTK_STOCK_OK, | |
| 363 | GTK_RESPONSE_ACCEPT, | |
| 364 | NULL); | |
| 365 | gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | |
| 366 | gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); | |
| 367 | gtk_container_set_border_width(GTK_CONTAINER(dialog), 12); | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
368 | #if GTK_CHECK_VERSION(2,14,0) |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
369 | vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
370 | #else |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
371 | vbox = GTK_DIALOG(dialog)->vbox; |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
372 | #endif |
| 15412 | 373 | |
| 374 | hbox = gtk_hbox_new(FALSE, 3); | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
375 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| 15412 | 376 | |
| 377 | label = gtk_label_new("To:"); | |
| 378 | gtk_size_group_add_widget(sg, label); | |
| 379 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 380 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 381 | ||
| 382 | to_entry = gtk_entry_new(); | |
| 383 | gtk_entry_set_activates_default (GTK_ENTRY (to_entry), TRUE); | |
| 384 | gtk_box_pack_start(GTK_BOX(hbox), to_entry, FALSE, FALSE, 0); | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
385 | |
| 15412 | 386 | hbox = gtk_hbox_new(FALSE, 3); |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
387 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| 15412 | 388 | label = gtk_label_new("Type:"); |
| 389 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 390 | gtk_size_group_add_widget(sg, label); | |
| 391 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 392 | type_combo = gtk_combo_box_new_text(); | |
| 393 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "default"); | |
| 394 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "unavailable"); | |
| 395 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "subscribe"); | |
| 396 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "unsubscribe"); | |
| 397 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "subscribed"); | |
| 398 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "unsubscribed"); | |
| 399 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "probe"); | |
| 400 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "error"); | |
| 401 | gtk_combo_box_set_active(GTK_COMBO_BOX(type_combo), 0); | |
| 402 | gtk_box_pack_start(GTK_BOX(hbox), type_combo, FALSE, FALSE, 0); | |
| 403 | ||
| 404 | hbox = gtk_hbox_new(FALSE, 3); | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
405 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| 15412 | 406 | label = gtk_label_new("Show:"); |
| 407 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 408 | gtk_size_group_add_widget(sg, label); | |
| 409 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 410 | show_combo = gtk_combo_box_new_text(); | |
| 411 | gtk_combo_box_append_text(GTK_COMBO_BOX(show_combo), "default"); | |
| 412 | gtk_combo_box_append_text(GTK_COMBO_BOX(show_combo), "away"); | |
| 413 | gtk_combo_box_append_text(GTK_COMBO_BOX(show_combo), "dnd"); | |
| 414 | gtk_combo_box_append_text(GTK_COMBO_BOX(show_combo), "xa"); | |
| 415 | gtk_combo_box_append_text(GTK_COMBO_BOX(show_combo), "chat"); | |
| 416 | ||
| 417 | gtk_combo_box_set_active(GTK_COMBO_BOX(show_combo), 0); | |
| 418 | gtk_box_pack_start(GTK_BOX(hbox), show_combo, FALSE, FALSE, 0); | |
| 419 | ||
| 420 | hbox = gtk_hbox_new(FALSE, 3); | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
421 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| 15412 | 422 | |
| 423 | label = gtk_label_new("Status:"); | |
| 424 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 425 | gtk_size_group_add_widget(sg, label); | |
| 426 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 427 | ||
| 428 | status_entry = gtk_entry_new(); | |
| 429 | gtk_entry_set_activates_default (GTK_ENTRY (status_entry), TRUE); | |
| 430 | gtk_box_pack_start(GTK_BOX(hbox), status_entry, FALSE, FALSE, 0); | |
| 431 | ||
| 432 | hbox = gtk_hbox_new(FALSE, 3); | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
433 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| 15412 | 434 | |
| 435 | label = gtk_label_new("Priority:"); | |
| 436 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 437 | gtk_size_group_add_widget(sg, label); | |
| 438 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 439 | ||
| 440 | priority_entry = gtk_spin_button_new_with_range(-128, 127, 1); | |
| 441 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(priority_entry), 0); | |
| 442 | gtk_box_pack_start(GTK_BOX(hbox), priority_entry, FALSE, FALSE, 0); | |
| 443 | ||
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
444 | gtk_widget_show_all(vbox); |
| 15412 | 445 | |
| 446 | result = gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 447 | if (result != GTK_RESPONSE_ACCEPT) { | |
| 448 | gtk_widget_destroy(dialog); | |
| 449 | return; | |
| 450 | } | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
451 | |
| 15412 | 452 | to = gtk_entry_get_text(GTK_ENTRY(to_entry)); |
| 453 | type = gtk_combo_box_get_active_text(GTK_COMBO_BOX(type_combo)); | |
| 454 | if (!strcmp(type, "default")) | |
| 455 | type = ""; | |
| 456 | show = gtk_combo_box_get_active_text(GTK_COMBO_BOX(show_combo)); | |
| 457 | if (!strcmp(show, "default")) | |
| 458 | show = ""; | |
| 459 | status = gtk_entry_get_text(GTK_ENTRY(status_entry)); | |
| 460 | priority = gtk_entry_get_text(GTK_ENTRY(priority_entry)); | |
| 461 | if (!strcmp(priority, "0")) | |
| 462 | priority = ""; | |
| 463 | ||
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
464 | stanza = g_strdup_printf("<presence %s%s%s id='console%x' %s%s%s>" |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
465 | "%s%s%s%s%s%s%s%s%s" |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
466 | "</presence>", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
467 | *to ? "to='" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
468 | *to ? to : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
469 | *to ? "'" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
470 | g_random_int(), |
| 15412 | 471 | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
472 | *type ? "type='" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
473 | *type ? type : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
474 | *type ? "'" : "", |
| 15412 | 475 | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
476 | *show ? "<show>" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
477 | *show ? show : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
478 | *show ? "</show>" : "", |
| 15412 | 479 | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
480 | *status ? "<status>" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
481 | *status ? status : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
482 | *status ? "</status>" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
483 | |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
484 | *priority ? "<priority>" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
485 | *priority ? priority : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
486 | *priority ? "</priority>" : ""); |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
487 | |
| 15412 | 488 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); |
| 489 | gtk_text_buffer_set_text(buffer, stanza, -1); | |
| 490 | gtk_text_buffer_get_iter_at_offset(buffer, &iter, strstr(stanza, "</presence>") - stanza); | |
| 491 | gtk_text_buffer_place_cursor(buffer, &iter); | |
| 492 | g_free(stanza); | |
| 493 | ||
| 494 | gtk_widget_destroy(dialog); | |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
495 | g_object_unref(sg); |
| 15412 | 496 | } |
| 497 | ||
| 498 | static void message_clicked_cb(GtkWidget *w, gpointer nul) | |
| 499 | { | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
500 | GtkWidget *vbox; |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
501 | GtkWidget *hbox; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
502 | GtkWidget *to_entry; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
503 | GtkWidget *body_entry; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
504 | GtkWidget *thread_entry; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
505 | GtkWidget *subject_entry; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
506 | GtkWidget *label; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
507 | GtkWidget *type_combo; |
| 15412 | 508 | GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
| 509 | GtkTextIter iter; | |
| 510 | GtkTextBuffer *buffer; | |
| 511 | const char *to, *body, *thread, *subject; | |
| 512 | char *stanza; | |
| 513 | int result; | |
| 514 | ||
| 515 | GtkWidget *dialog = gtk_dialog_new_with_buttons("<message/>", | |
| 516 | GTK_WINDOW(console->window), | |
| 517 | GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 518 | GTK_STOCK_CANCEL, | |
| 519 | GTK_RESPONSE_REJECT, | |
| 520 | GTK_STOCK_OK, | |
| 521 | GTK_RESPONSE_ACCEPT, | |
| 522 | NULL); | |
| 523 | gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | |
| 524 | gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); | |
| 525 | gtk_container_set_border_width(GTK_CONTAINER(dialog), 12); | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
526 | #if GTK_CHECK_VERSION(2,14,0) |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
527 | vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
528 | #else |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
529 | vbox = GTK_DIALOG(dialog)->vbox; |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
530 | #endif |
| 15412 | 531 | |
| 532 | hbox = gtk_hbox_new(FALSE, 3); | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
533 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| 15412 | 534 | |
| 535 | label = gtk_label_new("To:"); | |
| 536 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 537 | gtk_size_group_add_widget(sg, label); | |
| 538 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 539 | ||
| 540 | to_entry = gtk_entry_new(); | |
| 541 | gtk_entry_set_activates_default (GTK_ENTRY (to_entry), TRUE); | |
| 542 | gtk_box_pack_start(GTK_BOX(hbox), to_entry, FALSE, FALSE, 0); | |
| 543 | ||
| 544 | hbox = gtk_hbox_new(FALSE, 3); | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
545 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| 15412 | 546 | label = gtk_label_new("Type:"); |
| 547 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 548 | gtk_size_group_add_widget(sg, label); | |
| 549 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 550 | type_combo = gtk_combo_box_new_text(); | |
| 551 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "chat"); | |
| 552 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "headline"); | |
| 553 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "groupchat"); | |
| 554 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "normal"); | |
| 555 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "error"); | |
| 556 | gtk_combo_box_set_active(GTK_COMBO_BOX(type_combo), 0); | |
| 557 | gtk_box_pack_start(GTK_BOX(hbox), type_combo, FALSE, FALSE, 0); | |
| 558 | ||
| 559 | hbox = gtk_hbox_new(FALSE, 3); | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
560 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| 15412 | 561 | |
| 562 | label = gtk_label_new("Body:"); | |
| 563 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 564 | gtk_size_group_add_widget(sg, label); | |
| 565 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 566 | ||
| 567 | body_entry = gtk_entry_new(); | |
| 568 | gtk_entry_set_activates_default (GTK_ENTRY (body_entry), TRUE); | |
| 569 | gtk_box_pack_start(GTK_BOX(hbox), body_entry, FALSE, FALSE, 0); | |
| 570 | ||
| 571 | hbox = gtk_hbox_new(FALSE, 3); | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
572 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| 15412 | 573 | |
| 574 | label = gtk_label_new("Subject:"); | |
| 575 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 576 | gtk_size_group_add_widget(sg, label); | |
| 577 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 578 | ||
| 579 | subject_entry = gtk_entry_new(); | |
| 580 | gtk_entry_set_activates_default (GTK_ENTRY (subject_entry), TRUE); | |
| 581 | gtk_box_pack_start(GTK_BOX(hbox), subject_entry, FALSE, FALSE, 0); | |
| 582 | ||
| 583 | hbox = gtk_hbox_new(FALSE, 3); | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
584 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| 15412 | 585 | |
| 586 | label = gtk_label_new("Thread:"); | |
| 587 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 588 | gtk_size_group_add_widget(sg, label); | |
| 589 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 590 | ||
| 591 | thread_entry = gtk_entry_new(); | |
| 592 | gtk_entry_set_activates_default (GTK_ENTRY (thread_entry), TRUE); | |
| 593 | gtk_box_pack_start(GTK_BOX(hbox), thread_entry, FALSE, FALSE, 0); | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
594 | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29876
diff
changeset
|
595 | gtk_widget_show_all(vbox); |
| 15412 | 596 | |
| 597 | result = gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 598 | if (result != GTK_RESPONSE_ACCEPT) { | |
| 599 | gtk_widget_destroy(dialog); | |
| 600 | return; | |
| 601 | } | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
602 | |
| 15412 | 603 | to = gtk_entry_get_text(GTK_ENTRY(to_entry)); |
| 604 | body = gtk_entry_get_text(GTK_ENTRY(body_entry)); | |
| 605 | thread = gtk_entry_get_text(GTK_ENTRY(thread_entry)); | |
| 606 | subject = gtk_entry_get_text(GTK_ENTRY(subject_entry)); | |
| 607 | ||
| 608 | stanza = g_strdup_printf("<message %s%s%s id='console%x' type='%s'>" | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
609 | "%s%s%s%s%s%s%s%s%s" |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
610 | "</message>", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
611 | |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
612 | *to ? "to='" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
613 | *to ? to : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
614 | *to ? "'" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
615 | g_random_int(), |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
616 | gtk_combo_box_get_active_text(GTK_COMBO_BOX(type_combo)), |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
617 | |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
618 | *body ? "<body>" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
619 | *body ? body : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
620 | *body ? "</body>" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
621 | |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
622 | *subject ? "<subject>" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
623 | *subject ? subject : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
624 | *subject ? "</subject>" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
625 | |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
626 | *thread ? "<thread>" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
627 | *thread ? thread : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
628 | *thread ? "</thread>" : ""); |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
629 | |
| 15412 | 630 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); |
| 631 | gtk_text_buffer_set_text(buffer, stanza, -1); | |
| 632 | gtk_text_buffer_get_iter_at_offset(buffer, &iter, strstr(stanza, "</message>") - stanza); | |
| 633 | gtk_text_buffer_place_cursor(buffer, &iter); | |
| 634 | g_free(stanza); | |
| 635 | ||
| 636 | gtk_widget_destroy(dialog); | |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
637 | g_object_unref(sg); |
| 15412 | 638 | } |
| 639 | ||
| 640 | static void | |
|
29783
96ab389c9181
xmppconsole: Properly catch things before an account is "signed on".
Paul Aurich <darkrain42@pidgin.im>
parents:
29529
diff
changeset
|
641 | signing_on_cb(PurpleConnection *gc) |
| 15412 | 642 | { |
| 643 | if (!console) | |
| 644 | return; | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
645 | |
| 15884 | 646 | gtk_combo_box_append_text(GTK_COMBO_BOX(console->dropdown), purple_account_get_username(gc->account)); |
| 15412 | 647 | console->accounts = g_list_append(console->accounts, gc); |
| 648 | console->count++; | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
649 | |
|
29783
96ab389c9181
xmppconsole: Properly catch things before an account is "signed on".
Paul Aurich <darkrain42@pidgin.im>
parents:
29529
diff
changeset
|
650 | if (console->count == 1) |
|
96ab389c9181
xmppconsole: Properly catch things before an account is "signed on".
Paul Aurich <darkrain42@pidgin.im>
parents:
29529
diff
changeset
|
651 | console->gc = gc; |
|
96ab389c9181
xmppconsole: Properly catch things before an account is "signed on".
Paul Aurich <darkrain42@pidgin.im>
parents:
29529
diff
changeset
|
652 | else |
| 15412 | 653 | gtk_widget_show_all(console->hbox); |
| 654 | } | |
| 655 | ||
| 656 | static void | |
| 15884 | 657 | signed_off_cb(PurpleConnection *gc) |
| 15412 | 658 | { |
| 659 | int i = 0; | |
| 660 | GList *l; | |
| 661 | ||
| 662 | if (!console) | |
| 663 | return; | |
| 664 | ||
| 665 | l = console->accounts; | |
| 666 | while (l) { | |
| 15884 | 667 | PurpleConnection *g = l->data; |
| 15412 | 668 | if (gc == g) |
| 669 | break; | |
| 670 | i++; | |
| 671 | l = l->next; | |
| 672 | } | |
| 673 | ||
| 674 | if (l == NULL) | |
| 675 | return; | |
| 676 | ||
| 677 | gtk_combo_box_remove_text(GTK_COMBO_BOX(console->dropdown), i); | |
| 678 | console->accounts = g_list_remove(console->accounts, gc); | |
| 679 | console->count--; | |
| 680 | ||
| 681 | if (gc == console->gc) { | |
| 682 | console->gc = NULL; | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
683 | gtk_imhtml_append_text(GTK_IMHTML(console->imhtml), |
| 15412 | 684 | _("<font color='#777777'>Logged out.</font>"), 0); |
| 685 | } | |
| 686 | } | |
| 687 | ||
| 688 | static gboolean | |
| 15884 | 689 | plugin_load(PurplePlugin *plugin) |
| 15412 | 690 | { |
| 15884 | 691 | PurplePlugin *jabber; |
| 15412 | 692 | |
| 15884 | 693 | jabber = purple_find_prpl("prpl-jabber"); |
| 15412 | 694 | if (!jabber) |
| 695 | return FALSE; | |
| 696 | ||
| 697 | xmpp_console_handle = plugin; | |
| 15884 | 698 | purple_signal_connect(jabber, "jabber-receiving-xmlnode", xmpp_console_handle, |
| 699 | PURPLE_CALLBACK(xmlnode_received_cb), NULL); | |
| 700 | purple_signal_connect(jabber, "jabber-sending-text", xmpp_console_handle, | |
| 701 | PURPLE_CALLBACK(xmlnode_sent_cb), NULL); | |
|
29783
96ab389c9181
xmppconsole: Properly catch things before an account is "signed on".
Paul Aurich <darkrain42@pidgin.im>
parents:
29529
diff
changeset
|
702 | purple_signal_connect(purple_connections_get_handle(), "signing-on", |
|
96ab389c9181
xmppconsole: Properly catch things before an account is "signed on".
Paul Aurich <darkrain42@pidgin.im>
parents:
29529
diff
changeset
|
703 | plugin, PURPLE_CALLBACK(signing_on_cb), NULL); |
| 15884 | 704 | purple_signal_connect(purple_connections_get_handle(), "signed-off", |
| 705 | plugin, PURPLE_CALLBACK(signed_off_cb), NULL); | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
706 | |
| 15412 | 707 | return TRUE; |
| 708 | } | |
| 709 | ||
| 710 | static gboolean | |
| 15884 | 711 | plugin_unload(PurplePlugin *plugin) |
| 15412 | 712 | { |
| 15414 | 713 | if (console) |
| 714 | gtk_widget_destroy(console->window); | |
| 15412 | 715 | return TRUE; |
| 716 | } | |
| 717 | ||
| 718 | static void | |
| 719 | console_destroy(GtkObject *window, gpointer nul) | |
| 720 | { | |
| 721 | g_list_free(console->accounts); | |
| 722 | g_free(console); | |
| 723 | console = NULL; | |
| 724 | } | |
| 725 | ||
| 726 | static void | |
| 727 | dropdown_changed_cb(GtkComboBox *widget, gpointer nul) | |
| 728 | { | |
| 15884 | 729 | PurpleAccount *account; |
| 15412 | 730 | |
| 731 | if (!console) | |
| 732 | return; | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
733 | |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
734 | account = purple_accounts_find(gtk_combo_box_get_active_text(GTK_COMBO_BOX(console->dropdown)), |
| 15412 | 735 | "prpl-jabber"); |
| 736 | if (!account || !account->gc) | |
| 737 | return; | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
738 | |
| 15412 | 739 | console->gc = account->gc; |
| 740 | gtk_imhtml_clear(GTK_IMHTML(console->imhtml)); | |
| 741 | } | |
| 742 | ||
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
743 | static void |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
744 | create_console(PurplePluginAction *action) |
| 15412 | 745 | { |
| 746 | GtkWidget *vbox = gtk_vbox_new(FALSE, 6); | |
| 747 | GtkWidget *label; | |
| 748 | GtkTextBuffer *buffer; | |
| 749 | GtkWidget *toolbar; | |
|
18122
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
750 | GList *connections; |
| 15412 | 751 | GtkToolItem *button; |
| 752 | ||
| 753 | if (console) { | |
| 754 | gtk_window_present(GTK_WINDOW(console->window)); | |
| 755 | return; | |
| 756 | } | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
757 | |
| 15412 | 758 | console = g_new0(XmppConsole, 1); |
| 759 | ||
| 17213 | 760 | console->window = pidgin_create_window(_("XMPP Console"), PIDGIN_HIG_BORDER, NULL, TRUE); |
| 15412 | 761 | g_signal_connect(G_OBJECT(console->window), "destroy", G_CALLBACK(console_destroy), NULL); |
| 762 | gtk_window_set_default_size(GTK_WINDOW(console->window), 580, 400); | |
| 763 | gtk_container_add(GTK_CONTAINER(console->window), vbox); | |
| 764 | ||
| 765 | console->hbox = gtk_hbox_new(FALSE, 3); | |
| 766 | gtk_box_pack_start(GTK_BOX(vbox), console->hbox, FALSE, FALSE, 0); | |
| 767 | label = gtk_label_new(_("Account: ")); | |
| 768 | gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | |
| 769 | gtk_box_pack_start(GTK_BOX(console->hbox), label, FALSE, FALSE, 0); | |
| 770 | console->dropdown = gtk_combo_box_new_text(); | |
| 15884 | 771 | for (connections = purple_connections_get_all(); connections; connections = connections->next) { |
| 772 | PurpleConnection *gc = connections->data; | |
| 773 | if (!strcmp(purple_account_get_protocol_id(purple_connection_get_account(gc)), "prpl-jabber")) { | |
| 15412 | 774 | console->count++; |
| 775 | console->accounts = g_list_append(console->accounts, gc); | |
| 776 | gtk_combo_box_append_text(GTK_COMBO_BOX(console->dropdown), | |
| 15884 | 777 | purple_account_get_username(purple_connection_get_account(gc))); |
| 15412 | 778 | if (!console->gc) |
| 779 | console->gc = gc; | |
| 780 | } | |
| 781 | } | |
| 782 | gtk_combo_box_set_active(GTK_COMBO_BOX(console->dropdown),0); | |
| 783 | gtk_box_pack_start(GTK_BOX(console->hbox), console->dropdown, TRUE, TRUE, 0); | |
| 784 | g_signal_connect(G_OBJECT(console->dropdown), "changed", G_CALLBACK(dropdown_changed_cb), NULL); | |
| 785 | ||
| 786 | console->imhtml = gtk_imhtml_new(NULL, NULL); | |
| 787 | if (console->count == 0) | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
788 | gtk_imhtml_append_text(GTK_IMHTML(console->imhtml), |
| 15412 | 789 | _("<font color='#777777'>Not connected to XMPP</font>"), 0); |
|
31321
1fef3832cfa2
Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents:
30626
diff
changeset
|
790 | gtk_box_pack_start(GTK_BOX(vbox), |
|
1fef3832cfa2
Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents:
30626
diff
changeset
|
791 | pidgin_make_scrollable(console->imhtml, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC, GTK_SHADOW_ETCHED_IN, -1, -1), |
|
1fef3832cfa2
Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents:
30626
diff
changeset
|
792 | TRUE, TRUE, 0); |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
793 | |
| 15412 | 794 | toolbar = gtk_toolbar_new(); |
| 795 | button = gtk_tool_button_new(NULL, "<iq/>"); | |
| 796 | g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(iq_clicked_cb), NULL); | |
| 797 | gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); | |
| 798 | ||
| 799 | button = gtk_tool_button_new(NULL, "<presence/>"); | |
| 800 | g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(presence_clicked_cb), NULL); | |
| 801 | gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); | |
| 802 | ||
| 803 | button = gtk_tool_button_new(NULL, "<message/>"); | |
| 804 | g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(message_clicked_cb), NULL); | |
| 805 | gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
806 | |
| 15412 | 807 | gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0); |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
808 | |
| 15412 | 809 | console->entry = gtk_imhtml_new(NULL, NULL); |
| 810 | gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(console->entry), TRUE); | |
| 811 | g_signal_connect(G_OBJECT(console->entry),"message_send", G_CALLBACK(message_send_cb), console); | |
| 812 | ||
|
31321
1fef3832cfa2
Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents:
30626
diff
changeset
|
813 | console->sw = pidgin_make_scrollable(console->entry, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC, GTK_SHADOW_ETCHED_IN, -1, -1); |
|
1fef3832cfa2
Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents:
30626
diff
changeset
|
814 | gtk_box_pack_start(GTK_BOX(vbox), console->sw, FALSE, FALSE, 0); |
| 15412 | 815 | gtk_imhtml_set_editable(GTK_IMHTML(console->entry), TRUE); |
| 816 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); | |
| 817 | g_signal_connect(G_OBJECT(buffer), "changed", G_CALLBACK(entry_changed_cb), NULL); | |
|
31321
1fef3832cfa2
Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents:
30626
diff
changeset
|
818 | |
| 15412 | 819 | entry_changed_cb(buffer, NULL); |
| 820 | ||
| 821 | gtk_widget_show_all(console->window); | |
| 822 | if (console->count < 2) | |
| 823 | gtk_widget_hide(console->hbox); | |
| 824 | } | |
| 825 | ||
| 826 | static GList * | |
| 15884 | 827 | actions(PurplePlugin *plugin, gpointer context) |
| 15412 | 828 | { |
| 829 | GList *l = NULL; | |
| 15884 | 830 | PurplePluginAction *act = NULL; |
| 15412 | 831 | |
| 15884 | 832 | act = purple_plugin_action_new(_("XMPP Console"), create_console); |
| 15412 | 833 | l = g_list_append(l, act); |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
834 | |
| 15412 | 835 | return l; |
| 836 | } | |
| 837 | ||
| 838 | ||
| 15884 | 839 | static PurplePluginInfo info = |
| 15412 | 840 | { |
| 15884 | 841 | PURPLE_PLUGIN_MAGIC, |
| 842 | PURPLE_MAJOR_VERSION, | |
| 843 | PURPLE_MINOR_VERSION, | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
844 | PURPLE_PLUGIN_STANDARD, /**< type */ |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
845 | PIDGIN_PLUGIN_TYPE, /**< ui_requirement */ |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
846 | 0, /**< flags */ |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
847 | NULL, /**< dependencies */ |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
848 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
| 15412 | 849 | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
850 | "gtk-xmpp", /**< id */ |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
851 | N_("XMPP Console"), /**< name */ |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
852 | DISPLAY_VERSION, /**< version */ |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
853 | /** summary */ |
| 15412 | 854 | N_("Send and receive raw XMPP stanzas."), |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
855 | /** description */ |
|
29876
f233c73823f2
I don't think 'debug' spouts an extra 'b' when adding the '-ing'.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29783
diff
changeset
|
856 | N_("This plugin is useful for debugging XMPP servers or clients."), |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
857 | "Sean Egan <seanegan@gmail.com>", /**< author */ |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
858 | PURPLE_WEBSITE, /**< homepage */ |
| 15412 | 859 | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
860 | plugin_load, /**< load */ |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
861 | plugin_unload, /**< unload */ |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
862 | NULL, /**< destroy */ |
| 15412 | 863 | |
| 864 | NULL, /**< ui_info */ | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
865 | NULL, /**< extra_info */ |
| 15412 | 866 | NULL, |
|
16749
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16290
diff
changeset
|
867 | actions, |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16290
diff
changeset
|
868 | |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16290
diff
changeset
|
869 | /* padding */ |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16290
diff
changeset
|
870 | NULL, |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16290
diff
changeset
|
871 | NULL, |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16290
diff
changeset
|
872 | NULL, |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16290
diff
changeset
|
873 | NULL |
| 15412 | 874 | }; |
| 875 | ||
| 876 | static void | |
| 15884 | 877 | init_plugin(PurplePlugin *plugin) |
| 15412 | 878 | { |
| 879 | } | |
| 880 | ||
|
25625
52d3e1e45ebf
albertz noticed the XMPP Console was identifying itself as interval. Hooray
Paul Aurich <darkrain42@pidgin.im>
parents:
22108
diff
changeset
|
881 | PURPLE_INIT_PLUGIN(xmppconsole, init_plugin, info) |