PostGIS  2.1.10dev-r@@SVN_REVISION@@
static void pgui_create_import_file_table ( GtkWidget *  import_list_frame)
static

Definition at line 2876 of file shp2pgsql-gui.c.

References _, add_file_button, APPEND_MODE, CREATE_MODE, DELETE_MODE, FALSE, import_file_list_store, import_filename_column, IMPORT_FILENAME_COLUMN, import_filename_renderer, import_geom_column, import_geom_column_renderer, IMPORT_GEOMETRY_COLUMN, import_mode_column, IMPORT_MODE_COLUMN, import_mode_renderer, IMPORT_N_COLUMNS, import_remove_column, import_remove_renderer, import_schema_column, IMPORT_SCHEMA_COLUMN, import_schema_renderer, import_srid_column, IMPORT_SRID_COLUMN, import_srid_renderer, import_table_column, IMPORT_TABLE_COLUMN, import_table_renderer, import_tree, loader_mode_combo, LOADER_MODE_COMBO_COLUMNS, loader_mode_combo_list, LOADER_MODE_COMBO_OPTION_CHAR, LOADER_MODE_COMBO_TEXT, pgui_action_handle_file_drop(), pgui_action_handle_file_remove(), pgui_action_handle_loader_edit(), pgui_action_handle_tree_combo(), pgui_action_open_file_dialog(), PREPARE_MODE, and TRUE.

Referenced by pgui_create_main_window().

