Пример #1
0
// ZRL 目前只识别缩放比例设置,将来扩展状态栏工具时再充实该函数
GtkWidget*
statusbar_features_property_proxy (MidoriWebSettings* settings,
                                   const gchar*       property,
                                   GtkWidget*         toolbar)
{
    const gchar* kind = NULL;
    GtkWidget* button = NULL;
    GtkWidget* image;
// ZRL 暂时屏蔽其他功能 2014.12.20
#if 0
    if (!strcmp (property, "auto-load-images")
     || !strcmp (property, "enable-javascript")
     || !strcmp (property, "enable-plugins"))
        kind = "toggle";
    else if (!strcmp (property, "identify-as"))
        kind = "custom-user-agent";
    else if (strstr (property, "font") != NULL)
        kind = "font";
    else if (!strcmp (property, "zoom-level"))
#else
    if (!strcmp (property, "zoom-level"))
#endif
    {
        MidoriBrowser* browser = midori_browser_get_for_widget (toolbar);
        guint i;
        button = gtk_combo_box_text_new_with_entry ();
        gtk_entry_set_width_chars (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (button))), 4);
        for (i = 0; i < G_N_ELEMENTS (zoom_levels); i++)
            gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (button), zoom_levels[i].label);
        g_signal_connect (button, "changed",
            G_CALLBACK (statusbar_features_zoom_level_changed_cb), browser);
        g_signal_connect (browser, "notify::tab",
            G_CALLBACK (statusbar_features_browser_notify_tab_cb), button);
        statusbar_features_browser_notify_tab_cb (browser, NULL, button);
        return button;
    }

// ZRL 暂时屏蔽其他功能 2014.12.20
#if 0
    button = katze_property_proxy (settings, property, kind);
    if (GTK_IS_BIN (button))
    {
        GtkWidget* label = gtk_bin_get_child (GTK_BIN (button));
        if (GTK_IS_LABEL (label))
            gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
    }

    if (!strcmp (property, "auto-load-images"))
    {
        g_object_set_data (G_OBJECT (button), "feature-label", _("Images"));
        image = gtk_image_new_from_stock (STOCK_IMAGE, GTK_ICON_SIZE_MENU);
        gtk_button_set_image (GTK_BUTTON (button), image);
        gtk_widget_set_tooltip_text (button, _("Load images automatically"));
        statusbar_features_toolbar_notify_toolbar_style_cb (toolbar, NULL, button);
        g_signal_connect (toolbar, "notify::toolbar-style",
            G_CALLBACK (statusbar_features_toolbar_notify_toolbar_style_cb), button);
    }
    if (!strcmp (property, "enable-javascript"))
    {
        g_object_set_data (G_OBJECT (button), "feature-label", _("Scripts"));
        image = gtk_image_new_from_stock (STOCK_SCRIPT, GTK_ICON_SIZE_MENU);
        gtk_button_set_image (GTK_BUTTON (button), image);
        gtk_widget_set_tooltip_text (button, _("Enable scripts"));
        statusbar_features_toolbar_notify_toolbar_style_cb (toolbar, NULL, button);
        g_signal_connect (toolbar, "notify::toolbar-style",
            G_CALLBACK (statusbar_features_toolbar_notify_toolbar_style_cb), button);
    }
    else if (!strcmp (property, "enable-plugins"))
    {
        if (!midori_web_settings_has_plugin_support ())
            gtk_widget_hide (button);
        g_object_set_data (G_OBJECT (button), "feature-label", _("Netscape plugins"));
        image = gtk_image_new_from_stock (MIDORI_STOCK_PLUGINS, GTK_ICON_SIZE_MENU);
        gtk_button_set_image (GTK_BUTTON (button), image);
        gtk_widget_set_tooltip_text (button, _("Enable Netscape plugins"));
        statusbar_features_toolbar_notify_toolbar_style_cb (toolbar, NULL, button);
        g_signal_connect (toolbar, "notify::toolbar-style",
            G_CALLBACK (statusbar_features_toolbar_notify_toolbar_style_cb), button);
    }
#endif
    return button;
}
Пример #2
0
static void
statusbar_features_app_add_browser_cb (MidoriApp*       app,
                                       MidoriBrowser*   browser,
                                       MidoriExtension* extension)
{
    GtkWidget* statusbar;
    GtkWidget* bbox;
    MidoriWebSettings* settings;
    GtkWidget* toolbar;
    GtkWidget* button;
    GtkWidget* image;

    /* FIXME: Monitor each view and modify its settings individually
              instead of merely replicating the global preferences. */

    statusbar = katze_object_get_object (browser, "statusbar");
    bbox = gtk_hbox_new (FALSE, 0);
    settings = katze_object_get_object (browser, "settings");
    toolbar = katze_object_get_object (browser, "navigationbar");
    button = katze_property_proxy (settings, "auto-load-images", "toggle");
    g_object_set_data (G_OBJECT (button), "feature-label", _("Images"));
    image = gtk_image_new_from_stock (STOCK_IMAGE, GTK_ICON_SIZE_MENU);
    gtk_button_set_image (GTK_BUTTON (button), image);
    #if GTK_CHECK_VERSION(2, 12, 0)
    gtk_widget_set_tooltip_text (button, _("Load images automatically"));
    #endif
    statusbar_features_toolbar_notify_toolbar_style_cb (toolbar, NULL, button);
    g_signal_connect (toolbar, "notify::toolbar-style",
        G_CALLBACK (statusbar_features_toolbar_notify_toolbar_style_cb), button);
    gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 2);
    gtk_widget_show (button);
    button = katze_property_proxy (settings, "enable-scripts", "toggle");
    g_object_set_data (G_OBJECT (button), "feature-label", _("Scripts"));
    image = gtk_image_new_from_stock (STOCK_SCRIPTS, GTK_ICON_SIZE_MENU);
    gtk_button_set_image (GTK_BUTTON (button), image);
    #if GTK_CHECK_VERSION(2, 12, 0)
    gtk_widget_set_tooltip_text (button, _("Enable scripts"));
    #endif
    statusbar_features_toolbar_notify_toolbar_style_cb (toolbar, NULL, button);
    g_signal_connect (toolbar, "notify::toolbar-style",
        G_CALLBACK (statusbar_features_toolbar_notify_toolbar_style_cb), button);
    gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 2);
    gtk_widget_show (button);
    button = katze_property_proxy (settings, "enable-plugins", "toggle");
    g_object_set_data (G_OBJECT (button), "feature-label", _("Netscape plugins"));
    image = gtk_image_new_from_stock (STOCK_PLUGINS, GTK_ICON_SIZE_MENU);
    gtk_button_set_image (GTK_BUTTON (button), image);
    #if GTK_CHECK_VERSION(2, 12, 0)
    gtk_widget_set_tooltip_text (button, _("Enable Netscape plugins"));
    #endif
    statusbar_features_toolbar_notify_toolbar_style_cb (toolbar, NULL, button);
    g_signal_connect (toolbar, "notify::toolbar-style",
        G_CALLBACK (statusbar_features_toolbar_notify_toolbar_style_cb), button);
    gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 2);
    gtk_widget_show (button);
    gtk_widget_show (bbox);
    gtk_box_pack_start (GTK_BOX (statusbar), bbox, FALSE, FALSE, 3);
    g_object_unref (settings);
    g_object_unref (statusbar);

    g_signal_connect (extension, "deactivate",
        G_CALLBACK (statusbar_features_deactivate_cb), bbox);
}