gboolean gt_games_view_handle_event(GtGamesView* self, GdkEvent* event) { GtGamesViewPrivate* priv = gt_games_view_get_instance_private(self); return gtk_search_bar_handle_event(GTK_SEARCH_BAR(priv->search_bar), event); }
void gt_games_view_show_type(GtGamesView* self, gint type) { GtGamesViewPrivate* priv = gt_games_view_get_instance_private(self); switch (type) { case GT_GAMES_CONTAINER_TYPE_TOP: gtk_stack_set_visible_child(GTK_STACK(priv->games_stack), priv->top_container); priv->was_showing_game = FALSE; break; case GT_GAMES_CONTAINER_TYPE_SEARCH: gtk_stack_set_visible_child(GTK_STACK(priv->games_stack), priv->search_container); break; case GT_CHANNELS_CONTAINER_TYPE_GAME: gtk_stack_set_visible_child(GTK_STACK(priv->games_stack), priv->game_container); priv->was_showing_game = TRUE; break; default: break; } g_object_notify_by_pspec(G_OBJECT(self), props[PROP_SHOWING_TOP_GAMES]); g_object_notify_by_pspec(G_OBJECT(self), props[PROP_SHOWING_GAME_CHANNELS]); }
static void finalize(GObject* object) { GtGamesView* self = (GtGamesView*) object; GtGamesViewPrivate* priv = gt_games_view_get_instance_private(self); G_OBJECT_CLASS(gt_games_view_parent_class)->finalize(object); }
void gt_games_view_refresh(GtGamesView* self) { GtGamesViewPrivate* priv = gt_games_view_get_instance_private(self); if (GT_IS_CHANNELS_CONTAINER(VISIBLE_CHILD)) gt_channels_container_refresh(GT_CHANNELS_CONTAINER(VISIBLE_CHILD)); else gt_games_container_refresh(VISIBLE_CONTAINER); }
static void search_changed_cb(GtkEditable* edit, gpointer udata) { GtGamesView* self = GT_GAMES_VIEW(udata); GtGamesViewPrivate* priv = gt_games_view_get_instance_private(self); const gchar* query = gtk_entry_get_text(GTK_ENTRY(edit)); /* if (VISIBLE_CHILD == priv->search_container) */ gt_games_container_set_filter_query(GT_GAMES_CONTAINER(priv->search_container), query); }
static void search_active_cb(GObject* source, GParamSpec* pspec, gpointer udata) { GtGamesView* self = GT_GAMES_VIEW(udata); GtGamesViewPrivate* priv = gt_games_view_get_instance_private(self); if (priv->search_active) gtk_stack_set_visible_child(GTK_STACK(priv->games_stack), priv->search_container); else gtk_stack_set_visible_child(GTK_STACK(priv->games_stack), priv->top_container); }
static void gt_games_view_init(GtGamesView* self) { GtGamesViewPrivate* priv = gt_games_view_get_instance_private(self); gtk_widget_init_template(GTK_WIDGET(self)); g_object_bind_property(self, "search-active", priv->search_bar, "search-mode-enabled", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); g_signal_connect(self, "notify::search-active", G_CALLBACK(search_active_cb), self); g_signal_connect(priv->top_container, "game-activated", G_CALLBACK(game_activated_cb), self); g_signal_connect(priv->search_container, "game-activated", G_CALLBACK(game_activated_cb), self); }
static void search_active_cb(GObject* source, GParamSpec* pspec, gpointer udata) { GtGamesView* self = GT_GAMES_VIEW(udata); GtGamesViewPrivate* priv = gt_games_view_get_instance_private(self); if (priv->search_active) gt_games_view_show_type(self, GT_GAMES_CONTAINER_TYPE_SEARCH); else if (priv->was_showing_game) gt_games_view_show_type(self, GT_CHANNELS_CONTAINER_TYPE_GAME); else gt_games_view_show_type(self, GT_GAMES_CONTAINER_TYPE_TOP); }
static void set_property(GObject* obj, guint prop, const GValue* val, GParamSpec* pspec) { GtGamesView* self = GT_GAMES_VIEW(obj); GtGamesViewPrivate* priv = gt_games_view_get_instance_private(self); switch (prop) { case PROP_SEARCH_ACTIVE: priv->search_active = g_value_get_boolean(val); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop, pspec); } }
static void game_activated_cb(GtGamesContainer* container, GtGame* game, gpointer udata) { GtGamesView* self = GT_GAMES_VIEW(udata); GtGamesViewPrivate* priv = gt_games_view_get_instance_private(self); gchar* name; g_object_get(game, "name", &name, NULL); gt_channels_container_set_filter_query(GT_CHANNELS_CONTAINER(priv->game_container), name); gt_games_view_show_type(self, GT_CHANNELS_CONTAINER_TYPE_GAME); g_signal_handlers_block_by_func(self, search_active_cb, self); g_object_set(self, "search-active", FALSE, NULL); g_signal_handlers_unblock_by_func(self, search_active_cb, self); g_free(name); }
static void game_activated_cb(GtGamesContainer* container, GtGame* game, gpointer udata) { GtGamesView* self = GT_GAMES_VIEW(udata); GtGamesViewPrivate* priv = gt_games_view_get_instance_private(self); gchar* name; g_object_get(game, "name", &name, NULL); gt_channels_container_set_filter_query(GT_CHANNELS_CONTAINER(priv->game_container), name); gtk_stack_set_visible_child(GTK_STACK(priv->games_stack), priv->game_container); g_object_notify_by_pspec(G_OBJECT(self), props[PROP_SHOWING_TOP_GAMES]); g_object_notify_by_pspec(G_OBJECT(self), props[PROP_SHOWING_GAME_CHANNELS]); g_signal_handlers_block_by_func(self, search_active_cb, self); g_object_set(self, "search-active", FALSE, NULL); g_signal_handlers_unblock_by_func(self, search_active_cb, self); g_free(name); }
static void get_property (GObject* obj, guint prop, GValue* val, GParamSpec* pspec) { GtGamesView* self = GT_GAMES_VIEW(obj); GtGamesViewPrivate* priv = gt_games_view_get_instance_private(self); switch (prop) { case PROP_SEARCH_ACTIVE: g_value_set_boolean(val, priv->search_active); break; case PROP_SHOWING_TOP_GAMES: g_value_set_boolean(val, gtk_stack_get_visible_child(GTK_STACK(priv->games_stack)) == priv->top_container); break; case PROP_SHOWING_GAME_CHANNELS: g_value_set_boolean(val, gtk_stack_get_visible_child(GTK_STACK(priv->games_stack)) == priv->game_container); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop, pspec); } }