[epiphany/wip/bookmarks-import: 2/2] bookmarks: Add import dialog



commit a1675d510ffdcf2d0158a11edd70b534e0e9e320
Author: Iulian Radu <iulian radu67 gmail com>
Date:   Wed Nov 23 16:58:42 2016 +0200

    bookmarks: Add import dialog

 src/window-commands.c |   59 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 58 insertions(+), 1 deletions(-)
---
diff --git a/src/window-commands.c b/src/window-commands.c
index c4fa1aa..28aca78 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]