Mercurial > pidgin.yaz
changeset 9260:947876140943
[gaim-migrate @ 10059]
Patch by Stu Tomlinson to add gaim_conversation_has_focus() and
gaim_conv_window_has_focus(), and the (optional) UI ops.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Fri, 11 Jun 2004 00:08:29 +0000 |
parents | f5f7482678d2 |
children | 77fdeb4c459f |
files | plugins/ChangeLog.API src/conversation.c src/conversation.h src/gtkconv.c |
diffstat | 4 files changed, 94 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/ChangeLog.API Thu Jun 10 20:57:52 2004 +0000 +++ b/plugins/ChangeLog.API Fri Jun 11 00:08:29 2004 +0000 @@ -4,6 +4,9 @@ Gaim API: * gaim_url_parse() now takes two additional parameters, which are used for returning the username and password from the URL, if they exist. + * Added: has_focus UI op to GaimConversationUiOps and + GaimConvWindowUiOps. + * Added: gaim_conversation_has_focus() and gaim_conv_window_has_focus(). version 0.78 (05/30/2004): Plugin API: v4
--- a/src/conversation.c Thu Jun 10 20:57:52 2004 +0000 +++ b/src/conversation.c Fri Jun 11 00:08:29 2004 +0000 @@ -422,6 +422,22 @@ ops->flash(win); } +gboolean +gaim_conv_window_has_focus(GaimConvWindow *win) +{ + gboolean ret = FALSE; + GaimConvWindowUiOps *ops; + + g_return_val_if_fail(win != NULL, FALSE); + + ops = gaim_conv_window_get_ui_ops(win); + + if (ops != NULL && ops->has_focus != NULL) + ret = ops->has_focus(win); + + return ret; +} + void gaim_conv_window_set_ui_ops(GaimConvWindow *win, GaimConvWindowUiOps *ops) { @@ -1487,6 +1503,27 @@ ops->update_progress(conv, percent); } +gboolean +gaim_conversation_has_focus(GaimConversation *conv) +{ + gboolean ret = FALSE; + GaimConvWindow *win; + GaimConversationUiOps *ops; + + g_return_val_if_fail(conv != NULL, FALSE); + + win = gaim_conversation_get_window(conv); + if (gaim_conv_window_get_active_conversation(win) != conv) + return FALSE; + + ops = gaim_conversation_get_ui_ops(conv); + + if (ops != NULL && ops->has_focus != NULL) + ret = ops->has_focus(conv); + + return ret; +} + /* * TODO: Need to make sure calls to this function happen in the core * instead of the UI. That way UIs have less work to do, and the
--- a/src/conversation.h Thu Jun 10 20:57:52 2004 +0000 +++ b/src/conversation.h Fri Jun 11 00:08:29 2004 +0000 @@ -147,6 +147,7 @@ void (*move_conversation)(GaimConvWindow *win, GaimConversation *conv, unsigned int newIndex); int (*get_active_index)(const GaimConvWindow *win); + gboolean (*has_focus)(GaimConvWindow *win); }; /** @@ -177,8 +178,11 @@ void (*update_progress)(GaimConversation *conv, float percent); + gboolean (*has_focus)(GaimConversation *conv); + /* Events */ void (*updated)(GaimConversation *conv, GaimConvUpdateType type); + }; /** @@ -422,6 +426,16 @@ const GaimConvWindow *win); /** + * Determines if a conversation window has focus + * + * @param win The window. + * + * @return @c TRUE if the conversation window has focus, @c FALSE if + * it does not or the UI does not have a concept of window focus + */ +gboolean gaim_conv_window_has_focus(GaimConvWindow *win); + +/** * Returns the list of conversations in the specified window. * * @param win The window. @@ -798,6 +812,16 @@ void gaim_conversation_update_progress(GaimConversation *conv, float percent); /** + * Determines if a conversation has focus + * + * @param conv The conversation. + * + * @return @c TRUE if the conversation has focus, @c FALSE if + * it does not or the UI does not have a concept of conversation focus + */ +gboolean gaim_conversation_has_focus(GaimConversation *conv); + +/** * Updates the visual status and UI of a conversation. * * @param conv The conversation.
--- a/src/gtkconv.c Thu Jun 10 20:57:52 2004 +0000 +++ b/src/gtkconv.c Fri Jun 11 00:08:29 2004 +0000 @@ -4601,6 +4601,18 @@ return (index == -1 ? 0 : index); } +static gboolean +gaim_gtk_has_focus(GaimConvWindow *win) +{ + GaimGtkWindow *gtkwin; + gboolean has_focus = FALSE; + + gtkwin = GAIM_GTK_WINDOW(win); + g_object_get(G_OBJECT(gtkwin->window), "has-toplevel-focus", &has_focus, NULL); + + return has_focus; +} + static GaimConvWindowUiOps window_ui_ops = { gaim_gtk_conversations_get_conv_ui_ops, @@ -4614,7 +4626,8 @@ gaim_gtk_add_conversation, gaim_gtk_remove_conversation, gaim_gtk_move_conversation, - gaim_gtk_get_active_index + gaim_gtk_get_active_index, + gaim_gtk_has_focus }; GaimConvWindowUiOps * @@ -5208,6 +5221,21 @@ gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); } +static gboolean +gaim_gtkconv_has_focus(GaimConversation *conv) +{ + GaimConvWindow *win; + GaimGtkWindow *gtkwin; + gboolean has_focus; + + win = gaim_conversation_get_window(conv); + gtkwin = GAIM_GTK_WINDOW(win); + + g_object_get(G_OBJECT(gtkwin->window), "has-toplevel-focus", &has_focus, NULL); + + return has_focus; +} + static void gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type) { @@ -5345,6 +5373,7 @@ gaim_gtkconv_chat_remove_user, /* chat_remove_user */ gaim_gtkconv_chat_remove_users, /* chat_remove_users */ NULL, /* update_progress */ + gaim_gtkconv_has_focus, /* has_focus */ gaim_gtkconv_updated /* updated */ };