pidgin/pidgin

Simplify our menuitem creation util function

2016-07-01, Jorge VillaseƱor
38eebb7c9019
Simplify our menuitem creation util function

This is a preparation to migrate to the new icon naming
specification as well as migrate to newer gtk functions.

Nowhere in the code it is used the accel_key functionallity on
pidgin_new_item_stock() which is not even implemented. So now
they are removed.

Details:
* Remove one function with duplicated functionallity and only
used once. Replaced by the generic option.
* Migrate the deprecated way to create a menuitem to the new
option provided by gtk.
* Remove dead code.
--- a/ChangeLog.API Fri Jun 17 18:11:18 2016 -0500
+++ b/ChangeLog.API Fri Jul 01 00:19:12 2016 -0700
@@ -569,6 +569,8 @@
* FULL_CIRCLE_DEGREES renamed to PIDGIN_FULL_CIRCLE_DEGREES
* NUM_NICK_SEED_COLORS renamed to PIDGIN_NUM_NICK_SEED_COLORS
* PALETTE_NUM_COLORS renamed to PIDGIN_PALETTE_NUM_COLORS
+ * pidgin_new_item_from_stock renamed to pidgin_new_menu_item and
+ removed the accel related parameters.
* pidgin_setup_screenname_autocomplete now takes a filter function and
its data as final two arguments
* smiley_list renamed to PidginSmileyList
--- a/pidgin/gtkblist.c Fri Jun 17 18:11:18 2016 -0500
+++ b/pidgin/gtkblist.c Fri Jul 01 00:19:12 2016 -0700
@@ -1405,9 +1405,9 @@
account = purple_buddy_get_account(buddy);
permitted = purple_account_privacy_check(account, purple_buddy_get_name(buddy));
- pidgin_new_item_from_stock(menu, permitted ? _("_Block") : _("Un_block"),
- permitted ? PIDGIN_STOCK_TOOLBAR_BLOCK : PIDGIN_STOCK_TOOLBAR_UNBLOCK, G_CALLBACK(toggle_privacy),
- node, 0 ,0, NULL);
+ pidgin_new_menu_item(menu, permitted ? _("_Block") : _("Un_block"),
+ permitted ? PIDGIN_STOCK_TOOLBAR_BLOCK : PIDGIN_STOCK_TOOLBAR_UNBLOCK,
+ G_CALLBACK(toggle_privacy), node);
}
void
@@ -1460,8 +1460,9 @@
continue;
if (group == purple_blist_node_get_parent(node))
continue;
- menuitem = pidgin_new_item_from_stock(submenu, purple_group_get_name((PurpleGroup *)group), NULL,
- G_CALLBACK(gtk_blist_menu_move_to_cb), node, 0, 0, NULL);
+ menuitem = pidgin_new_menu_item(submenu,
+ purple_group_get_name((PurpleGroup *)group), NULL,
+ G_CALLBACK(gtk_blist_menu_move_to_cb), node);
g_object_set_data(G_OBJECT(menuitem), "groupnode", group);
}
gtk_widget_show_all(submenu);
@@ -1492,11 +1493,11 @@
}
if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, SERVER_IFACE, get_info)) {
- pidgin_new_item_from_stock(menu, _("Get _Info"), PIDGIN_STOCK_TOOLBAR_USER_INFO,
- G_CALLBACK(gtk_blist_menu_info_cb), buddy, 0, 0, NULL);
- }
- pidgin_new_item_from_stock(menu, _("I_M"), PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW,
- G_CALLBACK(gtk_blist_menu_im_cb), buddy, 0, 0, NULL);
+ pidgin_new_menu_item(menu, _("Get _Info"), PIDGIN_STOCK_TOOLBAR_USER_INFO,
+ G_CALLBACK(gtk_blist_menu_info_cb), buddy);
+ }
+ pidgin_new_menu_item(menu, _("I_M"), PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW,
+ G_CALLBACK(gtk_blist_menu_im_cb), buddy);
#ifdef USE_VV
if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, MEDIA_IFACE, get_caps)) {
@@ -1504,18 +1505,18 @@
const gchar *who = purple_buddy_get_name(buddy);
PurpleMediaCaps caps = purple_protocol_get_media_caps(account, who);
if (caps & PURPLE_MEDIA_CAPS_AUDIO) {
- pidgin_new_item_from_stock(menu, _("_Audio Call"),
+ pidgin_new_menu_item(menu, _("_Audio Call"),
PIDGIN_STOCK_TOOLBAR_AUDIO_CALL,
- G_CALLBACK(gtk_blist_menu_audio_call_cb), buddy, 0, 0, NULL);
+ G_CALLBACK(gtk_blist_menu_audio_call_cb), buddy);
}
if (caps & PURPLE_MEDIA_CAPS_AUDIO_VIDEO) {
- pidgin_new_item_from_stock(menu, _("Audio/_Video Call"),
+ pidgin_new_menu_item(menu, _("Audio/_Video Call"),
PIDGIN_STOCK_TOOLBAR_VIDEO_CALL,
- G_CALLBACK(gtk_blist_menu_video_call_cb), buddy, 0, 0, NULL);
+ G_CALLBACK(gtk_blist_menu_video_call_cb), buddy);
} else if (caps & PURPLE_MEDIA_CAPS_VIDEO) {
- pidgin_new_item_from_stock(menu, _("_Video Call"),
+ pidgin_new_menu_item(menu, _("_Video Call"),
PIDGIN_STOCK_TOOLBAR_VIDEO_CALL,
- G_CALLBACK(gtk_blist_menu_video_call_cb), buddy, 0, 0, NULL);
+ G_CALLBACK(gtk_blist_menu_video_call_cb), buddy);
}
}
@@ -1526,30 +1527,30 @@
purple_protocol_xfer_iface_can_receive(protocol,
purple_account_get_connection(purple_buddy_get_account(buddy)), purple_buddy_get_name(buddy)))
{
- pidgin_new_item_from_stock(menu, _("_Send File..."),
- PIDGIN_STOCK_TOOLBAR_SEND_FILE,
- G_CALLBACK(gtk_blist_menu_send_file_cb),
- buddy, 0, 0, NULL);
- }
- }
-
- pidgin_new_item_from_stock(menu, _("Add Buddy _Pounce..."), NULL,
- G_CALLBACK(gtk_blist_menu_bp_cb), buddy, 0, 0, NULL);
+ pidgin_new_menu_item(menu, _("_Send File..."),
+ PIDGIN_STOCK_TOOLBAR_SEND_FILE,
+ G_CALLBACK(gtk_blist_menu_send_file_cb),
+ buddy);
+ }
+ }
+
+ pidgin_new_menu_item(menu, _("Add Buddy _Pounce..."), NULL,
+ G_CALLBACK(gtk_blist_menu_bp_cb), buddy);
if (node->parent && node->parent->child->next &&
!sub && !contact_expanded) {
- pidgin_new_item_from_stock(menu, _("View _Log"), NULL,
- G_CALLBACK(gtk_blist_menu_showlog_cb),
- contact, 0, 0, NULL);
+ pidgin_new_menu_item(menu, _("View _Log"), NULL,
+ G_CALLBACK(gtk_blist_menu_showlog_cb), contact);
} else if (!sub) {
- pidgin_new_item_from_stock(menu, _("View _Log"), NULL,
- G_CALLBACK(gtk_blist_menu_showlog_cb), buddy, 0, 0, NULL);
+ pidgin_new_menu_item(menu, _("View _Log"), NULL,
+ G_CALLBACK(gtk_blist_menu_showlog_cb), buddy);
}
if (!purple_blist_node_is_transient(node)) {
gboolean show_offline = purple_blist_node_get_bool(node, "show_offline");
- pidgin_new_item_from_stock(menu, show_offline ? _("Hide When Offline") : _("Show When Offline"),
- NULL, G_CALLBACK(gtk_blist_menu_showoffline_cb), node, 0, 0, NULL);
+ pidgin_new_menu_item(menu,
+ show_offline ? _("Hide When Offline") : _("Show When Offline"),
+ NULL, G_CALLBACK(gtk_blist_menu_showoffline_cb), node);
}
pidgin_append_blist_node_proto_menu(menu, purple_account_get_connection(purple_buddy_get_account(buddy)), node);
@@ -1562,20 +1563,17 @@
!sub && !contact_expanded) {
pidgin_separator(menu);
pidgin_append_blist_node_privacy_menu(menu, node);
- pidgin_new_item_from_stock(menu, _("_Alias..."), PIDGIN_STOCK_ALIAS,
- G_CALLBACK(gtk_blist_menu_alias_cb),
- contact, 0, 0, NULL);
- pidgin_new_item_from_stock(menu, _("_Remove"), GTK_STOCK_REMOVE,
- G_CALLBACK(pidgin_blist_remove_cb),
- contact, 0, 0, NULL);
+ pidgin_new_menu_item(menu, _("_Alias..."), PIDGIN_STOCK_ALIAS,
+ G_CALLBACK(gtk_blist_menu_alias_cb), contact);
+ pidgin_new_menu_item(menu, _("_Remove"), GTK_STOCK_REMOVE,
+ G_CALLBACK(pidgin_blist_remove_cb), contact);
} else if (!sub || contact_expanded) {
pidgin_separator(menu);
pidgin_append_blist_node_privacy_menu(menu, node);
- pidgin_new_item_from_stock(menu, _("_Alias..."), PIDGIN_STOCK_ALIAS,
- G_CALLBACK(gtk_blist_menu_alias_cb), buddy, 0, 0, NULL);
- pidgin_new_item_from_stock(menu, _("_Remove"), GTK_STOCK_REMOVE,
- G_CALLBACK(pidgin_blist_remove_cb), buddy,
- 0, 0, NULL);
+ pidgin_new_menu_item(menu, _("_Alias..."), PIDGIN_STOCK_ALIAS,
+ G_CALLBACK(gtk_blist_menu_alias_cb), buddy);
+ pidgin_new_menu_item(menu, _("_Remove"), GTK_STOCK_REMOVE,
+ G_CALLBACK(pidgin_blist_remove_cb), buddy);
}
}
@@ -1698,13 +1696,11 @@
{
GtkWidget *item;
- pidgin_new_item_from_stock(menu, _("Set Custom Icon"), NULL,
- G_CALLBACK(set_node_custom_icon), node, 0,
- 0, NULL);
-
- item = pidgin_new_item_from_stock(menu, _("Remove Custom Icon"), NULL,
- G_CALLBACK(remove_node_custom_icon), node,
- 0, 0, NULL);
+ pidgin_new_menu_item(menu, _("Set Custom Icon"), NULL,
+ G_CALLBACK(set_node_custom_icon), node);
+
+ item = pidgin_new_menu_item(menu, _("Remove Custom Icon"), NULL,
+ G_CALLBACK(remove_node_custom_icon), node);
if (!purple_buddy_icons_node_has_custom_icon(node))
gtk_widget_set_sensitive(item, FALSE);
}
@@ -1716,20 +1712,21 @@
GtkWidget *item;
menu = gtk_menu_new();
- item = pidgin_new_item_from_stock(menu, _("Add _Buddy..."), GTK_STOCK_ADD,
- G_CALLBACK(pidgin_blist_add_buddy_cb), node, 0, 0, NULL);
+ item = pidgin_new_menu_item(menu, _("Add _Buddy..."), GTK_STOCK_ADD,
+ G_CALLBACK(pidgin_blist_add_buddy_cb), node);
gtk_widget_set_sensitive(item, purple_connections_get_all() != NULL);
- item = pidgin_new_item_from_stock(menu, _("Add C_hat..."), GTK_STOCK_ADD,
- G_CALLBACK(pidgin_blist_add_chat_cb), node, 0, 0, NULL);
+ item = pidgin_new_menu_item(menu, _("Add C_hat..."), GTK_STOCK_ADD,
+ G_CALLBACK(pidgin_blist_add_chat_cb), node);
gtk_widget_set_sensitive(item, pidgin_blist_joinchat_is_showable());
- pidgin_new_item_from_stock(menu, _("_Delete Group"), GTK_STOCK_REMOVE,
- G_CALLBACK(pidgin_blist_remove_cb), node, 0, 0, NULL);
- pidgin_new_item_from_stock(menu, _("_Rename"), NULL,
- G_CALLBACK(gtk_blist_menu_alias_cb), node, 0, 0, NULL);
+ pidgin_new_menu_item(menu, _("_Delete Group"), GTK_STOCK_REMOVE,
+ G_CALLBACK(pidgin_blist_remove_cb), node);
+ pidgin_new_menu_item(menu, _("_Rename"), NULL,
+ G_CALLBACK(gtk_blist_menu_alias_cb), node);
if (!purple_blist_node_is_transient(node)) {
gboolean show_offline = purple_blist_node_get_bool(node, "show_offline");
- pidgin_new_item_from_stock(menu, show_offline ? _("Hide When Offline") : _("Show When Offline"),
- NULL, G_CALLBACK(gtk_blist_menu_showoffline_cb), node, 0, 0, NULL);
+ pidgin_new_menu_item(menu,
+ show_offline ? _("Hide When Offline") : _("Show When Offline"),
+ NULL, G_CALLBACK(gtk_blist_menu_showoffline_cb), node);
}
add_buddy_icon_menu_items(menu, node);
@@ -1749,26 +1746,26 @@
autojoin = purple_blist_node_get_bool(node, "gtk-autojoin");
persistent = purple_blist_node_get_bool(node, "gtk-persistent");
- pidgin_new_item_from_stock(menu, _("_Join"), PIDGIN_STOCK_CHAT,
- G_CALLBACK(gtk_blist_menu_join_cb), node, 0, 0, NULL);
+ pidgin_new_menu_item(menu, _("_Join"), PIDGIN_STOCK_CHAT,
+ G_CALLBACK(gtk_blist_menu_join_cb), node);
pidgin_new_check_item(menu, _("Auto-Join"),
G_CALLBACK(gtk_blist_menu_autojoin_cb), node, autojoin);
pidgin_new_check_item(menu, _("Persistent"),
G_CALLBACK(gtk_blist_menu_persistent_cb), node, persistent);
- pidgin_new_item_from_stock(menu, _("View _Log"), NULL,
- G_CALLBACK(gtk_blist_menu_showlog_cb), node, 0, 0, NULL);
+ pidgin_new_menu_item(menu, _("View _Log"), NULL,
+ G_CALLBACK(gtk_blist_menu_showlog_cb), node);
pidgin_append_blist_node_proto_menu(menu, purple_account_get_connection(purple_chat_get_account(c)), node);
pidgin_append_blist_node_extended_menu(menu, node);
pidgin_separator(menu);
- pidgin_new_item_from_stock(menu, _("_Edit Settings..."), NULL,
- G_CALLBACK(chat_components_edit), node, 0, 0, NULL);
- pidgin_new_item_from_stock(menu, _("_Alias..."), PIDGIN_STOCK_ALIAS,
- G_CALLBACK(gtk_blist_menu_alias_cb), node, 0, 0, NULL);
- pidgin_new_item_from_stock(menu, _("_Remove"), GTK_STOCK_REMOVE,
- G_CALLBACK(pidgin_blist_remove_cb), node, 0, 0, NULL);
+ pidgin_new_menu_item(menu, _("_Edit Settings..."), NULL,
+ G_CALLBACK(chat_components_edit), node);
+ pidgin_new_menu_item(menu, _("_Alias..."), PIDGIN_STOCK_ALIAS,
+ G_CALLBACK(gtk_blist_menu_alias_cb), node);
+ pidgin_new_menu_item(menu, _("_Remove"), GTK_STOCK_REMOVE,
+ G_CALLBACK(pidgin_blist_remove_cb), node);
add_buddy_icon_menu_items(menu, node);
@@ -1782,24 +1779,24 @@
menu = gtk_menu_new();
- pidgin_new_item_from_stock(menu, _("View _Log"), NULL,
+ pidgin_new_menu_item(menu, _("View _Log"), NULL,
G_CALLBACK(gtk_blist_menu_showlog_cb),
- node, 0, 0, NULL);
+ node);
pidgin_separator(menu);
- pidgin_new_item_from_stock(menu, _("_Alias..."), PIDGIN_STOCK_ALIAS,
- G_CALLBACK(gtk_blist_menu_alias_cb), node, 0, 0, NULL);
- pidgin_new_item_from_stock(menu, _("_Remove"), GTK_STOCK_REMOVE,
- G_CALLBACK(pidgin_blist_remove_cb), node, 0, 0, NULL);
+ pidgin_new_menu_item(menu, _("_Alias..."), PIDGIN_STOCK_ALIAS,
+ G_CALLBACK(gtk_blist_menu_alias_cb), node);
+ pidgin_new_menu_item(menu, _("_Remove"), GTK_STOCK_REMOVE,
+ G_CALLBACK(pidgin_blist_remove_cb), node);
add_buddy_icon_menu_items(menu, node);
pidgin_separator(menu);
- pidgin_new_item_from_stock(menu, _("_Collapse"), GTK_STOCK_ZOOM_OUT,
+ pidgin_new_menu_item(menu, _("_Collapse"), GTK_STOCK_ZOOM_OUT,
G_CALLBACK(pidgin_blist_collapse_contact_cb),
- node, 0, 0, NULL);
+ node);
pidgin_append_blist_node_extended_menu(menu, node);
return menu;
@@ -1822,15 +1819,15 @@
add_buddy_icon_menu_items(menu, node);
if(gtknode->contact_expanded) {
- pidgin_new_item_from_stock(menu, _("_Collapse"),
- GTK_STOCK_ZOOM_OUT,
- G_CALLBACK(pidgin_blist_collapse_contact_cb),
- node, 0, 0, NULL);
+ pidgin_new_menu_item(menu, _("_Collapse"),
+ GTK_STOCK_ZOOM_OUT,
+ G_CALLBACK(pidgin_blist_collapse_contact_cb),
+ node);
} else {
- pidgin_new_item_from_stock(menu, _("_Expand"),
- GTK_STOCK_ZOOM_IN,
- G_CALLBACK(pidgin_blist_expand_contact_cb), node,
- 0, 0, NULL);
+ pidgin_new_menu_item(menu, _("_Expand"),
+ GTK_STOCK_ZOOM_IN,
+ G_CALLBACK(pidgin_blist_expand_contact_cb),
+ node);
}
if(node->child->next) {
PurpleBlistNode *bnode;
--- a/pidgin/gtkconv.c Fri Jun 17 18:11:18 2016 -0500
+++ b/pidgin/gtkconv.c Fri Jul 01 00:19:12 2016 -0700
@@ -1659,8 +1659,10 @@
menu = gtk_menu_new();
if (!is_me) {
- button = pidgin_new_item_from_stock(menu, _("IM"), PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW,
- G_CALLBACK(menu_chat_im_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL);
+ button = pidgin_new_menu_item(menu, _("IM"),
+ PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW,
+ G_CALLBACK(menu_chat_im_cb),
+ PIDGIN_CONVERSATION(conv));
if (gc == NULL)
gtk_widget_set_sensitive(button, FALSE);
@@ -1672,9 +1674,9 @@
{
gboolean can_receive_file = TRUE;
- button = pidgin_new_item_from_stock(menu, _("Send File"),
+ button = pidgin_new_menu_item(menu, _("Send File"),
PIDGIN_STOCK_TOOLBAR_SEND_FILE, G_CALLBACK(menu_chat_send_file_cb),
- PIDGIN_CONVERSATION(conv), 0, 0, NULL);
+ PIDGIN_CONVERSATION(conv));
if (gc == NULL || protocol == NULL)
can_receive_file = FALSE;
@@ -1696,11 +1698,13 @@
if (purple_chat_conversation_is_ignored_user(chat, who))
- button = pidgin_new_item_from_stock(menu, _("Un-Ignore"), PIDGIN_STOCK_IGNORE,
- G_CALLBACK(ignore_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL);
+ button = pidgin_new_menu_item(menu, _("Un-Ignore"),
+ PIDGIN_STOCK_IGNORE, G_CALLBACK(ignore_cb),
+ PIDGIN_CONVERSATION(conv));
else
- button = pidgin_new_item_from_stock(menu, _("Ignore"), PIDGIN_STOCK_IGNORE,
- G_CALLBACK(ignore_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL);
+ button = pidgin_new_menu_item(menu, _("Ignore"),
+ PIDGIN_STOCK_IGNORE, G_CALLBACK(ignore_cb),
+ PIDGIN_CONVERSATION(conv));
if (gc == NULL)
gtk_widget_set_sensitive(button, FALSE);
@@ -1709,8 +1713,10 @@
}
if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, SERVER_IFACE, get_info)) {
- button = pidgin_new_item_from_stock(menu, _("Info"), PIDGIN_STOCK_TOOLBAR_USER_INFO,
- G_CALLBACK(menu_chat_info_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL);
+ button = pidgin_new_menu_item(menu, _("Info"),
+ PIDGIN_STOCK_TOOLBAR_USER_INFO,
+ G_CALLBACK(menu_chat_info_cb),
+ PIDGIN_CONVERSATION(conv));
if (gc == NULL)
gtk_widget_set_sensitive(button, FALSE);
@@ -1720,11 +1726,15 @@
if (!is_me && protocol && !(purple_protocol_get_options(protocol) & OPT_PROTO_UNIQUE_CHATNAME)) {
if ((buddy = purple_blist_find_buddy(account, who)) != NULL)
- button = pidgin_new_item_from_stock(menu, _("Remove"), GTK_STOCK_REMOVE,
- G_CALLBACK(menu_chat_add_remove_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL);
+ button = pidgin_new_menu_item(menu, _("Remove"),
+ GTK_STOCK_REMOVE,
+ G_CALLBACK(menu_chat_add_remove_cb),
+ PIDGIN_CONVERSATION(conv));
else
- button = pidgin_new_item_from_stock(menu, _("Add"), GTK_STOCK_ADD,
- G_CALLBACK(menu_chat_add_remove_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL);
+ button = pidgin_new_menu_item(menu, _("Add"),
+ GTK_STOCK_ADD,
+ G_CALLBACK(menu_chat_add_remove_cb),
+ PIDGIN_CONVERSATION(conv));
if (gc == NULL)
gtk_widget_set_sensitive(button, FALSE);
@@ -1732,8 +1742,8 @@
g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free);
}
- button = pidgin_new_item_from_stock(menu, _("Last Said"), GTK_STOCK_INDEX,
- G_CALLBACK(menu_last_said_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL);
+ button = pidgin_new_menu_item(menu, _("Last Said"), GTK_STOCK_INDEX,
+ G_CALLBACK(menu_last_said_cb), PIDGIN_CONVERSATION(conv));
g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free);
if (!get_mark_for_user(PIDGIN_CONVERSATION(conv), who))
gtk_widget_set_sensitive(button, FALSE);
@@ -2969,20 +2979,17 @@
gtkconv->u.im->icon_timer);
}
- pidgin_new_item_from_stock(menu, _("Hide Icon"), NULL, G_CALLBACK(remove_icon),
- gtkconv, 0, 0, NULL);
-
- pidgin_new_item_from_stock(menu, _("Save Icon As..."), GTK_STOCK_SAVE_AS,
- G_CALLBACK(icon_menu_save_cb), gtkconv,
- 0, 0, NULL);
-
- pidgin_new_item_from_stock(menu, _("Set Custom Icon..."), NULL,
- G_CALLBACK(set_custom_icon_cb), gtkconv,
- 0, 0, NULL);
-
- pidgin_new_item_from_stock(menu, _("Change Size"), NULL,
- G_CALLBACK(change_size_cb), gtkconv,
- 0, 0, NULL);
+ pidgin_new_menu_item(menu, _("Hide Icon"), NULL,
+ G_CALLBACK(remove_icon), gtkconv);
+
+ pidgin_new_menu_item(menu, _("Save Icon As..."), GTK_STOCK_SAVE_AS,
+ G_CALLBACK(icon_menu_save_cb), gtkconv);
+
+ pidgin_new_menu_item(menu, _("Set Custom Icon..."), NULL,
+ G_CALLBACK(set_custom_icon_cb), gtkconv);
+
+ pidgin_new_menu_item(menu, _("Change Size"), NULL,
+ G_CALLBACK(change_size_cb), gtkconv);
/* Is there a custom icon for this person? */
conv = gtkconv->active_conv;
@@ -2993,9 +3000,9 @@
PurpleContact *contact = purple_buddy_get_contact(buddy);
if (contact && purple_buddy_icons_node_has_custom_icon((PurpleBlistNode*)contact))
{
- pidgin_new_item_from_stock(menu, _("Remove Custom Icon"), NULL,
- G_CALLBACK(remove_custom_icon_cb), gtkconv,
- 0, 0, NULL);
+ pidgin_new_menu_item(menu, _("Remove Custom Icon"),
+ NULL, G_CALLBACK(remove_custom_icon_cb),
+ gtkconv);
}
}
@@ -4912,9 +4919,8 @@
g_return_if_fail(menu != NULL);
g_return_if_fail(gtkconv != NULL);
- menuitem = pidgin_new_item_from_stock(NULL, _("_Send"), NULL,
- G_CALLBACK(send_cb), gtkconv,
- 0, 0, NULL);
+ menuitem = pidgin_new_menu_item(NULL, _("_Send"), NULL,
+ G_CALLBACK(send_cb), gtkconv);
is_empty = pidgin_webview_is_empty(webview);
if (is_empty)
gtk_widget_set_sensitive(menuitem, FALSE);
--- a/pidgin/gtkdocklet.c Fri Jun 17 18:11:18 2016 -0500
+++ b/pidgin/gtkdocklet.c Fri Jul 01 00:19:12 2016 -0700
@@ -589,8 +589,10 @@
pidgin_separator(submenu);
- pidgin_new_item_from_stock(submenu, _("New..."), NULL, G_CALLBACK(show_custom_status_editor_cb), NULL, 0, 0, NULL);
- pidgin_new_item_from_stock(submenu, _("Saved..."), NULL, G_CALLBACK(pidgin_status_window_show), NULL, 0, 0, NULL);
+ pidgin_new_menu_item(submenu, _("New..."), NULL,
+ G_CALLBACK(show_custom_status_editor_cb), NULL);
+ pidgin_new_menu_item(submenu, _("Saved..."), NULL,
+ G_CALLBACK(pidgin_status_window_show), NULL);
return menuitem;
}
@@ -713,12 +715,15 @@
pidgin_separator(menu);
- menuitem = pidgin_new_item_from_stock(menu, _("New _Message..."), PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW, G_CALLBACK(pidgin_dialogs_im), NULL, 0, 0, NULL);
+ menuitem = pidgin_new_menu_item(menu, _("New _Message..."),
+ PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW,
+ G_CALLBACK(pidgin_dialogs_im), NULL);
if (status == PURPLE_STATUS_OFFLINE)
gtk_widget_set_sensitive(menuitem, FALSE);
- menuitem = pidgin_new_item_from_stock(menu, _("Join Chat..."), PIDGIN_STOCK_CHAT,
- G_CALLBACK(pidgin_blist_joinchat_show), NULL, 0, 0, NULL);
+ menuitem = pidgin_new_menu_item(menu, _("Join Chat..."),
+ PIDGIN_STOCK_CHAT, G_CALLBACK(pidgin_blist_joinchat_show),
+ NULL);
if (status == PURPLE_STATUS_OFFLINE)
gtk_widget_set_sensitive(menuitem, FALSE);
@@ -727,9 +732,14 @@
pidgin_separator(menu);
- pidgin_new_item_from_stock(menu, _("_Accounts"), NULL, G_CALLBACK(pidgin_accounts_window_show), NULL, 0, 0, NULL);
- pidgin_new_item_from_stock(menu, _("Plu_gins"), PIDGIN_STOCK_TOOLBAR_PLUGINS, G_CALLBACK(pidgin_plugin_dialog_show), NULL, 0, 0, NULL);
- pidgin_new_item_from_stock(menu, _("Pr_eferences"), GTK_STOCK_PREFERENCES, G_CALLBACK(pidgin_prefs_show), NULL, 0, 0, NULL);
+ pidgin_new_menu_item(menu, _("_Accounts"), NULL,
+ G_CALLBACK(pidgin_accounts_window_show), NULL);
+ pidgin_new_menu_item(menu, _("Plu_gins"),
+ PIDGIN_STOCK_TOOLBAR_PLUGINS,
+ G_CALLBACK(pidgin_plugin_dialog_show), NULL);
+ pidgin_new_menu_item(menu, _("Pr_eferences"),
+ GTK_STOCK_PREFERENCES,
+ G_CALLBACK(pidgin_prefs_show), NULL);
pidgin_separator(menu);
@@ -745,7 +755,8 @@
/* add plugin actions */
docklet_plugin_actions(menu);
- pidgin_new_item_from_stock(menu, _("_Quit"), GTK_STOCK_QUIT, G_CALLBACK(purple_core_quit), NULL, 0, 0, NULL);
+ pidgin_new_menu_item(menu, _("_Quit"), GTK_STOCK_QUIT,
+ G_CALLBACK(purple_core_quit), NULL);
#ifdef _WIN32
g_signal_connect(menu, "leave-notify-event", G_CALLBACK(docklet_menu_leave_enter), NULL);
--- a/pidgin/gtkroomlist.c Fri Jun 17 18:11:18 2016 -0500
+++ b/pidgin/gtkroomlist.c Fri Jul 01 00:19:12 2016 -0700
@@ -317,10 +317,10 @@
info.room = room;
menu = gtk_menu_new();
- pidgin_new_item_from_stock(menu, _("_Join"), PIDGIN_STOCK_CHAT,
- G_CALLBACK(do_join_cb), &info, 0, 0, NULL);
- pidgin_new_item_from_stock(menu, _("_Add"), GTK_STOCK_ADD,
- G_CALLBACK(do_add_room_cb), &info, 0, 0, NULL);
+ pidgin_new_menu_item(menu, _("_Join"), PIDGIN_STOCK_CHAT,
+ G_CALLBACK(do_join_cb), &info);
+ pidgin_new_menu_item(menu, _("_Add"), GTK_STOCK_ADD,
+ G_CALLBACK(do_add_room_cb), &info);
gtk_widget_show_all(menu);
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, event->time);
--- a/pidgin/gtkstatusbox.c Fri Jun 17 18:11:18 2016 -0500
+++ b/pidgin/gtkstatusbox.c Fri Jul 01 00:19:12 2016 -0700
@@ -310,13 +310,12 @@
box->icon_box_menu = gtk_menu_new();
- pidgin_new_item_from_stock(box->icon_box_menu,
+ pidgin_new_menu_item(box->icon_box_menu,
_("Select Buddy Icon"), GTK_STOCK_ADD,
- G_CALLBACK(choose_buddy_icon_cb), box, 0, 0, NULL);
-
- menu_item = pidgin_new_item_from_stock(box->icon_box_menu, _("Remove"), GTK_STOCK_REMOVE,
- G_CALLBACK(remove_buddy_icon_cb),
- box, 0, 0, NULL);
+ G_CALLBACK(choose_buddy_icon_cb), box);
+
+ menu_item = pidgin_new_menu_item(box->icon_box_menu, _("Remove"), GTK_STOCK_REMOVE,
+ G_CALLBACK(remove_buddy_icon_cb), box);
if (!(path = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/accounts/buddyicon"))
|| !*path)
gtk_widget_set_sensitive(menu_item, FALSE);
--- a/pidgin/gtkutils.c Fri Jun 17 18:11:18 2016 -0500
+++ b/pidgin/gtkutils.c Fri Jul 01 00:19:12 2016 -0700
@@ -398,29 +398,6 @@
return menuitem;
}
-GtkWidget *pidgin_new_item(GtkWidget *menu, const char *str)
-{
- GtkWidget *menuitem;
- GtkWidget *label;
-
- menuitem = gtk_menu_item_new();
- if (menu)
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
- gtk_widget_show(menuitem);
-
- label = gtk_label_new(str);
- gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
- gtk_label_set_pattern(GTK_LABEL(label), "_");
- gtk_container_add(GTK_CONTAINER(menuitem), label);
- gtk_widget_show(label);
-/* FIXME: Go back and fix this
- gtk_widget_add_accelerator(menuitem, "activate", accel, str[0],
- GDK_MOD1_MASK, GTK_ACCEL_LOCKED);
-*/
- pidgin_set_accessible_label(menuitem, GTK_LABEL(label));
- return menuitem;
-}
-
GtkWidget *pidgin_new_check_item(GtkWidget *menu, const char *str,
GCallback cb, gpointer data, gboolean checked)
{
@@ -506,43 +483,33 @@
}
-GtkWidget *pidgin_new_item_from_stock(GtkWidget *menu, const char *str, const char *icon, GCallback cb, gpointer data, guint accel_key, guint accel_mods, char *mod)
+GtkWidget *pidgin_new_menu_item(GtkWidget *menu, const char *mnemonic,
+ const char *icon, GCallback cb, gpointer data)
{
GtkWidget *menuitem;
- /*
- GtkWidget *hbox;
+ GtkWidget *box;
GtkWidget *label;
- */
- GtkWidget *image;
-
- if (icon == NULL)
- menuitem = gtk_menu_item_new_with_mnemonic(str);
- else
- menuitem = gtk_image_menu_item_new_with_mnemonic(str);
-
- if (menu)
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
+
+ box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, PIDGIN_HIG_BOX_SPACE);
+
+ menuitem = gtk_menu_item_new();
if (cb)
g_signal_connect(G_OBJECT(menuitem), "activate", cb, data);
- if (icon != NULL) {
- image = gtk_image_new_from_stock(icon, gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL));
- gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image);
- }
-/* FIXME: this isn't right
- if (mod) {
- label = gtk_label_new(mod);
- gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 2);
- gtk_widget_show(label);
- }
-*/
-/*
- if (accel_key) {
- gtk_widget_add_accelerator(menuitem, "activate", accel, accel_key,
- accel_mods, GTK_ACCEL_LOCKED);
- }
-*/
+ if (icon) {
+ GtkWidget *image;
+ image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_MENU);
+ gtk_container_add(GTK_CONTAINER(box), image);
+ }
+
+ label = gtk_label_new_with_mnemonic(mnemonic);
+ gtk_container_add(GTK_CONTAINER(box), label);
+
+ gtk_container_add(GTK_CONTAINER(menuitem), box);
+
+ if (menu)
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
gtk_widget_show_all(menuitem);
--- a/pidgin/gtkutils.h Fri Jun 17 18:11:18 2016 -0500
+++ b/pidgin/gtkutils.h Fri Jul 01 00:19:12 2016 -0700
@@ -236,17 +236,6 @@
GtkWidget *pidgin_separator(GtkWidget *menu);
/**
- * pidgin_new_item:
- * @menu: The menu to which to append the menu item.
- * @str: The title to use for the newly created menu item.
- *
- * Creates a menu item.
- *
- * Returns: The newly created menu item.
- */
-GtkWidget *pidgin_new_item(GtkWidget *menu, const char *str);
-
-/**
* pidgin_new_check_item:
* @menu: The menu to which to append the check menu item.
* @str: The title to use for the newly created menu item.
@@ -262,9 +251,9 @@
GCallback cb, gpointer data, gboolean checked);
/**
- * pidgin_new_item_from_stock:
+ * pidgin_new_menu_item:
* @menu: The menu to which to append the menu item.
- * @str: The title for the menu item.
+ * @mnemonic: The title for the menu item.
* @icon: An icon to place to the left of the menu item,
* or %NULL for no icon.
* @cb: A function to call when the menu item is activated.
@@ -277,10 +266,8 @@
*
* Returns: The newly created menu item.
*/
-GtkWidget *pidgin_new_item_from_stock(GtkWidget *menu, const char *str,
- const char *icon, GCallback cb,
- gpointer data, guint accel_key,
- guint accel_mods, char *mod);
+GtkWidget *pidgin_new_menu_item(GtkWidget *menu, const char *mnemonic,
+ const char *icon, GCallback cb, gpointer data);
/**
* pidgin_pixbuf_button_from_stock:
--- a/pidgin/gtkwebview.c Fri Jun 17 18:11:18 2016 -0500
+++ b/pidgin/gtkwebview.c Fri Jul 01 00:19:12 2016 -0700
@@ -839,38 +839,37 @@
if (show_clipboard) {
/* Using connect_swapped means we don't need any wrapper functions */
- cut = pidgin_new_item_from_stock(menu, _("Cu_t"), GTK_STOCK_CUT,
- NULL, NULL, 0, 0, NULL);
- g_signal_connect_swapped(G_OBJECT(cut), "activate",
- G_CALLBACK(webkit_web_view_cut_clipboard),
- webview);
-
- copy = pidgin_new_item_from_stock(menu, _("_Copy"), GTK_STOCK_COPY,
- NULL, NULL, 0, 0, NULL);
- g_signal_connect_swapped(G_OBJECT(copy), "activate",
- G_CALLBACK(webkit_web_view_copy_clipboard),
- webview);
-
- paste = pidgin_new_item_from_stock(menu, _("_Paste"), GTK_STOCK_PASTE,
- NULL, NULL, 0, 0, NULL);
- g_signal_connect_swapped(G_OBJECT(paste), "activate",
- G_CALLBACK(webkit_web_view_paste_clipboard),
- webview);
-
- delete = pidgin_new_item_from_stock(menu, _("_Delete"), GTK_STOCK_DELETE,
- NULL, NULL, 0, 0, NULL);
- g_signal_connect_swapped(G_OBJECT(delete), "activate",
- G_CALLBACK(webkit_web_view_delete_selection),
- webview);
+ cut = pidgin_new_menu_item(menu, _("Cu_t"), GTK_STOCK_CUT,
+ NULL, NULL);
+ g_signal_connect_swapped(G_OBJECT(cut), "activate",
+ G_CALLBACK(webkit_web_view_cut_clipboard),
+ webview);
+
+ copy = pidgin_new_menu_item(menu, _("_Copy"), GTK_STOCK_COPY,
+ NULL, NULL);
+ g_signal_connect_swapped(G_OBJECT(copy), "activate",
+ G_CALLBACK(webkit_web_view_copy_clipboard),
+ webview);
+
+ paste = pidgin_new_menu_item(menu, _("_Paste"), GTK_STOCK_PASTE,
+ NULL, NULL);
+ g_signal_connect_swapped(G_OBJECT(paste), "activate",
+ G_CALLBACK(webkit_web_view_paste_clipboard),
+ webview);
+
+ delete = pidgin_new_menu_item(menu, _("_Delete"), GTK_STOCK_DELETE,
+ NULL, NULL);
+ g_signal_connect_swapped(G_OBJECT(delete), "activate",
+ G_CALLBACK(webkit_web_view_delete_selection),
+ webview);
pidgin_separator(menu);
- select = pidgin_new_item_from_stock(menu, _("Select _All"),
- GTK_STOCK_SELECT_ALL,
- NULL, NULL, 0, 0, NULL);
- g_signal_connect_swapped(G_OBJECT(select), "activate",
- G_CALLBACK(webkit_web_view_select_all),
- webview);
+ select = pidgin_new_menu_item(menu, _("Select _All"),
+ GTK_STOCK_SELECT_ALL, NULL, NULL);
+ g_signal_connect_swapped(G_OBJECT(select), "activate",
+ G_CALLBACK(webkit_web_view_select_all),
+ webview);
gtk_widget_set_sensitive(cut,
webkit_web_view_can_cut_clipboard(webview));
@@ -898,8 +897,8 @@
pidgin_separator(menu);
- inspect = pidgin_new_item_from_stock(menu, _("Inspect _Element"),
- PIDGIN_STOCK_DEBUG, NULL, NULL, 0, 0, NULL);
+ inspect = pidgin_new_menu_item(menu, _("Inspect _Element"),
+ PIDGIN_STOCK_DEBUG, NULL, NULL);
g_signal_connect_data(G_OBJECT(inspect), "activate",
G_CALLBACK(webview_inspector_inspect_element),
data, (GClosureNotify)g_free, 0);
--- a/pidgin/plugins/disco/gtkdisco.c Fri Jun 17 18:11:18 2016 -0500
+++ b/pidgin/plugins/disco/gtkdisco.c Fri Jul 01 00:19:12 2016 -0700
@@ -304,12 +304,12 @@
menu = gtk_menu_new();
if (service->flags & XMPP_DISCO_ADD)
- pidgin_new_item_from_stock(menu, _("Add to Buddy List"), GTK_STOCK_ADD,
- G_CALLBACK(add_to_blist_cb), pdl->dialog,
- 0, 0, NULL);
+ pidgin_new_menu_item(menu, _("Add to Buddy List"), GTK_STOCK_ADD,
+ G_CALLBACK(add_to_blist_cb), pdl->dialog);
if (service->flags & XMPP_DISCO_REGISTER) {
- GtkWidget *item = pidgin_new_item(menu, _("Register"));
+ GtkWidget *item = pidgin_new_menu_item(menu, _("Register"),
+ NULL, NULL, NULL);
g_signal_connect(G_OBJECT(item), "activate",
G_CALLBACK(register_button_cb), pdl->dialog);
}