Thu, 04 Mar 2010 22:35:32 +0000
Allow showing moods for buddies when signed on using an XMPP account not
supporting PEP.
Also remove the mentioning of return NULL for _get_moods to indicate not
supporting setting moods on an account, since there is now a connection flag
for it, and an account can receive moods even though it can't set them (in the
XMPP case).
Also fixes a crash in buddy tooltip.
| 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; |
| 186 | PurpleConnection *gc = console->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 | { | |
| 261 | GtkWidget *hbox, *to_entry, *label, *type_combo; | |
| 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); | |
| 280 | ||
| 281 | hbox = gtk_hbox_new(FALSE, 3); | |
| 282 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 283 | ||
| 284 | label = gtk_label_new("To:"); | |
| 285 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 286 | gtk_size_group_add_widget(sg, label); | |
| 287 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 288 | ||
| 289 | to_entry = gtk_entry_new(); | |
| 290 | gtk_entry_set_activates_default (GTK_ENTRY (to_entry), TRUE); | |
| 291 | 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
|
292 | |
| 15412 | 293 | hbox = gtk_hbox_new(FALSE, 3); |
| 294 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 295 | label = gtk_label_new("Type:"); | |
| 296 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 297 | ||
| 298 | gtk_size_group_add_widget(sg, label); | |
| 299 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 300 | type_combo = gtk_combo_box_new_text(); | |
| 301 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "get"); | |
| 302 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "set"); | |
| 303 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "result"); | |
| 304 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "error"); | |
| 305 | gtk_combo_box_set_active(GTK_COMBO_BOX(type_combo), 0); | |
| 306 | 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
|
307 | |
| 15412 | 308 | gtk_widget_show_all(GTK_DIALOG(dialog)->vbox); |
| 309 | ||
| 310 | result = gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 311 | if (result != GTK_RESPONSE_ACCEPT) { | |
| 312 | gtk_widget_destroy(dialog); | |
| 313 | return; | |
| 314 | } | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
315 | |
| 15412 | 316 | to = gtk_entry_get_text(GTK_ENTRY(to_entry)); |
| 317 | ||
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
318 | stanza = g_strdup_printf("<iq %s%s%s id='console%x' type='%s'></iq>", |
| 15412 | 319 | to && *to ? "to='" : "", |
| 320 | to && *to ? to : "", | |
| 321 | to && *to ? "'" : "", | |
| 322 | g_random_int(), | |
| 323 | 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
|
324 | |
| 15412 | 325 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); |
| 326 | gtk_text_buffer_set_text(buffer, stanza, -1); | |
| 327 | gtk_text_buffer_get_iter_at_offset(buffer, &iter, strstr(stanza, "</iq>") - stanza); | |
| 328 | gtk_text_buffer_place_cursor(buffer, &iter); | |
| 329 | g_free(stanza); | |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
330 | |
| 15412 | 331 | gtk_widget_destroy(dialog); |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
332 | g_object_unref(sg); |
| 15412 | 333 | } |
| 334 | ||
| 335 | static void presence_clicked_cb(GtkWidget *w, gpointer nul) | |
| 336 | { | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
337 | GtkWidget *hbox; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
338 | GtkWidget *to_entry; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
339 | GtkWidget *status_entry; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
340 | GtkWidget *priority_entry; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
341 | GtkWidget *label; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
342 | GtkWidget *show_combo; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
343 | GtkWidget *type_combo; |
| 15412 | 344 | GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
| 345 | GtkTextIter iter; | |
| 346 | GtkTextBuffer *buffer; | |
| 347 | const char *to, *type, *status, *show, *priority; | |
| 348 | int result; | |
| 349 | char *stanza; | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
350 | |
| 15412 | 351 | GtkWidget *dialog = gtk_dialog_new_with_buttons("<presence/>", |
| 352 | GTK_WINDOW(console->window), | |
| 353 | GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 354 | GTK_STOCK_CANCEL, | |
| 355 | GTK_RESPONSE_REJECT, | |
| 356 | GTK_STOCK_OK, | |
| 357 | GTK_RESPONSE_ACCEPT, | |
| 358 | NULL); | |
| 359 | gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | |
| 360 | gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); | |
| 361 | gtk_container_set_border_width(GTK_CONTAINER(dialog), 12); | |
| 362 | ||
| 363 | hbox = gtk_hbox_new(FALSE, 3); | |
| 364 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 365 | ||
| 366 | label = gtk_label_new("To:"); | |
| 367 | gtk_size_group_add_widget(sg, label); | |
| 368 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 369 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 370 | ||
| 371 | to_entry = gtk_entry_new(); | |
| 372 | gtk_entry_set_activates_default (GTK_ENTRY (to_entry), TRUE); | |
| 373 | 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
|
374 | |
| 15412 | 375 | hbox = gtk_hbox_new(FALSE, 3); |
| 376 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 377 | label = gtk_label_new("Type:"); | |
| 378 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 379 | gtk_size_group_add_widget(sg, label); | |
| 380 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 381 | type_combo = gtk_combo_box_new_text(); | |
| 382 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "default"); | |
| 383 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "unavailable"); | |
| 384 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "subscribe"); | |
| 385 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "unsubscribe"); | |
| 386 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "subscribed"); | |
| 387 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "unsubscribed"); | |
| 388 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "probe"); | |
| 389 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "error"); | |
| 390 | gtk_combo_box_set_active(GTK_COMBO_BOX(type_combo), 0); | |
| 391 | gtk_box_pack_start(GTK_BOX(hbox), type_combo, FALSE, FALSE, 0); | |
| 392 | ||
| 393 | hbox = gtk_hbox_new(FALSE, 3); | |
| 394 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 395 | label = gtk_label_new("Show:"); | |
| 396 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 397 | gtk_size_group_add_widget(sg, label); | |
| 398 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 399 | show_combo = gtk_combo_box_new_text(); | |
| 400 | gtk_combo_box_append_text(GTK_COMBO_BOX(show_combo), "default"); | |
| 401 | gtk_combo_box_append_text(GTK_COMBO_BOX(show_combo), "away"); | |
| 402 | gtk_combo_box_append_text(GTK_COMBO_BOX(show_combo), "dnd"); | |
| 403 | gtk_combo_box_append_text(GTK_COMBO_BOX(show_combo), "xa"); | |
| 404 | gtk_combo_box_append_text(GTK_COMBO_BOX(show_combo), "chat"); | |
| 405 | ||
| 406 | gtk_combo_box_set_active(GTK_COMBO_BOX(show_combo), 0); | |
| 407 | gtk_box_pack_start(GTK_BOX(hbox), show_combo, FALSE, FALSE, 0); | |
| 408 | ||
| 409 | hbox = gtk_hbox_new(FALSE, 3); | |
| 410 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 411 | ||
| 412 | label = gtk_label_new("Status:"); | |
| 413 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 414 | gtk_size_group_add_widget(sg, label); | |
| 415 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 416 | ||
| 417 | status_entry = gtk_entry_new(); | |
| 418 | gtk_entry_set_activates_default (GTK_ENTRY (status_entry), TRUE); | |
| 419 | gtk_box_pack_start(GTK_BOX(hbox), status_entry, FALSE, FALSE, 0); | |
| 420 | ||
| 421 | hbox = gtk_hbox_new(FALSE, 3); | |
| 422 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 423 | ||
| 424 | label = gtk_label_new("Priority:"); | |
| 425 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 426 | gtk_size_group_add_widget(sg, label); | |
| 427 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 428 | ||
| 429 | priority_entry = gtk_spin_button_new_with_range(-128, 127, 1); | |
| 430 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(priority_entry), 0); | |
| 431 | gtk_box_pack_start(GTK_BOX(hbox), priority_entry, FALSE, FALSE, 0); | |
| 432 | ||
| 433 | gtk_widget_show_all(GTK_DIALOG(dialog)->vbox); | |
| 434 | ||
| 435 | result = gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 436 | if (result != GTK_RESPONSE_ACCEPT) { | |
| 437 | gtk_widget_destroy(dialog); | |
| 438 | return; | |
| 439 | } | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
440 | |
| 15412 | 441 | to = gtk_entry_get_text(GTK_ENTRY(to_entry)); |
| 442 | type = gtk_combo_box_get_active_text(GTK_COMBO_BOX(type_combo)); | |
| 443 | if (!strcmp(type, "default")) | |
| 444 | type = ""; | |
| 445 | show = gtk_combo_box_get_active_text(GTK_COMBO_BOX(show_combo)); | |
| 446 | if (!strcmp(show, "default")) | |
| 447 | show = ""; | |
| 448 | status = gtk_entry_get_text(GTK_ENTRY(status_entry)); | |
| 449 | priority = gtk_entry_get_text(GTK_ENTRY(priority_entry)); | |
| 450 | if (!strcmp(priority, "0")) | |
| 451 | priority = ""; | |
| 452 | ||
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
453 | 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
|
454 | "%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
|
455 | "</presence>", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
456 | *to ? "to='" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
457 | *to ? to : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
458 | *to ? "'" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
459 | g_random_int(), |
| 15412 | 460 | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
461 | *type ? "type='" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
462 | *type ? type : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
463 | *type ? "'" : "", |
| 15412 | 464 | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
465 | *show ? "<show>" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
466 | *show ? show : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
467 | *show ? "</show>" : "", |
| 15412 | 468 | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
469 | *status ? "<status>" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
470 | *status ? status : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
471 | *status ? "</status>" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
472 | |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
473 | *priority ? "<priority>" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
474 | *priority ? priority : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
475 | *priority ? "</priority>" : ""); |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
476 | |
| 15412 | 477 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); |
| 478 | gtk_text_buffer_set_text(buffer, stanza, -1); | |
| 479 | gtk_text_buffer_get_iter_at_offset(buffer, &iter, strstr(stanza, "</presence>") - stanza); | |
| 480 | gtk_text_buffer_place_cursor(buffer, &iter); | |
| 481 | g_free(stanza); | |
| 482 | ||
| 483 | gtk_widget_destroy(dialog); | |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
484 | g_object_unref(sg); |
| 15412 | 485 | } |
| 486 | ||
| 487 | static void message_clicked_cb(GtkWidget *w, gpointer nul) | |
| 488 | { | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
489 | GtkWidget *hbox; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
490 | GtkWidget *to_entry; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
491 | GtkWidget *body_entry; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
492 | GtkWidget *thread_entry; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
493 | GtkWidget *subject_entry; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
494 | GtkWidget *label; |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
495 | GtkWidget *type_combo; |
| 15412 | 496 | GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
| 497 | GtkTextIter iter; | |
| 498 | GtkTextBuffer *buffer; | |
| 499 | const char *to, *body, *thread, *subject; | |
| 500 | char *stanza; | |
| 501 | int result; | |
| 502 | ||
| 503 | GtkWidget *dialog = gtk_dialog_new_with_buttons("<message/>", | |
| 504 | GTK_WINDOW(console->window), | |
| 505 | GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 506 | GTK_STOCK_CANCEL, | |
| 507 | GTK_RESPONSE_REJECT, | |
| 508 | GTK_STOCK_OK, | |
| 509 | GTK_RESPONSE_ACCEPT, | |
| 510 | NULL); | |
| 511 | gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | |
| 512 | gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); | |
| 513 | gtk_container_set_border_width(GTK_CONTAINER(dialog), 12); | |
| 514 | ||
| 515 | hbox = gtk_hbox_new(FALSE, 3); | |
| 516 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 517 | ||
| 518 | label = gtk_label_new("To:"); | |
| 519 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 520 | gtk_size_group_add_widget(sg, label); | |
| 521 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 522 | ||
| 523 | to_entry = gtk_entry_new(); | |
| 524 | gtk_entry_set_activates_default (GTK_ENTRY (to_entry), TRUE); | |
| 525 | gtk_box_pack_start(GTK_BOX(hbox), to_entry, FALSE, FALSE, 0); | |
| 526 | ||
| 527 | hbox = gtk_hbox_new(FALSE, 3); | |
| 528 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 529 | label = gtk_label_new("Type:"); | |
| 530 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 531 | gtk_size_group_add_widget(sg, label); | |
| 532 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 533 | type_combo = gtk_combo_box_new_text(); | |
| 534 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "chat"); | |
| 535 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "headline"); | |
| 536 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "groupchat"); | |
| 537 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "normal"); | |
| 538 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "error"); | |
| 539 | gtk_combo_box_set_active(GTK_COMBO_BOX(type_combo), 0); | |
| 540 | gtk_box_pack_start(GTK_BOX(hbox), type_combo, FALSE, FALSE, 0); | |
| 541 | ||
| 542 | hbox = gtk_hbox_new(FALSE, 3); | |
| 543 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 544 | ||
| 545 | label = gtk_label_new("Body:"); | |
| 546 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 547 | gtk_size_group_add_widget(sg, label); | |
| 548 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 549 | ||
| 550 | body_entry = gtk_entry_new(); | |
| 551 | gtk_entry_set_activates_default (GTK_ENTRY (body_entry), TRUE); | |
| 552 | gtk_box_pack_start(GTK_BOX(hbox), body_entry, FALSE, FALSE, 0); | |
| 553 | ||
| 554 | hbox = gtk_hbox_new(FALSE, 3); | |
| 555 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 556 | ||
| 557 | label = gtk_label_new("Subject:"); | |
| 558 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 559 | gtk_size_group_add_widget(sg, label); | |
| 560 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 561 | ||
| 562 | subject_entry = gtk_entry_new(); | |
| 563 | gtk_entry_set_activates_default (GTK_ENTRY (subject_entry), TRUE); | |
| 564 | gtk_box_pack_start(GTK_BOX(hbox), subject_entry, FALSE, FALSE, 0); | |
| 565 | ||
| 566 | hbox = gtk_hbox_new(FALSE, 3); | |
| 567 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 568 | ||
| 569 | label = gtk_label_new("Thread:"); | |
| 570 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 571 | gtk_size_group_add_widget(sg, label); | |
| 572 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 573 | ||
| 574 | thread_entry = gtk_entry_new(); | |
| 575 | gtk_entry_set_activates_default (GTK_ENTRY (thread_entry), TRUE); | |
| 576 | 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
|
577 | |
| 15412 | 578 | gtk_widget_show_all(GTK_DIALOG(dialog)->vbox); |
| 579 | ||
| 580 | result = gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 581 | if (result != GTK_RESPONSE_ACCEPT) { | |
| 582 | gtk_widget_destroy(dialog); | |
| 583 | return; | |
| 584 | } | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
585 | |
| 15412 | 586 | to = gtk_entry_get_text(GTK_ENTRY(to_entry)); |
| 587 | body = gtk_entry_get_text(GTK_ENTRY(body_entry)); | |
| 588 | thread = gtk_entry_get_text(GTK_ENTRY(thread_entry)); | |
| 589 | subject = gtk_entry_get_text(GTK_ENTRY(subject_entry)); | |
| 590 | ||
| 591 | 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
|
592 | "%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
|
593 | "</message>", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
594 | |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
595 | *to ? "to='" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
596 | *to ? to : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
597 | *to ? "'" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
598 | g_random_int(), |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
599 | 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
|
600 | |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
601 | *body ? "<body>" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
602 | *body ? body : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
603 | *body ? "</body>" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
604 | |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
605 | *subject ? "<subject>" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
606 | *subject ? subject : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
607 | *subject ? "</subject>" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
608 | |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
609 | *thread ? "<thread>" : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
610 | *thread ? thread : "", |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
611 | *thread ? "</thread>" : ""); |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
612 | |
| 15412 | 613 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); |
| 614 | gtk_text_buffer_set_text(buffer, stanza, -1); | |
| 615 | gtk_text_buffer_get_iter_at_offset(buffer, &iter, strstr(stanza, "</message>") - stanza); | |
| 616 | gtk_text_buffer_place_cursor(buffer, &iter); | |
| 617 | g_free(stanza); | |
| 618 | ||
| 619 | gtk_widget_destroy(dialog); | |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
620 | g_object_unref(sg); |
| 15412 | 621 | } |
| 622 | ||
| 623 | static void | |
|
29783
96ab389c9181
xmppconsole: Properly catch things before an account is "signed on".
Paul Aurich <darkrain42@pidgin.im>
parents:
29529
diff
changeset
|
624 | signing_on_cb(PurpleConnection *gc) |
| 15412 | 625 | { |
| 626 | if (!console) | |
| 627 | return; | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
628 | |
| 15884 | 629 | gtk_combo_box_append_text(GTK_COMBO_BOX(console->dropdown), purple_account_get_username(gc->account)); |
| 15412 | 630 | console->accounts = g_list_append(console->accounts, gc); |
| 631 | console->count++; | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
632 | |
|
29783
96ab389c9181
xmppconsole: Properly catch things before an account is "signed on".
Paul Aurich <darkrain42@pidgin.im>
parents:
29529
diff
changeset
|
633 | if (console->count == 1) |
|
96ab389c9181
xmppconsole: Properly catch things before an account is "signed on".
Paul Aurich <darkrain42@pidgin.im>
parents:
29529
diff
changeset
|
634 | console->gc = gc; |
|
96ab389c9181
xmppconsole: Properly catch things before an account is "signed on".
Paul Aurich <darkrain42@pidgin.im>
parents:
29529
diff
changeset
|
635 | else |
| 15412 | 636 | gtk_widget_show_all(console->hbox); |
| 637 | } | |
| 638 | ||
| 639 | static void | |
| 15884 | 640 | signed_off_cb(PurpleConnection *gc) |
| 15412 | 641 | { |
| 642 | int i = 0; | |
| 643 | GList *l; | |
| 644 | ||
| 645 | if (!console) | |
| 646 | return; | |
| 647 | ||
| 648 | l = console->accounts; | |
| 649 | while (l) { | |
| 15884 | 650 | PurpleConnection *g = l->data; |
| 15412 | 651 | if (gc == g) |
| 652 | break; | |
| 653 | i++; | |
| 654 | l = l->next; | |
| 655 | } | |
| 656 | ||
| 657 | if (l == NULL) | |
| 658 | return; | |
| 659 | ||
| 660 | gtk_combo_box_remove_text(GTK_COMBO_BOX(console->dropdown), i); | |
| 661 | console->accounts = g_list_remove(console->accounts, gc); | |
| 662 | console->count--; | |
| 663 | ||
| 664 | if (gc == console->gc) { | |
| 665 | console->gc = NULL; | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
666 | gtk_imhtml_append_text(GTK_IMHTML(console->imhtml), |
| 15412 | 667 | _("<font color='#777777'>Logged out.</font>"), 0); |
| 668 | } | |
| 669 | } | |
| 670 | ||
| 671 | static gboolean | |
| 15884 | 672 | plugin_load(PurplePlugin *plugin) |
| 15412 | 673 | { |
| 15884 | 674 | PurplePlugin *jabber; |
| 15412 | 675 | |
| 15884 | 676 | jabber = purple_find_prpl("prpl-jabber"); |
| 15412 | 677 | if (!jabber) |
| 678 | return FALSE; | |
| 679 | ||
| 680 | xmpp_console_handle = plugin; | |
| 15884 | 681 | purple_signal_connect(jabber, "jabber-receiving-xmlnode", xmpp_console_handle, |
| 682 | PURPLE_CALLBACK(xmlnode_received_cb), NULL); | |
| 683 | purple_signal_connect(jabber, "jabber-sending-text", xmpp_console_handle, | |
| 684 | 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
|
685 | 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
|
686 | plugin, PURPLE_CALLBACK(signing_on_cb), NULL); |
| 15884 | 687 | purple_signal_connect(purple_connections_get_handle(), "signed-off", |
| 688 | 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
|
689 | |
| 15412 | 690 | return TRUE; |
| 691 | } | |
| 692 | ||
| 693 | static gboolean | |
| 15884 | 694 | plugin_unload(PurplePlugin *plugin) |
| 15412 | 695 | { |
| 15414 | 696 | if (console) |
| 697 | gtk_widget_destroy(console->window); | |
| 15412 | 698 | return TRUE; |
| 699 | } | |
| 700 | ||
| 701 | static void | |
| 702 | console_destroy(GtkObject *window, gpointer nul) | |
| 703 | { | |
| 704 | g_list_free(console->accounts); | |
| 705 | g_free(console); | |
| 706 | console = NULL; | |
| 707 | } | |
| 708 | ||
| 709 | static void | |
| 710 | dropdown_changed_cb(GtkComboBox *widget, gpointer nul) | |
| 711 | { | |
| 15884 | 712 | PurpleAccount *account; |
| 15412 | 713 | |
| 714 | if (!console) | |
| 715 | return; | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
716 | |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
717 | account = purple_accounts_find(gtk_combo_box_get_active_text(GTK_COMBO_BOX(console->dropdown)), |
| 15412 | 718 | "prpl-jabber"); |
| 719 | if (!account || !account->gc) | |
| 720 | return; | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
721 | |
| 15412 | 722 | console->gc = account->gc; |
| 723 | gtk_imhtml_clear(GTK_IMHTML(console->imhtml)); | |
| 724 | } | |
| 725 | ||
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
726 | static void |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
727 | create_console(PurplePluginAction *action) |
| 15412 | 728 | { |
| 729 | GtkWidget *vbox = gtk_vbox_new(FALSE, 6); | |
| 730 | GtkWidget *sw = gtk_scrolled_window_new(NULL, NULL); | |
| 731 | GtkWidget *label; | |
| 732 | GtkTextBuffer *buffer; | |
| 733 | GtkWidget *toolbar; | |
|
18122
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
734 | GList *connections; |
| 15412 | 735 | GtkToolItem *button; |
| 736 | ||
| 737 | if (console) { | |
| 738 | gtk_window_present(GTK_WINDOW(console->window)); | |
| 739 | return; | |
| 740 | } | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
741 | |
| 15412 | 742 | console = g_new0(XmppConsole, 1); |
| 743 | ||
| 17213 | 744 | console->window = pidgin_create_window(_("XMPP Console"), PIDGIN_HIG_BORDER, NULL, TRUE); |
| 15412 | 745 | g_signal_connect(G_OBJECT(console->window), "destroy", G_CALLBACK(console_destroy), NULL); |
| 746 | gtk_window_set_default_size(GTK_WINDOW(console->window), 580, 400); | |
| 747 | gtk_container_add(GTK_CONTAINER(console->window), vbox); | |
| 748 | ||
| 749 | console->hbox = gtk_hbox_new(FALSE, 3); | |
| 750 | gtk_box_pack_start(GTK_BOX(vbox), console->hbox, FALSE, FALSE, 0); | |
| 751 | label = gtk_label_new(_("Account: ")); | |
| 752 | gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | |
| 753 | gtk_box_pack_start(GTK_BOX(console->hbox), label, FALSE, FALSE, 0); | |
| 754 | console->dropdown = gtk_combo_box_new_text(); | |
| 15884 | 755 | for (connections = purple_connections_get_all(); connections; connections = connections->next) { |
| 756 | PurpleConnection *gc = connections->data; | |
| 757 | if (!strcmp(purple_account_get_protocol_id(purple_connection_get_account(gc)), "prpl-jabber")) { | |
| 15412 | 758 | console->count++; |
| 759 | console->accounts = g_list_append(console->accounts, gc); | |
| 760 | gtk_combo_box_append_text(GTK_COMBO_BOX(console->dropdown), | |
| 15884 | 761 | purple_account_get_username(purple_connection_get_account(gc))); |
| 15412 | 762 | if (!console->gc) |
| 763 | console->gc = gc; | |
| 764 | } | |
| 765 | } | |
| 766 | gtk_combo_box_set_active(GTK_COMBO_BOX(console->dropdown),0); | |
| 767 | gtk_box_pack_start(GTK_BOX(console->hbox), console->dropdown, TRUE, TRUE, 0); | |
| 768 | g_signal_connect(G_OBJECT(console->dropdown), "changed", G_CALLBACK(dropdown_changed_cb), NULL); | |
| 769 | ||
| 770 | 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
|
771 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), |
| 15412 | 772 | GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
| 773 | ||
| 774 | console->imhtml = gtk_imhtml_new(NULL, NULL); | |
| 775 | gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); | |
| 776 | 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
|
777 | gtk_imhtml_append_text(GTK_IMHTML(console->imhtml), |
| 15412 | 778 | _("<font color='#777777'>Not connected to XMPP</font>"), 0); |
| 779 | 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
|
780 | |
| 15412 | 781 | toolbar = gtk_toolbar_new(); |
| 782 | button = gtk_tool_button_new(NULL, "<iq/>"); | |
| 783 | g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(iq_clicked_cb), NULL); | |
| 784 | gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); | |
| 785 | ||
| 786 | button = gtk_tool_button_new(NULL, "<presence/>"); | |
| 787 | g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(presence_clicked_cb), NULL); | |
| 788 | gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); | |
| 789 | ||
| 790 | button = gtk_tool_button_new(NULL, "<message/>"); | |
| 791 | g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(message_clicked_cb), NULL); | |
| 792 | 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
|
793 | |
| 15412 | 794 | 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
|
795 | |
| 15412 | 796 | sw = gtk_scrolled_window_new(NULL, NULL); |
| 797 | 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
|
798 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), |
| 15412 | 799 | 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
|
800 | |
| 15412 | 801 | console->entry = gtk_imhtml_new(NULL, NULL); |
| 802 | gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(console->entry), TRUE); | |
| 803 | g_signal_connect(G_OBJECT(console->entry),"message_send", G_CALLBACK(message_send_cb), console); | |
| 804 | ||
| 805 | gtk_box_pack_start(GTK_BOX(vbox), sw, FALSE, FALSE, 0); | |
| 806 | gtk_container_add(GTK_CONTAINER(sw), console->entry); | |
| 807 | gtk_imhtml_set_editable(GTK_IMHTML(console->entry), TRUE); | |
| 808 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); | |
| 809 | g_signal_connect(G_OBJECT(buffer), "changed", G_CALLBACK(entry_changed_cb), NULL); | |
| 810 | console->sw = sw; | |
| 811 | entry_changed_cb(buffer, NULL); | |
| 812 | ||
| 813 | gtk_widget_show_all(console->window); | |
| 814 | if (console->count < 2) | |
| 815 | gtk_widget_hide(console->hbox); | |
| 816 | } | |
| 817 | ||
| 818 | static GList * | |
| 15884 | 819 | actions(PurplePlugin *plugin, gpointer context) |
| 15412 | 820 | { |
| 821 | GList *l = NULL; | |
| 15884 | 822 | PurplePluginAction *act = NULL; |
| 15412 | 823 | |
| 15884 | 824 | act = purple_plugin_action_new(_("XMPP Console"), create_console); |
| 15412 | 825 | 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
|
826 | |
| 15412 | 827 | return l; |
| 828 | } | |
| 829 | ||
| 830 | ||
| 15884 | 831 | static PurplePluginInfo info = |
| 15412 | 832 | { |
| 15884 | 833 | PURPLE_PLUGIN_MAGIC, |
| 834 | PURPLE_MAJOR_VERSION, | |
| 835 | PURPLE_MINOR_VERSION, | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
836 | PURPLE_PLUGIN_STANDARD, /**< type */ |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
837 | 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
|
838 | 0, /**< flags */ |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
839 | NULL, /**< dependencies */ |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
840 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
| 15412 | 841 | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
842 | "gtk-xmpp", /**< id */ |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
843 | N_("XMPP Console"), /**< name */ |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
844 | DISPLAY_VERSION, /**< version */ |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
845 | /** summary */ |
| 15412 | 846 | 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
|
847 | /** description */ |
| 15412 | 848 | 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
|
849 | "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
|
850 | PURPLE_WEBSITE, /**< homepage */ |
| 15412 | 851 | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
852 | plugin_load, /**< load */ |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
853 | plugin_unload, /**< unload */ |
|
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
854 | NULL, /**< destroy */ |
| 15412 | 855 | |
| 856 | NULL, /**< ui_info */ | |
|
27264
ff58193d8ead
Nothing to see here, just some whitespace changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25625
diff
changeset
|
857 | NULL, /**< extra_info */ |
| 15412 | 858 | 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
|
859 | 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
|
860 | |
|
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
|
861 | /* 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
|
862 | 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
|
863 | 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
|
864 | 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
|
865 | NULL |
| 15412 | 866 | }; |
| 867 | ||
| 868 | static void | |
| 15884 | 869 | init_plugin(PurplePlugin *plugin) |
| 15412 | 870 | { |
| 871 | } | |
| 872 | ||
|
25625
52d3e1e45ebf
albertz noticed the XMPP Console was identifying itself as interval. Hooray
Paul Aurich <darkrain42@pidgin.im>
parents:
22108
diff
changeset
|
873 | PURPLE_INIT_PLUGIN(xmppconsole, init_plugin, info) |