PostGIS  2.5.0beta2dev-r@@SVN_REVISION@@

◆ pgui_create_import_file_table()

static void pgui_create_import_file_table ( GtkWidget *  import_list_frame)
static

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

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