2877 {
2878  GtkWidget *vbox_tree;
2879  GtkWidget *sw;
2880  GtkTreeIter iter;
2881  gint *column_indexes;
2882 
2883  gtk_container_set_border_width (GTK_CONTAINER (import_list_frame), 0);
2884 
2885  vbox_tree = gtk_vbox_new(FALSE, 15);
2886  gtk_container_set_border_width(GTK_CONTAINER(vbox_tree), 5);
2887  gtk_container_add(GTK_CONTAINER(import_list_frame), vbox_tree);
2888 
2889  /* Setup a model */
2890  import_file_list_store = gtk_list_store_new(IMPORT_N_COLUMNS,
2891  G_TYPE_POINTER,
2892  G_TYPE_STRING,
2893  G_TYPE_STRING,
2894  G_TYPE_STRING,
2895  G_TYPE_STRING,
2896  G_TYPE_STRING,
2897  G_TYPE_STRING,
2898  G_TYPE_BOOLEAN);
2899 
2900  /* Create the view and such */
2901  import_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(import_file_list_store));
2902 
2903  /* GTK has a slightly brain-dead API in that you can't directly find
2904  the column being used by a GtkCellRenderer when using the same
2905  callback to handle multiple fields; hence we manually store this
2906  information here and pass a pointer to the column index into
2907  the signal handler */
2908  column_indexes = g_malloc(sizeof(gint) * IMPORT_N_COLUMNS);
2909 
2910  /* Make the tree view in a scrollable window */
2911  sw = gtk_scrolled_window_new(NULL, NULL);
2912  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
2913  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_ETCHED_IN);
2914  gtk_widget_set_size_request(sw, -1, 150);
2915 
2916  gtk_box_pack_start(GTK_BOX(vbox_tree), sw, TRUE, TRUE, 0);
2917  gtk_container_add(GTK_CONTAINER (sw), import_tree);
2918 
2919  /* Place the "Add File" button below the list view */
2920  add_file_button = gtk_button_new_with_label(_("Add File"));
2921  gtk_container_add (GTK_CONTAINER (vbox_tree), add_file_button);
2922 
2923  /* Filename Field */
2924  import_filename_renderer = gtk_cell_renderer_text_new();
2925  g_object_set(import_filename_renderer, "editable", FALSE, NULL);
2927  g_signal_connect(G_OBJECT(import_filename_renderer), "edited", G_CALLBACK(pgui_action_handle_loader_edit), &column_indexes[IMPORT_FILENAME_COLUMN]);
2928  import_filename_column = gtk_tree_view_column_new_with_attributes(_("Shapefile"),
2930  "text",
2932  NULL);
2933  g_object_set(import_filename_column, "resizable", TRUE, NULL);
2934  gtk_tree_view_append_column(GTK_TREE_VIEW(import_tree), import_filename_column);
2935 
2936  /* Schema Field */
2937  import_schema_renderer = gtk_cell_renderer_text_new();
2938  g_object_set(import_schema_renderer, "editable", TRUE, NULL);
2939  column_indexes[IMPORT_SCHEMA_COLUMN] = IMPORT_SCHEMA_COLUMN;
2940  g_signal_connect(G_OBJECT(import_schema_renderer), "edited", G_CALLBACK(pgui_action_handle_loader_edit), &column_indexes[IMPORT_SCHEMA_COLUMN]);
2941  import_schema_column = gtk_tree_view_column_new_with_attributes(_("Schema"),
2943  "text",
2945  NULL);
2946  g_object_set(import_schema_column, "resizable", TRUE, "expand", TRUE, NULL);
2947  gtk_tree_view_append_column(GTK_TREE_VIEW(import_tree), import_schema_column);
2948 
2949  /* Table Field */
2950  import_table_renderer = gtk_cell_renderer_text_new();
2951  g_object_set(import_table_renderer, "editable", TRUE, NULL);
2952  column_indexes[IMPORT_TABLE_COLUMN] = IMPORT_TABLE_COLUMN;
2953  g_signal_connect(G_OBJECT(import_table_renderer), "edited", G_CALLBACK(pgui_action_handle_loader_edit), &column_indexes[IMPORT_TABLE_COLUMN]);
2954  import_table_column = gtk_tree_view_column_new_with_attributes(_("Table"),
2956  "text",
2958  NULL);
2959  g_object_set(import_table_column, "resizable", TRUE, "expand", TRUE, NULL);
2960  gtk_tree_view_append_column(GTK_TREE_VIEW(import_tree), import_table_column);
2961 
2962  /* Geo column field */
2963  import_geom_column_renderer = gtk_cell_renderer_text_new();
2964  g_object_set(import_geom_column_renderer, "editable", TRUE, NULL);
2966  g_signal_connect(G_OBJECT(import_geom_column_renderer), "edited", G_CALLBACK(pgui_action_handle_loader_edit), &column_indexes[IMPORT_GEOMETRY_COLUMN]);
2967  import_geom_column = gtk_tree_view_column_new_with_attributes(_("Geo Column"),
2969  "text",
2971  NULL);
2972  g_object_set(import_geom_column, "resizable", TRUE, "expand", TRUE, NULL);
2973  gtk_tree_view_append_column(GTK_TREE_VIEW(import_tree), import_geom_column);
2974 
2975  /* SRID Field */
2976  import_srid_renderer = gtk_cell_renderer_text_new();
2977  g_object_set(import_srid_renderer, "editable", TRUE, NULL);
2978  column_indexes[IMPORT_SRID_COLUMN] = IMPORT_SRID_COLUMN;
2979  g_signal_connect(G_OBJECT(import_srid_renderer), "edited", G_CALLBACK(pgui_action_handle_loader_edit), &column_indexes[IMPORT_SRID_COLUMN]);
2980  import_srid_column = gtk_tree_view_column_new_with_attributes("SRID",
2982  "text",
2984  NULL);
2985  g_object_set(import_srid_column, "resizable", TRUE, "expand", TRUE, NULL);
2986  gtk_tree_view_append_column(GTK_TREE_VIEW(import_tree), import_srid_column);
2987 
2988  /* Mode Combo Field */
2989  loader_mode_combo_list = gtk_list_store_new(LOADER_MODE_COMBO_COLUMNS,
2990  G_TYPE_STRING,
2991  G_TYPE_CHAR);
2992 
2993  gtk_list_store_insert(loader_mode_combo_list, &iter, CREATE_MODE);
2994  gtk_list_store_set(loader_mode_combo_list, &iter,
2995  LOADER_MODE_COMBO_TEXT, _("Create"),
2997  -1);
2998  gtk_list_store_insert(loader_mode_combo_list, &iter, APPEND_MODE);
2999  gtk_list_store_set(loader_mode_combo_list, &iter,
3000  LOADER_MODE_COMBO_TEXT, _("Append"),
3002  -1);
3003  gtk_list_store_insert(loader_mode_combo_list, &iter, DELETE_MODE);
3004  gtk_list_store_set(loader_mode_combo_list, &iter,
3005  LOADER_MODE_COMBO_TEXT, _("Delete"),
3007  -1);
3008  gtk_list_store_insert(loader_mode_combo_list, &iter, PREPARE_MODE);
3009  gtk_list_store_set(loader_mode_combo_list, &iter,
3010  LOADER_MODE_COMBO_TEXT, _("Prepare"),
3012  -1);
3013  loader_mode_combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(loader_mode_combo_list));
3014  import_mode_renderer = gtk_cell_renderer_combo_new();
3015  gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(loader_mode_combo),
3017  gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(loader_mode_combo),
3018  import_mode_renderer, "text", 0);
3019  g_object_set(import_mode_renderer,
3020  "model", loader_mode_combo_list,
3021  "editable", TRUE,
3022  "has-entry", FALSE,
3023  "text-column", LOADER_MODE_COMBO_TEXT,
3024  NULL);
3025  import_mode_column = gtk_tree_view_column_new_with_attributes(_("Mode"),
3027  "text",
3029  NULL);
3030  gtk_tree_view_append_column(GTK_TREE_VIEW(import_tree), import_mode_column);
3031  gtk_combo_box_set_active(GTK_COMBO_BOX(loader_mode_combo), 1);
3032  g_object_set(import_mode_column, "resizable", TRUE, "expand", TRUE, "sizing", GTK_TREE_VIEW_COLUMN_AUTOSIZE, NULL);
3033 
3034  g_signal_connect (G_OBJECT(import_mode_renderer), "changed", G_CALLBACK(pgui_action_handle_tree_combo), NULL);
3035 
3036  /* Remove Field */
3037  import_remove_renderer = gtk_cell_renderer_toggle_new();
3038  g_object_set(import_remove_renderer, "activatable", TRUE, NULL);
3039  g_signal_connect(G_OBJECT(import_remove_renderer), "toggled", G_CALLBACK (pgui_action_handle_file_remove), NULL);
3040  import_remove_column = gtk_tree_view_column_new_with_attributes("Rm",
3041  import_remove_renderer, NULL);
3042  g_object_set(import_remove_column, "resizable", TRUE, "expand", FALSE, "fixed-width", 64, "sizing", GTK_TREE_VIEW_COLUMN_FIXED, NULL);
3043  gtk_tree_view_append_column(GTK_TREE_VIEW(import_tree), import_remove_column);
3044 
3045  g_signal_connect (G_OBJECT (add_file_button), "clicked", G_CALLBACK (pgui_action_open_file_dialog), NULL);
3046 
3047  /* Drag n Drop wiring */
3048  GtkTargetEntry drop_types[] =
3049  {
3050  { "text/uri-list", 0, 0}
3051  };
3052 
3053  gint n_drop_types = sizeof(drop_types)/sizeof(drop_types[0]);
3054  gtk_drag_dest_set(GTK_WIDGET(import_tree),
3055  GTK_DEST_DEFAULT_ALL,
3056  drop_types, n_drop_types,
3057  GDK_ACTION_COPY);
3058  g_signal_connect(G_OBJECT(import_tree), "drag_data_received",
3059  G_CALLBACK(pgui_action_handle_file_drop), NULL);
3060 }
GtkTreeViewColumn * import_geom_column
Definition: shp2pgsql-gui.c:71
GtkWidget * loader_mode_combo
Definition: shp2pgsql-gui.c:78
GtkTreeViewColumn * import_mode_column
Definition: shp2pgsql-gui.c:73
GtkTreeViewColumn * import_filename_column
Definition: shp2pgsql-gui.c:68
static void pgui_action_handle_loader_edit(GtkCellRendererText *renderer, gchar *path, gchar *new_text, gpointer column)
#define _(String)
Definition: shpcommon.h:23
GtkCellRenderer * import_schema_renderer
Definition: shp2pgsql-gui.c:61
static void pgui_action_open_file_dialog(GtkWidget *widget, gpointer data)
GtkTreeViewColumn * import_schema_column
Definition: shp2pgsql-gui.c:69
static void pgui_action_handle_file_remove(GtkCellRendererToggle *renderer, gchar *path, gpointer user_data)
static void pgui_action_handle_file_drop(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, GtkSelectionData *selection_data, guint info, guint t, gpointer data)
GtkListStore * loader_mode_combo_list
Definition: shp2pgsql-gui.c:79
GtkCellRenderer * import_table_renderer
Definition: shp2pgsql-gui.c:62
GtkCellRenderer * import_srid_renderer
Definition: shp2pgsql-gui.c:64
GtkTreeViewColumn * import_table_column
Definition: shp2pgsql-gui.c:70
GtkTreeViewColumn * import_remove_column
Definition: shp2pgsql-gui.c:74
static void pgui_action_handle_tree_combo(GtkCellRendererCombo *combo, gchar *path_string, GtkTreeIter *new_iter, gpointer user_data)
GtkCellRenderer * import_geom_column_renderer
Definition: shp2pgsql-gui.c:63
GtkTreeViewColumn * import_srid_column
Definition: shp2pgsql-gui.c:72
GtkWidget * import_tree
Definition: shp2pgsql-gui.c:59
static GtkWidget * add_file_button
Definition: shp2pgsql-gui.c:76
GtkListStore * import_file_list_store
Definition: shp2pgsql-gui.c:58
#define FALSE
Definition: dbfopen.c:169
GtkCellRenderer * import_remove_renderer
Definition: shp2pgsql-gui.c:66
GtkCellRenderer * import_filename_renderer
Definition: shp2pgsql-gui.c:60
#define TRUE
Definition: dbfopen.c:170
GtkCellRenderer * import_mode_renderer
Definition: shp2pgsql-gui.c:65

Here is the call graph for this function:

Here is the caller graph for this function: