Definition in file dialog_initial.c.
#include "config.h"
#include <glib.h>
#include <gtk/gtk.h>
#include <gtkextra/gtksheet.h>
#include "types.h"
#include "field.h"
#include "dialog_initial.h"
#include "menus.h"
#include "dim_list_menu.h"
#include "fileout.h"
Go to the source code of this file.
Functions | |
void | main_window (QlContext *qlc) |
Creates the main QuickList window. | |
QlContext * | ql_context_init (void) |
QlContext * | ql_get_context (GtkWidget *widget) |
locate the current context | |
static gboolean | ql_filedata_new (QlTabData *tab) |
static gboolean | ql_viewdata_new (QlTabData *tab) |
QlTabData * | ql_new_tabdata (QlContext *qlc) |
initialise data for a notebook tab | |
QlFileData * | ql_get_filedata (QlContext *qlc) |
return the file data for the current notebook tab | |
QlViewData * | ql_get_viewdata (QlContext *qlc) |
QlTabData * | ql_get_tabdata (QlContext *qlc) |
QlFieldInfo * | ql_get_fieldinfo (QlTabData *tab, gint field_index) |
gboolean | ql_add_fieldinfo (QlTabData *tab, QlFieldInfo *field) |
gboolean | ql_set_fieldinfo (QlTabData *tab, QlFieldInfo *field, gint field_index) |
Set the field information for a specific field in a tab. | |
void | ql_remove_fieldinfo (QlTabData *tab, gint field_index) |
Remove a field from the sheet. | |
gint | ql_get_last_field (QlTabData *tab) |
void | ql_fieldinfo_foreach (QlTabData *tab, QlFieldInfoCB cb, gpointer user_data) |
iterate over each field in the tab | |
void | ql_free_context (QlContext *qlc) |
void main_window | ( | QlContext * | qlc | ) |
Creates the main QuickList window.
Uses a notebook interface and remains open and visible for as long as the program is running, unlike the old version.
Definition at line 41 of file dialog_initial.c.
00042 { 00043 GtkNotebook * notebook; 00044 /* BOX that fills the list window */ 00045 GtkWidget *list_vbox; 00046 /* widget inside menu_box */ 00047 GtkWidget *list_mb; 00048 GtkWidget *data_box; 00049 GtkWidget *qlstatusbar; 00050 GdkPixbuf * qlpixbuf; 00051 GError * qlerr; 00052 gchar * pixpath; 00053 00054 qlc->parent = gtk_window_new (GTK_WINDOW_TOPLEVEL); 00055 g_signal_connect (qlc->parent, "delete_event", 00056 G_CALLBACK (file_exit), qlc->parent); 00057 g_signal_connect (qlc->parent, "destroy", 00058 G_CALLBACK (file_exit), qlc->parent); 00059 /* associate the context with the parent window. */ 00060 g_object_set_data (G_OBJECT(qlc->parent), 00061 QLCONTEXT, qlc); 00062 gtk_window_set_position (GTK_WINDOW (qlc->parent), 00063 GTK_WIN_POS_NONE); 00064 gtk_window_set_resizable (GTK_WINDOW (qlc->parent), TRUE); 00066 /* if (!tab->view->width || !tab->view->height || !tab->view->x || !tab->view->y) 00067 { 00068 tab->view->width = 600; 00069 tab->view->height = 400; 00070 tab->view->x = 100; 00071 tab->view->y = 100; 00072 } 00073 set_window_size_loc (tab->qlc->parent); 00074 */ 00075 gtk_widget_set_size_request (qlc->parent, 600, 400); 00076 00077 list_mb = build_list_mb (qlc); 00078 list_vbox = gtk_vbox_new (FALSE, 0); 00079 gtk_container_add (GTK_CONTAINER (qlc->parent), list_vbox); 00080 gtk_box_pack_start (GTK_BOX (list_vbox), list_mb, FALSE, TRUE, 0); 00081 qlerr = NULL; 00082 qlc->recent_manager = gtk_recent_manager_new (); 00083 00084 pixpath = g_strconcat (PIXMAPDIR, "/quicklist.xpm", NULL); 00085 qlpixbuf = gdk_pixbuf_new_from_file (pixpath, &qlerr); 00086 g_free (pixpath); 00087 if (qlpixbuf) 00088 { 00089 gtk_window_set_icon (GTK_WINDOW (qlc->parent), qlpixbuf); 00090 gdk_pixbuf_unref (qlpixbuf); 00091 } 00092 00093 /* make sheet and add to scroll_win */ 00094 data_box = gtk_vbox_new (FALSE, 0); 00095 gtk_box_pack_start (GTK_BOX (list_vbox), data_box, FALSE, TRUE, 0); 00096 notebook = GTK_NOTEBOOK(gtk_notebook_new()); 00097 qlc->notebook = notebook; 00098 gtk_notebook_set_scrollable (qlc->notebook, TRUE); 00099 gtk_notebook_popup_enable (qlc->notebook); 00100 gtk_notebook_set_tab_pos (qlc->notebook, GTK_POS_TOP); 00101 gtk_box_pack_start (GTK_BOX(list_vbox), 00102 GTK_WIDGET (qlc->notebook), TRUE, TRUE, 0); 00103 qlstatusbar = gtk_statusbar_new (); 00104 gtk_box_pack_end (GTK_BOX (list_vbox), qlstatusbar, FALSE, FALSE, 0); 00105 gtk_widget_show_all (qlc->parent); 00106 dim_all_menus (qlc); 00107 }
gboolean ql_add_fieldinfo | ( | QlTabData * | tab, | |
QlFieldInfo * | field | |||
) |
Add a new field to the sheet in the specified tab.
Definition at line 249 of file dialog_initial.c.
00250 { 00251 gint size; 00252 g_return_val_if_fail (tab, FALSE); 00253 g_return_val_if_fail (field, FALSE); 00254 size = g_hash_table_size (tab->file->fields); 00255 g_hash_table_insert (tab->file->fields, GINT_TO_POINTER(size) ,field); 00256 return TRUE; 00257 }
QlContext* ql_context_init | ( | void | ) |
initialise a table of notebook tab data
Definition at line 111 of file dialog_initial.c.
00112 { 00113 QlContext * qlc; 00114 00115 qlc = g_new0 (QlContext, 1); 00116 qlc->tab_table = g_hash_table_new (g_direct_hash, g_direct_equal); 00117 return qlc; 00118 }
void ql_fieldinfo_foreach | ( | QlTabData * | tab, | |
QlFieldInfoCB | cb, | |||
gpointer | user_data | |||
) |
iterate over each field in the tab
tab | The notebook tab containing the GtkSheet | |
cb | QlFieldInfoCB function to pass each field from the sheet. | |
user_data | Pointer to data to pass to the callback. |
Definition at line 287 of file dialog_initial.c.
00288 { 00289 g_return_if_fail (tab); 00290 g_hash_table_foreach (tab->file->fields, cb, user_data); 00291 }
QlContext* ql_get_context | ( | GtkWidget * | widget | ) |
locate the current context
Retrieve the QuickList Context.
Similar to how glade locates the toplevel widget, this routine retrieves the data stored in the toplevel widget and returns the QuickList Context that includes all notebook tabs.
Definition at line 128 of file dialog_initial.c.
00129 { 00130 QlContext * qlc; 00131 GtkWidget *toplevel; 00132 00133 g_return_val_if_fail (widget, NULL); 00134 toplevel = gtk_widget_get_toplevel (GTK_WIDGET(widget)); 00135 if (!toplevel) 00136 return NULL; 00137 if (GTK_WIDGET_TOPLEVEL (toplevel)) 00138 { 00139 qlc = (QlContext*) g_object_get_data (G_OBJECT(toplevel), QLCONTEXT); 00140 return qlc; 00141 } 00142 return NULL; 00143 }
QlFieldInfo* ql_get_fieldinfo | ( | QlTabData * | tab, | |
gint | field_index | |||
) |
Get information about a specific field in the tab
Definition at line 238 of file dialog_initial.c.
00239 { 00240 QlFieldInfo * field; 00241 00242 g_return_val_if_fail (tab, NULL); 00243 field = (QlFieldInfo*)g_hash_table_lookup (tab->file->fields, 00244 GINT_TO_POINTER(field_index)); 00245 return field; 00246 }
QlFileData* ql_get_filedata | ( | QlContext * | qlc | ) |
return the file data for the current notebook tab
Note the use of the context rather than the actual tab - the dim_menu functions need access via the context.
Definition at line 190 of file dialog_initial.c.
00191 { 00192 gint index; 00193 QlTabData * tab; 00194 00195 g_return_val_if_fail (qlc, NULL); 00196 g_return_val_if_fail (qlc->notebook, NULL); 00197 index = gtk_notebook_get_current_page (qlc->notebook); 00198 if (index < 0) 00199 return NULL; 00200 tab = (QlTabData*)g_hash_table_lookup (qlc->tab_table, 00201 GINT_TO_POINTER(index)); 00202 return tab->file; 00203 }
gint ql_get_last_field | ( | QlTabData * | tab | ) |
replace the last_field value
Definition at line 280 of file dialog_initial.c.
00281 { 00282 g_return_val_if_fail (tab, -1); 00283 return g_hash_table_size (tab->file->fields); 00284 }
initialise data for a notebook tab
Associates a notebook tab with it's view (sheet or report) and model (the data from the original file).
Definition at line 169 of file dialog_initial.c.
00170 { 00171 QlTabData * tab; 00172 gint nindex; 00173 00174 nindex = 0; 00175 tab = g_new0 (QlTabData, 1); 00176 g_return_val_if_fail (ql_viewdata_new (tab), NULL); 00177 g_return_val_if_fail (ql_filedata_new (tab), NULL); 00178 tab->qlc = qlc; 00179 nindex = gtk_notebook_get_n_pages (qlc->notebook); 00180 g_hash_table_insert (qlc->tab_table, GINT_TO_POINTER(nindex), tab); 00181 return tab; 00182 }
void ql_remove_fieldinfo | ( | QlTabData * | tab, | |
gint | field_index | |||
) |
Remove a field from the sheet.
Despite the name, removes the entire field - once the fieldinfo has been removed, the field itself no longer exists.
Definition at line 271 of file dialog_initial.c.
00272 { 00273 g_return_if_fail (tab); 00274 g_return_if_fail (g_hash_table_lookup(tab->file->fields, 00275 GINT_TO_POINTER(field_index))); 00276 g_hash_table_remove (tab->file->fields, GINT_TO_POINTER (field_index)); 00277 }
gboolean ql_set_fieldinfo | ( | QlTabData * | tab, | |
QlFieldInfo * | field, | |||
gint | field_index | |||
) |
Set the field information for a specific field in a tab.
tab | Pointer to the notebook tab containing the GtkSheet | |
field | Pointer to the field information to set | |
field_index | Index value for the field to change. |
Definition at line 260 of file dialog_initial.c.
00261 { 00262 g_return_val_if_fail (tab, FALSE); 00263 g_return_val_if_fail (field, FALSE); 00264 g_return_val_if_fail (g_hash_table_lookup(tab->file->fields, 00265 GINT_TO_POINTER(field_index)), FALSE); 00266 g_hash_table_replace (tab->file->fields, GINT_TO_POINTER (field_index), field); 00267 return TRUE; 00268 }