Index: src/conversation.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/conversation.c,v retrieving revision 1.609 diff -u -p -r1.609 conversation.c --- src/conversation.c 2 Jun 2004 05:08:49 -0000 1.609 +++ src/conversation.c 5 Jun 2004 09:23:34 -0000 @@ -422,6 +422,22 @@ gaim_conv_window_flash(GaimConvWindow *w 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 @@ gaim_conversation_update_progress(GaimCo 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 Index: src/conversation.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/conversation.h,v retrieving revision 1.45 diff -u -p -r1.45 conversation.h --- src/conversation.h 2 Jun 2004 05:08:49 -0000 1.45 +++ src/conversation.h 5 Jun 2004 09:23:34 -0000 @@ -147,6 +147,7 @@ struct _GaimConvWindowUiOps 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 @@ struct _GaimConversationUiOps void (*update_progress)(GaimConversation *conv, float percent); + gboolean (*has_focus)(GaimConversation *conv); + /* Events */ void (*updated)(GaimConversation *conv, GaimConvUpdateType type); + }; /** @@ -422,6 +426,16 @@ GaimConversation *gaim_conv_window_get_a 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_write(GaimConvers 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. Index: src/gtkconv.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkconv.c,v retrieving revision 1.391 diff -u -p -r1.391 gtkconv.c --- src/gtkconv.c 2 Jun 2004 05:38:56 -0000 1.391 +++ src/gtkconv.c 5 Jun 2004 09:23:35 -0000 @@ -4487,6 +4487,18 @@ gaim_gtk_get_active_index(const GaimConv 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, @@ -4500,7 +4512,8 @@ static GaimConvWindowUiOps window_ui_ops 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 * @@ -5094,6 +5107,21 @@ gaim_gtkconv_chat_remove_users(GaimConve 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) { @@ -5231,6 +5259,7 @@ static GaimConversationUiOps conversatio 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 */ };