Ejemplo n.º 1
0
static MidoriBrowser*
midori_frontend_browser_new_window_cb (MidoriBrowser* browser,
                                       MidoriBrowser* new_browser,
                                       gpointer       user_data)
{
    if (new_browser == NULL)
        new_browser = midori_browser_new ();
    g_object_set (new_browser,
        "settings", midori_browser_get_settings (browser),
        NULL);
    gtk_widget_show (GTK_WIDGET (new_browser));
    return new_browser;
}
Ejemplo n.º 2
0
static void
browser_tooltips (void)
{
    MidoriBrowser* browser;
    GtkActionGroup* action_group;
    GList* actions;
    gchar* toolbar;
    guint errors = 0;

    browser = midori_browser_new ();
    action_group = midori_browser_get_action_group (browser);
    actions = gtk_action_group_list_actions (action_group);
    toolbar = g_strjoinv (" ", (gchar**)midori_browser_get_toolbar_actions (browser));

    while (actions)
    {
        GtkAction* action = actions->data;
        const gchar* name = gtk_action_get_name (action);

        if (strstr ("CompactMenu Location Separator", name))
        {
            actions = g_list_next (actions);
            continue;
        }

        if (strstr (toolbar, name) != NULL)
        {
            if (!gtk_action_get_tooltip (action))
            {
                printf ("'%s' can be toolbar item but tooltip is unset\n", name);
                errors++;
            }
        }
        else
        {
            if (gtk_action_get_tooltip (action))
            {
                printf ("'%s' is no toolbar item but tooltip is set\n", name);
                errors++;
            }
        }
        actions = g_list_next (actions);
    }
    g_free (toolbar);
    g_list_free (actions);
    gtk_widget_destroy (GTK_WIDGET (browser));

    if (errors)
        g_error ("Tooltip errors");
}
Ejemplo n.º 3
0
MidoriBrowser*
midori_web_app_new (const gchar* webapp,
                    gchar**      open_uris,
                    gchar**      execute_commands,
                    gint         inactivity_reset,
                    const gchar* block_uris)
{
    guint i;
    g_return_val_if_fail (webapp != NULL, NULL);

    midori_paths_init (MIDORI_RUNTIME_MODE_APP, webapp);
    /*
       Set sanitized URI as class name which .desktop files use as StartupWMClass
       So dock type launchers can distinguish different apps with the same executable
     */
    gchar* wm_class = g_strdelimit (g_strdup (webapp), ":.\\/", '_');
    gdk_set_program_class (wm_class);
    g_free (wm_class);

    MidoriBrowser* browser = midori_browser_new ();
    g_signal_connect (browser, "new-window",
        G_CALLBACK (midori_frontend_browser_new_window_cb), NULL);
    g_signal_connect (browser, "show-preferences",
        G_CALLBACK (midori_browser_privacy_preferences_cb), NULL);

    midori_browser_set_action_visible (browser, "Menubar", FALSE);
    midori_browser_set_action_visible (browser, "CompactMenu", FALSE);
#if ENABLE_ADDSPEEDDIAL
    midori_browser_set_action_visible (browser, "AddSpeedDial", FALSE);
#endif
    midori_browser_set_action_visible (browser, "Navigationbar", FALSE);

    MidoriWebSettings* settings = midori_settings_new_full (NULL);
    g_object_set (settings,
                  "show-menubar", FALSE,
                  "show-navigationbar", FALSE,
                  "toolbar-items", "Back,Forward,ReloadStop,Location,Homepage,Preferences",
                  "show-statusbar", FALSE,
                  "show-panel", FALSE,
                  "last-window-state", MIDORI_WINDOW_NORMAL,
                  "inactivity-reset", inactivity_reset,
                  "block-uris", block_uris,
                  NULL);
    midori_load_soup_session_full (settings);

    KatzeArray* search_engines = midori_search_engines_new_from_folder (NULL);
    g_object_set (browser,
                  "show-tabs", open_uris != NULL,
                  "settings", settings,
                  NULL);
    midori_browser_set_action_visible (browser, "Panel", FALSE);
    g_object_unref (search_engines);

    if (webapp != NULL)
    {
        gchar* tmp_uri = sokoke_magic_uri (webapp, FALSE, TRUE);
        g_object_set (settings, "homepage", tmp_uri, NULL);
        midori_browser_add_uri (browser, tmp_uri);
        g_free (tmp_uri);
    }

    for (i = 0; open_uris && open_uris[i]; i++)
    {
        gchar* new_uri = sokoke_magic_uri (open_uris[i], FALSE, TRUE);
        midori_browser_add_uri (browser, new_uri);
        g_free (new_uri);
    }
    if (midori_browser_get_n_pages (browser) == 0)
        midori_browser_add_uri (browser, "about:blank");
    gtk_widget_show (GTK_WIDGET (browser));

    for (i = 0; execute_commands && execute_commands[i]; i++)
    {
        midori_browser_assert_action (browser, execute_commands[i]);
        midori_browser_activate_action (browser, execute_commands[i]);
    }
    midori_session_persistent_settings (settings, NULL);
    return browser;
}
Ejemplo n.º 4
0
MidoriBrowser*
midori_private_app_new (const gchar* config,
                        const gchar* webapp,
                        gchar**      open_uris,
                        gchar**      execute_commands,
                        gint         inactivity_reset,
                        const gchar* block_uris)
{
    guint i;

    midori_paths_init (MIDORI_RUNTIME_MODE_PRIVATE, config);
#ifndef HAVE_WEBKIT2
    g_object_set_data (G_OBJECT (webkit_get_default_session ()), "pass-through-console", (void*)1);
#endif

    /* Mask the timezone, which can be read by Javascript */
    g_setenv ("TZ", "UTC", TRUE);

    MidoriBrowser* browser = midori_browser_new ();
    g_signal_connect (browser, "new-window",
        G_CALLBACK (midori_frontend_browser_new_window_cb), NULL);

    MidoriWebSettings* settings = midori_settings_new_full (NULL);
    g_object_set (settings,
                  "preferred-languages", "en",
                  "enable-private-browsing", TRUE,
    #ifdef HAVE_LIBSOUP_2_29_91
                  "first-party-cookies-only", TRUE,
    #endif
                  "enable-html5-database", FALSE,
                  "enable-html5-local-storage", FALSE,
                  "enable-offline-web-application-cache", FALSE,
    /* Arguably DNS prefetching is or isn't a privacy concern. For the
     * lack of more fine-grained control we'll go the safe route. */
                  "enable-dns-prefetching", FALSE,
                  "strip-referer", TRUE,
                  "show-panel", FALSE,
                  "last-window-state", MIDORI_WINDOW_NORMAL,
                  "inactivity-reset", inactivity_reset,
                  "block-uris", block_uris,
                  NULL);
    midori_load_soup_session (settings);

    /* In-memory trash for re-opening closed tabs */
    KatzeArray* trash = katze_array_new (KATZE_TYPE_ITEM);
    g_signal_connect_after (trash, "add-item",
      G_CALLBACK (midori_trash_add_item_no_save_cb), NULL);

    KatzeArray* search_engines = midori_search_engines_new_from_folder (NULL);
    g_object_set (browser,
                  "settings", settings,
                  "trash", trash,
                  "search-engines", search_engines,
                  NULL);
    g_object_unref (settings);
    g_object_unref (trash);
    g_object_unref (search_engines);

    midori_browser_set_action_visible (browser, "Tools", FALSE);
    midori_browser_set_action_visible (browser, "ClearPrivateData", FALSE);
#if ENABLE_ADDSPEEDDIAL
    midori_browser_set_action_visible (browser, "AddSpeedDial", FALSE);
#endif
    #if GTK_CHECK_VERSION (3, 0, 0)
    g_object_set (gtk_widget_get_settings (GTK_WIDGET (browser)),
                  "gtk-application-prefer-dark-theme", TRUE,
                  NULL);
    #endif

    if (webapp != NULL)
    {
        gchar* tmp_uri = sokoke_magic_uri (webapp, FALSE, TRUE);
        g_object_set (settings, "homepage", tmp_uri, NULL);
        midori_browser_add_uri (browser, tmp_uri);
        g_free (tmp_uri);
    }

    for (i = 0; open_uris && open_uris[i]; i++)
    {
        gchar* new_uri = sokoke_magic_uri (open_uris[i], FALSE, TRUE);
        midori_browser_add_uri (browser, new_uri);
        g_free (new_uri);
    }
    if (midori_browser_get_n_pages (browser) == 0)
        midori_browser_add_uri (browser, "about:private");
    gtk_widget_show (GTK_WIDGET (browser));

    for (i = 0; execute_commands && execute_commands[i]; i++)
    {
        midori_browser_assert_action (browser, execute_commands[i]);
        midori_browser_activate_action (browser, execute_commands[i]);
    }

    /* FIXME need proper stock extension mechanism */
//由于整合了若干预置扩展,此处相应修改
#if 0
    midori_browser_activate_action (browser, "libtransfers." G_MODULE_SUFFIX "=true");
    midori_browser_activate_action (browser, "libabout." G_MODULE_SUFFIX "=true");
    midori_browser_activate_action (browser, "libopen-with." G_MODULE_SUFFIX "=true");
#else
    midori_browser_activate_action (browser, "libtransfers." G_MODULE_SUFFIX "=true");
    midori_browser_activate_action (browser, "libbuiltinextension." G_MODULE_SUFFIX "=true");
#endif
    
    g_assert (g_module_error () == NULL);

    return browser;
}