cpw.attention_ui: 751d7c7c: Adds attention UI to Pidgin (can send at...
malu at pidgin.im
malu at pidgin.im
Mon Oct 20 14:51:02 EDT 2008
-----------------------------------------------------------------
Revision: 751d7c7c633c0898b1e505bfbfabafa3435d84ed
Ancestor: ac786ea6156dee361dab547dbc902b9ac3920a0a
Author: malu at pidgin.im
Date: 2008-10-20T18:44:06
Branch: im.pidgin.cpw.attention_ui
URL: http://d.pidgin.im/viewmtn/revision/info/751d7c7c633c0898b1e505bfbfabafa3435d84ed
Modified 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
ChangeLog:
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
-------------- next part --------------
============================================================
--- libpurple/conversation.c 3bccc3746ca0b742de2278d36d977e4e1707df29
+++ libpurple/conversation.c 62ccc41a1552e2634189377b2d3dc0a8276e4abe
@@ -960,6 +960,16 @@ purple_conversation_write(PurpleConversa
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_conversations_init(void)
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,
============================================================
--- libpurple/conversation.h 9ef84351aa54594150f930902721df72b6702970
+++ libpurple/conversation.h fc6da8d36b078242870c1499ac3425cde10b5ee6
@@ -645,8 +645,22 @@ void purple_conversation_write(PurpleCon
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
@param features Bitset defining supported features
============================================================
--- libpurple/protocols/jabber/message.c ac733ca657c7cce25ae8c5fafc2d0bf9a1ee055a
+++ libpurple/protocols/jabber/message.c 931ef05d0e62c7ab98da4c71591ba3151767804a
@@ -312,6 +312,7 @@ static void handle_buzz(JabberMessage *j
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);
}
============================================================
--- libpurple/protocols/msn/msn.c f8e681f66b852f7e33ea4840e7af340ba7263a21
+++ libpurple/protocols/msn/msn.c 0e9706e5efe9d4476339e50f647e8eb3a8d10f71
@@ -165,7 +165,9 @@ msn_cmd_nudge(PurpleConversation *conv,
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;
}
============================================================
--- libpurple/protocols/msn/switchboard.c f7fce1b63dc21b75eff51c1d6aafe704c5c41439
+++ libpurple/protocols/msn/switchboard.c 62f8f3810bc988382f7e46c4d01619d4630dfdba
@@ -1031,6 +1031,9 @@ datacast_msg(MsnCmdProc *cmdproc, MsnMes
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 */
============================================================
--- libpurple/protocols/yahoo/yahoo.c 7e5229419ad9251d0903c281223a7b90d319ec21
+++ libpurple/protocols/yahoo/yahoo.c 472ba9285bb399003e32bf296cfd2d0429c2e3cf
@@ -878,6 +878,8 @@ static void yahoo_process_message(Purple
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 @@ yahoopurple_cmd_buzz(PurpleConversation
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;
}
============================================================
--- libpurple/sound.h dd56aa35b0020eefc8931f2d46e4269ae914a9f3
+++ libpurple/sound.h ecabdd69d48a1dd144cbacc7126bb9d66c95e831
@@ -51,6 +51,8 @@ typedef enum _PurpleSoundEventID
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;
============================================================
--- pidgin/gtkconv.c d5d1af9143decabb9f3f68f68b0bbc788cc5516e
+++ pidgin/gtkconv.c 57d3d7d0dec018d162aba31dadc7270ae348f554
@@ -1207,6 +1207,20 @@ static void
}
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 @@ static GtkItemFactoryEntry menu_items[]
{ "/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 @@ setup_menubar(PidginWindow *win)
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 @@ gray_stuff_out(PidginConversation *gtkco
/* 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 @@ gray_stuff_out(PidginConversation *gtkco
/* 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 @@ gray_stuff_out(PidginConversation *gtkco
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 @@ gray_stuff_out(PidginConversation *gtkco
/* 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 @@ wrote_msg_update_unseen_cb(PurpleAccount
}
}
+
static PurpleConversationUiOps conversation_ui_ops =
{
pidgin_conv_new,
============================================================
--- pidgin/gtkconvwin.h 250c2499fcc142e466d0695dc27e203f56ff9156
+++ pidgin/gtkconvwin.h a39e16430cbe5f497f24d64416af02229e550919
@@ -51,6 +51,7 @@ struct _PidginWindow
GtkWidget *view_log;
GtkWidget *send_file;
+ GtkWidget *get_attention;
GtkWidget *add_pounce;
GtkWidget *get_info;
GtkWidget *invite;
============================================================
--- pidgin/gtkimhtmltoolbar.c ada2e86fb579482dc94a39b78c8e55b8a82ada7a
+++ pidgin/gtkimhtmltoolbar.c 2032b764e60b322ad326e96acfbfaf32a5ac2af4
@@ -913,6 +913,11 @@ insert_smiley_cb(GtkWidget *smiley, GtkI
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 @@ static void gtk_imhtmltoolbar_create_old
{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 @@ static void gtk_imhtmltoolbar_init (GtkI
GtkWidget *insert_button;
GtkWidget *font_button;
GtkWidget *smiley_button;
+ GtkWidget *attention_button;
GtkWidget *font_menu;
GtkWidget *insert_menu;
GtkWidget *menuitem;
@@ -1438,6 +1446,26 @@ static void gtk_imhtmltoolbar_init (GtkI
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);
============================================================
--- pidgin/gtkimhtmltoolbar.h 9bb8b93a7f7eacb6a58b6f4c1c255a2b2cf2f215
+++ pidgin/gtkimhtmltoolbar.h c439504fbbfc92406edc3e72c9452725df35d21d
@@ -65,7 +65,8 @@ struct _GtkIMHtmlToolbar {
GtkWidget *image;
GtkWidget *link;
GtkWidget *smiley;
-
+ GtkWidget *attention;
+
GtkWidget *font_dialog;
GtkWidget *fgcolor_dialog;
GtkWidget *bgcolor_dialog;
============================================================
--- pidgin/gtksound.c 0cc7acc221605e6665426880ed18147a98d32dec
+++ pidgin/gtksound.c 5ac97a0baf55a07aa1429a01ad10aaf1c3ddb9ec
@@ -70,7 +70,9 @@ static const struct pidgin_sound_event s
{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 @@ chat_msg_received_cb(PurpleAccount *acco
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 @@ pidgin_sound_init(void)
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 @@ pidgin_sound_init(void)
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
============================================================
--- pidgin/pidginstock.c fb7740443271d7148fa5152aef2888be2e80193e
+++ pidgin/pidginstock.c 93efd940e024da30d72f904e78e0198a60904feb
@@ -192,7 +192,8 @@ static struct SizedStockIcon {
{ 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 },
============================================================
--- pidgin/pidginstock.h fcccf6f3ed762cf7dfa76325ef6bf0336118a76e
+++ pidgin/pidginstock.h d15f369cc0478fec481363dea93c7cd1b8886057
@@ -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"
============================================================
--- pidgin/pixmaps/Makefile.am afe4586dfd4d2049b0545009555652cde33d3e00
+++ pidgin/pixmaps/Makefile.am 8b12c42eb96378a521f356685d9566589a829de6
@@ -434,7 +434,8 @@ TOOLBAR_16 = \
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
More information about the Commits
mailing list