# HG changeset patch # User Gary Kramlich # Date 1664532669 18000 # Node ID f9bb5493c0a0906fb6e1546897b348f6c6c0153a # Parent 78a984e17548e6b5fc9db459a6cd170df3e6d632 Remove the PidginProxyOptions widget This was created to try and save some duplication, but then we moved everything to list boxes and avoided a bunch of duplication. Testing Done: * Opened the account editor and preferences and made sure there were no issues. * Ran `ninja pidgin-pot`. Reviewed at https://reviews.imfreedom.org/r/1872/ diff -r 78a984e17548 -r f9bb5493c0a0 pidgin/meson.build --- a/pidgin/meson.build Fri Sep 30 04:02:12 2022 -0500 +++ b/pidgin/meson.build Fri Sep 30 05:11:09 2022 -0500 @@ -52,7 +52,6 @@ 'pidginpluginsmenu.c', 'pidginpresenceicon.c', 'pidginprotocolchooser.c', - 'pidginproxyoptions.c', 'pidginstatusbox.c', 'pidginstatuseditor.c', 'pidginstatusmanager.c', @@ -122,7 +121,6 @@ 'pidginpluginsmenu.h', 'pidginpresenceicon.h', 'pidginprotocolchooser.h', - 'pidginproxyoptions.h', 'pidginstatusbox.h', 'pidginstatuseditor.h', 'pidginstatusmanager.h', diff -r 78a984e17548 -r f9bb5493c0a0 pidgin/pidginproxyoptions.c --- a/pidgin/pidginproxyoptions.c Fri Sep 30 04:02:12 2022 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,438 +0,0 @@ -/* - * Pidgin - Internet Messenger - * Copyright (C) Pidgin Developers - * - * 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, see . - */ - -#include - -#include "pidginproxyoptions.h" - -#include "gtkaccount.h" -#include "pidgincore.h" - -struct _PidginProxyOptions { - GtkBox parent; - - gboolean show_global; - PurpleProxyInfo *info; - - GtkListStore *model; - GtkTreeModelFilter *filter; - - GtkWidget *proxy_type; - - GtkWidget *options; - GtkWidget *hostname; - GtkWidget *port; - GtkWidget *username; - GtkWidget *password; -}; - -enum { - PROP_0, - PROP_SHOW_GLOBAL, - PROP_INFO, - N_PROPERTIES -}; -static GParamSpec *properties[N_PROPERTIES] = {NULL, }; - -enum { - COLUMN_TYPE, - COLUMN_TITLE, -}; - -G_DEFINE_TYPE(PidginProxyOptions, pidgin_proxy_options, GTK_TYPE_BOX) - -/****************************************************************************** - * Helpers - *****************************************************************************/ -static gboolean -pidgin_proxy_options_null_to_empty_str(G_GNUC_UNUSED GBinding *binding, - const GValue *from_value, - GValue *to_value, - G_GNUC_UNUSED gpointer data) -{ - const gchar *str_val = g_value_get_string(from_value); - - if(str_val == NULL) { - str_val = ""; - } - - g_value_set_string(to_value, str_val); - - return TRUE; -} - -static gboolean -pidgin_proxy_options_empty_str_to_null(G_GNUC_UNUSED GBinding *binding, - const GValue *from_value, - GValue *to_value, - G_GNUC_UNUSED gpointer data) -{ - const gchar *str_val = g_value_get_string(from_value); - - if(str_val != NULL && *str_val == '\0') { - str_val = NULL; - } - - g_value_set_string(to_value, str_val); - - return TRUE; -} - -static gboolean -pidgin_proxy_options_gint_to_double(G_GNUC_UNUSED GBinding *binding, - const GValue *from_value, GValue *to_value, - G_GNUC_UNUSED gpointer data) -{ - g_value_set_double(to_value, (gdouble)g_value_get_int(from_value)); - - return TRUE; -} - -static gboolean -pidgin_proxy_options_double_to_gint(G_GNUC_UNUSED GBinding *binding, - const GValue *from_value, GValue *to_value, - G_GNUC_UNUSED gpointer user_data) -{ - g_value_set_int(to_value, (gint)g_value_get_double(from_value)); - - return TRUE; -} - -static gboolean -pidgin_proxy_options_filter_visible(GtkTreeModel *model, GtkTreeIter *iter, - gpointer data) -{ - PidginProxyOptions *options = data; - PurpleProxyType type; - - gtk_tree_model_get(model, iter, COLUMN_TYPE, &type, -1); - - if(type == PURPLE_PROXY_TYPE_USE_GLOBAL) { - return options->show_global; - } - - return TRUE; -} - -/****************************************************************************** - * Callbacks - *****************************************************************************/ -static void -pidgin_proxy_options_proxy_type_changed_cb(GtkComboBox *box, gpointer data) { - PidginProxyOptions *options = data; - PurpleProxyType type; - GtkTreeIter iter; - gboolean sensitive = TRUE; - - if(!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(options->proxy_type), &iter)) { - return; - } - - gtk_tree_model_get(GTK_TREE_MODEL(options->filter), &iter, - COLUMN_TYPE, &type, - -1); - - purple_proxy_info_set_proxy_type(options->info, type); - - switch(type) { - case PURPLE_PROXY_TYPE_USE_GLOBAL: - case PURPLE_PROXY_TYPE_NONE: - case PURPLE_PROXY_TYPE_USE_ENVVAR: - sensitive = FALSE; - break; - default: - break; - } - - gtk_widget_set_sensitive(options->options, sensitive); -} - -/****************************************************************************** - * GObject Implementation - *****************************************************************************/ -static void -pidgin_proxy_options_get_property(GObject *obj, guint param_id, GValue *value, - GParamSpec *pspec) -{ - PidginProxyOptions *options = PIDGIN_PROXY_OPTIONS(obj); - - switch(param_id) { - case PROP_SHOW_GLOBAL: - g_value_set_boolean(value, - pidgin_proxy_options_get_show_global(options)); - break; - case PROP_INFO: - g_value_set_object(value, pidgin_proxy_options_get_info(options)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); - break; - } -} - -static void -pidgin_proxy_options_set_property(GObject *obj, guint param_id, - const GValue *value, GParamSpec *pspec) -{ - PidginProxyOptions *options = PIDGIN_PROXY_OPTIONS(obj); - - switch(param_id) { - case PROP_SHOW_GLOBAL: - pidgin_proxy_options_set_show_global(options, - g_value_get_boolean(value)); - break; - case PROP_INFO: - pidgin_proxy_options_set_info(options, g_value_get_object(value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); - break; - } -} - -static void -pidgin_proxy_options_init(PidginProxyOptions *options) { - gtk_widget_init_template(GTK_WIDGET(options)); - - /* Set the visible function so we can control the visibility of the "Use - * Global Proxy" option. - */ - gtk_tree_model_filter_set_visible_func(options->filter, - pidgin_proxy_options_filter_visible, - options, NULL); - - /* Force the filter to refresh. */ - gtk_tree_model_filter_refilter(options->filter); -} - -static void -pidgin_proxy_options_constructed(GObject *obj) { - PidginProxyOptions *options = PIDGIN_PROXY_OPTIONS(obj); - - G_OBJECT_CLASS(pidgin_proxy_options_parent_class)->constructed(obj); - - if(options->info == NULL) { - pidgin_proxy_options_set_info(options, NULL); - } -} - -static void -pidgin_proxy_options_class_init(PidginProxyOptionsClass *klass) { - GObjectClass *obj_class = G_OBJECT_CLASS(klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); - - obj_class->get_property = pidgin_proxy_options_get_property; - obj_class->set_property = pidgin_proxy_options_set_property; - obj_class->constructed = pidgin_proxy_options_constructed; - - /** - * PidginProxyOptions:show-global: - * - * Whether or not to show the "Use Global Proxy Settings" option. This - * is turned off for the preferences where we use this widget to define - * the global proxy settings. - * - * Since: 3.0.0 - */ - properties[PROP_SHOW_GLOBAL] = g_param_spec_boolean( - "show-global", "show-global", - "Whether or not to show the global proxy settings option", - TRUE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS); - - /** - * PidginProxyOptions:info: - * - * The [class@Purple.ProxyInfo] that this options widget is configuring. If - * unset, a new instance will be created. - * - * Since: 3.0.0 - */ - properties[PROP_INFO] = g_param_spec_object( - "info", "info", - "The proxy info to configure", - PURPLE_TYPE_PROXY_INFO, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS); - - g_object_class_install_properties(obj_class, N_PROPERTIES, properties); - - gtk_widget_class_set_template_from_resource( - widget_class, - "/im/pidgin/Pidgin3/proxyoptions.ui" - ); - - gtk_widget_class_bind_template_child(widget_class, PidginProxyOptions, - model); - gtk_widget_class_bind_template_child(widget_class, PidginProxyOptions, - filter); - - gtk_widget_class_bind_template_child(widget_class, PidginProxyOptions, - proxy_type); - - gtk_widget_class_bind_template_child(widget_class, PidginProxyOptions, - options); - gtk_widget_class_bind_template_child(widget_class, PidginProxyOptions, - hostname); - gtk_widget_class_bind_template_child(widget_class, PidginProxyOptions, - port); - gtk_widget_class_bind_template_child(widget_class, PidginProxyOptions, - username); - gtk_widget_class_bind_template_child(widget_class, PidginProxyOptions, - password); - - gtk_widget_class_bind_template_callback(widget_class, - pidgin_proxy_options_proxy_type_changed_cb); -} - -/****************************************************************************** - * Public API - *****************************************************************************/ -GtkWidget * -pidgin_proxy_options_new(void) { - return g_object_new(PIDGIN_TYPE_PROXY_OPTIONS, NULL); -} - -void -pidgin_proxy_options_set_show_global(PidginProxyOptions *options, - gboolean show_global) -{ - PurpleProxyType proxy_type = PURPLE_PROXY_TYPE_USE_GLOBAL; - - g_return_if_fail(PIDGIN_IS_PROXY_OPTIONS(options)); - - if(show_global == options->show_global) { - return; - } - - options->show_global = show_global; - - if(options->info == NULL) { - g_object_notify_by_pspec(G_OBJECT(options), - properties[PROP_SHOW_GLOBAL]); - - return; - } - - proxy_type = purple_proxy_info_get_proxy_type(options->info); - if(proxy_type == PURPLE_PROXY_TYPE_USE_GLOBAL && show_global == FALSE) { - proxy_type = PURPLE_PROXY_TYPE_NONE; - } - - purple_proxy_info_set_proxy_type(options->info, proxy_type); - - options->show_global = show_global; - - g_object_notify_by_pspec(G_OBJECT(options), properties[PROP_SHOW_GLOBAL]); - - /* Tell the filter to rerun. */ - gtk_tree_model_filter_refilter(options->filter); -} - -gboolean -pidgin_proxy_options_get_show_global(PidginProxyOptions *options) { - g_return_val_if_fail(PIDGIN_IS_PROXY_OPTIONS(options), FALSE); - - return options->show_global; -} - -void -pidgin_proxy_options_set_info(PidginProxyOptions *options, - PurpleProxyInfo *info) -{ - GtkTreeIter iter; - GtkTreeModel *model; - - g_return_if_fail(PIDGIN_IS_PROXY_OPTIONS(options)); - - /* We want to always have a PurpleProxyInfo instance to make management - * easier. So if someone clears it, just replace it with an empty one - * instead. - */ - if(!PURPLE_IS_PROXY_INFO(info)) { - PurpleProxyInfo *empty_info = purple_proxy_info_new(); - - if(!g_set_object(&options->info, empty_info)) { - g_assert_not_reached(); - } - - g_object_unref(empty_info); - } else if(!g_set_object(&options->info, info)) { - return; - } - - model = GTK_TREE_MODEL(options->filter); - if(gtk_tree_model_get_iter_first(model, &iter)) { - do { - PurpleProxyType type = purple_proxy_info_get_proxy_type(options->info); - PurpleProxyType row_type; - - gtk_tree_model_get(model, &iter, COLUMN_TYPE, &row_type, -1); - if(row_type == type) { - gtk_combo_box_set_active_iter(GTK_COMBO_BOX(options->proxy_type), - &iter); - break; - } - } while(gtk_tree_model_iter_next(model, &iter)); - } - - g_object_bind_property_full(options->info, "hostname", - options->hostname, "text", - G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE, - pidgin_proxy_options_null_to_empty_str, - pidgin_proxy_options_empty_str_to_null, - NULL, - NULL); - - g_object_bind_property_full(options->info, "port", - options->port, "value", - G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE, - pidgin_proxy_options_gint_to_double, - pidgin_proxy_options_double_to_gint, - NULL, - NULL); - - g_object_bind_property_full(options->info, "username", - options->username, "text", - G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE, - pidgin_proxy_options_null_to_empty_str, - pidgin_proxy_options_empty_str_to_null, - NULL, - NULL); - - - g_object_bind_property_full(options->info, "password", - options->password, "text", - G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE, - pidgin_proxy_options_null_to_empty_str, - pidgin_proxy_options_empty_str_to_null, - NULL, - NULL); - - g_object_notify_by_pspec(G_OBJECT(options), properties[PROP_INFO]); -} - -PurpleProxyInfo * -pidgin_proxy_options_get_info(PidginProxyOptions *options) { - g_return_val_if_fail(PIDGIN_IS_PROXY_OPTIONS(options), NULL); - - return options->info; -} diff -r 78a984e17548 -r f9bb5493c0a0 pidgin/pidginproxyoptions.h --- a/pidgin/pidginproxyoptions.h Fri Sep 30 04:02:12 2022 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -/* - * Pidgin - Internet Messenger - * Copyright (C) Pidgin Developers - * - * 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, see . - */ - -#if !defined(PIDGIN_GLOBAL_HEADER_INSIDE) && !defined(PIDGIN_COMPILATION) -# error "only may be included directly" -#endif - -#ifndef PIDGIN_PROXY_OPTIONS_H -#define PIDGIN_PROXY_OPTIONS_H - -#include - -#include - -G_BEGIN_DECLS - -/** - * PidginProxyOptions: - * - * A widget for the proxy options in the account editor. - * - * Since: 3.0.0 - */ - -#define PIDGIN_TYPE_PROXY_OPTIONS (pidgin_proxy_options_get_type()) -G_DECLARE_FINAL_TYPE(PidginProxyOptions, pidgin_proxy_options, PIDGIN, - PROXY_OPTIONS, GtkBox) - -/** - * pidgin_proxy_options_new: - * - * Creates a new proxy options widget. - * - * Returns: (transfer full): The widget. - * - * Since: 3.0.0 - */ -GtkWidget *pidgin_proxy_options_new(void); - -/** - * pidgin_proxy_options_set_show_global: - * @options: The instance. - * @show_global: Whether or not to show the use global settings proxy item. - * - * Sets whether or not to show the "Use Global Proxy Settings" item. - * - * Since: 3.0.0 - */ -void pidgin_proxy_options_set_show_global(PidginProxyOptions *options, gboolean show_global); - -/** - * pidgin_proxy_options_get_show_global: - * @options: The instance. - * - * Gets whether or not @options is displaying the "Use Global Proxy Settings" - * item. - * - * Returns: %TRUE if displaying it, %FALSE otherwise. - * - * Since: 3.0.0 - */ -gboolean pidgin_proxy_options_get_show_global(PidginProxyOptions *options); - -/** - * pidgin_proxy_options_get_info: - * @options: The instance. - * - * Gets the [class@Purple.ProxyInfo] that is being configured. - * - * Returns: (transfer none): The proxy info. - * - * Since: 3.0.0 - */ -PurpleProxyInfo *pidgin_proxy_options_get_info(PidginProxyOptions *options); - -/** - * pidgin_proxy_options_set_info: - * @options: The instance. - * @info: (nullable): The [class@Purple.ProxyInfo] to set. - * - * The proxy info that will be configured. - * - * Since: 3.0.0 - */ -void pidgin_proxy_options_set_info(PidginProxyOptions *options, PurpleProxyInfo *info); - -G_END_DECLS - -#endif /* PIDGIN_PROXY_OPTIONS_H */ diff -r 78a984e17548 -r f9bb5493c0a0 pidgin/resources/pidgin.gresource.xml --- a/pidgin/resources/pidgin.gresource.xml Fri Sep 30 04:02:12 2022 -0500 +++ b/pidgin/resources/pidgin.gresource.xml Fri Sep 30 05:11:09 2022 -0500 @@ -45,7 +45,6 @@ Xfer/xfer.ui gtk/menus.ui presenceicon.ui - proxyoptions.ui statusprimitivechooser.ui icons/16x16/status/pidgin-user-available.png icons/16x16/status/pidgin-user-away.png diff -r 78a984e17548 -r f9bb5493c0a0 pidgin/resources/proxyoptions.ui --- a/pidgin/resources/proxyoptions.ui Fri Sep 30 04:02:12 2022 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,217 +0,0 @@ - - - - - - - - - - - - - - - - PURPLE_PROXY_TYPE_USE_GLOBAL - Use Global Proxy Settings - - - PURPLE_PROXY_TYPE_NONE - No Proxy - - - PURPLE_PROXY_TYPE_SOCKS4 - SOCKS 4 - - - PURPLE_PROXY_TYPE_SOCKS5 - SOCKS 5 - - - PURPLE_PROXY_TYPE_TOR - TOR/Privacy (SOCKS 5) - - - PURPLE_PROXY_TYPE_HTTP - HTTP - - - PURPLE_PROXY_TYPE_USE_ENVVAR - Use Environmental Settings - - - - - model - - - -1 - 65535 - 1 - 10 - - - - - - - - - - - - - - - If you look real closely - - - - you can see the butterflies mating - - - diff -r 78a984e17548 -r f9bb5493c0a0 po/POTFILES.in --- a/po/POTFILES.in Fri Sep 30 04:02:12 2022 -0500 +++ b/po/POTFILES.in Fri Sep 30 05:11:09 2022 -0500 @@ -363,7 +363,6 @@ pidgin/pidginpluginsmenu.c pidgin/pidginpresenceicon.c pidgin/pidginprotocolchooser.c -pidgin/pidginproxyoptions.c pidgin/pidginstatusbox.c pidgin/pidginstatuseditor.c pidgin/pidginstatusmanager.c @@ -423,7 +422,6 @@ pidgin/resources/Whiteboard/whiteboard.ui pidgin/resources/Xfer/xfer.ui pidgin/resources/gtk/menus.ui -pidgin/resources/proxyoptions.ui pidgin/win32/gtkwin32dep.c pidgin/win32/winpidgin.c purple-history/purplehistorycore.c