Index: conversation.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/conversation.c,v retrieving revision 1.605 diff -u -p -u -r1.605 conversation.c --- conversation.c 28 May 2004 05:53:33 -0000 1.605 +++ conversation.c 30 May 2004 14:58:53 -0000 @@ -444,6 +444,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) { @@ -1520,6 +1536,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: conversation.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/conversation.h,v retrieving revision 1.44 diff -u -p -u -r1.44 conversation.h --- conversation.h 20 Apr 2004 05:00:26 -0000 1.44 +++ conversation.h 30 May 2004 14:58:53 -0000 @@ -148,6 +148,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); }; /** @@ -178,8 +179,11 @@ struct _GaimConversationUiOps void (*update_progress)(GaimConversation *conv, float percent); + gboolean (*has_focus)(GaimConversation *conv); + /* Events */ void (*updated)(GaimConversation *conv, GaimConvUpdateType type); + }; /** @@ -425,6 +429,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. @@ -801,6 +815,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: gtkconv.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkconv.c,v retrieving revision 1.386 diff -u -p -u -r1.386 gtkconv.c --- gtkconv.c 28 May 2004 20:36:32 -0000 1.386 +++ gtkconv.c 30 May 2004 14:58:55 -0000 @@ -4408,6 +4408,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, @@ -4421,7 +4433,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 * @@ -5015,6 +5032,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) { @@ -5152,6 +5184,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 */ };