static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* evt, gpointer udata) { GtWin* self = GT_WIN(udata); GtWinPrivate* priv = gt_win_get_instance_private(self); GdkModifierType modifiers = gtk_accelerator_get_default_mod_mask(); gboolean playing; GAction *action; g_object_get(self->player, "playing", &playing, NULL); if (MAIN_VISIBLE_CHILD == GTK_WIDGET(self->player)) { if (evt->keyval == GDK_KEY_Escape) { if (priv->fullscreen) g_object_set(self, "fullscreen", FALSE, NULL); else { action = g_action_map_lookup_action(G_ACTION_MAP(self), "close_player"); g_action_activate(action, NULL); } } else if (evt->keyval == GDK_KEY_f) { g_object_set(self, "fullscreen", !priv->fullscreen, NULL); } } else { if (evt->keyval == GDK_KEY_Escape) gt_browse_header_bar_stop_search(GT_BROWSE_HEADER_BAR(priv->browse_header_bar)); else if (evt->keyval == GDK_KEY_f && (evt->state & modifiers) == GDK_CONTROL_MASK) gt_browse_header_bar_toggle_search(GT_BROWSE_HEADER_BAR(priv->browse_header_bar)); else { GtkWidget* view = gtk_stack_get_visible_child(GTK_STACK(priv->browse_stack)); if (view == priv->channels_view) gt_channels_view_handle_event(GT_CHANNELS_VIEW(priv->channels_view), (GdkEvent*) evt); else if (view == priv->games_view) gt_games_view_handle_event(GT_GAMES_VIEW(priv->games_view), (GdkEvent*) evt); else if (view == priv->follows_view) gt_follows_view_handle_event(GT_FOLLOWS_VIEW(priv->follows_view), (GdkEvent* )evt); } } return FALSE; }
static void set_property(GObject* obj, guint prop, const GValue* val, GParamSpec* pspec) { GtBrowseHeaderBar* self = GT_BROWSE_HEADER_BAR(obj); GtBrowseHeaderBarPrivate* priv = gt_browse_header_bar_get_instance_private(self); switch (prop) { case PROP_CHANNELS_VIEW: g_clear_object(&priv->channels_view); priv->channels_view = g_value_dup_object(val); break; case PROP_GAMES_VIEW: g_clear_object(&priv->games_view); priv->games_view = g_value_dup_object(val); break; case PROP_FAVOURITES_VIEW: g_clear_object(&priv->favourites_view); priv->favourites_view = g_value_dup_object(val); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop, pspec); } }
static void show_refresh_button_cb(GObject* source, GParamSpec* pspec, gpointer udata) { GtBrowseHeaderBar* self = GT_BROWSE_HEADER_BAR(udata); GtBrowseHeaderBarPrivate* priv = gt_browse_header_bar_get_instance_private(self); GtkWidget* view = NULL; g_object_get(GT_WIN_TOPLEVEL(self), "visible-view", &view, NULL); gtk_revealer_set_reveal_child(GTK_REVEALER(priv->refresh_revealer), view != GTK_WIDGET(priv->favourites_view)); g_object_unref(view); }
static void show_nav_buttons_cb(GObject* source, GParamSpec* pspec, gpointer udata) { GtBrowseHeaderBar* self = GT_BROWSE_HEADER_BAR(udata); GtBrowseHeaderBarPrivate* priv = gt_browse_header_bar_get_instance_private(self); GtWin* win = GT_WIN_TOPLEVEL(self); gboolean showing_game_channels = FALSE; gboolean showing_games_view = FALSE; g_object_get(priv->games_view, "showing-game-channels", &showing_game_channels, NULL); g_object_get(win, "showing-games-view", &showing_games_view, NULL); gtk_revealer_set_reveal_child(GTK_REVEALER(priv->nav_buttons_revealer), showing_game_channels && showing_games_view); }
static void search_active_cb(GObject* source, GParamSpec* pspec, gpointer udata) { GtBrowseHeaderBar* self = GT_BROWSE_HEADER_BAR(udata); GtBrowseHeaderBarPrivate* priv = gt_browse_header_bar_get_instance_private(self); gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->search_button)); GtkWidget* visible_view = NULL; g_object_get(GT_WIN_TOPLEVEL(self), "visible_view", &visible_view, NULL); g_object_set(visible_view, "search-active", active, NULL); g_object_unref(visible_view); }
static void visible_view_cb(GObject* source, GParamSpec* pspec, gpointer udata) { GtBrowseHeaderBar* self = GT_BROWSE_HEADER_BAR(udata); GtBrowseHeaderBarPrivate* priv = gt_browse_header_bar_get_instance_private(self); GtkWidget* visible_view = NULL; gboolean search_active = FALSE; g_object_get(GT_WIN_TOPLEVEL(self), "visible_view", &visible_view, NULL); g_object_get(visible_view, "search-active", &search_active, NULL); g_signal_handlers_block_by_func(self, search_active_cb, self); g_object_set(priv->search_button, "active", search_active, NULL); g_signal_handlers_unblock_by_func(self, search_active_cb, self); g_object_unref(visible_view); }
static void realize(GtkWidget* widget, gpointer udata) { GtBrowseHeaderBar* self = GT_BROWSE_HEADER_BAR(udata); GtBrowseHeaderBarPrivate* priv = gt_browse_header_bar_get_instance_private(self); g_object_bind_property(priv->games_view, "search-active", priv->search_button, "active", G_BINDING_DEFAULT); g_object_bind_property(priv->channels_view, "search-active", priv->search_button, "active", G_BINDING_DEFAULT); g_object_bind_property(priv->favourites_view, "search-active", priv->search_button, "active", G_BINDING_DEFAULT); g_signal_connect(GT_WIN_TOPLEVEL(widget), "notify::visible-view", G_CALLBACK(visible_view_cb), self); g_signal_connect(GT_WIN_TOPLEVEL(widget), "notify::visible-view", G_CALLBACK(show_nav_buttons_cb), self); g_signal_connect(GT_WIN_TOPLEVEL(widget), "notify::visible-view", G_CALLBACK(show_refresh_button_cb), self); g_signal_connect(priv->games_view, "notify::showing-game-channels", G_CALLBACK(show_nav_buttons_cb), self); g_signal_connect(priv->search_button, "notify::active", G_CALLBACK(search_active_cb), self); }