pidgin/pidgin

Parents 5c78f6c9a36b
Children cb9a81e8845a
Finish porting the rest of the toggle actions to the new menubar widget
--- a/pidgin/gtkblist.c Fri Mar 27 07:03:16 2020 -0500
+++ b/pidgin/gtkblist.c Fri Mar 27 19:03:57 2020 -0500
@@ -2009,64 +2009,12 @@
return handled;
}
-static void pidgin_blist_buddy_details_cb(GtkToggleAction *item, gpointer data)
-{
- pidgin_set_cursor(gtkblist->window, GDK_WATCH);
-
- purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/blist/show_buddy_icons",
- gtk_toggle_action_get_active(item));
-
- pidgin_clear_cursor(gtkblist->window);
-}
-
-static void pidgin_blist_show_idle_time_cb(GtkToggleAction *item, gpointer data)
-{
- pidgin_set_cursor(gtkblist->window, GDK_WATCH);
-
- purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/blist/show_idle_time",
- gtk_toggle_action_get_active(item));
-
- pidgin_clear_cursor(gtkblist->window);
-}
-
static void pidgin_blist_show_protocol_icons_cb(GtkToggleAction *item, gpointer data)
{
purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/blist/show_protocol_icons",
gtk_toggle_action_get_active(item));
}
-static void pidgin_blist_show_empty_groups_cb(GtkToggleAction *item, gpointer data)
-{
- pidgin_set_cursor(gtkblist->window, GDK_WATCH);
-
- purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/blist/show_empty_groups",
- gtk_toggle_action_get_active(item));
-
- pidgin_clear_cursor(gtkblist->window);
-}
-
-static void pidgin_blist_edit_mode_cb(GtkToggleAction *checkitem, gpointer data)
-{
- pidgin_set_cursor(gtkblist->window, GDK_WATCH);
-
- purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/blist/show_offline_buddies",
- gtk_toggle_action_get_active(checkitem));
-
- pidgin_clear_cursor(gtkblist->window);
-}
-
-static void
-pidgin_blist_sound_method_pref_cb(const char *name, PurplePrefType type,
- gconstpointer value, gpointer data)
-{
- gboolean sensitive = TRUE;
-
- if(purple_strequal(value, "none"))
- sensitive = FALSE;
-
- gtk_action_set_sensitive(gtk_ui_manager_get_action(gtkblist->ui, "/BList/ToolsMenu/MuteSounds"), sensitive);
-}
-
static void
add_buddies_from_vcard(const char *protocol_id, PurpleGroup *group, GList *list,
const char *alias)
@@ -3584,7 +3532,6 @@
/* Buddies menu */
{ "BuddiesMenu", NULL, N_("_Buddies"), NULL, NULL, NULL },
{ "JoinAChat", PIDGIN_STOCK_CHAT, N_("Join a _Chat..."), "<control>C", NULL, pidgin_blist_joinchat_show },
- { "ShowMenu", NULL, N_("Sh_ow"), NULL, NULL, NULL },
{ "SortMenu", NULL, N_("_Sort Buddies"), NULL, NULL, NULL },
{ "AddBuddy", GTK_STOCK_ADD, N_("_Add Buddy..."), "<control>B", NULL, pidgin_blist_add_buddy_cb },
{ "AddChat", GTK_STOCK_ADD, N_("Add C_hat..."), NULL, NULL, pidgin_blist_add_chat_cb },
@@ -3597,29 +3544,12 @@
{ "SetMood", NULL, N_("Set _Mood"), "<control>D", NULL, set_mood_show },
};
-/* Toggle items */
-static const GtkToggleActionEntry blist_menu_toggle_entries[] = {
- /* Buddies->Show menu */
- { "ShowOffline", NULL, N_("_Offline Buddies"), NULL, NULL, G_CALLBACK(pidgin_blist_edit_mode_cb), FALSE },
- { "ShowEmptyGroups", NULL, N_("_Empty Groups"), NULL, NULL, G_CALLBACK(pidgin_blist_show_empty_groups_cb), FALSE },
- { "ShowBuddyDetails", NULL, N_("Buddy _Details"), NULL, NULL, G_CALLBACK(pidgin_blist_buddy_details_cb), FALSE },
- { "ShowIdleTimes", NULL, N_("Idle _Times"), NULL, NULL, G_CALLBACK(pidgin_blist_show_idle_time_cb), FALSE },
- { "ShowProtocolIcons", NULL, N_("_Protocol Icons"), NULL, NULL, G_CALLBACK(pidgin_blist_show_protocol_icons_cb), FALSE },
-};
-
static const char *blist_menu =
"<ui>"
"<menubar name='BList'>"
"<menu action='BuddiesMenu'>"
"<menuitem action='JoinAChat'/>"
"<separator/>"
- "<menu action='ShowMenu'>"
- "<menuitem action='ShowOffline'/>"
- "<menuitem action='ShowEmptyGroups'/>"
- "<menuitem action='ShowBuddyDetails'/>"
- "<menuitem action='ShowIdleTimes'/>"
- "<menuitem action='ShowProtocolIcons'/>"
- "</menu>"
"<menu action='SortMenu'/>"
"<separator/>"
"<menuitem action='AddBuddy'/>"
@@ -5675,10 +5605,6 @@
blist_menu_entries,
G_N_ELEMENTS(blist_menu_entries),
GTK_WINDOW(gtkblist->window));
- gtk_action_group_add_toggle_actions(action_group,
- blist_menu_toggle_entries,
- G_N_ELEMENTS(blist_menu_toggle_entries),
- GTK_WINDOW(gtkblist->window));
gtkblist->ui = gtk_ui_manager_new();
gtk_ui_manager_insert_action_group(gtkblist->ui, action_group, 0);
@@ -5876,27 +5802,6 @@
gtk_widget_set_name(gtkblist->statusbox, "pidgin_blist_statusbox");
gtk_widget_show(gtkblist->statusbox);
- /* set the Show Offline Buddies option. must be done
- * after the treeview or faceprint gets mad. -Robot101
- */
- gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(gtk_ui_manager_get_action(gtkblist->ui, "/BList/BuddiesMenu/ShowMenu/ShowOffline")),
- purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_offline_buddies"));
-
- gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(gtk_ui_manager_get_action(gtkblist->ui, "/BList/BuddiesMenu/ShowMenu/ShowEmptyGroups")),
- purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_empty_groups"));
-
- gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(gtk_ui_manager_get_action(gtkblist->ui, "/BList/BuddiesMenu/ShowMenu/ShowBuddyDetails")),
- purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_buddy_icons"));
-
- gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(gtk_ui_manager_get_action(gtkblist->ui, "/BList/BuddiesMenu/ShowMenu/ShowIdleTimes")),
- purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_idle_time"));
-
- gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(gtk_ui_manager_get_action(gtkblist->ui, "/BList/BuddiesMenu/ShowMenu/ShowProtocolIcons")),
- purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_protocol_icons"));
-
- if(purple_strequal(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method"), "none"))
- gtk_action_set_sensitive(gtk_ui_manager_get_action(gtkblist->ui, "/BList/ToolsMenu/MuteSounds"), FALSE);
-
/* Update some dynamic things */
update_menu_bar(gtkblist);
pidgin_blist_update_plugin_actions();
@@ -5930,10 +5835,6 @@
purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/blist/sort_type",
_prefs_change_sort_method, NULL);
- /* menus */
- purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/sound/method",
- pidgin_blist_sound_method_pref_cb, NULL);
-
/* Setup some purple signal handlers. */
handle = purple_accounts_get_handle();
--- a/pidgin/pidginactiongroup.c Fri Mar 27 07:03:16 2020 -0500
+++ b/pidgin/pidginactiongroup.c Fri Mar 27 19:03:57 2020 -0500
@@ -101,7 +101,8 @@
value = purple_prefs_get_bool(pref_name);
/* change the state of the action to match the preference value. */
- g_action_change_state(action, g_variant_new_boolean(value));
+ g_simple_action_set_state(G_SIMPLE_ACTION(action),
+ g_variant_new_boolean(value));
/* finally add a preference callback to update the state based on the
* preference.
@@ -124,6 +125,71 @@
(gboolean)GPOINTER_TO_INT(value));
}
+static void
+pidgin_action_group_show_buddy_icons_callback(const gchar *name,
+ PurplePrefType type,
+ gconstpointer value,
+ gpointer data)
+{
+ PidginActionGroup *group = PIDGIN_ACTION_GROUP(data);
+
+ pidgin_action_group_bool_pref_handler(group,
+ PIDGIN_ACTION_SHOW_BUDDY_ICONS,
+ (gboolean)GPOINTER_TO_INT(value));
+}
+
+static void
+pidgin_action_group_show_empty_groups_callback(const gchar *name,
+ PurplePrefType type,
+ gconstpointer value,
+ gpointer data)
+{
+ PidginActionGroup *group = PIDGIN_ACTION_GROUP(data);
+
+ pidgin_action_group_bool_pref_handler(group,
+ PIDGIN_ACTION_SHOW_EMPTY_GROUPS,
+ (gboolean)GPOINTER_TO_INT(value));
+}
+
+static void
+pidgin_action_group_show_idle_times_callback(const gchar *name,
+ PurplePrefType type,
+ gconstpointer value,
+ gpointer data)
+{
+ PidginActionGroup *group = PIDGIN_ACTION_GROUP(data);
+
+ pidgin_action_group_bool_pref_handler(group,
+ PIDGIN_ACTION_SHOW_IDLE_TIMES,
+ (gboolean)GPOINTER_TO_INT(value));
+}
+
+static void
+pidgin_action_group_show_offline_buddies_callback(const gchar *name,
+ PurplePrefType type,
+ gconstpointer value,
+ gpointer data)
+{
+ PidginActionGroup *group = PIDGIN_ACTION_GROUP(data);
+
+ pidgin_action_group_bool_pref_handler(group,
+ PIDGIN_ACTION_SHOW_OFFLINE_BUDDIES,
+ (gboolean)GPOINTER_TO_INT(value));
+}
+
+static void
+pidgin_action_group_show_protocol_icons_callback(const gchar *name,
+ PurplePrefType type,
+ gconstpointer value,
+ gpointer data)
+{
+ PidginActionGroup *group = PIDGIN_ACTION_GROUP(data);
+
+ pidgin_action_group_bool_pref_handler(group,
+ PIDGIN_ACTION_SHOW_PROTOCOL_ICONS,
+ (gboolean)GPOINTER_TO_INT(value));
+}
+
/******************************************************************************
* Action Callbacks
*****************************************************************************/
@@ -256,6 +322,49 @@
}
static void
+pidgin_action_group_show_buddy_icons(GSimpleAction *action, GVariant *value,
+ gpointer data)
+{
+ purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/blist/show_buddy_icons",
+ g_variant_get_boolean(value));
+}
+
+static void
+pidgin_action_group_show_empty_groups(GSimpleAction *action, GVariant *value,
+ gpointer data)
+{
+ purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/blist/show_empty_groups",
+ g_variant_get_boolean(value));
+}
+
+static void
+pidgin_action_group_show_idle_times(GSimpleAction *action,
+ GVariant *value,
+ gpointer data)
+{
+ purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/blist/show_idle_time",
+ g_variant_get_boolean(value));
+}
+
+static void
+pidgin_action_group_show_offline_buddies(GSimpleAction *action,
+ GVariant *value,
+ gpointer data)
+{
+ purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/blist/show_offline_buddies",
+ g_variant_get_boolean(value));
+}
+
+static void
+pidgin_action_group_show_protocol_icons(GSimpleAction *action,
+ GVariant *value,
+ gpointer data)
+{
+ purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/blist/show_protocol_icons",
+ g_variant_get_boolean(value));
+}
+
+static void
pidgin_action_group_system_log(GSimpleAction *simple, GVariant *parameter,
gpointer data)
{
@@ -328,6 +437,26 @@
.name = PIDGIN_ACTION_ROOM_LIST,
.activate = pidgin_action_group_room_list,
}, {
+ .name = PIDGIN_ACTION_SHOW_BUDDY_ICONS,
+ .state = "false",
+ .change_state = pidgin_action_group_show_buddy_icons,
+ }, {
+ .name = PIDGIN_ACTION_SHOW_EMPTY_GROUPS,
+ .state = "false",
+ .change_state = pidgin_action_group_show_empty_groups,
+ }, {
+ .name = PIDGIN_ACTION_SHOW_IDLE_TIMES,
+ .state = "false",
+ .change_state = pidgin_action_group_show_idle_times,
+ }, {
+ .name = PIDGIN_ACTION_SHOW_OFFLINE_BUDDIES,
+ .state = "false",
+ .change_state = pidgin_action_group_show_offline_buddies,
+ }, {
+ .name = PIDGIN_ACTION_SHOW_PROTOCOL_ICONS,
+ .state = "false",
+ .change_state = pidgin_action_group_show_protocol_icons,
+ }, {
.name = PIDGIN_ACTION_SYSTEM_LOG,
.activate = pidgin_action_group_system_log,
}, {
@@ -345,6 +474,21 @@
pidgin_action_group_setup_bool(group, PIDGIN_ACTION_MUTE_SOUNDS,
PIDGIN_PREFS_ROOT "/sound/mute",
pidgin_action_group_mute_sounds_callback);
+ pidgin_action_group_setup_bool(group, PIDGIN_ACTION_SHOW_BUDDY_ICONS,
+ PIDGIN_PREFS_ROOT "/blist/show_buddy_icons",
+ pidgin_action_group_show_buddy_icons_callback);
+ pidgin_action_group_setup_bool(group, PIDGIN_ACTION_SHOW_EMPTY_GROUPS,
+ PIDGIN_PREFS_ROOT "/blist/show_empty_groups",
+ pidgin_action_group_show_empty_groups_callback);
+ pidgin_action_group_setup_bool(group, PIDGIN_ACTION_SHOW_IDLE_TIMES,
+ PIDGIN_PREFS_ROOT "/blist/show_idle_time",
+ pidgin_action_group_show_idle_times_callback);
+ pidgin_action_group_setup_bool(group, PIDGIN_ACTION_SHOW_OFFLINE_BUDDIES,
+ PIDGIN_PREFS_ROOT "/blist/show_offline_buddies",
+ pidgin_action_group_show_offline_buddies_callback);
+ pidgin_action_group_setup_bool(group, PIDGIN_ACTION_SHOW_PROTOCOL_ICONS,
+ PIDGIN_PREFS_ROOT "/blist/show_protocol_icons",
+ pidgin_action_group_show_protocol_icons_callback);
};
static void
--- a/pidgin/pidginactiongroup.h Fri Mar 27 07:03:16 2020 -0500
+++ b/pidgin/pidginactiongroup.h Fri Mar 27 19:03:57 2020 -0500
@@ -144,6 +144,41 @@
#define PIDGIN_ACTION_ROOM_LIST ("room-list")
/**
+ * PIDGIN_ACTION_SHOW_BUDDY_ICONS:
+ *
+ * A constant that represents the show-buddy-icons action.
+ */
+#define PIDGIN_ACTION_SHOW_BUDDY_ICONS ("show-buddy-icons")
+
+/**
+ * PIDGIN_ACTION_SHOW_EMPTY_GROUPS:
+ *
+ * A constant that represents the show-empty-groups action.
+ */
+#define PIDGIN_ACTION_SHOW_EMPTY_GROUPS ("show-empty-groups")
+
+/**
+ * PIDGIN_ACTION_SHOW_IDLE_TIMES:
+ *
+ * A constant that represents the show-idle-times action.
+ */
+#define PIDGIN_ACTION_SHOW_IDLE_TIMES ("show-idle-times")
+
+/**
+ * PIDGIN_ACTION_SHOW_OFFLINE_BUDDIES:
+ *
+ * A constant that represents the show-offline-buddies action.
+ */
+#define PIDGIN_ACTION_SHOW_OFFLINE_BUDDIES ("show-offline-buddies")
+
+/**
+ * PIDGIN_ACTION_SHOW_PROTOCOL_ICONS:
+ *
+ * A constant that represents the show-protocol-icons action.
+ */
+#define PIDGIN_ACTION_SHOW_PROTOCOL_ICONS ("show-protocol-icons")
+
+/**
* PIDGIN_ACTION_SYSTEM_LOG:
*
* A constant that represents the system-log action.
--- a/pidgin/resources/BuddyList/menu.ui Fri Mar 27 07:03:16 2020 -0500
+++ b/pidgin/resources/BuddyList/menu.ui Fri Mar 27 19:03:57 2020 -0500
@@ -90,11 +90,11 @@
</object>
</child>
<child>
- <object class="GtkCheckMenuItem" id="show_buddy_details">
+ <object class="GtkCheckMenuItem" id="show_buddy_icons">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="action_name">blist.show-buddy-details</property>
- <property name="label" translatable="yes">Buddy _Details</property>
+ <property name="action_name">blist.show-buddy-icons</property>
+ <property name="label" translatable="yes">Buddy _Icons</property>
<property name="use_underline">True</property>
</object>
</child>