static void channel_favourited_cb(GObject* source, GParamSpec* pspec, gpointer udata) { GtFavouritesManager* self = GT_FAVOURITES_MANAGER(udata); GtFavouritesManagerPrivate* priv = gt_favourites_manager_get_instance_private(self); GtChannel* chan = GT_CHANNEL(source); gboolean favourited; g_object_get(chan, "favourited", &favourited, NULL); if (favourited) { self->favourite_channels = g_list_append(self->favourite_channels, chan); // g_signal_connect(chan, "notify::online", G_CALLBACK(channel_online_cb), self); g_object_ref(chan); if (gt_app_credentials_valid(main_app)) gt_twitch_follow_channel(main_app->twitch, gt_channel_get_name(chan)); //TODO: Error handling // gt_twitch_follow_channel_async(main_app->twitch, gt_channel_get_name(chan), NULL, NULL); //TODO: Error handling g_message("{GtChannel} Favourited '%s' (%p)", gt_channel_get_name(chan), chan); g_signal_emit(self, sigs[SIG_CHANNEL_FAVOURITED], 0, chan); } else { GList* found = g_list_find_custom(self->favourite_channels, chan, (GCompareFunc) gt_channel_compare); // Should never return null; g_assert_nonnull(found); // g_signal_handlers_disconnect_by_func(found->data, channel_online_cb, self); if (gt_app_credentials_valid(main_app)) gt_twitch_unfollow_channel_async(main_app->twitch, gt_channel_get_name(chan), NULL, NULL); //TODO: Error handling // gt_twitch_unfollow_channel(main_app->twitch, gt_channel_get_name(chan)); //TODO: Error handling g_message("{GtChannel} Unfavourited '%s' (%p)", gt_channel_get_name(chan), chan); g_signal_emit(self, sigs[SIG_CHANNEL_UNFAVOURITED], 0, found->data); g_clear_object(&found->data); self->favourite_channels = g_list_delete_link(self->favourite_channels, found); } }
static void logged_in_cb(GObject* source, GParamSpec* pspec, gpointer udata) { GtFavouritesManager* self = GT_FAVOURITES_MANAGER(udata); if (gt_app_credentials_valid(main_app)) gt_favourites_manager_load_from_twitch(self); }
static void refresh_view_cb(GSimpleAction* action, GVariant* arg, gpointer udata) { GtWin* self = GT_WIN(udata); GtWinPrivate* priv = gt_win_get_instance_private(self); GtkWidget* visible_child = gtk_stack_get_visible_child(GTK_STACK(priv->browse_stack)); if (visible_child == priv->channels_view) gt_channels_view_refresh(GT_CHANNELS_VIEW(priv->channels_view)); else if (visible_child == priv->games_view) gt_games_view_refresh(GT_GAMES_VIEW(priv->games_view)); else if (visible_child == priv->follows_view) { //TODO: Quick hack, turn this into a proper refresh function if (gt_app_credentials_valid(main_app)) gt_follows_manager_load_from_twitch(main_app->fav_mgr); else gt_follows_manager_load_from_file(main_app->fav_mgr); } }