# HG changeset patch # User Christian Hammond # Date 1086912509 0 # Node ID 9478761409437b810fae88fb8e9dfb2ccc9bd0a5 # Parent f5f7482678d2d37c22f81ff367a1f35af522195b [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 diff -r f5f7482678d2 -r 947876140943 plugins/ChangeLog.API --- 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 diff -r f5f7482678d2 -r 947876140943 src/conversation.c --- 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 diff -r f5f7482678d2 -r 947876140943 src/conversation.h --- 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. diff -r f5f7482678d2 -r 947876140943 src/gtkconv.c --- 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 */ };