/** * gs_plugin_initialize: */ void gs_plugin_initialize (GsPlugin *plugin) { g_autoptr(GSettings) settings = NULL; plugin->priv = GS_PLUGIN_GET_PRIVATE (GsPluginPrivate); plugin->priv->session = soup_session_new_with_options (SOUP_SESSION_USER_AGENT, gs_user_agent (), NULL); /* this is opt-in, and turned off by default */ settings = g_settings_new ("org.gnome.desktop.privacy"); if (!g_settings_get_boolean (settings, "send-software-usage-stats")) { gs_plugin_set_enabled (plugin, FALSE); g_debug ("disabling '%s' as 'send-software-usage-stats' " "disabled in GSettings", plugin->name); return; } /* check that we are running on Fedora */ if (!gs_plugin_check_distro_id (plugin, "fedora")) { gs_plugin_set_enabled (plugin, FALSE); g_debug ("disabling '%s' as we're not Fedora", plugin->name); return; } }
static void gs_page_needs_user_action (GsPageHelper *helper, AsScreenshot *ss) { GtkWidget *content_area; GtkWidget *dialog; GtkWidget *ssimg; g_autofree gchar *escaped = NULL; GsPagePrivate *priv = gs_page_get_instance_private (helper->page); dialog = gtk_message_dialog_new (gs_shell_get_window (priv->shell), GTK_DIALOG_MODAL | GTK_DIALOG_USE_HEADER_BAR, GTK_MESSAGE_INFO, GTK_BUTTONS_CANCEL, /* TRANSLATORS: this is a prompt message, and * '%s' is an application summary, e.g. 'GNOME Clocks' */ _("Prepare %s"), gs_app_get_name (helper->app)); escaped = g_markup_escape_text (as_screenshot_get_caption (ss, NULL), -1); gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog), "%s", escaped); /* this will be enabled when the device is in the right mode */ helper->button_install = gtk_dialog_add_button (GTK_DIALOG (dialog), /* TRANSLATORS: update the fw */ _("Install"), GTK_RESPONSE_OK); helper->notify_quirk_id = g_signal_connect (helper->app, "notify::quirk", G_CALLBACK (gs_page_notify_quirk_cb), helper); gtk_widget_set_sensitive (helper->button_install, FALSE); /* load screenshot */ helper->soup_session = soup_session_new_with_options (SOUP_SESSION_USER_AGENT, gs_user_agent (), NULL); ssimg = gs_screenshot_image_new (helper->soup_session); gs_screenshot_image_set_screenshot (GS_SCREENSHOT_IMAGE (ssimg), ss); gs_screenshot_image_set_size (GS_SCREENSHOT_IMAGE (ssimg), 400, 225); gs_screenshot_image_load_async (GS_SCREENSHOT_IMAGE (ssimg), helper->cancellable); gtk_widget_set_margin_start (ssimg, 24); gtk_widget_set_margin_end (ssimg, 24); content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); gtk_container_add (GTK_CONTAINER (content_area), ssimg); gtk_container_child_set (GTK_CONTAINER (content_area), ssimg, "pack-type", GTK_PACK_END, NULL); /* handle this async */ g_signal_connect (dialog, "response", G_CALLBACK (gs_page_update_app_response_cb), helper); gs_shell_modal_dialog_present (priv->shell, GTK_DIALOG (dialog)); }
static gchar * gs_editor_css_download_resources (GsEditor *self, const gchar *css, GError **error) { g_autoptr(GsPlugin) plugin = NULL; g_autoptr(SoupSession) soup_session = NULL; /* make remote URIs local */ plugin = gs_plugin_new (); gs_plugin_set_name (plugin, "editor"); soup_session = soup_session_new_with_options (SOUP_SESSION_USER_AGENT, gs_user_agent (), SOUP_SESSION_TIMEOUT, 10, NULL); gs_plugin_set_soup_session (plugin, soup_session); return gs_plugin_download_rewrite_resource (plugin, NULL, css, NULL, error); }
static SnapdClient * get_client (GsPlugin *plugin, GError **error) { GsPluginData *priv = gs_plugin_get_data (plugin); g_autoptr(SnapdClient) client = NULL; const gchar *old_user_agent; g_autofree gchar *user_agent = NULL; client = snapd_client_new (); snapd_client_set_allow_interaction (client, TRUE); old_user_agent = snapd_client_get_user_agent (client); user_agent = g_strdup_printf ("%s %s", gs_user_agent (), old_user_agent); snapd_client_set_user_agent (client, user_agent); snapd_client_set_auth_data (client, priv->auth_data); return g_steal_pointer (&client); }