PostGIS  2.5.7dev-r@@SVN_REVISION@@
shp2pgsql-gui.c File Reference
#include "../postgis_config.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <sys/stat.h>
#include "libpq-fe.h"
#include "shp2pgsql-core.h"
#include "pgsql2shp-core.h"
Include dependency graph for shp2pgsql-gui.c:

Go to the source code of this file.

Macros

#define GUI_RCSID   "shp2pgsql-gui $Revision$"
 
#define SHAPEFIELDMAXWIDTH   60
 
#define gtk_dialog_get_content_area(dialog)   GTK_DIALOG(dialog)->vbox
 
#define GUIMSG_LINE_MAXLEN   256
 
#define MAXLEN   16
 
#define MAXLEN   16
 

Enumerations

enum  {
  IMPORT_POINTER_COLUMN , IMPORT_FILENAME_COLUMN , IMPORT_SCHEMA_COLUMN , IMPORT_TABLE_COLUMN ,
  IMPORT_GEOMETRY_COLUMN , IMPORT_SRID_COLUMN , IMPORT_MODE_COLUMN , IMPORT_REMOVE_COLUMN ,
  IMPORT_N_COLUMNS
}
 
enum  { LOADER_MODE_COMBO_TEXT , LOADER_MODE_COMBO_OPTION_CHAR , LOADER_MODE_COMBO_COLUMNS }
 
enum  { CREATE_MODE , APPEND_MODE , DELETE_MODE , PREPARE_MODE }
 
enum  {
  EXPORT_POINTER_COLUMN , EXPORT_SCHEMA_COLUMN , EXPORT_TABLE_COLUMN , EXPORT_GEOMETRY_COLUMN ,
  EXPORT_GEOMETRY_LISTSTORE_COLUMN , EXPORT_FILENAME_COLUMN , EXPORT_REMOVE_COLUMN , EXPORT_N_COLUMNS
}
 
enum  {
  TABLECHOOSER_SCHEMA_COLUMN , TABLECHOOSER_TABLE_COLUMN , TABLECHOOSER_GEO_LISTSTORE_COLUMN , TABLECHOOSER_GEO_COLUMN ,
  TABLECHOOSER_HASGEO_COLUMN , TABLECHOOSER_N_COLUMNS
}
 
enum  { TABLECHOOSER_GEOCOL_COMBO_TEXT , TABLECHOOSER_GEOCOL_COMBO_COLUMNS }
 

Functions

static void pgui_log_va (const char *fmt, va_list ap)
 
static void pgui_seterr_va (const char *fmt, va_list ap)
 
static void update_conn_ui_from_conn_config (void)
 
static void pgui_sanitize_connection_string (char *connection_string)
 
static void pgui_logf (const char *fmt,...)
 
static void pgui_seterr (const char *fmt,...)
 
static void pgui_raise_error_dialogue (void)
 
static int pgui_exec (const char *sql)
 
static int pgui_copy_start (const char *sql)
 
static int pgui_copy_write (const char *line)
 
static int pgui_copy_end (const int rollback)
 
static void update_filename_field_width (void)
 
static int connection_test (void)
 
static gint pgui_event_popup_delete (GtkWidget *widget, GdkEvent *event, gpointer data)
 
static void pgui_action_progress_cancel (GtkDialog *dialog, gint response_id, gpointer user_data)
 
static gint pgui_action_progress_delete (GtkWidget *widget, GdkEvent *event, gpointer data)
 
static void update_loader_config_globals_from_options_ui (SHPLOADERCONFIG *config)
 
static void update_options_ui_from_loader_config_globals (void)
 
static void pgui_set_loader_configs_from_options_ui ()
 
static void update_table_chooser_from_database ()
 
