pidgin/pidgin

Parents d0bd0ccdf2a2
Children 55483ee6710f
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
--- a/pidgin/gtkblist.c Mon May 04 06:03:00 2020 +0000
+++ b/pidgin/gtkblist.c Thu Mar 26 22:55:20 2020 -0500
@@ -58,6 +58,8 @@
#include "pidgin/minidialog.h"
#include "pidgin/pidginabout.h"
#include "pidgin/pidginaccountchooser.h"
+#include "pidgin/pidginactiongroup.h"
+#include "pidgin/pidginbuddylistmenu.h"
#include "pidgin/pidgindebug.h"
#include "pidgin/pidgingdkpixbuf.h"
#include "pidgin/pidginlog.h"
@@ -3640,7 +3642,6 @@
gtk_blist_key_press_cb to "Get User Info" on the selected buddy. */
/* Buddies menu */
{ "BuddiesMenu", NULL, N_("_Buddies"), NULL, NULL, NULL },
- { "NewInstantMessage", PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW, N_("New Instant _Message..."), "<control>M", NULL, pidgin_dialogs_im },
{ "JoinAChat", PIDGIN_STOCK_CHAT, N_("Join a _Chat..."), "<control>C", NULL, pidgin_blist_joinchat_show },
{ "GetUserInfo", PIDGIN_STOCK_TOOLBAR_USER_INFO, N_("Get User _Info..."), "<control>I", NULL, pidgin_dialogs_info },
{ "ViewUserLog", NULL, N_("View User _Log..."), "<control>L", NULL, pidgin_dialogs_log },
@@ -3669,7 +3670,6 @@
/* Help */
{ "HelpMenu", NULL, N_("_Help"), NULL, NULL, NULL },
- { "OnlineHelp", GTK_STOCK_HELP, N_("Online _Help"), "F1", NULL, gtk_blist_show_onlinehelp_cb },
{ "DebugWindow", NULL, N_("_Debug Window"), NULL, NULL, toggle_debug },
{ "About", GTK_STOCK_ABOUT, N_("_About"), NULL, NULL, G_CALLBACK(_pidgin_about_cb) },
};
@@ -3691,7 +3691,6 @@
"<ui>"
"<menubar name='BList'>"
"<menu action='BuddiesMenu'>"
- "<menuitem action='NewInstantMessage'/>"
"<menuitem action='JoinAChat'/>"
"<menuitem action='GetUserInfo'/>"
"<menuitem action='ViewUserLog'/>"
@@ -3730,8 +3729,6 @@
"<placeholder name='PluginActions'/>"
"</menu>"
"<menu action='HelpMenu'>"
- "<menuitem action='OnlineHelp'/>"
- "<separator/>"
"<menuitem action='DebugWindow'/>"
"<separator/>"
"<menuitem action='About'/>"
@@ -5704,6 +5701,7 @@
{
PidginBuddyListPrivate *priv;
void *handle;
+ GSimpleActionGroup *actions;
GtkTreeViewColumn *column;
GtkWidget *menu;
GtkWidget *sep;
@@ -5768,6 +5766,9 @@
gtk_widget_add_events(gtkblist->window, GDK_VISIBILITY_NOTIFY_MASK);
/******************************* Menu bar *************************************/
+ actions = pidgin_action_group_new();
+ gtk_widget_insert_action_group(gtkblist->window, "blist", actions);
+
action_group = gtk_action_group_new("BListActions");
gtk_action_group_set_translation_domain(action_group, PACKAGE);
gtk_action_group_add_actions(action_group,
@@ -5805,6 +5806,9 @@
menu = gtk_ui_manager_get_widget(gtkblist->ui, "/BList/AccountsMenu");
accountmenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(menu));
+ menu = pidgin_buddy_list_menu_new();
+ gtk_box_pack_start(GTK_BOX(gtkblist->main_vbox), menu, FALSE, FALSE, 0);
+
/****************************** Notebook *************************************/
gtkblist->notebook = gtk_notebook_new();
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gtkblist->notebook), FALSE);
--- a/pidgin/meson.build Mon May 04 06:03:00 2020 +0000
+++ b/pidgin/meson.build Thu Mar 26 22:55:20 2020 -0500
@@ -35,6 +35,8 @@
'minidialog.c',
'pidginabout.c',
'pidginaccountchooser.c',
+ 'pidginactiongroup.c',
+ 'pidginbuddylistmenu.c',
'pidgincontactcompletion.c',
'pidgindebug.c',
'pidgingdkpixbuf.c',
@@ -88,6 +90,8 @@
'minidialog.h',
'pidginabout.h',
'pidginaccountchooser.h',
+ 'pidginactiongroup.h',
+ 'pidginbuddylistmenu.h',
'pidgincontactcompletion.h',
'pidgindebug.h',
'pidgingdkpixbuf.h',
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/pidginactiongroup.c Thu Mar 26 22:55:20 2020 -0500
@@ -0,0 +1,81 @@
+/*
+ * 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 "pidginactiongroup.h"
+
+#include "internal.h"
+#include "gtkdialogs.h"
+
+struct _PidginActionGroup {
+ GSimpleActionGroup parent;
+};
+
+/******************************************************************************
+ * Action Callbacks
+ *****************************************************************************/
+static void
+pidgin_action_group_new_message(GSimpleAction *simple, GVariant *parameter,
+ gpointer data)
+{
+ pidgin_dialogs_im();
+}
+
+static void
+pidgin_action_group_online_help(GSimpleAction *simple, GVariant *parameter,
+ gpointer data)
+{
+ purple_notify_uri(NULL, PURPLE_WEBSITE "documentation");
+}
+
+/******************************************************************************
+ * GObject Implementation
+ *****************************************************************************/
+G_DEFINE_TYPE(PidginActionGroup, pidgin_action_group,
+ G_TYPE_SIMPLE_ACTION_GROUP)
+
+static void
+pidgin_action_group_init(PidginActionGroup *group) {
+ GActionEntry entries[] = {
+ {
+ .name = PIDGIN_ACTION_NEW_MESSAGE,
+ .activate = pidgin_action_group_new_message,
+ }, {
+ .name = PIDGIN_ACTION_ONLINE_HELP,
+ .activate = pidgin_action_group_online_help,
+ },
+ };
+
+ g_action_map_add_action_entries(G_ACTION_MAP(group), entries,
+ G_N_ELEMENTS(entries), NULL);
+};
+
+static void
+pidgin_action_group_class_init(PidginActionGroupClass *klass) {
+}
+
+/******************************************************************************
+ * Public API
+ *****************************************************************************/
+GSimpleActionGroup *
+pidgin_action_group_new(void) {
+ return G_SIMPLE_ACTION_GROUP(g_object_new(PIDGIN_TYPE_ACTION_GROUP, NULL));
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/pidginactiongroup.h Thu Mar 26 22:55:20 2020 -0500
@@ -0,0 +1,61 @@
+/*
+ * 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
+ */
+#ifndef PIDGIN_ACTION_GROUP_H
+#define PIDGIN_ACTION_GROUP_H
+
+#include <glib.h>
+
+#include <gio/gio.h>
+
+/**
+ * PIDGIN_ACTION_NEW_MESSAGE:
+ *
+ * A constant that represents the new message action.
+ */
+#define PIDGIN_ACTION_NEW_MESSAGE ("new-message")
+
+/**
+ * PIDGIN_ACTION_ONLINE_HELP:
+ *
+ * A constant that represents the online help action.
+ */
+#define PIDGIN_ACTION_ONLINE_HELP ("online-help")
+
+G_BEGIN_DECLS
+
+#define PIDGIN_TYPE_ACTION_GROUP (pidgin_action_group_get_type())
+G_DECLARE_FINAL_TYPE(PidginActionGroup, pidgin_action_group, PIDGIN,
+ ACTION_GROUP, GSimpleActionGroup)
+
+/**
+ * pidgin_action_group_new:
+ *
+ * Creates a new #PidginActionGroup instance that contains all of the
+ * #GAction's in Pidgin.
+ *
+ * Returns: (transfer full): The new #PidginActionGroup instance.
+ */
+GSimpleActionGroup *pidgin_action_group_new(void);
+
+G_END_DECLS
+
+#endif /* PIDGIN_ACTION_GROUP_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/pidginbuddylistmenu.c Thu Mar 26 22:55:20 2020 -0500
@@ -0,0 +1,53 @@
+/*
+ * 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 "pidginbuddylistmenu.h"
+
+struct _PidginBuddyListMenu {
+ GtkMenuBar parent;
+};
+
+/******************************************************************************
+ * GObject Implementation
+ *****************************************************************************/
+G_DEFINE_TYPE(PidginBuddyListMenu, pidgin_buddy_list_menu, GTK_TYPE_MENU_BAR)
+
+static void
+pidgin_buddy_list_menu_init(PidginBuddyListMenu *menu) {
+ gtk_widget_init_template(GTK_WIDGET(menu));
+}
+
+static void
+pidgin_buddy_list_menu_class_init(PidginBuddyListMenuClass *klass) {
+ gtk_widget_class_set_template_from_resource(
+ GTK_WIDGET_CLASS(klass),
+ "/im/pidgin/Pidgin/BuddyList/menu.ui"
+ );
+}
+
+/******************************************************************************
+ * Public API
+ *****************************************************************************/
+GtkWidget *
+pidgin_buddy_list_menu_new(void) {
+ return GTK_WIDGET(g_object_new(PIDGIN_TYPE_BUDDY_LIST_MENU, NULL));
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/pidginbuddylistmenu.h Thu Mar 26 22:55:20 2020 -0500
@@ -0,0 +1,46 @@
+/*
+ * 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
+ */
+#ifndef PIDGIN_BUDDY_LIST_MENU_H
+#define PIDGIN_BUDDY_LIST_MENU_H
+
+#include <glib.h>
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define PIDGIN_TYPE_BUDDY_LIST_MENU (pidgin_buddy_list_menu_get_type())
+G_DECLARE_FINAL_TYPE(PidginBuddyListMenu, pidgin_buddy_list_menu, PIDGIN,
+ BUDDY_LIST_MENU, GtkMenuBar)
+
+/**
+ * pidgin_buddy_list_menu_new:
+ *
+ * Creates a new #PidginBuddyListMenu instance.
+ *
+ * Returns: (transfer full): The new #PidginBuddyListMenu instance.
+ */
+GtkWidget *pidgin_buddy_list_menu_new(void);
+
+G_END_DECLS
+
+#endif /* PIDGIN_BUDDY_LIST_MENU_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/resources/BuddyList/menu.ui Thu Mar 26 22:55:20 2020 -0500
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.2 -->
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <template class="PidginBuddyListMenu" parent="GtkMenuBar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkMenuItem">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Buddies</property>
+ <property name="use_underline">True</property>
+ <child type="submenu">
+ <object class="GtkMenu">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkMenuItem" id="new_message">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="action_name">blist.new-message</property>
+ <property name="label" translatable="yes">New Instant _Message...</property>
+ <property name="use_underline">True</property>
+ <accelerator key="m" signal="activate" modifiers="GDK_CONTROL_MASK"/>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem">
+ <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>
+ <child>
+ <object class="GtkMenuItem">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Tools</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Help</property>
+ <property name="use_underline">True</property>
+ <child type="submenu">
+ <object class="GtkMenu">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkMenuItem">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="action_name">blist.online-help</property>
+ <property name="label" translatable="yes">Online _Help</property>
+ <property name="use_underline">True</property>
+ <accelerator key="F1" signal="activate"/>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
--- a/pidgin/resources/pidgin.gresource.xml Mon May 04 06:03:00 2020 +0000
+++ b/pidgin/resources/pidgin.gresource.xml Thu Mar 26 22:55:20 2020 -0500
@@ -6,6 +6,7 @@
<file compressed="true">About/about.md</file>
<file compressed="true">About/credits.json</file>
<file compressed="true">Accounts/chooser.ui</file>
+ <file compressed="true">BuddyList/menu.ui</file>
<file compressed="true">Conversations/invite_dialog.ui</file>
<file compressed="true">Debug/debug.ui</file>
<file compressed="true">Debug/plugininfo.ui</file>