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