Wed, 31 Oct 2018 01:45:24 +0000
Merged in default (pull request #409)
Port Finch away from deprecated g_type_class_add_private()
Approved-by: Elliott Sales de Andrade
Approved-by: Gary Kramlich
Approved-by: Eion Robb
--- a/libpurple/plugins/meson.build Thu Oct 18 21:03:19 2018 -0500 +++ b/libpurple/plugins/meson.build Wed Oct 31 01:45:24 2018 +0000 @@ -73,6 +73,11 @@ name_prefix : '', install : true, install_dir : PURPLE_PLUGINDIR) + test_request_input = library('test-request-input', 'test-request-input.c', + dependencies : [libpurple_dep], + name_prefix : '', + ) + if enable_dbus dbus_example_bindings_c = custom_target('dbus_example_bindings_c', input : 'dbus-example.c',
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libpurple/plugins/test-request-input.c Wed Oct 31 01:45:24 2018 +0000 @@ -0,0 +1,157 @@ +/* pidgin + * + * Pidgin is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA + */ + +#include <glib.h> + +#include "internal.h" +#include "notify.h" +#include "plugins.h" +#include "version.h" + +#define PREF_ROOT "/plugins" +#define PREF_TEST "/plugins/tests" +#define PREF_PREFIX "/plugins/tests/request-input" +#define PREF_SINGLE PREF_PREFIX "/single" +#define PREF_MULTIPLE PREF_PREFIX "/multiple" +#define PREF_HTML PREF_PREFIX "/html" + +static void +plugin_input_callback(const gchar *pref, const gchar *text) { + purple_prefs_set_string(pref, text); +} + +static void +plugin_input_single(PurplePluginAction *action) { + purple_request_input( + NULL, + _("Test request input single"), + _("Test request input single"), + NULL, + purple_prefs_get_string(PREF_SINGLE), + FALSE, + FALSE, + NULL, + _("OK"), + PURPLE_CALLBACK(plugin_input_callback), + _("Cancel"), + NULL, + purple_request_cpar_new(), + PREF_SINGLE + ); +} + +static void +plugin_input_multiple(PurplePluginAction *action) { + purple_request_input( + NULL, + _("Test request input multiple"), + _("Test request input multiple"), + NULL, + purple_prefs_get_string(PREF_MULTIPLE), + TRUE, + FALSE, + NULL, + _("OK"), + PURPLE_CALLBACK(plugin_input_callback), + _("Cancel"), + NULL, + purple_request_cpar_new(), + PREF_MULTIPLE + ); +} + +static void +plugin_input_html(PurplePluginAction *action) { + purple_request_input( + NULL, + _("Test request input HTML"), + _("Test request input HTML"), + NULL, + purple_prefs_get_string(PREF_HTML), + FALSE, + FALSE, + "html", + _("OK"), + PURPLE_CALLBACK(plugin_input_callback), + _("Cancel"), + NULL, + purple_request_cpar_new(), + PREF_HTML + ); +} + +static GList * +plugin_actions(PurplePlugin *plugin) { + GList *l = NULL; + PurplePluginAction *action = NULL; + + action = purple_plugin_action_new(_("Input single"), plugin_input_single); + l = g_list_append(l, action); + + action = purple_plugin_action_new(_("Input multiple"), plugin_input_multiple); + l = g_list_append(l, action); + + action = purple_plugin_action_new(_("Input html"), plugin_input_html); + l = g_list_append(l, action); + + return l; +} + +static PurplePluginInfo * +plugin_query(GError **error) { + const gchar * const authors[] = { + "Gary Kramlich <grim@reaperworld.com>", + NULL + }; + + return purple_plugin_info_new( + "id", "core-test_request_input", + "name", N_("Test: request input"), + "version", DISPLAY_VERSION, + "category", N_("Testing"), + "summary", N_("Test Request Input"), + "description", N_("This plugin adds actions to test purple_request_input"), + "authors", authors, + "website", "https://pidgin.im", + "abi-version", PURPLE_ABI_VERSION, + "actions-cb", plugin_actions, + NULL + ); +}; + +static gboolean +plugin_load(PurplePlugin *plugin, GError **error) { + purple_prefs_add_none(PREF_ROOT); + purple_prefs_add_none(PREF_TEST); + purple_prefs_add_none(PREF_PREFIX); + purple_prefs_add_string(PREF_SINGLE, ""); + purple_prefs_add_string(PREF_MULTIPLE, ""); + purple_prefs_add_string(PREF_HTML, ""); + + return TRUE; +} + +static gboolean +plugin_unload(PurplePlugin *plugin, GError **error) { + return TRUE; +} + +PURPLE_PLUGIN_INIT(test_request_input, plugin_query, plugin_load, plugin_unload);
--- a/meson.build Thu Oct 18 21:03:19 2018 -0500 +++ b/meson.build Wed Oct 31 01:45:24 2018 +0000 @@ -679,7 +679,7 @@ '-DFINCH_DISABLE_DEPRECATED', '-DGNT_DISABLE_DEPRECATED', language : 'c') -if compiler.get_id() == 'gcc' +if get_option('buildtype') != 'plain' and compiler.get_id() == 'gcc' # We enable -Wall later. # If it's set after the warning CFLAGS in the compiler invocation, it counteracts the -Wno... flags. # This leads to warnings we don't want. @@ -735,7 +735,7 @@ # ]) endif endif -if SUNCC +if get_option('buildtype') != 'plain' and SUNCC add_project_arguments('-features=extensions', language : 'c') endif
--- a/pidgin/gtkrequest.c Thu Oct 18 21:03:19 2018 -0500 +++ b/pidgin/gtkrequest.c Wed Oct 31 01:45:24 2018 +0000 @@ -18,6 +18,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + +#include <talkatu.h> + #include "internal.h" #include "pidgin.h" @@ -26,7 +29,6 @@ #include "tls-certificate-info.h" #include "util.h" -#include "gtkwebview.h" #include "gtkrequest.h" #include "gtkutils.h" #include "pidginstock.h" @@ -140,32 +142,36 @@ generic_response_start(data); - if (data->u.input.multiline) { - GtkTextIter start_iter, end_iter; + if (data->u.input.multiline || purple_strequal(data->u.input.hint, "html")) { GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(data->u.input.entry)); - gtk_text_buffer_get_start_iter(buffer, &start_iter); - gtk_text_buffer_get_end_iter(buffer, &end_iter); - - if (purple_strequal(data->u.input.hint, "html")) - multiline_value = pidgin_webview_get_body_html(PIDGIN_WEBVIEW(data->u.input.entry)); - else + if (purple_strequal(data->u.input.hint, "html")) { + multiline_value = talkatu_markup_get_html(buffer, NULL); + } else { + GtkTextIter start_iter, end_iter; + + gtk_text_buffer_get_start_iter(buffer, &start_iter); + gtk_text_buffer_get_end_iter(buffer, &end_iter); + multiline_value = gtk_text_buffer_get_text(buffer, &start_iter, &end_iter, FALSE); + } value = multiline_value; } - else + else { value = gtk_entry_get_text(GTK_ENTRY(data->u.input.entry)); + } if (id >= 0 && (gsize)id < data->cb_count && data->cbs[id] != NULL) ((PurpleRequestInputCb)data->cbs[id])(data->user_data, value); else if (data->cbs[1] != NULL) ((PurpleRequestInputCb)data->cbs[1])(data->user_data, value); - if (data->u.input.multiline) + if (data->u.input.multiline) { g_free(multiline_value); + } purple_request_close(PURPLE_REQUEST_INPUT, data); } @@ -489,7 +495,6 @@ GtkWidget *vbox; GtkWidget *hbox; GtkLabel *label; - GtkWidget *entry; GtkWidget *img; char *label_text; char *primary_esc, *secondary_esc; @@ -572,57 +577,53 @@ gtk_widget_show_all(hbox); - if (purple_strequal(data->u.input.hint, "html")) { - GtkWidget *frame; - - /* webview */ - frame = pidgin_create_webview(TRUE, &entry, NULL); - gtk_widget_set_size_request(entry, 320, 130); - gtk_widget_set_name(entry, "pidgin_request_webview"); - if (default_value != NULL) - pidgin_webview_append_html(PIDGIN_WEBVIEW(entry), default_value); - gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); - gtk_widget_show(frame); - } - else { - if (multiline) { - /* GtkTextView */ - entry = gtk_text_view_new(); - gtk_text_view_set_editable(GTK_TEXT_VIEW(entry), TRUE); - - if (default_value != NULL) { - GtkTextBuffer *buffer; - - buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(entry)); + if(multiline || purple_strequal(data->u.input.hint, "html")) { + GtkWidget *editor = talkatu_editor_new(); + GtkWidget *view = talkatu_editor_get_view(TALKATU_EDITOR(editor)); + GtkTextBuffer *buffer = NULL; + + gtk_widget_set_size_request(view, 320, 130); + gtk_widget_set_name(view, "pidgin_request_view"); + gtk_box_pack_start(GTK_BOX(vbox), editor, TRUE, TRUE, 0); + gtk_widget_show(editor); + + if (purple_strequal(data->u.input.hint, "html")) { + buffer = talkatu_html_buffer_new(); + + if(default_value != NULL) { + talkatu_markup_set_html(TALKATU_BUFFER(buffer), default_value, -1); + } + } else { + buffer = gtk_text_buffer_new(NULL); + + if(default_value != NULL) { gtk_text_buffer_set_text(buffer, default_value, -1); } - - gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(entry), GTK_WRAP_WORD_CHAR); - - gtk_box_pack_start(GTK_BOX(vbox), - pidgin_make_scrollable(entry, GTK_POLICY_NEVER, GTK_POLICY_ALWAYS, GTK_SHADOW_IN, 320, 130), - TRUE, TRUE, 0); } - else { - entry = gtk_entry_new(); - - gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); - - gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0); - - if (default_value != NULL) - gtk_entry_set_text(GTK_ENTRY(entry), default_value); - - if (masked) - { - gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); - } + + gtk_text_view_set_buffer(GTK_TEXT_VIEW(view), buffer); + + data->u.input.entry = view; + } else { + GtkWidget *entry = gtk_entry_new(); + + gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); + gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0); + + if(default_value != NULL) { + gtk_entry_set_text(GTK_ENTRY(entry), default_value); } - gtk_widget_show_all(vbox); + + if(masked) { + gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); + } + + data->u.input.entry = entry; } - pidgin_set_accessible_label(entry, label); - data->u.input.entry = entry; + gtk_widget_show_all(vbox); + + pidgin_set_accessible_label(data->u.input.entry, label); pidgin_auto_parent_window(dialog);