static void gs_shell_overview_get_featured_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { GsShellOverview *self = GS_SHELL_OVERVIEW (user_data); GsShellOverviewPrivate *priv = gs_shell_overview_get_instance_private (self); GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object); GtkWidget *tile; GsApp *app; g_autoptr(GError) error = NULL; g_autoptr(GsAppList) list = NULL; list = gs_plugin_loader_get_featured_finish (plugin_loader, res, &error); if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) goto out; if (g_getenv ("GNOME_SOFTWARE_FEATURED") == NULL) { /* Don't show apps from the category that's currently featured as the category of the day */ gs_plugin_list_filter (&list, filter_category, priv->category_of_day); gs_plugin_list_randomize (&list); } gs_container_remove_all (GTK_CONTAINER (priv->bin_featured)); gtk_widget_set_visible (priv->featured_heading, list != NULL); if (list == NULL) { g_warning ("failed to get featured apps: %s", error ? error->message : "no apps to show"); goto out; } /* at the moment, we only care about the first app */ app = GS_APP (list->data); tile = gs_feature_tile_new (app); g_signal_connect (tile, "clicked", G_CALLBACK (feature_tile_clicked), self); gtk_container_add (GTK_CONTAINER (priv->bin_featured), tile); priv->empty = FALSE; out: priv->loading_featured = FALSE; priv->refresh_count--; if (priv->refresh_count == 0) { priv->cache_valid = TRUE; g_signal_emit (self, signals[SIGNAL_REFRESHED], 0); } }
void gs_shell_overview_setup (GsShellOverview *self, GsShell *shell, GsPluginLoader *plugin_loader, GtkBuilder *builder, GCancellable *cancellable) { GsShellOverviewPrivate *priv = gs_shell_overview_get_instance_private (self); GtkAdjustment *adj; GtkWidget *tile; gint i; g_return_if_fail (GS_IS_SHELL_OVERVIEW (self)); priv->plugin_loader = g_object_ref (plugin_loader); priv->builder = g_object_ref (builder); priv->cancellable = g_object_ref (cancellable); /* avoid a ref cycle */ priv->shell = shell; adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->scrolledwindow_overview)); gtk_container_set_focus_vadjustment (GTK_CONTAINER (priv->box_overview), adj); tile = gs_feature_tile_new (NULL); gtk_container_add (GTK_CONTAINER (priv->bin_featured), tile); for (i = 0; i < N_TILES; i++) { tile = gs_popular_tile_new (NULL); gtk_container_add (GTK_CONTAINER (priv->box_popular), tile); tile = gs_popular_tile_new (NULL); gtk_container_add (GTK_CONTAINER (priv->box_popular_rotating), tile); } /* chain up */ gs_page_setup (GS_PAGE (self), shell, plugin_loader, cancellable); }
static void gs_editor_startup_cb (GtkApplication *application, GsEditor *self) { GtkTextBuffer *buffer; GtkWidget *main_window; GtkWidget *widget; gboolean ret; guint retval; g_autoptr(GError) error = NULL; /* get UI */ retval = gtk_builder_add_from_resource (self->builder, "/org/gnome/Software/Editor/gs-editor.ui", &error); if (retval == 0) { g_warning ("failed to load ui: %s", error->message); return; } /* load all system appstream */ as_store_set_add_flags (self->store_global, AS_STORE_ADD_FLAG_USE_MERGE_HEURISTIC); ret = as_store_load (self->store_global, AS_STORE_LOAD_FLAG_IGNORE_INVALID | AS_STORE_LOAD_FLAG_APP_INFO_SYSTEM | AS_STORE_LOAD_FLAG_APPDATA | AS_STORE_LOAD_FLAG_DESKTOP, self->cancellable, &error); if (!ret) { g_warning ("failed to load global store: %s", error->message); return; } /* load all the IDs into the completion model */ gs_editor_load_completion_model (self); self->featured_tile1 = gs_feature_tile_new (NULL); self->upgrade_banner = gs_upgrade_banner_new (); widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "box_featured")); gtk_container_add (GTK_CONTAINER (widget), self->featured_tile1); gtk_container_add (GTK_CONTAINER (widget), self->upgrade_banner); widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "textview_css")); buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget)); g_signal_connect (buffer, "changed", G_CALLBACK (gs_design_dialog_buffer_changed_cb), self); widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "flowbox_main")); gtk_flow_box_set_sort_func (GTK_FLOW_BOX (widget), gs_editor_flow_box_sort_cb, self, NULL); widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "button_save")); g_signal_connect (widget, "clicked", G_CALLBACK (gs_editor_button_save_clicked_cb), self); widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "button_new_feature")); g_signal_connect (widget, "clicked", G_CALLBACK (gs_editor_button_new_feature_clicked_cb), self); widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "button_new_os_upgrade")); g_signal_connect (widget, "clicked", G_CALLBACK (gs_editor_button_new_os_upgrade_clicked_cb), self); widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "button_new")); g_signal_connect (widget, "clicked", G_CALLBACK (gs_editor_button_new_clicked_cb), self); widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "button_remove")); g_signal_connect (widget, "clicked", G_CALLBACK (gs_editor_button_remove_clicked_cb), self); widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "button_import")); g_signal_connect (widget, "clicked", G_CALLBACK (gs_editor_button_import_clicked_cb), self); widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "button_back")); g_signal_connect (widget, "clicked", G_CALLBACK (gs_editor_button_back_clicked_cb), self); widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "button_menu")); g_signal_connect (widget, "clicked", G_CALLBACK (gs_editor_button_menu_clicked_cb), self); widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "button_notification_dismiss")); g_signal_connect (widget, "clicked", G_CALLBACK (gs_editor_button_notification_dismiss_clicked_cb), self); widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "button_notification_undo_remove")); g_signal_connect (widget, "clicked", G_CALLBACK (gs_editor_button_undo_remove_clicked_cb), self); widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "checkbutton_editors_pick")); g_signal_connect (widget, "toggled", G_CALLBACK (gs_editor_checkbutton_editors_pick_cb), self); widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "checkbutton_category_featured")); g_signal_connect (widget, "toggled", G_CALLBACK (gs_editor_checkbutton_category_featured_cb), self); widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "entry_desktop_id")); g_signal_connect (widget, "notify::text", G_CALLBACK (gs_editor_entry_desktop_id_notify_cb), self); widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "entry_name")); g_signal_connect (widget, "notify::text", G_CALLBACK (gs_editor_entry_name_notify_cb), self); widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "entry_summary")); g_signal_connect (widget, "notify::text", G_CALLBACK (gs_editor_entry_summary_notify_cb), self); widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "window_main")); g_signal_connect (widget, "delete_event", G_CALLBACK (gs_editor_delete_event_cb), self); /* clear entries */ gs_editor_refresh_choice (self); gs_editor_refresh_details (self); gs_editor_refresh_file (self, NULL); /* set the appropriate page */ gs_editor_set_page (self, "none"); main_window = GTK_WIDGET (gtk_builder_get_object (self->builder, "window_main")); gtk_application_add_window (application, GTK_WINDOW (main_window)); gtk_widget_show (main_window); }