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);
}
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);
}
Beispiel #4
0
static void
anchored_cb(GtkWidget* widget,
            GtkWidget* prev_toplevel,
            gpointer udata)
{
    GtTwitchChatView* self = GT_TWITCH_CHAT_VIEW(udata);
    GtTwitchChatViewPrivate* priv = gt_twitch_chat_view_get_instance_private(self);
    GtWin* win = GT_WIN_TOPLEVEL(self);

    gtk_widget_insert_action_group(GTK_WIDGET(win),
                                   "chat-view", G_ACTION_GROUP(priv->action_group));

    credentials_set_cb(NULL, NULL, self);

    g_signal_connect(main_app, "notify::oauth-token", G_CALLBACK(credentials_set_cb), self);

    g_signal_handlers_disconnect_by_func(self, anchored_cb, udata); //One-shot
}
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);
}
Beispiel #6
0
static void
credentials_set_cb(GObject* source,
                   GParamSpec* pspec,
                   gpointer udata)
{
    GtTwitchChatView* self = GT_TWITCH_CHAT_VIEW(udata);
    GtTwitchChatViewPrivate* priv = gt_twitch_chat_view_get_instance_private(self);
    gchar* user_name;
    gchar* oauth_token;

    g_object_get(main_app,
                 "user-name", &user_name,
                 "oauth-token", &oauth_token,
                 NULL);

    if (!user_name || !oauth_token ||
        strlen(user_name) < 1 || strlen(oauth_token) < 1)
    {
        gt_twitch_chat_client_disconnect(priv->chat);
        gtk_text_buffer_set_text(priv->chat_buffer, "", -1);

        gtk_stack_set_visible_child_name(GTK_STACK(priv->main_stack), "loginview");

        priv->joined_channel = FALSE;
    }
    else
    {
        GtChannel* open_chan = NULL;

        g_object_get(GT_WIN_TOPLEVEL(self)->player, "open-channel", &open_chan, NULL);

        gt_twitch_chat_client_connect(priv->chat, oauth_token, user_name);
        gtk_stack_set_visible_child_name(GTK_STACK(priv->main_stack), "chatview");

        if (open_chan && !priv->joined_channel)
        {
            gt_twitch_chat_client_join(priv->chat, gt_channel_get_name(open_chan));
            g_object_unref(open_chan);
        }
    }

    g_free(user_name);
    g_free(oauth_token);
}
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);
}
Beispiel #8
0
static gboolean
utils_mouse_clicked_link_cb(GtkWidget* widget,
                            GdkEventButton* evt,
                            gpointer udata)
{
    if (evt->button == 1 && evt->type == GDK_BUTTON_PRESS)
    {
        GtWin* parent = GT_WIN_TOPLEVEL(widget);

#if GTK_CHECK_VERSION(3, 22, 0)
        gtk_show_uri_on_window(GTK_WINDOW(parent), (gchar*) udata, GDK_CURRENT_TIME, NULL);
#else
        gtk_show_uri(NULL, (gchar*) udata, GDK_CURRENT_TIME, NULL);
#endif

    }

    return FALSE;
}