Fri, 29 Jul 2022 02:51:43 -0500
Remove PidginAccountsMenu not that protocol actions have been ported to GMenu
Testing Done:
Ran and verified the ContactListWindow worked as expected.
Reviewed at https://reviews.imfreedom.org/r/1550/
| pidgin/meson.build | file | annotate | diff | comparison | revisions | |
| pidgin/pidginaccountsmenu.c | file | annotate | diff | comparison | revisions | |
| pidgin/pidginaccountsmenu.h | file | annotate | diff | comparison | revisions | |
| pidgin/pidgincontactlistwindow.c | file | annotate | diff | comparison | revisions | |
| pidgin/resources/Accounts/menu.ui | file | annotate | diff | comparison | revisions | |
| pidgin/resources/BuddyList/window.ui | file | annotate | diff | comparison | revisions | |
| pidgin/resources/pidgin.gresource.xml | file | annotate | diff | comparison | revisions |
--- a/pidgin/meson.build Fri Jul 29 02:15:31 2022 -0500 +++ b/pidgin/meson.build Fri Jul 29 02:51:43 2022 -0500 @@ -25,7 +25,6 @@ 'pidginaccountmanager.c', 'pidginaccountsdisabledmenu.c', 'pidginaccountsenabledmenu.c', - 'pidginaccountsmenu.c', 'pidginaccountstore.c', 'pidginactiongroup.c', 'pidginapplication.c', @@ -100,7 +99,6 @@ 'pidginaccountmanager.h', 'pidginaccountsdisabledmenu.h', 'pidginaccountsenabledmenu.h', - 'pidginaccountsmenu.h', 'pidginaccountstore.h', 'pidginactiongroup.h', 'pidginapplication.h',
--- a/pidgin/pidginaccountsmenu.c Fri Jul 29 02:15:31 2022 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,263 +0,0 @@ -/* - * Pidgin - Internet Messenger - * Copyright (C) Pidgin Developers <devel@pidgin.im> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#include "pidginaccountsmenu.h" - -#include <purple.h> - -#include "pidginaccountactionsmenu.h" - -#include "pidgincore.h" - -struct _PidginAccountsMenu { - GtkMenu parent; - - GtkWidget *enable_account; - GtkWidget *disabled_menu; - GtkWidget *separator; - - GHashTable *account_items; - GHashTable *disabled_items; -}; - -/****************************************************************************** - * GSignal Handlers - *****************************************************************************/ -static void -pidgin_accounts_menu_enable_account(GtkMenuItem *item, gpointer data) { - PurpleAccount *account = PURPLE_ACCOUNT(data); - - purple_account_set_enabled(account, TRUE); -} - -/****************************************************************************** - * Helpers - *****************************************************************************/ -static GtkWidget * -pidgin_accounts_menu_create_account_menu_item(PidginAccountsMenu *menu, - PurpleAccount *account) -{ - GtkWidget *item = NULL; - const gchar *account_name = purple_account_get_username(account); - const gchar *protocol_name = purple_account_get_protocol_name(account); - gchar *label = g_strdup_printf("%s (%s)", account_name, protocol_name); - - item = gtk_menu_item_new_with_label(label); - g_free(label); - gtk_widget_show(item); - - return item; -} - -static void -pidgin_accounts_menu_add_enabled_account(PidginAccountsMenu *menu, - PurpleAccount *account) -{ - GtkWidget *item = NULL, *submenu = NULL; - gpointer data = NULL; - gboolean found = FALSE; - - /* if the account is in the disabled list, delete its widget */ - found = g_hash_table_lookup_extended(menu->disabled_items, account, NULL, - &data); - if(found) { - g_clear_pointer(&data, gtk_widget_destroy); - g_hash_table_remove(menu->disabled_items, account); - - if(g_hash_table_size(menu->disabled_items) == 0) { - gtk_widget_set_sensitive(menu->enable_account, FALSE); - } - } - - item = pidgin_accounts_menu_create_account_menu_item(menu, account); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - g_hash_table_insert(menu->account_items, - g_object_ref(G_OBJECT(account)), - item); - - /* create the submenu and attach it to item right away, this allows us to - * reuse item for the submenu items. - */ - submenu = pidgin_account_actions_menu_new(account); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); -} - -static void -pidgin_accounts_menu_add_disabled_account(PidginAccountsMenu *menu, - PurpleAccount *account) -{ - GtkWidget *item = NULL; - gpointer data = NULL; - gboolean found = FALSE; - - /* if the account is in the enabled list, delete its widget */ - found = g_hash_table_lookup_extended(menu->account_items, account, NULL, - &data); - if(found) { - g_clear_pointer(&data, gtk_widget_destroy); - g_hash_table_remove(menu->account_items, account); - } - - item = pidgin_accounts_menu_create_account_menu_item(menu, account); - g_signal_connect(G_OBJECT(item), "activate", - G_CALLBACK(pidgin_accounts_menu_enable_account), account); - gtk_menu_shell_append(GTK_MENU_SHELL(menu->disabled_menu), item); - - g_hash_table_insert(menu->disabled_items, - g_object_ref(G_OBJECT(account)), - item); - - /* We know there's at least one item in the menu, so make sure it is - * sensitive. - */ - gtk_widget_set_sensitive(menu->enable_account, TRUE); -} - -static void -pidgin_accounts_menu_foreach_cb(PurpleAccount *account, gpointer data) { - PidginAccountsMenu *menu = PIDGIN_ACCOUNTS_MENU(data); - - if(purple_account_get_enabled(account)) { - pidgin_accounts_menu_add_enabled_account(menu, account); - } else { - pidgin_accounts_menu_add_disabled_account(menu, account); - } -} - -static void -pidgin_accounts_menu_add_current(PidginAccountsMenu *menu) { - PurpleAccountManager *manager = NULL; - - manager = purple_account_manager_get_default(); - purple_account_manager_foreach(manager, pidgin_accounts_menu_foreach_cb, - menu); -} - -/****************************************************************************** - * Purple Signal Callbacks - *****************************************************************************/ -static void -pidgin_accounts_menu_account_status_changed(PurpleAccount *account, - gpointer d) -{ - PidginAccountsMenu *menu = PIDGIN_ACCOUNTS_MENU(d); - gpointer data = NULL; - - data = g_hash_table_lookup(menu->account_items, account); - if(GTK_IS_WIDGET(data)) { - gtk_menu_item_set_submenu(GTK_MENU_ITEM(data), - pidgin_account_actions_menu_new(account)); - } -} - -static void -pidgin_accounts_menu_account_enabled(PurpleAccount *account, gpointer data) { - pidgin_accounts_menu_add_enabled_account(PIDGIN_ACCOUNTS_MENU(data), - account); -} - -static void -pidgin_accounts_menu_account_disabled(PurpleAccount *account, gpointer data) { - pidgin_accounts_menu_add_disabled_account(PIDGIN_ACCOUNTS_MENU(data), - account); -} - -/****************************************************************************** - * GObject Implementation - *****************************************************************************/ -G_DEFINE_TYPE(PidginAccountsMenu, pidgin_accounts_menu, GTK_TYPE_MENU) - -static void -pidgin_accounts_menu_init(PidginAccountsMenu *menu) { - gpointer handle; - - /* initialize our template */ - gtk_widget_init_template(GTK_WIDGET(menu)); - - /* create our storage for the items */ - menu->account_items = g_hash_table_new_full(g_direct_hash, g_direct_equal, - g_object_unref, NULL); - menu->disabled_items = g_hash_table_new_full(g_direct_hash, g_direct_equal, - g_object_unref, NULL); - - /* add all of the existing accounts */ - pidgin_accounts_menu_add_current(menu); - - /* finally connect to the purple signals to stay up to date */ - handle = purple_accounts_get_handle(); - purple_signal_connect(handle, "account-signed-on", menu, - G_CALLBACK(pidgin_accounts_menu_account_status_changed), - menu); - purple_signal_connect(handle, "account-signed-off", menu, - G_CALLBACK(pidgin_accounts_menu_account_status_changed), - menu); - purple_signal_connect(handle, "account-actions-changed", menu, - G_CALLBACK(pidgin_accounts_menu_account_status_changed), - menu); - purple_signal_connect(handle, "account-enabled", menu, - G_CALLBACK(pidgin_accounts_menu_account_enabled), - menu); - purple_signal_connect(handle, "account-disabled", menu, - G_CALLBACK(pidgin_accounts_menu_account_disabled), - menu); -}; - -static void -pidgin_accounts_menu_finalize(GObject *obj) { - PidginAccountsMenu *menu = PIDGIN_ACCOUNTS_MENU(obj); - - purple_signals_disconnect_by_handle(obj); - - g_hash_table_destroy(menu->account_items); - g_hash_table_destroy(menu->disabled_items); - - G_OBJECT_CLASS(pidgin_accounts_menu_parent_class)->finalize(obj); -} - -static void -pidgin_accounts_menu_class_init(PidginAccountsMenuClass *klass) { - GObjectClass *obj_class = G_OBJECT_CLASS(klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); - - obj_class->finalize = pidgin_accounts_menu_finalize; - - gtk_widget_class_set_template_from_resource( - widget_class, - "/im/pidgin/Pidgin3/Accounts/menu.ui" - ); - - gtk_widget_class_bind_template_child(widget_class, PidginAccountsMenu, - enable_account); - gtk_widget_class_bind_template_child(widget_class, PidginAccountsMenu, - disabled_menu); - gtk_widget_class_bind_template_child(widget_class, PidginAccountsMenu, - separator); -} - -/****************************************************************************** - * Public API - *****************************************************************************/ -GtkWidget * -pidgin_accounts_menu_new(void) { - return GTK_WIDGET(g_object_new(PIDGIN_TYPE_ACCOUNTS_MENU, NULL)); -} -
--- a/pidgin/pidginaccountsmenu.h Fri Jul 29 02:15:31 2022 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* - * Pidgin - Internet Messenger - * Copyright (C) Pidgin Developers <devel@pidgin.im> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -#if !defined(PIDGIN_GLOBAL_HEADER_INSIDE) && !defined(PIDGIN_COMPILATION) -# error "only <pidgin.h> may be included directly" -#endif - -#ifndef PIDGIN_ACCOUNTS_MENU_H -#define PIDGIN_ACCOUNTS_MENU_H - -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -/** - * PidginAccountsMenu: - * - * #PidginAccountsMenu is a #GtkMenu that provides an interface to users to open - * the account manager as well as activate account actions. - * - * It manages itself as accounts are created/deleted and enabled/disabled and - * can be added as a submenu to any #GtkMenuItem. - * - * Since: 3.0.0 - */ - -#define PIDGIN_TYPE_ACCOUNTS_MENU (pidgin_accounts_menu_get_type()) -G_DECLARE_FINAL_TYPE(PidginAccountsMenu, pidgin_accounts_menu, PIDGIN, - ACCOUNTS_MENU, GtkMenu) - -/** - * pidgin_accounts_menu_new: - * - * Creates a new #PidginAccountsMenu instance that keeps itself up to date. - * - * Returns: (transfer full): The new #PidginAccountsMenu instance. - */ -GtkWidget *pidgin_accounts_menu_new(void); - -G_END_DECLS - -#endif /* PIDGIN_ACCOUNTS_MENU_H */
--- a/pidgin/pidgincontactlistwindow.c Fri Jul 29 02:15:31 2022 -0500 +++ b/pidgin/pidgincontactlistwindow.c Fri Jul 29 02:51:43 2022 -0500 @@ -31,9 +31,6 @@ GtkWidget *menu_bar; GtkWidget *sort_buddies; - - GtkWidget *accounts; - GtkWidget *accounts_menu; }; G_DEFINE_TYPE(PidginContactListWindow, pidgin_contact_list_window, @@ -54,9 +51,6 @@ group = pidgin_action_group_new(); gtk_widget_insert_action_group(GTK_WIDGET(contact_list), "blist", G_ACTION_GROUP(group)); - - gtk_menu_item_set_submenu(GTK_MENU_ITEM(contact_list->accounts), - contact_list->accounts_menu); } static void @@ -74,10 +68,6 @@ menu_bar); gtk_widget_class_bind_template_child(widget_class, PidginContactListWindow, sort_buddies); - gtk_widget_class_bind_template_child(widget_class, PidginContactListWindow, - accounts); - gtk_widget_class_bind_template_child(widget_class, PidginContactListWindow, - accounts_menu); } /******************************************************************************
--- a/pidgin/resources/Accounts/menu.ui Fri Jul 29 02:15:31 2022 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.38.2 - -Pidgin - Internet Messenger -Copyright (C) Pidgin Developers <devel@pidgin.im> - -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 02110-1301, USA. - ---> -<interface> - <requires lib="gtk+" version="3.22"/> - <!-- interface-license-type gplv2 --> - <!-- interface-name Pidgin --> - <!-- interface-description Internet Messenger --> - <!-- interface-copyright Pidgin Developers <devel@pidgin.im> --> - <template class="PidginAccountsMenu" parent="GtkMenu"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="menu-type-hint">dnd</property> - <child> - <object class="GtkMenuItem" id="enable_account"> - <property name="visible">True</property> - <property name="sensitive">False</property> - <property name="can-focus">False</property> - <property name="label" translatable="yes">_Enable Account</property> - <property name="use-underline">True</property> - <child type="submenu"> - <object class="GtkMenu" id="disabled_menu"> - <property name="visible">True</property> - <property name="can-focus">False</property> - </object> - </child> - </object> - </child> - <child> - <object class="GtkSeparatorMenuItem" id="separator"> - <property name="visible">True</property> - <property name="can-focus">False</property> - </object> - </child> - </template> -</interface>
--- a/pidgin/resources/BuddyList/window.ui Fri Jul 29 02:15:31 2022 -0500 +++ b/pidgin/resources/BuddyList/window.ui Fri Jul 29 02:51:43 2022 -0500 @@ -61,14 +61,6 @@ </child> </object> </child> - <child> - <object class="GtkMenuItem" id="accounts"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="label" translatable="yes">_Accounts</property> - <property name="use-underline">True</property> - </object> - </child> </object> <packing> <property name="expand">False</property> @@ -79,8 +71,4 @@ </object> </child> </template> - <object class="PidginAccountsMenu" id="accounts_menu"> - <property name="visible">True</property> - <property name="can-focus">False</property> - </object> </interface>
--- a/pidgin/resources/pidgin.gresource.xml Fri Jul 29 02:15:31 2022 -0500 +++ b/pidgin/resources/pidgin.gresource.xml Fri Jul 29 02:51:43 2022 -0500 @@ -9,7 +9,6 @@ <file compressed="true">Accounts/chooser.ui</file> <file compressed="true">Accounts/entry.css</file> <file compressed="true">Accounts/manager.ui</file> - <file compressed="true">Accounts/menu.ui</file> <file compressed="true">Avatar/avatar.ui</file> <file compressed="true">Avatar/menu.ui</file> <file compressed="true">BuddyList/window.ui</file>