/** * inf_user_table_add_user: * @user_table: A #InfUserTable. * @user: A #InfUser not already contained in @user_table. * * Inserts @user into @user_table. */ void inf_user_table_add_user(InfUserTable* user_table, InfUser* user) { g_return_if_fail(INF_IS_USER_TABLE(user_table)); g_return_if_fail(INF_IS_USER(user)); g_signal_emit(G_OBJECT(user_table), user_table_signals[ADD_USER], 0, user); }
/** * inf_user_table_lookup_user_by_id: * @user_table: A #InfUserTable. * @id: User ID to lookup. * * Returns the #InfUser with the given User ID in @user_table. * * Return Value: A #InfUser, or %NULL. **/ InfUser* inf_user_table_lookup_user_by_id(InfUserTable* user_table, guint id) { InfUserTablePrivate* priv; g_return_val_if_fail(INF_IS_USER_TABLE(user_table), NULL); priv = INF_USER_TABLE_PRIVATE(user_table); return INF_USER(g_hash_table_lookup(priv->table, GUINT_TO_POINTER(id))); }
/** * inf_user_table_foreach_local_user: * @user_table: A #InfUserTable. * @func: The function to call for each user. * @user_data: User data to pass to the function. * * Calls the given function for each local user in the user_table. A local * user is a user that has the %INF_USER_LOCAL flag set and that has not * status %INF_USER_UNAVAILABLE. You should not add or remove users while this * function is being executed. **/ void inf_user_table_foreach_local_user(InfUserTable* user_table, InfUserTableForeachUserFunc func, gpointer user_data) { InfUserTablePrivate* priv; GSList* item; g_return_if_fail(INF_IS_USER_TABLE(user_table)); g_return_if_fail(func != NULL); priv = INF_USER_TABLE_PRIVATE(user_table); for(item = priv->locals; item != NULL; item = g_slist_next(item)) func(INF_USER(item->data), user_data); }
/** * inf_text_gtk_viewport_new: * @scroll: A #GtkScrolledWindow. * @user_table: The #InfUserTable for the text session displayed in @viewport. * * Creates a new #InfTextGtkViewport for @scroll. This draws the position of * remote user's cursors into the scrollbars of @scroll. * * Returns: A new #InfTextGtkViewport. */ InfTextGtkViewport* inf_text_gtk_viewport_new(GtkScrolledWindow* scroll, InfUserTable* user_table) { GObject* object; g_return_val_if_fail(GTK_IS_SCROLLED_WINDOW(scroll), NULL); g_return_val_if_fail(INF_IS_USER_TABLE(user_table), NULL); object = g_object_new( INF_TEXT_GTK_TYPE_VIEWPORT, "scrolled-window", scroll, "user-table", user_table, NULL ); return INF_TEXT_GTK_VIEWPORT(object); }
/** * inf_user_table_lookup_user_by_name: * @user_table: A #InfUserTable. * @name: User name to lookup. * * Returns an #InfUser with the given name if there is one. * * Return Value: A #InfUser, or %NULL. **/ InfUser* inf_user_table_lookup_user_by_name(InfUserTable* user_table, const gchar* name) { InfUserTablePrivate* priv; InfUser* user; g_return_val_if_fail(INF_IS_USER_TABLE(user_table), NULL); g_return_val_if_fail(name != NULL, NULL); priv = INF_USER_TABLE_PRIVATE(user_table); user = g_hash_table_find( priv->table, inf_user_table_lookup_user_by_name_func, *(gpointer*) (gpointer) &name /* cast const away without warning */ ); return user; }
/** * inf_user_table_foreach_user: * @user_table: A #InfUserTable. * @func: The function to call for each user. * @user_data: User data to pass to the function. * * Calls the given function for each user in the user_table. You should not * add or remove users while this function is being executed. **/ void inf_user_table_foreach_user(InfUserTable* user_table, InfUserTableForeachUserFunc func, gpointer user_data) { InfUserTablePrivate* priv; InfUserTableForeachUserData data; g_return_if_fail(INF_IS_USER_TABLE(user_table)); g_return_if_fail(func != NULL); priv = INF_USER_TABLE_PRIVATE(user_table); data.func = func; data.user_data = user_data; g_hash_table_foreach( priv->table, inf_user_table_foreach_user_func, &data ); }