Mercurial > pidgin.yaz
changeset 27127:79c9695f7a8b
Nothing to see here, just some whitespace changes.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sat, 06 Jun 2009 04:00:22 +0000 |
parents | 0901c3662286 |
children | a4574f513be5 |
files | pidgin/plugins/xmppconsole.c |
diffstat | 1 files changed, 164 insertions(+), 165 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin/plugins/xmppconsole.c Sat Jun 06 02:12:32 2009 +0000 +++ b/pidgin/plugins/xmppconsole.c Sat Jun 06 04:00:22 2009 +0000 @@ -62,58 +62,62 @@ g_return_val_if_fail(node != NULL, NULL); - if(pretty && depth) { + if (pretty && depth) { tab = g_strnfill(depth, '\t'); text = g_string_append(text, tab); } node_name = g_markup_escape_text(node->name, -1); - g_string_append_printf(text, "<font color='" - BRACKET_COLOR "'><</font><font color='" - TAG_COLOR "'><b>%s</b></font>", node_name); + g_string_append_printf(text, + "<font color='" BRACKET_COLOR "'><</font>" + "<font color='" TAG_COLOR "'><b>%s</b></font>", + node_name); if (node->xmlns) { - if((!node->parent || - !node->parent->xmlns || - strcmp(node->xmlns, node->parent->xmlns)) && - strcmp(node->xmlns, "jabber:client")) + if ((!node->parent || + !node->parent->xmlns || + strcmp(node->xmlns, node->parent->xmlns)) && + strcmp(node->xmlns, "jabber:client")) { char *xmlns = g_markup_escape_text(node->xmlns, -1); - g_string_append_printf(text, " <font color='" - ATTR_NAME_COLOR "'><b>xmlns</b></font>='<font color='" - XMLNS_COLOR "'><b>%s</b></font>'", xmlns); + g_string_append_printf(text, + " <font color='" ATTR_NAME_COLOR "'><b>xmlns</b></font>=" + "'<font color='" XMLNS_COLOR "'><b>%s</b></font>'", + xmlns); g_free(xmlns); } } - for(c = node->child; c; c = c->next) + for (c = node->child; c; c = c->next) { - if(c->type == XMLNODE_TYPE_ATTRIB) { + if (c->type == XMLNODE_TYPE_ATTRIB) { esc = g_markup_escape_text(c->name, -1); esc2 = g_markup_escape_text(c->data, -1); - g_string_append_printf(text, " <font color='" - ATTR_NAME_COLOR "'><b>%s</b></font>='<font color='" - ATTR_VALUE_COLOR "'>%s</font>'", esc, esc2); + g_string_append_printf(text, + " <font color='" ATTR_NAME_COLOR "'><b>%s</b></font>=" + "'<font color='" ATTR_VALUE_COLOR "'>%s</font>'", + esc, esc2); g_free(esc); g_free(esc2); - } else if(c->type == XMLNODE_TYPE_TAG || c->type == XMLNODE_TYPE_DATA) { - if(c->type == XMLNODE_TYPE_DATA) + } else if (c->type == XMLNODE_TYPE_TAG || c->type == XMLNODE_TYPE_DATA) { + if (c->type == XMLNODE_TYPE_DATA) pretty = FALSE; need_end = TRUE; } } - if(need_end) { - g_string_append_printf(text, - "<font color='"BRACKET_COLOR"'>></font>%s", pretty ? "<br>" : ""); + if (need_end) { + g_string_append_printf(text, + "<font color='"BRACKET_COLOR"'>></font>%s", + pretty ? "<br>" : ""); - for(c = node->child; c; c = c->next) + for (c = node->child; c; c = c->next) { - if(c->type == XMLNODE_TYPE_TAG) { + if (c->type == XMLNODE_TYPE_TAG) { int esc_len; esc = xmlnode_to_pretty_str(c, &esc_len, depth+1); text = g_string_append_len(text, esc, esc_len); g_free(esc); - } else if(c->type == XMLNODE_TYPE_DATA && c->data_sz > 0) { + } else if (c->type == XMLNODE_TYPE_DATA && c->data_sz > 0) { esc = g_markup_escape_text(c->data, c->data_sz); text = g_string_append(text, esc); g_free(esc); @@ -122,11 +126,14 @@ if(tab && pretty) text = g_string_append(text, tab); - g_string_append_printf(text, "<font color='"BRACKET_COLOR"'><</font>/<font color='" - TAG_COLOR"'><b>%s</b></font><font color='"BRACKET_COLOR - "'>></font><br>", node_name); + g_string_append_printf(text, + "<font color='" BRACKET_COLOR "'><</font>/" + "<font color='" TAG_COLOR "'><b>%s</b></font>" + "<font color='" BRACKET_COLOR "'>></font><br>", + node_name); } else { - g_string_append_printf(text, "/<font color='"BRACKET_COLOR"'>></font><br>"); + g_string_append_printf(text, + "/<font color='" BRACKET_COLOR "'>></font><br>"); } g_free(node_name); @@ -163,10 +170,10 @@ if (!console || console->gc != gc) return; node = xmlnode_from_str(*packet, -1); - + if (!node) return; - + str = xmlnode_to_pretty_str(node, NULL, 0); formatted = g_strdup_printf("<body bgcolor='#dcecc4'><pre>%s</pre></body>", str); gtk_imhtml_append_text(GTK_IMHTML(console->imhtml), formatted, 0); @@ -204,37 +211,35 @@ static void entry_changed_cb(GtkTextBuffer *buffer, void *data) { char *xmlstr, *str; - GtkTextIter iter; - int wrapped_lines; - int lines; - GdkRectangle oneline; - int height; - int pad_top, pad_inside, pad_bottom; + GtkTextIter iter; + int wrapped_lines; + int lines; + GdkRectangle oneline; + int height; + int pad_top, pad_inside, pad_bottom; GtkTextIter start, end; xmlnode *node; - - wrapped_lines = 1; - gtk_text_buffer_get_start_iter(buffer, &iter); - gtk_text_view_get_iter_location(GTK_TEXT_VIEW(console->entry), &iter, &oneline); - while (gtk_text_view_forward_display_line(GTK_TEXT_VIEW(console->entry), &iter)) - wrapped_lines++; - lines = gtk_text_buffer_get_line_count(buffer); + wrapped_lines = 1; + gtk_text_buffer_get_start_iter(buffer, &iter); + gtk_text_view_get_iter_location(GTK_TEXT_VIEW(console->entry), &iter, &oneline); + while (gtk_text_view_forward_display_line(GTK_TEXT_VIEW(console->entry), &iter)) + wrapped_lines++; + + lines = gtk_text_buffer_get_line_count(buffer); - /* Show a maximum of 64 lines */ - lines = MIN(lines, 6); - wrapped_lines = MIN(wrapped_lines, 6); + /* Show a maximum of 64 lines */ + lines = MIN(lines, 6); + wrapped_lines = MIN(wrapped_lines, 6); - pad_top = gtk_text_view_get_pixels_above_lines(GTK_TEXT_VIEW(console->entry)); - pad_bottom = gtk_text_view_get_pixels_below_lines(GTK_TEXT_VIEW(console->entry)); - pad_inside = gtk_text_view_get_pixels_inside_wrap(GTK_TEXT_VIEW(console->entry)); + pad_top = gtk_text_view_get_pixels_above_lines(GTK_TEXT_VIEW(console->entry)); + pad_bottom = gtk_text_view_get_pixels_below_lines(GTK_TEXT_VIEW(console->entry)); + pad_inside = gtk_text_view_get_pixels_inside_wrap(GTK_TEXT_VIEW(console->entry)); - height = (oneline.height + pad_top + pad_bottom) * lines; - height += (oneline.height + pad_inside) * (wrapped_lines - lines); + height = (oneline.height + pad_top + pad_bottom) * lines; + height += (oneline.height + pad_inside) * (wrapped_lines - lines); - gtk_widget_set_size_request(console->sw, -1, height+6); - - + gtk_widget_set_size_request(console->sw, -1, height + 6); gtk_text_buffer_get_start_iter(buffer, &start); gtk_text_buffer_get_end_iter(buffer, &end); @@ -287,7 +292,7 @@ to_entry = gtk_entry_new(); gtk_entry_set_activates_default (GTK_ENTRY (to_entry), TRUE); gtk_box_pack_start(GTK_BOX(hbox), to_entry, FALSE, FALSE, 0); - + hbox = gtk_hbox_new(FALSE, 3); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); label = gtk_label_new("Type:"); @@ -302,7 +307,7 @@ gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "error"); gtk_combo_box_set_active(GTK_COMBO_BOX(type_combo), 0); gtk_box_pack_start(GTK_BOX(hbox), type_combo, FALSE, FALSE, 0); - + gtk_widget_show_all(GTK_DIALOG(dialog)->vbox); result = gtk_dialog_run(GTK_DIALOG(dialog)); @@ -310,16 +315,16 @@ gtk_widget_destroy(dialog); return; } - + to = gtk_entry_get_text(GTK_ENTRY(to_entry)); - stanza = g_strdup_printf("<iq %s%s%s id='console%x' type='%s'></iq>", + stanza = g_strdup_printf("<iq %s%s%s id='console%x' type='%s'></iq>", to && *to ? "to='" : "", to && *to ? to : "", to && *to ? "'" : "", g_random_int(), gtk_combo_box_get_active_text(GTK_COMBO_BOX(type_combo))); - + buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); gtk_text_buffer_set_text(buffer, stanza, -1); gtk_text_buffer_get_iter_at_offset(buffer, &iter, strstr(stanza, "</iq>") - stanza); @@ -328,25 +333,24 @@ gtk_widget_destroy(dialog); g_object_unref(sg); - } static void presence_clicked_cb(GtkWidget *w, gpointer nul) { - GtkWidget *hbox, - *to_entry, - *status_entry, - *priority_entry, - *label, - *show_combo, - *type_combo; + GtkWidget *hbox; + GtkWidget *to_entry; + GtkWidget *status_entry; + GtkWidget *priority_entry; + GtkWidget *label; + GtkWidget *show_combo; + GtkWidget *type_combo; GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); GtkTextIter iter; GtkTextBuffer *buffer; const char *to, *type, *status, *show, *priority; int result; char *stanza; - + GtkWidget *dialog = gtk_dialog_new_with_buttons("<presence/>", GTK_WINDOW(console->window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, @@ -370,7 +374,7 @@ to_entry = gtk_entry_new(); gtk_entry_set_activates_default (GTK_ENTRY (to_entry), TRUE); gtk_box_pack_start(GTK_BOX(hbox), to_entry, FALSE, FALSE, 0); - + hbox = gtk_hbox_new(FALSE, 3); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); label = gtk_label_new("Type:"); @@ -417,7 +421,6 @@ gtk_entry_set_activates_default (GTK_ENTRY (status_entry), TRUE); gtk_box_pack_start(GTK_BOX(hbox), status_entry, FALSE, FALSE, 0); - hbox = gtk_hbox_new(FALSE, 3); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); @@ -430,7 +433,6 @@ gtk_spin_button_set_value(GTK_SPIN_BUTTON(priority_entry), 0); gtk_box_pack_start(GTK_BOX(hbox), priority_entry, FALSE, FALSE, 0); - gtk_widget_show_all(GTK_DIALOG(dialog)->vbox); result = gtk_dialog_run(GTK_DIALOG(dialog)); @@ -438,7 +440,7 @@ gtk_widget_destroy(dialog); return; } - + to = gtk_entry_get_text(GTK_ENTRY(to_entry)); type = gtk_combo_box_get_active_text(GTK_COMBO_BOX(type_combo)); if (!strcmp(type, "default")) @@ -451,32 +453,30 @@ if (!strcmp(priority, "0")) priority = ""; + stanza = g_strdup_printf("<presence %s%s%s id='console%x' %s%s%s>" + "%s%s%s%s%s%s%s%s%s" + "</presence>", + *to ? "to='" : "", + *to ? to : "", + *to ? "'" : "", + g_random_int(), + *type ? "type='" : "", + *type ? type : "", + *type ? "'" : "", - stanza = g_strdup_printf("<presence %s%s%s id='console%x' %s%s%s>" - "%s%s%s%s%s%s%s%s%s" - "</presence>", - *to ? "to='" : "", - *to ? to : "", - *to ? "'" : "", - g_random_int(), - - *type ? "type='" : "", - *type ? type : "", - *type ? "'" : "", - - *show ? "<show>" : "", - *show ? show : "", - *show ? "</show>" : "", + *show ? "<show>" : "", + *show ? show : "", + *show ? "</show>" : "", - *status ? "<status>" : "", - *status ? status : "", - *status ? "</status>" : "", - - *priority ? "<priority>" : "", - *priority ? priority : "", - *priority ? "</priority>" : ""); - + *status ? "<status>" : "", + *status ? status : "", + *status ? "</status>" : "", + + *priority ? "<priority>" : "", + *priority ? priority : "", + *priority ? "</priority>" : ""); + buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); gtk_text_buffer_set_text(buffer, stanza, -1); gtk_text_buffer_get_iter_at_offset(buffer, &iter, strstr(stanza, "</presence>") - stanza); @@ -489,13 +489,13 @@ static void message_clicked_cb(GtkWidget *w, gpointer nul) { - GtkWidget *hbox, - *to_entry, - *body_entry, - *thread_entry, - *subject_entry, - *label, - *type_combo; + GtkWidget *hbox; + GtkWidget *to_entry; + GtkWidget *body_entry; + GtkWidget *thread_entry; + GtkWidget *subject_entry; + GtkWidget *label; + GtkWidget *type_combo; GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); GtkTextIter iter; GtkTextBuffer *buffer; @@ -554,7 +554,6 @@ gtk_entry_set_activates_default (GTK_ENTRY (body_entry), TRUE); gtk_box_pack_start(GTK_BOX(hbox), body_entry, FALSE, FALSE, 0); - hbox = gtk_hbox_new(FALSE, 3); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); @@ -578,7 +577,7 @@ thread_entry = gtk_entry_new(); gtk_entry_set_activates_default (GTK_ENTRY (thread_entry), TRUE); gtk_box_pack_start(GTK_BOX(hbox), thread_entry, FALSE, FALSE, 0); - + gtk_widget_show_all(GTK_DIALOG(dialog)->vbox); result = gtk_dialog_run(GTK_DIALOG(dialog)); @@ -586,34 +585,34 @@ gtk_widget_destroy(dialog); return; } - + to = gtk_entry_get_text(GTK_ENTRY(to_entry)); body = gtk_entry_get_text(GTK_ENTRY(body_entry)); thread = gtk_entry_get_text(GTK_ENTRY(thread_entry)); subject = gtk_entry_get_text(GTK_ENTRY(subject_entry)); stanza = g_strdup_printf("<message %s%s%s id='console%x' type='%s'>" - "%s%s%s%s%s%s%s%s%s" - "</message>", - - *to ? "to='" : "", - *to ? to : "", - *to ? "'" : "", - g_random_int(), - gtk_combo_box_get_active_text(GTK_COMBO_BOX(type_combo)), - - *body ? "<body>" : "", - *body ? body : "", - *body ? "</body>" : "", - - *subject ? "<subject>" : "", - *subject ? subject : "", - *subject ? "</subject>" : "", - - *thread ? "<thread>" : "", - *thread ? thread : "", - *thread ? "</thread>" : ""); - + "%s%s%s%s%s%s%s%s%s" + "</message>", + + *to ? "to='" : "", + *to ? to : "", + *to ? "'" : "", + g_random_int(), + gtk_combo_box_get_active_text(GTK_COMBO_BOX(type_combo)), + + *body ? "<body>" : "", + *body ? body : "", + *body ? "</body>" : "", + + *subject ? "<subject>" : "", + *subject ? subject : "", + *subject ? "</subject>" : "", + + *thread ? "<thread>" : "", + *thread ? thread : "", + *thread ? "</thread>" : ""); + buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); gtk_text_buffer_set_text(buffer, stanza, -1); gtk_text_buffer_get_iter_at_offset(buffer, &iter, strstr(stanza, "</message>") - stanza); @@ -629,11 +628,11 @@ { if (!console) return; - + gtk_combo_box_append_text(GTK_COMBO_BOX(console->dropdown), purple_account_get_username(gc->account)); console->accounts = g_list_append(console->accounts, gc); console->count++; - + if (console->count > 1) gtk_widget_show_all(console->hbox); } @@ -666,7 +665,7 @@ if (gc == console->gc) { console->gc = NULL; - gtk_imhtml_append_text(GTK_IMHTML(console->imhtml), + gtk_imhtml_append_text(GTK_IMHTML(console->imhtml), _("<font color='#777777'>Logged out.</font>"), 0); } } @@ -689,7 +688,7 @@ plugin, PURPLE_CALLBACK(signed_on_cb), NULL); purple_signal_connect(purple_connections_get_handle(), "signed-off", plugin, PURPLE_CALLBACK(signed_off_cb), NULL); - + return TRUE; } @@ -716,18 +715,18 @@ if (!console) return; - - account = purple_accounts_find(gtk_combo_box_get_active_text(GTK_COMBO_BOX(console->dropdown)), + + account = purple_accounts_find(gtk_combo_box_get_active_text(GTK_COMBO_BOX(console->dropdown)), "prpl-jabber"); if (!account || !account->gc) return; - + console->gc = account->gc; gtk_imhtml_clear(GTK_IMHTML(console->imhtml)); } -static void -create_console(PurplePluginAction *action) +static void +create_console(PurplePluginAction *action) { GtkWidget *vbox = gtk_vbox_new(FALSE, 6); GtkWidget *sw = gtk_scrolled_window_new(NULL, NULL); @@ -743,7 +742,7 @@ gtk_window_present(GTK_WINDOW(console->window)); return; } - + console = g_new0(XmppConsole, 1); console->window = pidgin_create_window(_("XMPP Console"), PIDGIN_HIG_BORDER, NULL, TRUE); @@ -773,32 +772,32 @@ g_signal_connect(G_OBJECT(console->dropdown), "changed", G_CALLBACK(dropdown_changed_cb), NULL); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_ETCHED_IN); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); console->imhtml = gtk_imhtml_new(NULL, NULL); gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); if (console->count == 0) - gtk_imhtml_append_text(GTK_IMHTML(console->imhtml), + gtk_imhtml_append_text(GTK_IMHTML(console->imhtml), _("<font color='#777777'>Not connected to XMPP</font>"), 0); gtk_container_add(GTK_CONTAINER(sw), console->imhtml); - + toolbar = gtk_toolbar_new(); -#if GTK_CHECK_VERSION(2,4,0) +#if GTK_CHECK_VERSION(2,4,0) button = gtk_tool_button_new(NULL, "<iq/>"); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(iq_clicked_cb), NULL); gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); #else - gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "<iq/>", + gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "<iq/>", _("Insert an <iq/> stanza."), "foo", NULL, GTK_SIGNAL_FUNC(iq_clicked_cb), NULL); #endif -#if GTK_CHECK_VERSION(2,4,0) +#if GTK_CHECK_VERSION(2,4,0) button = gtk_tool_button_new(NULL, "<presence/>"); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(presence_clicked_cb), NULL); gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); #else - gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "<presence/>", + gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "<presence/>", _("Insert a <presence/> stanza."), NULL, gtk_label_new(NULL), GTK_SIGNAL_FUNC(presence_clicked_cb), NULL); #endif @@ -807,17 +806,17 @@ g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(message_clicked_cb), NULL); gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); #else - gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "<message/>", + gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "<message/>", _("Insert a <message/> stanza."), "foo", gtk_label_new(NULL), GTK_SIGNAL_FUNC(message_clicked_cb), NULL); #endif - + gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0); - + sw = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_ETCHED_IN); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - + console->entry = gtk_imhtml_new(NULL, NULL); gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(console->entry), TRUE); g_signal_connect(G_OBJECT(console->entry),"message_send", G_CALLBACK(message_send_cb), console); @@ -843,7 +842,7 @@ act = purple_plugin_action_new(_("XMPP Console"), create_console); l = g_list_append(l, act); - + return l; } @@ -853,28 +852,28 @@ PURPLE_PLUGIN_MAGIC, PURPLE_MAJOR_VERSION, PURPLE_MINOR_VERSION, - PURPLE_PLUGIN_STANDARD, /**< type */ - PIDGIN_PLUGIN_TYPE, /**< ui_requirement */ - 0, /**< flags */ - NULL, /**< dependencies */ - PURPLE_PRIORITY_DEFAULT, /**< priority */ + PURPLE_PLUGIN_STANDARD, /**< type */ + PIDGIN_PLUGIN_TYPE, /**< ui_requirement */ + 0, /**< flags */ + NULL, /**< dependencies */ + PURPLE_PRIORITY_DEFAULT, /**< priority */ - "gtk-xmpp", /**< id */ - N_("XMPP Console"), /**< name */ - DISPLAY_VERSION, /**< version */ - /** summary */ + "gtk-xmpp", /**< id */ + N_("XMPP Console"), /**< name */ + DISPLAY_VERSION, /**< version */ + /** summary */ N_("Send and receive raw XMPP stanzas."), - /** description */ + /** description */ N_("This plugin is useful for debbuging XMPP servers or clients."), - "Sean Egan <seanegan@gmail.com>", /**< author */ - PURPLE_WEBSITE, /**< homepage */ + "Sean Egan <seanegan@gmail.com>", /**< author */ + PURPLE_WEBSITE, /**< homepage */ - plugin_load, /**< load */ - plugin_unload, /**< unload */ - NULL, /**< destroy */ + plugin_load, /**< load */ + plugin_unload, /**< unload */ + NULL, /**< destroy */ NULL, /**< ui_info */ - NULL, /**< extra_info */ + NULL, /**< extra_info */ NULL, actions,