static gboolean table_chooser_visibility_func (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
 
static void update_dumper_config_globals_from_options_ui (SHPDUMPERCONFIG *config)
 
static void update_options_ui_from_dumper_config_globals (void)
 
static void pgui_set_dumper_configs_from_options_ui ()
 
static void pgui_action_chooser_toggle_show_geocolumn (GtkToggleButton *togglebutton, gpointer user_data)
 
static void pgui_action_dumper_options_open (GtkWidget *widget, gpointer data)
 
static void pgui_action_dumper_options_close (GtkWidget *widget, gint response, gpointer data)
 
static SHPLOADERCONFIGcreate_new_file_config (const char *filename)
 
static void add_loader_file_config_to_list (SHPLOADERCONFIG *loader_file_config)
 
static void free_loader_config (SHPLOADERCONFIG *config)
 
static SHPDUMPERCONFIGcreate_new_table_config (GtkTreeIter *iter)
 
static void add_dumper_table_config_to_list (SHPDUMPERCONFIG *dumper_table_config, GtkListStore *chooser_liststore, GtkTreeIter *chooser_iter)
 
static void free_dumper_config (SHPDUMPERCONFIG *config)
 
static int validate_shape_column_against_pg_column (int dbf_fieldtype, char *pg_fieldtype)
 
static int validate_remote_loader_columns (SHPLOADERCONFIG *config, PGresult *result)
 
static void pgui_quit (GtkWidget *widget, gpointer data)
 
static void pgui_action_about_open ()
 
static void pgui_action_cancel (GtkWidget *widget, gpointer data)
 
static void pgui_action_loader_options_open (GtkWidget *widget, gpointer data)
 
static void pgui_action_loader_options_close (GtkWidget *widget, gint response, gpointer data)
 
static void pgui_action_open_file_dialog (GtkWidget *widget, gpointer data)
 
static void pgui_action_open_table_dialog (GtkWidget *widget, gpointer data)
 
static void pgui_action_handle_table_remove (GtkCellRendererToggle *renderer, gchar *path, gpointer user_data)
 
static void pgui_action_import (GtkWidget *widget, gpointer data)
 
static void pgui_action_export (GtkWidget *widget, gpointer data)
 
static void process_single_uri (char *uri)
 
static void update_loader_file_config_from_listview_iter (GtkTreeIter *iter, SHPLOADERCONFIG *loader_file_config)
 
static void pgui_action_handle_file_drop (GtkWidget *widget, GdkDragContext *dc, gint x, gint y, GtkSelectionData *selection_data, guint info, guint t, gpointer data)
 
static void pgui_action_handle_tree_combo (GtkCellRendererCombo *combo, gchar *path_string, GtkTreeIter *new_iter, gpointer user_data)
 
static void pgui_action_handle_loader_edit (GtkCellRendererText *renderer, gchar *path, gchar *new_text, gpointer column)
 
static void pgui_action_handle_file_remove (GtkCellRendererToggle *renderer, gchar *path, gpointer user_data)
 
static void update_dumper_table_config_from_listview_iter (GtkTreeIter *iter, SHPDUMPERCONFIG *dumper_table_config)
 
static void pgui_action_handle_table_geocol_combo (GtkCellRendererCombo *combo, gchar *path_string, GtkTreeIter *new_iter, gpointer user_data)
 
static void pgui_action_handle_dumper_edit (GtkCellRendererText *renderer, gchar *path, gchar *new_text, gpointer column)
 
static void update_conn_config_from_conn_ui (void)
 
static void pgui_action_connection_details (GtkWidget *widget, gpointer data)
 
static int pgui_validate_connection ()
 
static void pgui_action_connection_okay (GtkWidget *widget, gpointer data)
 
static void pgui_create_about_dialog (void)
 
static void pgui_create_filechooser_dialog (void)
 
static void pgui_create_folderchooser_dialog (void)
 
static void pgui_create_progress_dialog ()
 
static void pgui_create_options_dialog_add_label (GtkWidget *table, const char *str, gfloat alignment, int row)
 
static void pgui_create_loader_options_dialog ()
 
static void pgui_create_dumper_options_dialog ()
 
static void pgui_create_tablechooser_dialog ()
 
static void pgui_create_import_file_table (GtkWidget *import_list_frame)
 
static void pgui_create_export_table_table (GtkWidget *export_list_frame)
 
static void pgui_create_connection_window ()
 
static void pgui_create_main_window (const SHPCONNECTIONCONFIG *conn)
 
static void usage ()
 
int main (int argc, char *argv[])
 

Variables

static GtkWidget * window_main = NULL
 
static GtkWidget * textview_log = NULL
 
static GtkTextBuffer * textbuffer_log = NULL
 
GtkListStore * import_file_list_store
 
GtkWidget * import_tree
 
GtkCellRenderer * import_filename_renderer
 
GtkCellRenderer * import_schema_renderer
 
GtkCellRenderer * import_table_renderer
 
GtkCellRenderer * import_geom_column_renderer
 
GtkCellRenderer * import_srid_renderer
 
GtkCellRenderer * import_mode_renderer
 
GtkCellRenderer * import_remove_renderer
 
GtkTreeViewColumn * import_filename_column
 
GtkTreeViewColumn * import_schema_column
 
GtkTreeViewColumn * import_table_column
 
GtkTreeViewColumn * import_geom_column
 
GtkTreeViewColumn * import_srid_column
 
GtkTreeViewColumn * import_mode_column
 
GtkTreeViewColumn * import_remove_column
 
static GtkWidget * add_file_button = NULL
 
GtkWidget * loader_mode_combo = NULL
 
GtkListStore * loader_mode_combo_list
 
GtkListStore * export_table_list_store
 
GtkWidget * export_tree
 
GtkWidget * export_geom_column_combo
 
GtkCellRenderer * export_schema_renderer
 
GtkCellRenderer * export_table_renderer
 
GtkCellRenderer * export_geom_column_renderer
 
GtkCellRenderer * export_filename_renderer
 
GtkCellRenderer * export_remove_renderer
 
GtkTreeViewColumn * export_schema_column
 
GtkTreeViewColumn * export_table_column
 
GtkTreeViewColumn * export_geom_column
 
GtkTreeViewColumn * export_filename_column
 
GtkTreeViewColumn * export_remove_column
 
static GtkWidget * add_table_button = NULL
 
static GtkWidget * window_conn = NULL
 
static GtkWidget * entry_pg_user = NULL
 
static GtkWidget * entry_pg_pass = NULL
 
static GtkWidget * entry_pg_host = NULL
 
static GtkWidget * entry_pg_port = NULL
 
static GtkWidget * entry_pg_db = NULL
 
static GtkWidget * dialog_loader_options = NULL
 
static GtkWidget * entry_options_encoding = NULL
 
static GtkWidget * checkbutton_loader_options_preservecase = NULL
 
static GtkWidget * checkbutton_loader_options_forceint = NULL
 
static GtkWidget * checkbutton_loader_options_autoindex = NULL
 
static GtkWidget * checkbutton_loader_options_dbfonly = NULL
 
static GtkWidget * checkbutton_loader_options_dumpformat = NULL
 
static GtkWidget * checkbutton_loader_options_geography = NULL
 
static GtkWidget * checkbutton_loader_options_simplegeoms = NULL
 
static GtkWidget * dialog_dumper_options = NULL
 
static GtkWidget * checkbutton_dumper_options_includegid = NULL
 
static GtkWidget * checkbutton_dumper_options_keep_fieldname_case = NULL
 
static GtkWidget * checkbutton_dumper_options_unescapedattrs = NULL
 
static GtkWidget * dialog_about = NULL
 
static GtkWidget * dialog_filechooser = NULL
 
static GtkWidget * dialog_folderchooser = NULL
 
static GtkWidget * dialog_progress = NULL
 
static GtkWidget * progress = NULL
 
static GtkWidget * label_progress = NULL
 
static GtkWidget * dialog_tablechooser = NULL
 
GtkListStore * chooser_filtered_table_list_store
 
GtkListStore * chooser_table_list_store
 
GtkWidget * chooser_tree
 
GtkCellRenderer * chooser_schema_renderer
 
GtkCellRenderer * chooser_table_renderer
 
GtkTreeViewColumn * chooser_schema_column
 
GtkTreeViewColumn * chooser_table_column
 
static GtkWidget * checkbutton_chooser_geoonly = NULL
 
static int valid_connection = 0
 
static char pgui_errmsg [GUIMSG_LINE_MAXLEN+1]
 
static PGconn * pg_connection = NULL
 
static SHPCONNECTIONCONFIGconn = NULL
 
static SHPLOADERCONFIGglobal_loader_config = NULL
 
static SHPDUMPERCONFIGglobal_dumper_config = NULL
 
static volatile int is_running = FALSE