static void test_ephy_embed_shell_web_view_created (void) { EphyEmbedShell *embed_shell; GtkWidget *view; gboolean web_view_created = FALSE; embed_shell = ephy_embed_shell_get_default (); g_signal_connect (embed_shell, "web-view-created", G_CALLBACK (web_view_created_cb), &web_view_created); view = ephy_web_view_new (); g_assert (web_view_created); gtk_widget_destroy (view); }
static void webkit_pref_callback_user_agent (GSettings *settings, const char *key, gpointer data) { EphyEmbedShell *shell = ephy_embed_shell_get_default (); char *user_agent; if (ephy_embed_shell_get_mode (shell) == EPHY_EMBED_SHELL_MODE_APPLICATION) user_agent = g_strdup_printf ("%s (Web App)", ephy_user_agent_get_internal ()); else user_agent = g_strdup (ephy_user_agent_get_internal ()); webkit_settings_set_user_agent (webkit_settings, user_agent); g_free (user_agent); }
static void webkit_pref_callback_cookie_accept_policy (GSettings *settings, const char *key, gpointer data) { WebKitCookieManager *cookie_manager; char *value; EphyEmbedShell *shell; value = g_settings_get_string (settings, key); if (!value) return; shell = ephy_embed_shell_get_default (); cookie_manager = webkit_web_context_get_cookie_manager (ephy_embed_shell_get_web_context (shell)); ephy_embed_prefs_set_cookie_accept_policy (cookie_manager, value); g_free (value); }
/* Based on Christian Persch's code from gecko backend of epiphany (old transform_accept_languages_list() function) */ static void webkit_pref_callback_accept_languages (GSettings *settings, const char *key, gpointer data) { GArray *array; char **languages; guint i; EphyEmbedShell *shell = ephy_embed_shell_get_default (); WebKitWebContext *web_context = ephy_embed_shell_get_web_context (shell); languages = g_settings_get_strv (settings, key); array = g_array_new (TRUE, FALSE, sizeof (char *)); for (i = 0; languages[i]; i++) { if (!g_strcmp0 (languages[i], "system")) { ephy_langs_append_languages (array); } else if (languages[i][0] != '\0') { char *str = g_ascii_strdown (languages[i], -1); g_array_append_val (array, str); } } g_strfreev (languages); ephy_langs_sanitise (array); webkit_web_context_set_preferred_languages (web_context, (const char * const *)(void *)array->data); /* Used by the Firefox Sync web view in prefs-dialog.c. */ g_object_set_data_full (G_OBJECT (web_context), "preferred-languages", g_strdupv ((char **)(void *)array->data), (GDestroyNotify)g_strfreev); if (g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_ENABLE_SPELL_CHECKING)) { char **normalized = normalize_languages ((char **)(void *)array->data); webkit_web_context_set_spell_checking_languages (web_context, (const char * const *)normalized); g_strfreev (normalized); } for (i = 0; i < array->len; i++) g_free (g_array_index (array, char *, i)); g_array_free (array, TRUE); }
static void test_ephy_completion_model_update_empty (void) { EphyCompletionModel *model; GMainLoop *loop = NULL; model = ephy_completion_model_new (ephy_embed_shell_get_global_history_service (ephy_embed_shell_get_default ()), ephy_shell_get_bookmarks_manager (ephy_shell_get_default ())); g_assert (model); loop = g_main_loop_new (NULL, FALSE); ephy_completion_model_update_for_string (model, "hello", (EphyHistoryJobCallback)update_empty_cb, loop); g_main_loop_run (loop); g_object_unref (model); g_main_loop_unref (loop); }
/** * ephy_title_box_set_address: * @title_box: an #EphyTitleBox * @address: (nullable): the URI to use for the subtitle of this #EphyTitleBox * * Sets the address of @title_box to @address */ void ephy_title_box_set_address (EphyTitleBox *title_box, const char *address) { EphyEmbedShellMode mode; g_return_if_fail (EPHY_IS_TITLE_BOX (title_box)); mode = ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()); if (address == NULL || mode == EPHY_EMBED_SHELL_MODE_APPLICATION) { gtk_label_set_text (GTK_LABEL (title_box->subtitle), address); } else { gboolean rtl; char *subtitle; rtl = gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL; subtitle = g_strconcat (rtl ? "▾ " : address, rtl ? address : " ▾", NULL); gtk_label_set_text (GTK_LABEL (title_box->subtitle), subtitle); g_free (subtitle); } }
static void test_ephy_embed_shell_launch_handler (void) { EphyEmbedShell *embed_shell; gboolean ret; GFile *file; embed_shell = ephy_embed_shell_get_default (); ret = ephy_embed_shell_launch_handler (embed_shell, NULL, "text/html", 0); g_assert (ret == FALSE); file = g_file_new_for_path (TEST_DIR"/data/test.html"); g_assert (file); ret = ephy_embed_shell_launch_handler (embed_shell, file, NULL, 0); g_assert (ret == FALSE); ret = ephy_embed_shell_launch_handler (embed_shell, file, "text/html", 0); g_assert (ret == FALSE); g_object_unref (file); }
static void webkit_pref_callback_enable_spell_checking (GSettings *settings, const char *key, gpointer data) { WebKitWebContext *web_context; gboolean value = FALSE; EphyEmbedShell *shell = ephy_embed_shell_get_default (); web_context = ephy_embed_shell_get_web_context (shell); value = g_settings_get_boolean (settings, key); webkit_web_context_set_spell_checking_enabled (web_context, value); if (value) { char **languages = g_settings_get_strv (settings, EPHY_PREFS_WEB_LANGUAGE); char **normalized = normalize_languages (languages); webkit_web_context_set_spell_checking_languages (web_context, (const char * const *)normalized); g_strfreev (languages); g_strfreev (normalized); } }
static GObject * ephy_permissions_dialog_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_params) { EphyPermissionsDialog *dialog; EphyPermissionsDialogPrivate *priv; EphyEmbedShell *shell; EphyPermissionManager *manager; GObject *object; GtkWidget *notebook; object = parent_class->constructor (type, n_construct_properties, construct_params); dialog = EPHY_PERMISSIONS_DIALOG (object); priv = dialog->priv; ephy_state_add_window (GTK_WIDGET (dialog), "permissions-manager", 540, 400, FALSE, EPHY_STATE_WINDOW_SAVE_SIZE); gtk_window_set_title (GTK_WINDOW (dialog), _("Site Permissions")); gtk_window_set_role (GTK_WINDOW (dialog), "epiphany-permissions-manager"); gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_PROPERTIES /* FIXME? */); /* Don't stay on top of all windows! */ gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_NORMAL); gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 2); gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_HELP, GTK_RESPONSE_HELP); gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE); notebook = gtk_notebook_new (); priv->notebook = GTK_NOTEBOOK (notebook); gtk_container_set_border_width (GTK_CONTAINER (priv->notebook), 5); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), notebook, TRUE, TRUE, 0); gtk_widget_show (notebook); priv->buttons_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); ephy_permissions_dialog_add_tab (dialog, EPT_COOKIE, _("Cookies")); ephy_permissions_dialog_add_tab (dialog, EPT_IMAGE, _("Images")); ephy_permissions_dialog_add_tab (dialog, EPT_POPUP, _("Popup Windows")); /* ephy_permissions_dialog_add_tab (dialog, "password", _("Passwords")); */ shell = ephy_embed_shell_get_default (); priv->manager = manager = EPHY_PERMISSION_MANAGER (ephy_embed_shell_get_embed_single (shell)); sync_notebook_tab (priv->notebook, NULL, 0, dialog); g_signal_connect (G_OBJECT (notebook), "switch-page", G_CALLBACK (sync_notebook_tab), dialog); g_signal_connect (priv->manager, "permission-added", G_CALLBACK (permission_added_cb), dialog); g_signal_connect (priv->manager, "permission-changed", G_CALLBACK (permission_changed_cb), dialog); g_signal_connect (priv->manager, "permission-deleted", G_CALLBACK (permission_deleted_cb), dialog); g_signal_connect (priv->manager, "permissions-cleared", G_CALLBACK (permissions_cleared_cb), dialog); return object; }
static void webkit_pref_callback_user_stylesheet (GSettings *settings, const char *key, gpointer data) { gboolean value; value = g_settings_get_boolean (settings, key); if (!value) webkit_user_content_manager_remove_all_style_sheets (WEBKIT_USER_CONTENT_MANAGER (ephy_embed_shell_get_user_content_manager (ephy_embed_shell_get_default ()))); else { GFile *file; char *filename; filename = g_build_filename (ephy_dot_dir (), USER_STYLESHEET_FILENAME, NULL); file = g_file_new_for_path (filename); g_free (filename); g_file_read_async (file, G_PRIORITY_DEFAULT, NULL, (GAsyncReadyCallback)user_style_seet_read_cb, NULL); g_object_unref (file); } }
static void user_style_sheet_output_stream_splice_cb (GOutputStream *output_stream, GAsyncResult *result, gpointer user_data) { gssize bytes; bytes = g_output_stream_splice_finish (output_stream, result, NULL); if (bytes > 0) { WebKitUserStyleSheet *style_sheet; style_sheet = webkit_user_style_sheet_new (g_memory_output_stream_get_data (G_MEMORY_OUTPUT_STREAM (output_stream)), WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES, WEBKIT_USER_STYLE_LEVEL_USER, NULL, NULL); webkit_user_content_manager_add_style_sheet (WEBKIT_USER_CONTENT_MANAGER (ephy_embed_shell_get_user_content_manager (ephy_embed_shell_get_default ())), style_sheet); webkit_user_style_sheet_unref (style_sheet); } }
static void test_ephy_completion_model_create (void) { EphyCompletionModel *model; model = ephy_completion_model_new (EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service (ephy_embed_shell_get_default ())), ephy_shell_get_bookmarks (ephy_shell_get_default ()), TRUE); g_assert (model); g_object_unref (model); }
static void ephy_completion_model_init (EphyCompletionModel *model) { EphyCompletionModelPrivate *priv; EphyBookmarks *bookmarks_service; model->priv = priv = EPHY_COMPLETION_MODEL_GET_PRIVATE (model); priv->history_service = EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service (ephy_embed_shell_get_default ())); bookmarks_service = ephy_shell_get_bookmarks (ephy_shell_get_default ()); priv->bookmarks = ephy_bookmarks_get_bookmarks (bookmarks_service); }