Mercurial > pidgin
changeset 29244:22b8a92fb5ee
Adds attention UI to Pidgin (can send attentions using a menu item)
API to "fire" an attention on a conversation, triggering signals.
Currently gtksound is set up to use the alert sound for received and sent
attentions.
Refs #2788
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Mon, 20 Oct 2008 18:44:06 +0000 |
parents | c1e58cfd1107 |
children | 249fee48c3ed |
files | libpurple/conversation.c libpurple/conversation.h libpurple/protocols/jabber/message.c libpurple/protocols/msn/msn.c libpurple/protocols/msn/switchboard.c libpurple/protocols/yahoo/yahoo.c libpurple/sound.h pidgin/gtkconv.c pidgin/gtkconvwin.h pidgin/gtkimhtmltoolbar.c pidgin/gtkimhtmltoolbar.h pidgin/gtksound.c pidgin/pidginstock.c pidgin/pidginstock.h pidgin/pixmaps/Makefile.am |
diffstat | 15 files changed, 144 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/conversation.c Thu Oct 16 22:20:52 2008 +0000 +++ b/libpurple/conversation.c Mon Oct 20 18:44:06 2008 +0000 @@ -960,6 +960,16 @@ g_free(displayed); } +void +purple_conversation_attention(PurpleConversation *conv, const char *who, + guint type, PurpleMessageFlags flags, time_t mtime) +{ + PurpleAccount *account = purple_conversation_get_account(conv); + purple_signal_emit(purple_conversations_get_handle(), + flags == PURPLE_MESSAGE_SEND ? "sent-attention" : "got-attention", + account, who, conv, type); +} + gboolean purple_conversation_has_focus(PurpleConversation *conv) { @@ -2180,7 +2190,27 @@ purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONVERSATION), purple_value_new(PURPLE_TYPE_UINT)); - + + purple_signal_register(handle, "sent-attention", + purple_marshal_VOID__POINTER_POINTER_POINTER_UINT, + NULL, 4, + purple_value_new(PURPLE_TYPE_SUBTYPE, + PURPLE_SUBTYPE_ACCOUNT), + purple_value_new(PURPLE_TYPE_STRING), + purple_value_new(PURPLE_TYPE_SUBTYPE, + PURPLE_SUBTYPE_CONVERSATION), + purple_value_new(PURPLE_TYPE_UINT)); + + purple_signal_register(handle, "got-attention", + purple_marshal_VOID__POINTER_POINTER_POINTER_UINT, + NULL, 4, + purple_value_new(PURPLE_TYPE_SUBTYPE, + PURPLE_SUBTYPE_ACCOUNT), + purple_value_new(PURPLE_TYPE_STRING), + purple_value_new(PURPLE_TYPE_SUBTYPE, + PURPLE_SUBTYPE_CONVERSATION), + purple_value_new(PURPLE_TYPE_UINT)); + purple_signal_register(handle, "sending-im-msg", purple_marshal_VOID__POINTER_POINTER_POINTER, NULL, 3,
--- a/libpurple/conversation.h Thu Oct 16 22:20:52 2008 +0000 +++ b/libpurple/conversation.h Mon Oct 20 18:44:06 2008 +0000 @@ -645,7 +645,21 @@ const char *message, PurpleMessageFlags flags, time_t mtime); - +/** + * Sends an attention to a conversation window. + * + * This is to be called by prpls to tell UIs to set off the action for + * an attention message + * + * @param conv The conversation + * @param who The user who sent the attention + * @param type The attention type (will be 0 for protocols that only have 1 type) + * @param flags The message flags (send, receive) + * @param mtime The time the attentsion was sent + */ +void purple_conversation_attention(PurpleConversation *conv, const char *who, + guint attention_type, PurpleMessageFlags flags, time_t mtime); + /** Set the features as supported for the given conversation. @param conv The conversation
--- a/libpurple/protocols/jabber/message.c Thu Oct 16 22:20:52 2008 +0000 +++ b/libpurple/protocols/jabber/message.c Mon Oct 20 18:44:06 2008 +0000 @@ -312,6 +312,7 @@ str = g_strdup_printf(_("%s has buzzed you!"), username); purple_conversation_write(c, NULL, str, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NOTIFY, time(NULL)); + purple_conversation_attention(c, username, 0, PURPLE_MESSAGE_RECV, time(NULL)); g_free(username); g_free(str); }
--- a/libpurple/protocols/msn/msn.c Thu Oct 16 22:20:52 2008 +0000 +++ b/libpurple/protocols/msn/msn.c Mon Oct 20 18:44:06 2008 +0000 @@ -165,7 +165,9 @@ username = purple_conversation_get_name(conv); purple_prpl_send_attention(gc, username, MSN_NUDGE); - + purple_conversation_attention(conv, username, 0, PURPLE_MESSAGE_SEND, + time(NULL)); + return PURPLE_CMD_RET_OK; }
--- a/libpurple/protocols/msn/switchboard.c Thu Oct 16 22:20:52 2008 +0000 +++ b/libpurple/protocols/msn/switchboard.c Mon Oct 20 18:44:06 2008 +0000 @@ -1031,6 +1031,9 @@ else purple_prpl_got_attention(account->gc, user, MSN_NUDGE); + + purple_conversation_attention(swboard->conv, user, 0, + PURPLE_MESSAGE_RECV, time(NULL)); } else if (!strcmp(id, "2")) { /* Wink */
--- a/libpurple/protocols/yahoo/yahoo.c Thu Oct 16 22:20:52 2008 +0000 +++ b/libpurple/protocols/yahoo/yahoo.c Mon Oct 20 18:44:06 2008 +0000 @@ -878,6 +878,8 @@ username = g_markup_escape_text(im->from, -1); purple_prpl_got_attention(gc, username, YAHOO_BUZZ); + purple_conversation_attention(c, username, 0, PURPLE_MESSAGE_RECV, + time(NULL)); g_free(username); g_free(m); g_free(im); @@ -4117,6 +4119,7 @@ return PURPLE_CMD_RET_FAILED; purple_prpl_send_attention(account->gc, c->name, YAHOO_BUZZ); + purple_conversation_attention(c, c->name, 0, PURPLE_MESSAGE_SEND, time(NULL)); return PURPLE_CMD_RET_OK; }
--- a/libpurple/sound.h Thu Oct 16 22:20:52 2008 +0000 +++ b/libpurple/sound.h Mon Oct 20 18:44:06 2008 +0000 @@ -51,6 +51,8 @@ PURPLE_SOUND_CHAT_SAY, /**< Someone else says somthing in a chat. */ PURPLE_SOUND_POUNCE_DEFAULT, /**< Default sound for a buddy pounce. */ PURPLE_SOUND_CHAT_NICK, /**< Someone says your name in a chat. */ + PURPLE_SOUND_SEND_ATTENTION, /**< Send an attention */ + PURPLE_SOUND_GOT_ATTENTION, /**< Got an attention */ PURPLE_NUM_SOUNDS /**< Total number of sounds. */ } PurpleSoundEventID;
--- a/pidgin/gtkconv.c Thu Oct 16 22:20:52 2008 +0000 +++ b/pidgin/gtkconv.c Mon Oct 20 18:44:06 2008 +0000 @@ -1207,6 +1207,20 @@ } static void +menu_get_attention_cb(gpointer data, guint action, GtkWidget *widget) +{ + PidginWindow *win = data; + PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win); + + if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { + purple_prpl_send_attention(purple_conversation_get_gc(conv), + purple_conversation_get_name(conv), 0); + purple_conversation_attention(conv, purple_conversation_get_name(conv), + 0, PURPLE_MESSAGE_SEND, time(NULL)); + } +} + +static void menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget) { PidginWindow *win = data; @@ -3074,6 +3088,7 @@ { "/Conversation/sep1", NULL, NULL, 0, "<Separator>", NULL }, { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", PIDGIN_STOCK_TOOLBAR_SEND_FILE }, + { N_("/Conversation/Get _Attention"), NULL, menu_get_attention_cb, 0, "<StockItem>", PIDGIN_STOCK_TOOLBAR_SEND_ATTENTION }, { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, 0, "<Item>", NULL }, { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, @@ -3389,6 +3404,9 @@ gtk_item_factory_get_widget(win->menu.item_factory, N_("/Conversation/Send File...")); + win->menu.get_attention = + gtk_item_factory_get_widget(win->menu.item_factory, + N_("/Conversation/Get Attention...")); win->menu.add_pounce = gtk_item_factory_get_widget(win->menu.item_factory, N_("/Conversation/Add Buddy Pounce...")); @@ -6258,6 +6276,7 @@ /* Deal with menu items */ gtk_widget_show(win->menu.view_log); gtk_widget_show(win->menu.send_file); + gtk_widget_show(win->menu.get_attention); gtk_widget_show(win->menu.add_pounce); gtk_widget_show(win->menu.get_info); gtk_widget_hide(win->menu.invite); @@ -6286,6 +6305,7 @@ /* Deal with menu items */ gtk_widget_show(win->menu.view_log); gtk_widget_hide(win->menu.send_file); + gtk_widget_hide(win->menu.get_attention); gtk_widget_hide(win->menu.add_pounce); gtk_widget_hide(win->menu.get_info); gtk_widget_show(win->menu.invite); @@ -6363,6 +6383,7 @@ gtk_widget_set_sensitive(win->menu.send_file, (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, purple_conversation_get_name(conv))))); + gtk_widget_set_sensitive(win->menu.get_attention, (prpl_info->send_attention != NULL)); gtk_widget_set_sensitive(win->menu.alias, (account != NULL) && (purple_find_buddy(account, purple_conversation_get_name(conv)) != NULL)); @@ -6383,6 +6404,7 @@ /* Then deal with menu items */ gtk_widget_set_sensitive(win->menu.view_log, TRUE); gtk_widget_set_sensitive(win->menu.send_file, FALSE); + gtk_widget_set_sensitive(win->menu.get_attention, FALSE); gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); gtk_widget_set_sensitive(win->menu.get_info, FALSE); gtk_widget_set_sensitive(win->menu.invite, FALSE); @@ -6687,6 +6709,7 @@ } } + static PurpleConversationUiOps conversation_ui_ops = { pidgin_conv_new,
--- a/pidgin/gtkconvwin.h Thu Oct 16 22:20:52 2008 +0000 +++ b/pidgin/gtkconvwin.h Mon Oct 20 18:44:06 2008 +0000 @@ -51,6 +51,7 @@ GtkWidget *view_log; GtkWidget *send_file; + GtkWidget *get_attention; GtkWidget *add_pounce; GtkWidget *get_info; GtkWidget *invite;
--- a/pidgin/gtkimhtmltoolbar.c Thu Oct 16 22:20:52 2008 +0000 +++ b/pidgin/gtkimhtmltoolbar.c Mon Oct 20 18:44:06 2008 +0000 @@ -913,6 +913,11 @@ gtk_widget_grab_focus(toolbar->imhtml); } +static void send_attention_cb(GtkWidget *attention, GtkIMHtmlToolbar *toolbar) +{ + GtkWidget *parent = gtk_widget_get_parent_window(toolbar); +} + static void update_buttons_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, GtkIMHtmlToolbar *toolbar) { gtk_widget_set_sensitive(GTK_WIDGET(toolbar->bold), buttons & GTK_IMHTML_BOLD); @@ -1232,6 +1237,8 @@ {PIDGIN_STOCK_TOOLBAR_INSERT_LINK, insert_link_cb, &toolbar->link, _("Insert Link")}, {PIDGIN_STOCK_TOOLBAR_INSERT_IMAGE, insert_image_cb, &toolbar->image, _("Insert IM Image")}, {PIDGIN_STOCK_TOOLBAR_SMILEY, insert_smiley_cb, &toolbar->smiley, _("Insert Smiley")}, + {PIDGIN_STOCK_TOOLBAR_SEND_ATTENTION, send_attention_cb, &toolbar->attention, + _("Send Attention")}, {NULL, NULL, NULL, NULL} }; int iter; @@ -1297,6 +1304,7 @@ GtkWidget *insert_button; GtkWidget *font_button; GtkWidget *smiley_button; + GtkWidget *attention_button; GtkWidget *font_menu; GtkWidget *insert_menu; GtkWidget *menuitem; @@ -1438,6 +1446,26 @@ g_signal_connect_swapped(G_OBJECT(smiley_button), "clicked", G_CALLBACK(gtk_button_clicked), toolbar->smiley); gtk_widget_show_all(smiley_button); + /* Sep */ + sep = gtk_vseparator_new(); + gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 0); + gtk_widget_show_all(sep); + + /* Attention */ + attention_button = gtk_button_new(); + gtk_button_set_relief(GTK_BUTTON(attention_button), GTK_RELIEF_NONE); + bbox = gtk_hbox_new(FALSE, 3); + gtk_container_add(GTK_CONTAINER(attention_button), bbox); + image = gtk_image_new_from_stock(PIDGIN_STOCK_TOOLBAR_SEND_ATTENTION, + gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL)); + gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0); + label = gtk_label_new_with_mnemonic(_("_Attention!")); + gtk_box_pack_start(GTK_BOX(bbox), label, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(box), attention_button, FALSE, FALSE, 0); + g_signal_connect_swapped(G_OBJECT(attention_button), "clicked", + G_CALLBACK(gtk_button_clicked), toolbar->attention); + gtk_widget_show_all(attention_button); + gtk_box_pack_start(GTK_BOX(hbox), box, FALSE, FALSE, 0); g_object_set_data(G_OBJECT(hbox), "lean-view", box); gtk_widget_show(box);
--- a/pidgin/gtkimhtmltoolbar.h Thu Oct 16 22:20:52 2008 +0000 +++ b/pidgin/gtkimhtmltoolbar.h Mon Oct 20 18:44:06 2008 +0000 @@ -65,7 +65,8 @@ GtkWidget *image; GtkWidget *link; GtkWidget *smiley; - + GtkWidget *attention; + GtkWidget *font_dialog; GtkWidget *fgcolor_dialog; GtkWidget *bgcolor_dialog;
--- a/pidgin/gtksound.c Thu Oct 16 22:20:52 2008 +0000 +++ b/pidgin/gtksound.c Mon Oct 20 18:44:06 2008 +0000 @@ -70,7 +70,9 @@ {N_("Others talk in chat"), "chat_msg_recv", "receive.wav"}, /* this isn't a terminator, it's the buddy pounce default sound event ;-) */ {NULL, "pounce_default", "alert.wav"}, - {N_("Someone says your username in chat"), "nick_said", "alert.wav"} + {N_("Someone says your username in chat"), "nick_said", "alert.wav"}, + {N_("Attention received"), "got_attention", "alert.wav"}, + {N_("Attention sent"), "sent_attention", "alert.wav"} }; static gboolean @@ -215,6 +217,20 @@ play_conv_event(conv, event); } +static void +sent_attention_cb(PurpleAccount *account, const char *who, + PurpleConversation *conv, guint type, PurpleSoundEventID event) +{ + play_conv_event(conv, event); +} + +static void +got_attention_cb(PurpleAccount *account, const char *who, + PurpleConversation *conv, guint type, PurpleSoundEventID event) +{ + play_conv_event(conv, event); +} + /* * We mute sounds for the 10 seconds after you log in so that * you don't get flooded with sounds when the blist shows all @@ -294,6 +310,10 @@ purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/nick_said", ""); purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/pounce_default", TRUE); purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/pounce_default", ""); + purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/sent_attention", TRUE); + purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/sent_attention", ""); + purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/got_attention", TRUE); + purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/got_attention", ""); purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/conv_focus", TRUE); purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/mute", FALSE); purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/command", ""); @@ -340,6 +360,12 @@ purple_signal_connect(conv_handle, "received-chat-msg", gtk_sound_handle, PURPLE_CALLBACK(chat_msg_received_cb), GINT_TO_POINTER(PURPLE_SOUND_CHAT_SAY)); + purple_signal_connect(conv_handle, "sent-attention", gtk_sound_handle, + PURPLE_CALLBACK(sent_attention_cb), + GINT_TO_POINTER(PURPLE_SOUND_SEND_ATTENTION)); + purple_signal_connect(conv_handle, "got-attention", gtk_sound_handle, + PURPLE_CALLBACK(got_attention_cb), + GINT_TO_POINTER(PURPLE_SOUND_GOT_ATTENTION)); } static void
--- a/pidgin/pidginstock.c Thu Oct 16 22:20:52 2008 +0000 +++ b/pidgin/pidginstock.c Mon Oct 20 18:44:06 2008 +0000 @@ -192,7 +192,8 @@ { PIDGIN_STOCK_TOOLBAR_SELECT_AVATAR, "toolbar", "select-avatar.png", FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, NULL }, { PIDGIN_STOCK_TOOLBAR_SEND_FILE, "toolbar", "send-file.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL }, { PIDGIN_STOCK_TOOLBAR_TRANSFER, "toolbar", "transfer.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL }, - + { PIDGIN_STOCK_TOOLBAR_SEND_ATTENTION, "toolbar", "get-attention.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL }, + { PIDGIN_STOCK_TRAY_AVAILABLE, "tray", "tray-online.png", FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL }, { PIDGIN_STOCK_TRAY_INVISIBLE, "tray", "tray-invisible.png", FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL }, { PIDGIN_STOCK_TRAY_AWAY, "tray", "tray-away.png", FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL },
--- a/pidgin/pidginstock.h Thu Oct 16 22:20:52 2008 +0000 +++ b/pidgin/pidginstock.h Mon Oct 20 18:44:06 2008 +0000 @@ -152,6 +152,7 @@ #define PIDGIN_STOCK_TOOLBAR_SELECT_AVATAR "pidgin-select-avatar" #define PIDGIN_STOCK_TOOLBAR_SEND_FILE "pidgin-send-file" #define PIDGIN_STOCK_TOOLBAR_TRANSFER "pidgin-transfer" +#define PIDGIN_STOCK_TOOLBAR_SEND_ATTENTION "pidgin-send-attention" /* Tray icons */ #define PIDGIN_STOCK_TRAY_AVAILABLE "pidgin-tray-available"
--- a/pidgin/pixmaps/Makefile.am Thu Oct 16 22:20:52 2008 +0000 +++ b/pidgin/pixmaps/Makefile.am Mon Oct 20 18:44:06 2008 +0000 @@ -434,7 +434,8 @@ toolbar/16/plugins.png \ toolbar/16/send-file.png \ toolbar/16/transfer.png \ - toolbar/16/unblock.png + toolbar/16/unblock.png \ + toolbar/16/get-attention.png TOOLBAR_22_SCALABLE = \ toolbar/22/scalable/select-avatar.svg