diff --git a/configure.in b/configure.in index ce757a4..1f6c44d 100644 --- a/configure.in +++ b/configure.in @@ -119,7 +119,7 @@ if test "$no_glib" = "yes"; then exit 1 fi -PKG_CHECK_MODULES(GNOME,libglade-2.0 libgnomeui-2.0, HAVE_GNOME=true, HAVE_GNOME=false) +PKG_CHECK_MODULES(GNOME,gtk+-2.0 >= 2.5 libglade-2.0 libgnomeui-2.0, HAVE_GNOME=true, HAVE_GNOME=false) AC_ARG_ENABLE(gmdb2, AC_HELP_STRING([--disable-gmdb2], [do not build gmdb2]), diff --git a/src/gmdb2/Makefile.am b/src/gmdb2/Makefile.am index 941be1c..0130d15 100644 --- a/src/gmdb2/Makefile.am +++ b/src/gmdb2/Makefile.am @@ -1,8 +1,9 @@ SUBDIRS = help gladefiles pixmaps bin_PROGRAMS = gmdb2 include_HEADERS = gmdb.h -gmdb2_SOURCES = main2.c file.c util.c table.c query.c module.c macro.c report.c form.c info.c table_def.c table_data.c table_export.c debug.c sql.c schema.c prefs.c -LIBS = -rdynamic $(GNOME_LIBS) @LIBS@ @LEXLIB@ + +gmdb2_SOURCES = main2.c file.c util.c table.c info.c table_def.c table_data.c table_export.c debug.c sql.c schema.c prefs.c +LIBS = -rdynamic $(GNOME_LIBS) @LIBS@ @LEXLIB@ AM_CPPFLAGS = -I$(top_srcdir)/include \ $(GNOME_CFLAGS) \ -DDATADIR="\"$(datadir)\"" \ diff --git a/src/gmdb2/file.c b/src/gmdb2/file.c index d1378d1..ec696ab 100644 --- a/src/gmdb2/file.c +++ b/src/gmdb2/file.c @@ -18,6 +18,8 @@ #include "gmdb.h" #include +#include +#include #include #include #include @@ -27,6 +29,14 @@ MdbHandle *mdb; extern int main_show_debug; extern GladeXML *mainwin_xml; +#define MAX_ACTIONITEMS 7 +#define MAX_ICONVIEWS 6 +typedef struct { + GtkWidget* actionitems[MAX_ACTIONITEMS]; + GtkWidget* iconviews[MAX_ICONVIEWS]; +} GmdbWidgets; +GmdbWidgets* gmdbwidgets = NULL; + static void gmdb_file_open_recent(gchar *menuname) { gchar *text, cfgname[100]; @@ -103,15 +113,98 @@ gmdb_file_add_recent(gchar *file_path) gnome_config_set_string("/gmdb/RecentFiles/menu_recent1.filepath", file_path); gnome_config_sync(); } + +static void +gmdb_reset_widgets (GmdbWidgets* gw) { + int i; + GtkWidget *w; + + gmdb_table_set_sensitive (FALSE); + + for (i = 0; i < MAX_ACTIONITEMS; ++i) { + w = gw->actionitems[i]; + gtk_widget_set_sensitive (w, FALSE); + } + for (i = 0; i < MAX_ICONVIEWS; ++i) { + w = gw->iconviews[i]; + gtk_list_store_clear (GTK_LIST_STORE (gtk_icon_view_get_model (GTK_ICON_VIEW (w)))); + } + + w = glade_xml_get_widget (mainwin_xml, "gmdb"); + gtk_window_set_title (GTK_WINDOW (w), "MDB File Viewer"); +} + +static void +gmdb_icon_list_fill (MdbHandle* mdb, GtkTreeModel* store, GdkPixbuf* pixbuf, int objtype) { + int i; + MdbCatalogEntry* entry; + GtkTreeIter iter; + + for (i=0; i < mdb->num_catalog; i++) { + entry = g_ptr_array_index (mdb->catalog, i); + if (entry->object_type == objtype) { + /* skip the MSys tables - FIXME: can other objects be hidden too? */ + if (objtype != MDB_TABLE || mdb_is_user_table (entry)) { + gtk_list_store_prepend (GTK_LIST_STORE (store), &iter); + gtk_list_store_set (GTK_LIST_STORE (store), &iter, 0, pixbuf, 1, entry->object_name, -1); + } + } + } +} + +static void +gmdb_file_init (void) { + GtkWidget* w; + GtkListStore* store; + int i; + gchar* ainames[] = { "sql_menu", "debug_menu", "schema_menu", "info_menu", "sql_button", "schema_button", "info_button" }; + gchar* swnames[] = { "sw_form", "sw_macro", "sw_module", "sw_query", "sw_report", "sw_table" }; + + if (gmdbwidgets) { + return; + } + + gmdbwidgets = g_new0 (GmdbWidgets, 1); + + for (i = 0; i < MAX_ACTIONITEMS; ++i) { + gmdbwidgets->actionitems[i] = glade_xml_get_widget (mainwin_xml, ainames[i]); + } + for (i = 0; i < MAX_ICONVIEWS; ++i) { + store = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_STRING); + + gmdbwidgets->iconviews[i] = gtk_icon_view_new(); + gtk_icon_view_set_model (GTK_ICON_VIEW (gmdbwidgets->iconviews[i]), GTK_TREE_MODEL (store)); + gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (gmdbwidgets->iconviews[i]), 0); + gtk_icon_view_set_text_column (GTK_ICON_VIEW (gmdbwidgets->iconviews[i]), 1); + + w = glade_xml_get_widget (mainwin_xml, swnames[i]); + gtk_container_add (GTK_CONTAINER (w), gmdbwidgets->iconviews[i]); + gtk_widget_show_all (w); + } + + g_signal_connect_after (gmdbwidgets->iconviews[5], "selection-changed", G_CALLBACK (gmdb_table_select_cb), NULL); + gmdb_table_init_popup (gmdbwidgets->iconviews[5]); +} + void gmdb_file_open(gchar *file_path) { GtkWidget *win; + GdkPixbuf *pixbuf; + GtkTreeModel *store; gchar *file_name; gchar title[100]; int i; + gchar* pbnames[] = { GMDB_ICONDIR "form_big.xpm", GMDB_ICONDIR "macro_big.xpm", + GMDB_ICONDIR "module_big.xpm", GMDB_ICONDIR "query_big.xpm", GMDB_ICONDIR "report_big.xpm", + GMDB_ICONDIR "table_big.xpm" }; + int objtype[] = { MDB_FORM, MDB_MACRO, MDB_MODULE, MDB_QUERY, MDB_REPORT, MDB_TABLE }; - gmdb_reset_widgets(); + if (!gmdbwidgets) { + gmdb_file_init(); + } + + gmdb_reset_widgets (gmdbwidgets); mdb = mdb_open(file_path, MDB_NOFLAGS); if (!mdb) { GtkWidget* dlg = gtk_message_dialog_new (NULL, @@ -127,12 +220,14 @@ gmdb_file_open(gchar *file_path) sql->mdb = mdb; mdb_read_catalog(mdb, MDB_ANY); - gmdb_table_populate(mdb); - gmdb_query_populate(mdb); - gmdb_form_populate(mdb); - gmdb_report_populate(mdb); - gmdb_macro_populate(mdb); - gmdb_module_populate(mdb); + + for (i = 0; i < MAX_ICONVIEWS; ++i) { + store = gtk_icon_view_get_model (GTK_ICON_VIEW (gmdbwidgets->iconviews[i])); + pixbuf = gdk_pixbuf_new_from_file (pbnames[i], NULL); + gmdb_icon_list_fill (mdb, store, pixbuf, objtype[i]); + g_object_unref (pixbuf); + } + //if (main_show_debug) gmdb_debug_init(mdb); for (i=strlen(file_path);i>0 && file_path[i-1]!='/';i--); @@ -142,7 +237,10 @@ gmdb_file_open(gchar *file_path) g_snprintf(title, 100, "%s - MDB File Viewer",file_name); gtk_window_set_title(GTK_WINDOW(win), title); - gmdb_set_sensitive(TRUE); + for (i = 0; i < MAX_ACTIONITEMS; ++i) { + win = gmdbwidgets->actionitems[i]; + gtk_widget_set_sensitive (win, TRUE); + } } void @@ -180,7 +278,7 @@ gmdb_file_select_cb(GtkWidget *button, gpointer data) void gmdb_file_close_cb(GtkWidget *button, gpointer data) { - gmdb_reset_widgets(); + gmdb_reset_widgets (gmdbwidgets); gmdb_debug_close_all(); gmdb_sql_close_all(); } diff --git a/src/gmdb2/form.c b/src/gmdb2/form.c deleted file mode 100644 index 4e2a5bc..0000000 --- a/src/gmdb2/form.c +++ /dev/null @@ -1,48 +0,0 @@ -/* MDB Tools - A library for reading MS Access database file - * Copyright (C) 2000 Brian Bruns - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#include "gmdb.h" -#include - -extern GladeXML* mainwin_xml; -extern GtkWidget *app; - -static void -gmdb_form_add_icon(gchar *text) -{ -GnomeIconList *gil; - - gil = (GnomeIconList *) glade_xml_get_widget(mainwin_xml, "form_iconlist"); - gnome_icon_list_append(gil, GMDB_ICONDIR "form_big.xpm", text); -} - -void gmdb_form_populate(MdbHandle *mdb) -{ -int i; -MdbCatalogEntry *entry; - - /* loop over each entry in the catalog */ - for (i=0; i < mdb->num_catalog; i++) { - entry = g_ptr_array_index (mdb->catalog, i); - - /* if it's a form */ - if (entry->object_type == MDB_FORM) { - /* add table to tab */ - gmdb_form_add_icon(entry->object_name); - } /* if MDB_FORM */ - } /* for */ -} diff --git a/src/gmdb2/gladefiles/gmdb.glade b/src/gmdb2/gladefiles/gmdb.glade index 124d917..5ee8d2c 100644 --- a/src/gmdb2/gladefiles/gmdb.glade +++ b/src/gmdb2/gladefiles/gmdb.glade @@ -54,6 +54,7 @@ True + False GNOMEUIINFO_MENU_PROPERTIES_ITEM @@ -169,6 +170,7 @@ True + False S_QL Window True @@ -190,6 +192,7 @@ True + False _Debug Window True @@ -210,6 +213,7 @@ True + False E_xport Schema True @@ -315,6 +319,7 @@ True + False View database file properties gtk-properties @@ -333,6 +338,7 @@ True + False Perform SQL query gtk-execute @@ -345,6 +351,7 @@ True + False Export schema definition gtk-convert @@ -404,7 +411,7 @@ GTK_SHADOW_IN - + True True GTK_POLICY_AUTOMATIC @@ -412,21 +419,6 @@ GTK_SHADOW_NONE GTK_CORNER_TOP_LEFT - - - True - True - GTK_SELECTION_SINGLE - 78 - 8 - 8 - 2 - False - True - - - - @@ -571,7 +563,7 @@ GTK_SHADOW_IN - + True True GTK_POLICY_AUTOMATIC @@ -579,19 +571,6 @@ GTK_SHADOW_NONE GTK_CORNER_TOP_LEFT - - - True - True - GTK_SELECTION_SINGLE - 78 - 8 - 8 - 2 - False - False - - @@ -692,7 +671,7 @@ GTK_SHADOW_IN - + True True GTK_POLICY_AUTOMATIC @@ -700,19 +679,6 @@ GTK_SHADOW_NONE GTK_CORNER_TOP_LEFT - - - True - True - GTK_SELECTION_SINGLE - 78 - 8 - 8 - 2 - False - False - - @@ -813,7 +779,7 @@ GTK_SHADOW_IN - + True True GTK_POLICY_AUTOMATIC @@ -821,19 +787,6 @@ GTK_SHADOW_NONE GTK_CORNER_TOP_LEFT - - - True - True - GTK_SELECTION_SINGLE - 78 - 8 - 8 - 2 - False - False - - @@ -934,7 +887,7 @@ GTK_SHADOW_IN - + True True GTK_POLICY_AUTOMATIC @@ -942,19 +895,6 @@ GTK_SHADOW_NONE GTK_CORNER_TOP_LEFT - - - True - True - GTK_SELECTION_SINGLE - 78 - 8 - 8 - 2 - False - False - - @@ -1055,7 +995,7 @@ GTK_SHADOW_IN - + True True GTK_POLICY_AUTOMATIC @@ -1063,19 +1003,6 @@ GTK_SHADOW_NONE GTK_CORNER_TOP_LEFT - - - True - True - GTK_SELECTION_SINGLE - 78 - 8 - 8 - 2 - False - False - - diff --git a/src/gmdb2/gmdb.h b/src/gmdb2/gmdb.h index a5cd25a..f162a75 100644 --- a/src/gmdb2/gmdb.h +++ b/src/gmdb2/gmdb.h @@ -5,7 +5,6 @@ #include #include #include -#include #include #ifndef _gmdb_h_ @@ -24,8 +23,6 @@ void gmdb_prefs_cb(GtkWidget *w, gpointer data); void gmdb_help_cb(GtkWidget *w, gpointer data); void gmdb_about_cb(GtkWidget *w, gpointer data); void gmdb_load_recent_files(void); -void gmdb_reset_widgets(void); -void gmdb_set_sensitive(gboolean b); GtkWidget *gmdb_table_data_new(MdbCatalogEntry *entry); GtkWidget *gmdb_table_def_new(MdbCatalogEntry *entry); @@ -46,13 +43,6 @@ void gmdb_file_open(gchar *file_path); void gmdb_sql_new_window_cb(GtkWidget *w, gpointer data); -void gmdb_table_populate(MdbHandle *mdb); -void gmdb_form_populate(MdbHandle *mdb); -void gmdb_query_populate(MdbHandle *mdb); -void gmdb_report_populate(MdbHandle *mdb); -void gmdb_macro_populate(MdbHandle *mdb); -void gmdb_module_populate(MdbHandle *mdb); - void gmdb_table_add_tab(GtkWidget *notebook); void gmdb_debug_tab_new(GtkWidget *notebook); @@ -85,11 +75,11 @@ void gmdb_schema_help_cb(GtkWidget *w, gpointer data); /* table.c */ void gmdb_table_debug_cb(GtkList *list, GtkWidget *w, gpointer data); void gmdb_table_export_cb(GtkList *list, GtkWidget *w, gpointer data); -void gmdb_table_unselect_cb(GnomeIconList *gil, int num, GdkEvent *ev, gpointer data); -void gmdb_table_select_cb(GnomeIconList *gil, int num, GdkEvent *ev, gpointer data); void gmdb_table_def_cb(GtkList *list, GtkWidget *w, gpointer data); +void gmdb_table_unselect_cb (GtkIconView*, gpointer); +void gmdb_table_select_cb (GtkIconView*, gpointer); void gmdb_table_data_cb(GtkList *list, GtkWidget *w, gpointer data); -void gmdb_table_init_popup(void); +void gmdb_table_init_popup (GtkWidget*); void gmdb_table_set_sensitive(gboolean b); /* table_export.c */ @@ -103,13 +93,6 @@ char gmdb_export_get_quotechar(GladeXML *xml); int gmdb_export_get_headers(GladeXML *xml); gchar *gmdb_export_get_filepath(GladeXML *xml); -extern GtkWidget *table_list; -extern GtkWidget *form_list; -extern GtkWidget *query_list; -extern GtkWidget *report_list; -extern GtkWidget *macro_list; -extern GtkWidget *module_list; - extern MdbSQL *sql; #ifdef __cplusplus diff --git a/src/gmdb2/macro.c b/src/gmdb2/macro.c deleted file mode 100644 index 0cd6035..0000000 --- a/src/gmdb2/macro.c +++ /dev/null @@ -1,48 +0,0 @@ -/* MDB Tools - A library for reading MS Access database file - * Copyright (C) 2000 Brian Bruns - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#include "gmdb.h" -#include - -extern GladeXML* mainwin_xml; -extern GtkWidget *app; - -static void -gmdb_macro_add_icon(gchar *text) -{ -GnomeIconList *gil; - - gil = (GnomeIconList *) glade_xml_get_widget (mainwin_xml, "macro_iconlist"); - gnome_icon_list_append(gil, GMDB_ICONDIR "macro_big.xpm", text); -} - -void gmdb_macro_populate(MdbHandle *mdb) -{ -int i; -MdbCatalogEntry *entry; - - /* loop over each entry in the catalog */ - for (i=0; i < mdb->num_catalog; i++) { - entry = g_ptr_array_index (mdb->catalog, i); - - /* if it's a macro */ - if (entry->object_type == MDB_MACRO) { - /* add table to tab */ - gmdb_macro_add_icon(entry->object_name); - } /* if MDB_MACRO */ - } /* for */ -} diff --git a/src/gmdb2/main2.c b/src/gmdb2/main2.c index 85e884d..89eed0e 100644 --- a/src/gmdb2/main2.c +++ b/src/gmdb2/main2.c @@ -123,64 +123,6 @@ gchar *text, *text2; g_free(text); } } -void -gmdb_reset_widgets() -{ - GnomeIconList *gil; - GtkWidget *win; - - gil = (GnomeIconList *) glade_xml_get_widget (mainwin_xml, "table_iconlist"); - gnome_icon_list_clear(gil); - gmdb_table_set_sensitive(FALSE); - gil = (GnomeIconList *) glade_xml_get_widget (mainwin_xml, "query_iconlist"); - gnome_icon_list_clear(gil); - gil = (GnomeIconList *) glade_xml_get_widget (mainwin_xml, "form_iconlist"); - gnome_icon_list_clear(gil); - gil = (GnomeIconList *) glade_xml_get_widget (mainwin_xml, "report_iconlist"); - gnome_icon_list_clear(gil); - gil = (GnomeIconList *) glade_xml_get_widget (mainwin_xml, "macro_iconlist"); - gnome_icon_list_clear(gil); - gil = (GnomeIconList *) glade_xml_get_widget (mainwin_xml, "module_iconlist"); - gnome_icon_list_clear(gil); - - win = (GtkWidget *) glade_xml_get_widget (mainwin_xml, "gmdb"); - gtk_window_set_title(GTK_WINDOW(win), "MDB File Viewer"); - gmdb_set_sensitive(FALSE); - -} - -void -gmdb_set_sensitive(gboolean b) -{ - GtkWidget *mi, *button; - - mi = (GtkWidget *) glade_xml_get_widget (mainwin_xml, "sql_menu"); - gtk_widget_set_sensitive(mi,b); - - mi = (GtkWidget *) glade_xml_get_widget (mainwin_xml, "debug_menu"); - gtk_widget_set_sensitive(mi,b); - - mi = (GtkWidget *) glade_xml_get_widget (mainwin_xml, "schema_menu"); - gtk_widget_set_sensitive(mi,b); - - mi = (GtkWidget *) glade_xml_get_widget (mainwin_xml, "info_menu"); - gtk_widget_set_sensitive(mi,b); - - button = (GtkWidget *) glade_xml_get_widget (mainwin_xml, "sql_button"); - gtk_widget_set_sensitive(button,b); - - button = (GtkWidget *) glade_xml_get_widget (mainwin_xml, "schema_button"); - gtk_widget_set_sensitive(button,b); - - button = (GtkWidget *) glade_xml_get_widget (mainwin_xml, "info_button"); - gtk_widget_set_sensitive(button,b); -} - -static void -gmdb_init_popups() -{ - gmdb_table_init_popup(); -} static void gmdb_load_icons(GladeXML *xml) @@ -260,12 +202,9 @@ GnomeProgram *program; if (argc>1) { gmdb_file_open(argv[1]); - } else { - gmdb_reset_widgets(); } gmdb_load_recent_files(); - gmdb_init_popups(); /* start the event loop */ gtk_main(); diff --git a/src/gmdb2/module.c b/src/gmdb2/module.c deleted file mode 100644 index 6110cc7..0000000 --- a/src/gmdb2/module.c +++ /dev/null @@ -1,48 +0,0 @@ -/* MDB Tools - A library for reading MS Access database file - * Copyright (C) 2000 Brian Bruns - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#include "gmdb.h" -#include - -extern GladeXML* mainwin_xml; -extern GtkWidget *app; - -static void -gmdb_module_add_icon(gchar *text) -{ -GnomeIconList *gil; - - gil = (GnomeIconList *) glade_xml_get_widget (mainwin_xml, "module_iconlist"); - gnome_icon_list_append(gil, GMDB_ICONDIR "module_big.xpm", text); -} - -void gmdb_module_populate(MdbHandle *mdb) -{ -int i; -MdbCatalogEntry *entry; - - /* loop over each entry in the catalog */ - for (i=0; i < mdb->num_catalog; i++) { - entry = g_ptr_array_index (mdb->catalog, i); - - /* if it's a module */ - if (entry->object_type == MDB_MODULE) { - /* add table to tab */ - gmdb_module_add_icon(entry->object_name); - } /* if MDB_MODULE */ - } /* for */ -} diff --git a/src/gmdb2/prefs.c b/src/gmdb2/prefs.c index 73327d6..1a1e8c7 100644 --- a/src/gmdb2/prefs.c +++ b/src/gmdb2/prefs.c @@ -17,6 +17,8 @@ */ #include "gmdb.h" +#include + extern GtkWidget *app; extern MdbHandle *mdb; diff --git a/src/gmdb2/query.c b/src/gmdb2/query.c deleted file mode 100644 index a3871f3..0000000 --- a/src/gmdb2/query.c +++ /dev/null @@ -1,49 +0,0 @@ -/* MDB Tools - A library for reading MS Access database file - * Copyright (C) 2000 Brian Bruns - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#include "gmdb.h" -#include - -extern GladeXML* mainwin_xml; -GtkWidget *query_list; -extern GtkWidget *app; - -static void -gmdb_query_add_icon(gchar *text) -{ -GnomeIconList *gil; - - gil = (GnomeIconList *) glade_xml_get_widget (mainwin_xml, "query_iconlist"); - gnome_icon_list_append(gil, GMDB_ICONDIR "query_big.xpm", text); - -} - -void gmdb_query_populate(MdbHandle *mdb) -{ -int i; -MdbCatalogEntry *entry; - - /* loop over each entry in the catalog */ - for (i=0; i < mdb->num_catalog; i++) { - entry = g_ptr_array_index (mdb->catalog, i); - - /* if it's a query */ - if (entry->object_type == MDB_QUERY) { - gmdb_query_add_icon(entry->object_name); - } /* if MDB_QUERY */ - } /* for */ -} diff --git a/src/gmdb2/report.c b/src/gmdb2/report.c deleted file mode 100644 index a8aabf8..0000000 --- a/src/gmdb2/report.c +++ /dev/null @@ -1,48 +0,0 @@ -/* MDB Tools - A library for reading MS Access database file - * Copyright (C) 2000 Brian Bruns - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#include "gmdb.h" -#include - -extern GladeXML* mainwin_xml; -extern GtkWidget *app; - -static void -gmdb_report_add_icon(gchar *text) -{ -GnomeIconList *gil; - - gil = (GnomeIconList *) glade_xml_get_widget (mainwin_xml, "report_iconlist"); - gnome_icon_list_append(gil, GMDB_ICONDIR "report_big.xpm", text); -} - -void gmdb_report_populate(MdbHandle *mdb) -{ -int i; -MdbCatalogEntry *entry; - - /* loop over each entry in the catalog */ - for (i=0; i < mdb->num_catalog; i++) { - entry = g_ptr_array_index (mdb->catalog, i); - - /* if it's a report */ - if (entry->object_type == MDB_REPORT) { - /* add table to tab */ - gmdb_report_add_icon(entry->object_name); - } /* if MDB_REPORT */ - } /* for */ -} diff --git a/src/gmdb2/table.c b/src/gmdb2/table.c index 4db77d1..9b76aef 100644 --- a/src/gmdb2/table.c +++ b/src/gmdb2/table.c @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "gmdb.h" + +#include #include GtkWidget *table_list; @@ -83,23 +85,36 @@ MdbCatalogEntry *entry; gmdb_table_data_new(entry); } + void -gmdb_table_unselect_cb(GnomeIconList *gil, int num, GdkEvent *ev, gpointer data) -{ - selected_table = -1; - gmdb_table_set_sensitive(FALSE); -} -void -gmdb_table_select_cb(GnomeIconList *gil, int num, GdkEvent *ev, gpointer data) -{ +gmdb_table_select_cb (GtkIconView* giv, gpointer data) { int i; MdbCatalogEntry *entry; gchar *text; - - text = (gchar *) gnome_icon_list_get_icon_data(gil, num); + GList *selection; + GtkTreeModel *store; + GtkTreePath *path; + GtkTreeIter iter; selected_table = -1; - + + selection = gtk_icon_view_get_selected_items (giv); + if (g_list_length (selection) < 1) { + gmdb_table_set_sensitive (FALSE); + g_list_free (selection); + return; + } + + store = gtk_icon_view_get_model (giv); + path = (GtkTreePath*) selection->data; + if (!gtk_tree_model_get_iter (store, &iter, path)) { + /* FIXME */ + g_error ("Failed to get selection iter!!!"); + g_list_foreach (selection, (GFunc) gtk_tree_path_free, NULL); + g_list_free (selection); + } + + gtk_tree_model_get (store, &iter, 1, &text, -1); for (i=0;inum_catalog;i++) { entry = g_ptr_array_index(mdb->catalog,i); if (entry->object_type==MDB_TABLE && @@ -107,36 +122,32 @@ gmdb_table_select_cb(GnomeIconList *gil, int num, GdkEvent *ev, gpointer data) selected_table = i; } } + g_free (text); if (selected_table>0) { gmdb_table_set_sensitive(TRUE); } else { gmdb_table_set_sensitive(FALSE); } - -} -static gboolean -gmdb_table_popup_cb(GtkWidget *menu, GdkEvent *event) -{ - GdkEventButton *event_button; - GnomeIconList *gil; - gdouble x,y; - int num; - - gil = (GnomeIconList *) glade_xml_get_widget (mainwin_xml, "table_iconlist"); - if (selected_table == -1) return FALSE; + g_list_foreach (selection, (GFunc) gtk_tree_path_free, NULL); + g_list_free (selection); +} + +static gboolean +gmdb_table_popup_cb (GtkIconView* giv, GdkEvent* event, gpointer data) { + GtkWidget* menu = GTK_WIDGET (data); + GdkEventButton *event_button; + int num; + if (event->type == GDK_BUTTON_PRESS) { event_button = (GdkEventButton *) event; - x = event_button->x; - y = event_button->y; - num = gnome_icon_list_get_icon_at(gil, x, y); - if (num != -1) { - gnome_icon_list_select_icon(gil, num); - } if (event_button->button == 3) { - gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, - event_button->button, event_button->time); - return TRUE; + GtkTreePath *path = gtk_icon_view_get_path_at_pos (giv, (gint) event_button->x, (gint) event_button->y); + if (path) { + gtk_icon_view_select_path (giv, path); + gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event_button->button, event_button->time); + return TRUE; + } } } return FALSE; @@ -157,29 +168,26 @@ gmdb_table_set_sensitive(gboolean b) gtk_widget_set_sensitive(button,b); } void -gmdb_table_init_popup() -{ -GnomeIconList *gil; +gmdb_table_init_popup (GtkWidget* w) { GtkWidget *menu, *mi; - - gil = (GnomeIconList *) glade_xml_get_widget (mainwin_xml, "table_iconlist"); + GtkIconView *giv = GTK_ICON_VIEW (w); menu = gtk_menu_new(); gtk_widget_show(menu); mi = gtk_menu_item_new_with_label("Definition"); gtk_widget_show(mi); g_signal_connect_swapped (G_OBJECT (mi), "activate", - G_CALLBACK (gmdb_table_def_cb), gil); + G_CALLBACK (gmdb_table_def_cb), giv); gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); mi = gtk_menu_item_new_with_label("Data"); gtk_widget_show(mi); g_signal_connect_swapped (G_OBJECT (mi), "activate", - G_CALLBACK (gmdb_table_data_cb), gil); + G_CALLBACK (gmdb_table_data_cb), giv); gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); mi = gtk_menu_item_new_with_label("Export"); gtk_widget_show(mi); g_signal_connect_swapped (G_OBJECT (mi), "activate", - G_CALLBACK (gmdb_table_export_cb), gil); + G_CALLBACK (gmdb_table_export_cb), giv); gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); mi = gtk_separator_menu_item_new(); gtk_widget_show(mi); @@ -187,37 +195,11 @@ GtkWidget *menu, *mi; mi = gtk_menu_item_new_with_label("Debug"); gtk_widget_show(mi); g_signal_connect_swapped (G_OBJECT (mi), "activate", - G_CALLBACK (gmdb_table_debug_cb), gil); + G_CALLBACK (gmdb_table_debug_cb), giv); gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); //mi = gtk_menu_item_new_with_label("Usage Map"); //gtk_widget_show(mi); //gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); - g_signal_connect_swapped (GTK_OBJECT (gil), "button_press_event", - G_CALLBACK (gmdb_table_popup_cb), GTK_OBJECT(menu)); + g_signal_connect (giv, "button_press_event", G_CALLBACK (gmdb_table_popup_cb), menu); } -static void -gmdb_table_add_icon(gchar *text) -{ -GnomeIconList *gil; -int pos; - - gil = (GnomeIconList *) glade_xml_get_widget (mainwin_xml, "table_iconlist"); - - pos = gnome_icon_list_append(gil, GMDB_ICONDIR "table_big.xpm", text); - gnome_icon_list_set_icon_data(gil, pos, text); -} - -void gmdb_table_populate(MdbHandle *mdb) -{ -int i; -MdbCatalogEntry *entry; - - /* add all user tables in catalog to tab */ - for (i=0; i < mdb->num_catalog; i++) { - entry = g_ptr_array_index (mdb->catalog, i); - if (mdb_is_user_table(entry)) { - gmdb_table_add_icon(entry->object_name); - } - } /* for */ -}