Пример #1
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;
    gsize i;
    gchar** filters;

    /* 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 = midori_browser_get_settings (browser);
    toolbar = katze_object_get_object (browser, "navigationbar");

    filters = midori_extension_get_string_list (extension, "items", NULL);
    if (filters && *filters)
    {
        i = 0;
        while (filters[i] != NULL)
        {
            button = statusbar_features_property_proxy (settings, filters[i], toolbar);
            gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 2);
            i++;
        }
    }
    else
    {
// ZRL 暂时屏蔽其他功能
#if 0
        button = statusbar_features_property_proxy (settings, "auto-load-images", toolbar);
        gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 2);
        button = statusbar_features_property_proxy (settings, "enable-javascript", toolbar);
        gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 2);
        button = statusbar_features_property_proxy (settings, "enable-plugins", toolbar);
        gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 2);
        button = statusbar_features_property_proxy (settings, "identify-as", toolbar);
        gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 2);
#endif
        button = statusbar_features_property_proxy (settings, "zoom-level", toolbar);
        gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 2);
    }
    gtk_widget_show_all (bbox);
    gtk_box_pack_end (GTK_BOX (statusbar), bbox, FALSE, FALSE, 3);
    g_object_unref (statusbar);
    g_object_unref (toolbar);

    g_strfreev (filters);
    g_signal_connect (extension, "deactivate",
        G_CALLBACK (statusbar_features_deactivate_cb), bbox);
}
Пример #2
0
static void
colorful_tabs_app_add_browser_cb (MidoriApp*       app,
                                  MidoriBrowser*   browser,
                                  MidoriExtension* extension)
{
    GtkWidget* statusbar;
    GtkWidget* bbox;
    GtkWidget* button;

    statusbar = katze_object_get_object (browser, "statusbar");
    bbox = gtk_hbox_new (FALSE, 0);
    button = gtk_check_button_new_with_label (_("Tint tabs distinctly"));
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
                                  midori_extension_get_boolean (extension, "tint"));
    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_signal_connect (button, "toggled",
                      G_CALLBACK (colorful_tabs_button_toggled_cb), extension);
    g_signal_connect (browser, "add-tab",
                      G_CALLBACK (colorful_tabs_browser_add_tab_cb), extension);
    g_signal_connect (extension, "deactivate",
                      G_CALLBACK (colorful_tabs_deactivate_cb), bbox);
}
Пример #3
0
static void
tab_panel_browser_add_tab_cb (MidoriBrowser*   browser,
                              GtkWidget*       view,
                              MidoriExtension* extension)
{
    GtkWidget* notebook = katze_object_get_object (browser, "notebook");
    gint page = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), view);
    MidoriWebSettings* settings = midori_browser_get_settings (browser);
    gboolean minimized = katze_object_get_boolean (view, "minimized");
    GdkPixbuf* icon = midori_view_get_icon (MIDORI_VIEW (view));
    const gchar* title = midori_view_get_display_title (MIDORI_VIEW (view));
    GtkTreeModel* model = tab_panel_get_model_for_browser (browser);

    if (minimized)
    {
        GtkWidget* toolbar = tab_panel_get_toolbar_for_browser (browser);
        GtkWidget* image = gtk_image_new_from_pixbuf (
            midori_view_get_icon (MIDORI_VIEW (view)));
        GtkToolItem* toolitem = gtk_tool_button_new (image, NULL);
        gtk_tool_item_set_tooltip_text (toolitem, title);
        gtk_widget_show (image);
        g_object_set_data (G_OBJECT (view), "tab-panel-ext-toolitem", toolitem);
        gtk_widget_show (GTK_WIDGET (toolitem));
        gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
        tab_panel_toggle_toolbook (toolbar);
        g_signal_connect (toolitem, "clicked",
            G_CALLBACK (tab_panel_toolitem_clicked_cb), view);
        g_signal_connect (gtk_bin_get_child (GTK_BIN (toolitem)), "button-press-event",
            G_CALLBACK (tab_panel_toolitem_button_press_event_cb), view);
    }
    else
    {
        GtkTreeIter iter;
        gboolean buttons = katze_object_get_boolean (settings, "close-buttons-on-tabs");
        gint ellipsize = midori_view_get_label_ellipsize (MIDORI_VIEW (view));

        gtk_tree_store_insert_with_values (GTK_TREE_STORE (model),
            &iter, NULL, page, 0, view, 1, GTK_STOCK_CLOSE, 2, buttons,
            3, icon, 4, title, 5, ellipsize, 6, NULL, -1);
    }

    if (!g_signal_handler_find (view, G_SIGNAL_MATCH_FUNC,
        g_signal_lookup ("notify", MIDORI_TYPE_VIEW), 0, NULL,
        tab_panel_view_notify_minimized_cb, extension))
    {
        g_signal_connect (settings, "notify::close-buttons-on-tabs",
            G_CALLBACK (tab_panel_settings_notify_cb), model);
        g_signal_connect (view, "notify::minimized",
            G_CALLBACK (tab_panel_view_notify_minimized_cb), extension);
        g_signal_connect (view, "notify::icon",
            G_CALLBACK (tab_panel_view_notify_icon_cb), extension);
        g_signal_connect (view, "notify::title",
            G_CALLBACK (tab_panel_view_notify_title_cb), extension);
    }

    g_object_unref (notebook);
}
Пример #4
0
void
midori_normal_app_on_quit (MidoriApp* app)
{
    MidoriWebSettings* settings = katze_object_get_object (app, "settings");
    MidoriBookmarksDb* bookmarks = katze_object_get_object (app, "bookmarks");
    KatzeArray* history = katze_object_get_object (app, "history");

    g_object_notify (G_OBJECT (settings), "load-on-startup");
    midori_bookmarks_db_on_quit (bookmarks);
    midori_history_on_quit (history, settings);
    midori_private_data_on_quit (settings);

    MidoriStartup load_on_startup = katze_object_get_int (settings, "load-on-startup");
    if (load_on_startup < MIDORI_STARTUP_LAST_OPEN_PAGES)
    {
        gchar* config_file = midori_paths_get_config_filename_for_writing ("session.xbel");
        g_unlink (config_file);
    }
}
Пример #5
0
static void tb_editor_activate_cb(MidoriExtension *extension, MidoriApp *app)
{
	KatzeArray *browsers;
	MidoriBrowser *browser;
	guint i;

	browsers = katze_object_get_object(app, "browsers");
	i = 0;
	while ((browser = katze_array_get_nth_item(browsers, i++)))
		tb_editor_app_add_browser_cb(app, browser, extension);
	g_signal_connect(app, "add-browser", G_CALLBACK(tb_editor_app_add_browser_cb), extension);
	g_object_unref(browsers);
}
Пример #6
0
static void tb_editor_update_toolbar(TBEditorWidget *tbw)
{
	MidoriWebSettings *settings;
	GString *str = g_string_new(NULL);

	gtk_tree_model_foreach(GTK_TREE_MODEL(tbw->store_used), tb_editor_foreach_used, str);

	settings = katze_object_get_object(tbw->browser, "settings");
	g_object_set(settings, "toolbar-items", str->str, NULL);
	g_object_unref(settings);

	g_string_free(str, TRUE);
}
Пример #7
0
static void
tab_panel_activate_cb (MidoriExtension* extension,
                       MidoriApp*       app)
{
    KatzeArray* browsers;
    MidoriBrowser* browser;

    browsers = katze_object_get_object (app, "browsers");
    KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
        tab_panel_app_add_browser_cb (app, browser, extension);
    g_object_unref (browsers);
    g_signal_connect (app, "add-browser",
        G_CALLBACK (tab_panel_app_add_browser_cb), extension);
}
Пример #8
0
static void
page_holder_app_add_browser_cb (MidoriApp*       app,
                                MidoriBrowser*   browser,
                                MidoriExtension* extension)
{
    GtkWidget* panel;
    GtkWidget* notebook;
    GtkWidget* toolbar;
    GtkToolItem* toolitem;

    panel = katze_object_get_object (browser, "panel");
    notebook = gtk_notebook_new ();
    gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_RIGHT);
    gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE);
    gtk_widget_show (notebook);
    toolbar = gtk_toolbar_new ();
    gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH_HORIZ);
    gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_BUTTON);
    gtk_widget_show (toolbar);

    toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_JUMP_TO);
    gtk_tool_item_set_is_important (toolitem, TRUE);
    g_signal_connect (toolitem, "clicked",
                      G_CALLBACK (page_holder_button_jump_to_clicked_cb), notebook);
    gtk_widget_show (GTK_WIDGET (toolitem));
    gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);

    toolitem = gtk_separator_tool_item_new ();
    gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (toolitem), FALSE);
    gtk_tool_item_set_expand (toolitem, TRUE);
    gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
    gtk_widget_show (GTK_WIDGET (toolitem));

    toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_ADD);
    gtk_tool_item_set_is_important (toolitem, TRUE);
    g_signal_connect (toolitem, "clicked",
                      G_CALLBACK (page_holder_button_add_clicked_cb), notebook);
    gtk_widget_show (GTK_WIDGET (toolitem));
    gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);

    midori_panel_append_widget (MIDORI_PANEL (panel), notebook,
                                /* i18n: A panel showing a user specified web page */
                                STOCK_PAGE_HOLDER, _("Pageholder"), toolbar);
    g_signal_connect (extension, "deactivate",
                      G_CALLBACK (page_holder_deactivate_cb), notebook);

    g_object_unref (panel);
}
Пример #9
0
static void
formhistory_activate_cb (MidoriExtension* extension,
                         MidoriApp*       app)
{
    const gchar* config_dir = midori_extension_get_config_dir (extension);
    FormHistoryPriv* priv = formhistory_new (config_dir);
    KatzeArray* browsers = katze_object_get_object (app, "browsers");
    MidoriBrowser* browser;
    g_object_set_data (G_OBJECT (extension), "priv", priv);

    KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
        formhistory_app_add_browser_cb (app, browser, extension);
    g_signal_connect (app, "add-browser",
        G_CALLBACK (formhistory_app_add_browser_cb), extension);
    g_object_unref (browsers);
}
Пример #10
0
static void
clock_deactivate_cb (MidoriExtension* extension,
                     MidoriApp*   app)
{
    KatzeArray* browsers;
    MidoriBrowser* browser;
    GtkWidget* label;

    browsers = katze_object_get_object (app, "browsers");
    KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
    {
        clock_browser_destroy_cb (browser, NULL);
        label = g_object_get_data (G_OBJECT (browser), "clock-label");
        gtk_widget_destroy (label);
        g_object_set_data (G_OBJECT (browser), "clock-label", NULL);
    }
Пример #11
0
static gint
page_holder_notebook_append_view (GtkWidget* notebook)
{
    GtkWidget* view;
    MidoriBrowser* browser;
    MidoriWebSettings *settings;
    GtkWidget* label;

    view = midori_view_new (NULL);
    browser = midori_browser_get_for_widget (notebook);
    settings = katze_object_get_object (browser, "settings");
    midori_view_set_settings (MIDORI_VIEW (view), settings);
    g_object_unref (settings);
    gtk_widget_show (view);
    label = midori_view_get_proxy_tab_label (MIDORI_VIEW (view));
    return gtk_notebook_append_page (GTK_NOTEBOOK (notebook), view, label);
}
Пример #12
0
static void
statusbar_features_deactivate_cb (MidoriExtension* extension,
                                  GtkWidget*       bbox)
{
    MidoriApp* app = midori_extension_get_app (extension);
    MidoriBrowser* browser = midori_browser_get_for_widget (bbox);
    GtkWidget* toolbar = katze_object_get_object (browser, "navigationbar");

    gtk_widget_destroy (bbox);
    g_signal_handlers_disconnect_matched (toolbar, G_SIGNAL_MATCH_FUNC,
        0, -1, NULL, statusbar_features_toolbar_notify_toolbar_style_cb, NULL);
    g_object_unref (toolbar);
    g_signal_handlers_disconnect_by_func (
        extension, statusbar_features_deactivate_cb, bbox);
    g_signal_handlers_disconnect_by_func (
        app, statusbar_features_app_add_browser_cb, extension);
}
Пример #13
0
static void cookie_manager_app_add_browser_cb(MidoriApp *app, MidoriBrowser *browser,
											  CookieManager *cm)
{
	MidoriPanel *panel;
	GtkWidget *page;
	CookieManagerPrivate *priv = cm->priv;

	panel = katze_object_get_object(browser, "panel");

	page = cookie_manager_page_new(cm, priv->store, priv->filter_text);
	gtk_widget_show(page);
	midori_panel_append_page(panel, MIDORI_VIEWABLE(page));
	g_signal_connect(page, "destroy", G_CALLBACK(cookie_manager_page_destroy_cb), cm);

	priv->panel_pages = g_slist_append(priv->panel_pages, page);

	g_object_unref(panel);
}
Пример #14
0
static void
mouse_gestures_activate_cb (MidoriExtension* extension,
                            MidoriApp*       app)
{
    KatzeArray* browsers;
    MidoriBrowser* browser;

    gesture = mouse_gesture_new ();
    gesture->button = midori_extension_get_integer (extension, "button");

    browsers = katze_object_get_object (app, "browsers");
    KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
        mouse_gestures_app_add_browser_cb (app, browser, extension);
    g_signal_connect (app, "add-browser",
        G_CALLBACK (mouse_gestures_app_add_browser_cb), extension);

    g_object_unref (browsers);
}
Пример #15
0
static GSList *tb_editor_parse_active_items(MidoriBrowser *browser)
{
	gchar *items;
	gchar **names;
	GSList *list = NULL;
	MidoriWebSettings *settings;

	settings = katze_object_get_object(browser, "settings");
	g_object_get(settings, "toolbar-items", &items, NULL);
	g_object_unref(settings);

	names = g_strsplit(items ? items : "", ",", 0);
	list = tb_editor_array_to_list((const gchar **) names);

	g_strfreev(names);
	g_free(items);

	return list;
}
Пример #16
0
static void
formhistory_preferences_response_cb (GtkWidget*       dialog,
                                     gint             response_id,
                                     MidoriExtension* extension)
{
    GtkWidget* checkbox;
    gboolean old_state;
    gboolean new_state;
    MidoriApp* app;
    KatzeArray* browsers;
    MidoriBrowser* browser;

    if (response_id == GTK_RESPONSE_APPLY)
    {
        checkbox = g_object_get_data (G_OBJECT (dialog), "always-load-checkbox");
        new_state = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox));
        old_state = midori_extension_get_boolean (extension, "always-load");

        if (old_state != new_state)
        {
            midori_extension_set_boolean (extension, "always-load", new_state);

            app = midori_extension_get_app (extension);
            browsers = katze_object_get_object (app, "browsers");
            KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
            {
                GList* tabs = midori_browser_get_tabs (browser);
                for (; tabs; tabs = g_list_next (tabs))
                    formhistory_deactivate_tab (tabs->data, extension);
                g_signal_handlers_disconnect_by_func (
                    browser, formhistory_add_tab_cb, extension);

                if (new_state)
                {
                    for (; tabs; tabs = g_list_next (tabs))
                        formhistory_add_tab_cb (browser, tabs->data, extension);
                    g_signal_connect (browser, "add-tab",
                        G_CALLBACK (formhistory_add_tab_cb), extension);
                }
                g_list_free (tabs);
            }
Пример #17
0
static void
clock_app_add_browser_cb (MidoriApp*       app,
                            MidoriBrowser*   browser,
                            MidoriExtension* extension)
{
    GtkWidget* statusbar;
    GtkWidget* label;

    label = gtk_label_new (NULL);

    statusbar = katze_object_get_object (browser, "statusbar");
    gtk_box_pack_end  (GTK_BOX (statusbar), label, FALSE, FALSE, 0);

    g_object_set_data (G_OBJECT (browser), "clock-label", label);
    g_object_set_data (G_OBJECT (browser), "clock-extension", extension);

    clock_set_current_time (browser);
    gtk_widget_show (label);

    g_object_unref (statusbar);

    g_signal_connect (browser, "destroy", G_CALLBACK (clock_browser_destroy_cb), NULL);
}
Пример #18
0
static void
midori_app_add_browser_cb (MidoriApp*     app,
                           MidoriBrowser* browser,
                           gpointer       user_data)
{
    GtkWidget* panel;
    GtkWidget* addon;

    panel = katze_object_get_object (browser, "panel");

    addon = g_object_new (MIDORI_TYPE_BOOKMARKS, "app", app, "visible", TRUE, NULL);
    midori_panel_append_page (MIDORI_PANEL (panel), MIDORI_VIEWABLE (addon));

    addon = g_object_new (MIDORI_TYPE_HISTORY, "app", app, "visible", TRUE, NULL);
    midori_panel_append_page (MIDORI_PANEL (panel), MIDORI_VIEWABLE (addon));

    /* Extensions */
    g_signal_connect (browser, "show-preferences",
        G_CALLBACK (midori_browser_privacy_preferences_cb), NULL);
    g_signal_connect (browser, "show-preferences",
        G_CALLBACK (midori_browser_show_preferences_cb), app);

    g_object_unref (panel);
}
Пример #19
0
static GtkWidget*
shortcuts_get_preferences_dialog (MidoriExtension* extension)
{
    MidoriApp* app;
    GtkWidget* browser;
    const gchar* dialog_title;
    GtkWidget* dialog;
    gint width, height;
    GtkWidget* xfce_heading;
    GtkWidget* hbox;
    GtkListStore* liststore;
    GtkTreeModel* model;
    GtkWidget* treeview;
    GtkTreeViewColumn* column;
    GtkCellRenderer* renderer;
    GtkWidget* scrolled;
    GtkActionGroup* action_group;
    GList* actions;
    guint i;
    GtkAction* action;
    #if HAVE_OSX
    GtkWidget* icon;
    #endif

    app = midori_extension_get_app (extension);
    browser = katze_object_get_object (app, "browser");

    dialog_title = _("Customize Keyboard shortcuts");
    dialog = gtk_dialog_new_with_buttons (dialog_title, GTK_WINDOW (browser),
        GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
        #if !HAVE_OSX
        GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
        #endif
        NULL);
    g_signal_connect (dialog, "destroy",
                      G_CALLBACK (gtk_widget_destroyed), &dialog);
    gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_PROPERTIES);
    sokoke_widget_get_text_size (dialog, "M", &width, &height);
    gtk_window_set_default_size (GTK_WINDOW (dialog), width * 52, height * 24);
    g_signal_connect (dialog, "response",
                      G_CALLBACK (shortcuts_preferences_response_cb), NULL);
    if ((xfce_heading = sokoke_xfce_header_new (
        gtk_window_get_icon_name (GTK_WINDOW (dialog)), dialog_title)))
        gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
                            xfce_heading, FALSE, FALSE, 0);
    hbox = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox,
                                 TRUE, TRUE, 12);
    liststore = gtk_list_store_new (7,
        G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_BOOLEAN,
        G_TYPE_STRING, GTK_TYPE_ACTION);
    model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (liststore));
    treeview = gtk_tree_view_new_with_model (model);
    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
    column = gtk_tree_view_column_new ();
    renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_column_pack_start (column, renderer, FALSE);
    gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), renderer, "text", 0);
    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
    column = gtk_tree_view_column_new ();
    renderer = gtk_cell_renderer_accel_new ();
    gtk_tree_view_column_pack_start (column, renderer, TRUE);
    gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), renderer, "accel-key", 1);
    gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), renderer, "accel-mods", 2);
    gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), renderer, "accel-mode", 3);
    gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), renderer, "sensitive", 4);
    gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), renderer, "editable", 4);
    g_signal_connect (renderer, "accel-edited",
        G_CALLBACK (shortcuts_accel_edited_cb), model);
    g_signal_connect (renderer, "accel-cleared",
        G_CALLBACK (shortcuts_accel_cleared_cb), model);
    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
    scrolled = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
                                    GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
    gtk_container_add (GTK_CONTAINER (scrolled), treeview);
    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
                                         GTK_SHADOW_IN);
    gtk_box_pack_start (GTK_BOX (hbox), scrolled, TRUE, TRUE, 5);

    action_group = midori_browser_get_action_group (MIDORI_BROWSER (browser));
    actions = gtk_action_group_list_actions (action_group);
    i = 0;
    /* FIXME: Catch added and removed actions */
    while ((action = g_list_nth_data (actions, i++)))
    {
        gchar* label = shortcuts_label_for_action (action);
        GtkAccelKey key;
        gboolean has_hotkey = shortcuts_hotkey_for_action (action, &key);
        gtk_list_store_insert_with_values (GTK_LIST_STORE (liststore),
            NULL, G_MAXINT, 0, label, 1, key.accel_key, 2, key.accel_mods,
                            3, GTK_CELL_RENDERER_ACCEL_MODE_OTHER,
                            4, has_hotkey, 6, action, -1);
        g_free (label);
    }
    g_list_free (actions);

    g_object_unref (liststore);
    gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model),
                                          0, GTK_SORT_ASCENDING);
    g_object_unref (model);

    gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);

    g_object_unref (browser);

    return dialog;
}
Пример #20
0
static void
tab_panel_app_add_browser_cb (MidoriApp*       app,
                              MidoriBrowser*   browser,
                              MidoriExtension* extension)
{
    GtkTreeStore* model;
    GtkWidget* treeview;
    GtkTreeViewColumn* column;
    GtkCellRenderer* renderer_pixbuf;
    GtkCellRenderer* renderer_text;
    GtkWidget* panel;
    GtkWidget* toolbar;
    gint i;
    /* GtkToolItem* toolitem; */

    g_object_set (browser, "show-tabs", FALSE, NULL);

    panel = katze_object_get_object (browser, "panel");

    model = gtk_tree_store_new (8, MIDORI_TYPE_VIEW,
        G_TYPE_STRING, G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF, G_TYPE_STRING,
        G_TYPE_INT, GDK_TYPE_COLOR, GDK_TYPE_COLOR);
    g_object_set_data (G_OBJECT (browser), "tab-panel-ext-model", model);
    treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
    gtk_tree_view_set_show_expanders (GTK_TREE_VIEW (treeview), FALSE);
    g_signal_connect (treeview, "query-tooltip",
        G_CALLBACK (tab_panel_treeview_query_tooltip_cb), NULL);
    gtk_widget_set_has_tooltip (treeview, TRUE);
    column = gtk_tree_view_column_new ();
    renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
    gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);
    gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (column), renderer_pixbuf,
        "pixbuf", 3, "cell-background-gdk", 6, NULL);
    renderer_text = gtk_cell_renderer_text_new ();
    gtk_tree_view_column_pack_start (column, renderer_text, TRUE);
    gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (column), renderer_text,
        "text", 4, "ellipsize", 5,
        "cell-background-gdk", 6, "foreground-gdk", 7, NULL);
    gtk_tree_view_column_set_expand (column, TRUE);
    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
    column = gtk_tree_view_column_new ();
    renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
    gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);
    gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (column), renderer_pixbuf,
        "stock-id", 1, "follow-state", 2,
        "visible", 2, "cell-background-gdk", 6, NULL);
    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
    g_object_connect (treeview,
                      "signal::row-activated",
                      midori_extension_row_activated_cb, extension,
                      "signal::cursor-changed",
                      midori_extension_cursor_or_row_changed_cb, extension,
                      "signal::columns-changed",
                      midori_extension_cursor_or_row_changed_cb, extension,
                      "signal::button-release-event",
                      midori_extension_button_release_event_cb, extension,
                      "signal::key-release-event",
                      midori_extension_key_release_event_cb, extension,
                      "signal::popup-menu",
                      midori_extension_popup_menu_cb, extension,
                      NULL);
    gtk_widget_show (treeview);

    toolbar = gtk_toolbar_new ();
    g_object_set_data (G_OBJECT (browser), "tab-panel-ext-toolbar", toolbar);
    gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH_HORIZ);
    gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_BUTTON);
    gtk_widget_show (toolbar);

    /*
    TODO: Implement optional thumbnail images
    toolitem = gtk_toggle_tool_button_new_from_stock (STOCK_IMAGE);
    gtk_tool_item_set_is_important (toolitem, TRUE);
    g_signal_connect (toolitem, "toggled",
            G_CALLBACK (tab_panel_button_thumbnail_toggled_cb), notebook);
    gtk_widget_show (GTK_WIDGET (toolitem));
    gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1); */

    i = midori_panel_append_widget (MIDORI_PANEL (panel), treeview,
                                    STOCK_TAB_PANEL, _("Tab Panel"), toolbar);
    if (gtk_widget_get_visible (GTK_WIDGET (browser)))
        midori_panel_set_current_page (MIDORI_PANEL (panel), i);
    g_object_unref (panel);

    midori_browser_foreach (browser,
        (GtkCallback)tab_panel_browser_foreach_cb, treeview);

    g_signal_connect_after (browser, "add-tab",
        G_CALLBACK (tab_panel_browser_add_tab_cb), extension);
    g_signal_connect (browser, "remove-tab",
        G_CALLBACK (tab_panel_browser_remove_tab_cb), extension);
    g_signal_connect (browser, "notify::tab",
        G_CALLBACK (tab_panel_browser_notify_tab_cb), treeview);
    g_signal_connect (extension, "deactivate",
        G_CALLBACK (tab_panel_deactivate_cb), treeview);
    g_signal_connect (browser, "move-tab",
        G_CALLBACK (tab_panel_browser_move_tab_cb), NULL);
}
Пример #21
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);
}