diff options
author | Iulian Radu <iulian.radu67@gmail.com> | 2016-11-23 16:58:42 +0200 |
---|---|---|
committer | Iulian Radu <iulian.radu67@gmail.com> | 2016-11-23 16:58:42 +0200 |
commit | a1675d510ffdcf2d0158a11edd70b534e0e9e320 (patch) | |
tree | 5e5c7d7d289026c8a0fc31be34cd1845bced48a4 | |
parent | 75321a41ce8882d24a9a39a955b06f110e7c5fd0 (diff) | |
download | epiphany-wip/bookmarks-import.tar.gz |
bookmarks: Add import dialogwip/bookmarks-import
-rw-r--r-- | src/window-commands.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/window-commands.c b/src/window-commands.c index c4fa1aafb..28aca786d 100644 --- a/src/window-commands.c +++ b/src/window-commands.c @@ -92,12 +92,69 @@ window_cmd_new_incognito_window (GSimpleAction *action, ephy_open_incognito_window (NULL); } +static GtkTreeModel * +create_tree_model (void) +{ + const gchar *option_names[1] = { + N_("Import from file") + }; + + enum { + TEXT_COL + }; + + GtkListStore *list_store; + GtkTreeIter iter; + int i; + + list_store = gtk_list_store_new (1, G_TYPE_STRING); + for (i = G_N_ELEMENTS (option_names) - 1; i >= 0; i--) { + gtk_list_store_prepend (list_store, &iter); + gtk_list_store_set (list_store, &iter, + TEXT_COL, _(option_names[i]), + -1); + } + + return GTK_TREE_MODEL (list_store); +} + void window_cmd_import_bookmarks (GSimpleAction *action, GVariant *parameter, gpointer user_data) { + EphyWindow *window = EPHY_WINDOW (user_data); + GtkWidget *dialog; + GtkWidget *content_area; + GtkWidget *combo_box; + GtkTreeModel *tree_model; + GtkCellRenderer *cell_renderer; + /* Show dialog with icon, title. */ + dialog = gtk_dialog_new_with_buttons (_("Import bookmarks"), + GTK_WINDOW (window), + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_USE_HEADER_BAR, + _("_Cancel"), + GTK_RESPONSE_CANCEL, + _("_Import"), + GTK_RESPONSE_OK, + NULL); + + content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); + gtk_container_set_border_width (GTK_CONTAINER (content_area), 5); + + tree_model = create_tree_model (); + combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (tree_model)); + g_object_unref (tree_model); + gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), 0); + + cell_renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell_renderer, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell_renderer, + "text", 0, NULL); + gtk_container_add (GTK_CONTAINER (content_area), combo_box); + + gtk_widget_show_all (dialog); } void |