Mercurial > pidgin
changeset 32593:bb7d8b9d8846
Use GtkActions instead of GtkWidgets for the shortcuts to items in the menu
on the conversation window for GTK+ 2.6+. I don't think it works properly
for 2.4<x<2.6 though.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Tue, 28 Jul 2009 05:28:46 +0000 |
parents | d446530cb831 |
children | 94217a930ea8 |
files | pidgin/gtkconv.c pidgin/gtkconvwin.h |
diffstat | 2 files changed, 124 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin/gtkconv.c Tue Jul 28 04:30:58 2009 +0000 +++ b/pidgin/gtkconv.c Tue Jul 28 05:28:46 2009 +0000 @@ -2405,8 +2405,13 @@ purple_conversation_close_logs(old_conv); gtkconv->active_conv = conv; +#if GTK_CHECK_VERSION(2,6,0) + purple_conversation_set_logging(conv, + gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(gtkconv->win->menu.logging))); +#else purple_conversation_set_logging(conv, gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtkconv->win->menu.logging))); +#endif entry = GTK_IMHTML(gtkconv->entry); protocol_name = purple_account_get_protocol_name(conv->account); @@ -3416,19 +3421,31 @@ if (!strcmp(method, "none")) { +#if GTK_CHECK_VERSION(2,6,0) + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(win->menu.sounds), + FALSE); + gtk_action_set_sensitive(win->menu.sounds, FALSE); +#else gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds), FALSE); gtk_widget_set_sensitive(win->menu.sounds, FALSE); +#endif } else { PidginConversation *gtkconv = pidgin_conv_window_get_active_gtkconv(win); +#if GTK_CHECK_VERSION(2,6,0) + if (gtkconv != NULL) + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(win->menu.sounds), + gtkconv->make_sound); + gtk_action_set_sensitive(win->menu.sounds, TRUE); +#else if (gtkconv != NULL) gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds), gtkconv->make_sound); gtk_widget_set_sensitive(win->menu.sounds, TRUE); - +#endif } } @@ -3680,96 +3697,96 @@ gtk_ui_manager_get_widget(win->menu.ui, "/Conversation"); win->menu.view_log = - gtk_ui_manager_get_widget(win->menu.ui, + gtk_ui_manager_get_action(win->menu.ui, "/Conversation/ConversationMenu/ViewLog"); #ifdef USE_VV win->audio_call = - gtk_ui_manager_get_widget(win->menu.ui, + gtk_ui_manager_get_action(win->menu.ui, "/Conversation/ConversationMenu/MediaMenu/AudioCall"); win->video_call = - gtk_ui_manager_get_widget(win->menu.ui, + gtk_ui_manager_get_action(win->menu.ui, "/Conversation/ConversationMenu/MediaMenu/VideoCall"); win->audio_video_call = - gtk_ui_manager_get_widget(win->menu.ui, + gtk_ui_manager_get_action(win->menu.ui, "/Conversation/ConversationMenu/MediaMenu/AudioVideoCall"); #endif /* --- */ win->menu.send_file = - gtk_ui_manager_get_widget(win->menu.ui, + gtk_ui_manager_get_action(win->menu.ui, "/Conversation/ConversationMenu/SendFile"); win->menu.add_pounce = - gtk_ui_manager_get_widget(win->menu.ui, + gtk_ui_manager_get_action(win->menu.ui, "/Conversation/ConversationMenu/AddBuddyPounce"); /* --- */ win->menu.get_info = - gtk_ui_manager_get_widget(win->menu.ui, + gtk_ui_manager_get_action(win->menu.ui, "/Conversation/ConversationMenu/GetInfo"); win->menu.invite = - gtk_ui_manager_get_widget(win->menu.ui, + gtk_ui_manager_get_action(win->menu.ui, "/Conversation/ConversationMenu/Invite"); /* --- */ win->menu.alias = - gtk_ui_manager_get_widget(win->menu.ui, + gtk_ui_manager_get_action(win->menu.ui, "/Conversation/ConversationMenu/Alias"); win->menu.block = - gtk_ui_manager_get_widget(win->menu.ui, + gtk_ui_manager_get_action(win->menu.ui, "/Conversation/ConversationMenu/Block"); win->menu.unblock = - gtk_ui_manager_get_widget(win->menu.ui, + gtk_ui_manager_get_action(win->menu.ui, "/Conversation/ConversationMenu/Unblock"); win->menu.add = - gtk_ui_manager_get_widget(win->menu.ui, + gtk_ui_manager_get_action(win->menu.ui, "/Conversation/ConversationMenu/Add"); win->menu.remove = - gtk_ui_manager_get_widget(win->menu.ui, + gtk_ui_manager_get_action(win->menu.ui, "/Conversation/ConversationMenu/Remove"); /* --- */ win->menu.insert_link = - gtk_ui_manager_get_widget(win->menu.ui, + gtk_ui_manager_get_action(win->menu.ui, "/Conversation/ConversationMenu/InsertLink"); win->menu.insert_image = - gtk_ui_manager_get_widget(win->menu.ui, + gtk_ui_manager_get_action(win->menu.ui, "/Conversation/ConversationMenu/InsertImage"); /* --- */ win->menu.logging = - gtk_ui_manager_get_widget(win->menu.ui, + gtk_ui_manager_get_action(win->menu.ui, "/Conversation/OptionsMenu/EnableLogging"); win->menu.sounds = - gtk_ui_manager_get_widget(win->menu.ui, + gtk_ui_manager_get_action(win->menu.ui, "/Conversation/OptionsMenu/EnableSounds"); method = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method"); if (method != NULL && !strcmp(method, "none")) { gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(win->menu.sounds), FALSE); - gtk_widget_set_sensitive(win->menu.sounds, FALSE); + gtk_action_set_sensitive(win->menu.sounds, FALSE); } purple_prefs_connect_callback(win, PIDGIN_PREFS_ROOT "/sound/method", sound_method_pref_changed_cb, win); win->menu.show_formatting_toolbar = - gtk_ui_manager_get_widget(win->menu.ui, + gtk_ui_manager_get_action(win->menu.ui, "/Conversation/OptionsMenu/ShowFormattingToolbars"); win->menu.show_timestamps = - gtk_ui_manager_get_widget(win->menu.ui, + gtk_ui_manager_get_action(win->menu.ui, "/Conversation/OptionsMenu/ShowTimestamps"); win->menu.show_icon = NULL; @@ -4078,7 +4095,8 @@ if (!(b = purple_find_buddy(account, conv->name))) return FALSE; - +#if GTK_CHECK_VERSION(2,4,0) +#else gtk_widget_show(win->menu.send_to); menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(win->menu.send_to)); @@ -4100,6 +4118,7 @@ break; } } +#endif return FALSE; } @@ -6707,6 +6726,16 @@ gtk_imhtml_append_text(GTK_IMHTML(gtkconv->entry), message, 0); } +/* Mask functions with ones from newer GTK+ */ +#if GTK_CHECK_VERSION(2,6,0) +#define gtk_widget_set_sensitive_ gtk_widget_set_sensitive +#define gtk_widget_show_ gtk_widget_show +#define gtk_widget_hide_ gtk_widget_hide +#define gtk_widget_set_sensitive gtk_action_set_sensitive +#define gtk_widget_show(x) gtk_action_set_visible((x), TRUE) +#define gtk_widget_hide(x) gtk_action_set_visible((x), FALSE) +#endif + /* * Makes sure all the menu items and all the buttons are hidden/shown and * sensitive/insensitive. This is called after changing tabs and when an @@ -6941,6 +6970,17 @@ } } +/* Restore the functions */ +#if GTK_CHECK_VERSION(2,6,0) +#undef gtk_widget_set_sensitive +#undef gtk_widget_show +#undef gtk_widget_hide + +#define gtk_widget_set_sensitive gtk_widget_set_sensitive_ +#define gtk_widget_show gtk_widget_show_ +#define gtk_widget_hide gtk_widget_hide_ +#endif + static void pidgin_conv_update_fields(PurpleConversation *conv, PidginConvFields fields) { @@ -7627,9 +7667,15 @@ gtkconv = PIDGIN_CONVERSATION(conv); win = gtkconv->win; +#if GTK_CHECK_VERSION(2,6,0) + gtk_toggle_action_set_active( + GTK_TOGGLE_ACTION(win->menu.show_timestamps), + (gboolean)GPOINTER_TO_INT(value)); +#else gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), (gboolean)GPOINTER_TO_INT(value)); +#endif gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), (gboolean)GPOINTER_TO_INT(value)); @@ -7655,9 +7701,15 @@ gtkconv = PIDGIN_CONVERSATION(conv); win = gtkconv->win; +#if GTK_CHECK_VERSION(2,6,0) + gtk_toggle_action_set_active( + GTK_TOGGLE_ACTION(win->menu.show_formatting_toolbar), + (gboolean)GPOINTER_TO_INT(value)); +#else gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), (gboolean)GPOINTER_TO_INT(value)); +#endif if ((gboolean)GPOINTER_TO_INT(value)) gtk_widget_show(gtkconv->toolbar); @@ -8886,6 +8938,8 @@ /* Right click was pressed. Popup the context menu. */ GtkWidget *menu = gtk_menu_new(), *sub; gboolean populated = populate_menu_with_options(menu, gtkconv, TRUE); +#if GTK_CHECK_VERSION(2,4,0) +#else sub = gtk_menu_item_get_submenu(GTK_MENU_ITEM(gtkconv->win->menu.send_to)); if (sub && GTK_WIDGET_IS_SENSITIVE(gtkconv->win->menu.send_to)) { @@ -8900,7 +8954,7 @@ gtk_widget_destroy(menu); return FALSE; } - +#endif gtk_widget_show_all(menu); gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time); return TRUE; @@ -9410,8 +9464,13 @@ /* Update the menubar */ +#if GTK_CHECK_VERSION(2,6,0) + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(gtkconv->win->menu.logging), + purple_conversation_is_logging(conv)); +#else gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkconv->win->menu.logging), purple_conversation_is_logging(conv)); +#endif generate_send_to_items(win); regenerate_options_items(win); @@ -9420,6 +9479,17 @@ pidgin_conv_switch_active_conversation(conv); sound_method = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method"); +#if GTK_CHECK_VERSION(2,6,0) + if (strcmp(sound_method, "none") != 0) + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(win->menu.sounds), + gtkconv->make_sound); + + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(win->menu.show_formatting_toolbar), + purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar")); + + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(win->menu.show_timestamps), + purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_timestamps")); +#else if (strcmp(sound_method, "none") != 0) gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds), gtkconv->make_sound); @@ -9429,6 +9499,7 @@ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_timestamps")); +#endif /* * We pause icons when they are not visible. If this icon should
--- a/pidgin/gtkconvwin.h Tue Jul 28 04:30:58 2009 +0000 +++ b/pidgin/gtkconvwin.h Tue Jul 28 05:28:46 2009 +0000 @@ -46,8 +46,31 @@ struct { +/* Some necessary functions were only added in 2.6.0 */ GtkWidget *menubar; +#if GTK_CHECK_VERSION(2,6,0) + GtkAction *view_log; + + GtkAction *send_file; + GtkAction *add_pounce; + GtkAction *get_info; + GtkAction *invite; + + GtkAction *alias; + GtkAction *block; + GtkAction *unblock; + GtkAction *add; + GtkAction *remove; + + GtkAction *insert_link; + GtkAction *insert_image; + + GtkAction *logging; + GtkAction *sounds; + GtkAction *show_formatting_toolbar; + GtkAction *show_timestamps; +#else GtkWidget *view_log; GtkWidget *send_file; @@ -68,6 +91,7 @@ GtkWidget *sounds; GtkWidget *show_formatting_toolbar; GtkWidget *show_timestamps; +#endif GtkWidget *show_icon; GtkWidget *send_to; @@ -102,9 +126,15 @@ gint drag_leave_signal; /* Media menu options. */ +#if GTK_CHECK_VERSION(2,4,0) + GtkAction *audio_call; + GtkAction *video_call; + GtkAction *audio_video_call; +#else GtkWidget *audio_call; GtkWidget *video_call; GtkWidget *audio_video_call; +#endif }; /*@}*/