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

Definition at line 2882 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().

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

Here is the call graph for this function:

Here is the caller graph for this function: