[gq-commit] gq/src browse.c,1.75,1.76 browse.h,1.26,1.27 common.h,1.25,1.26 filter.c,1.22,1.23 input
Status: Beta
Brought to you by:
sur5r
From: <sta...@us...> - 2003-10-11 21:35:35
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv12879 Modified Files: browse.c browse.h common.h filter.c input.c input.h mainwin.c mainwin.h schemabrowse.c schemabrowse.h search.c search.h Log Message: * Rewrote the mainwin tab handling: No longer have the tablist in struct mainwin_data - replaced by the mainwin notebook itself. * Changed the responsibilities for the struct tab creation: The different mode constructors now create this as well. The destroy signal is used to free all memory alloced for a tab: The struct tab used to be leaked. * Changed modes to adhere to the new handling of tabs * Got rid of fixed length buffers * Moved the inputform new/free functions from browse.c to input.c For the records: The changes to the overall operation of the mainwin wrt tab handling turned out to be not as "beautiful" as expected. There might be more to do in this area. However, the thing is a bit more OO now. Index: browse.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/browse.c,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -d -r1.75 -r1.76 *** browse.c 10 Oct 2003 06:58:59 -0000 1.75 --- browse.c 11 Oct 2003 21:35:28 -0000 1.76 *************** *** 58,61 **** --- 58,63 ---- /* #include "../icons/warning.xpm" */ + static void destroy_browse_mode(GtkWidget *w, struct tab *tab); + static gboolean button_press_on_tree_item(GtkWidget *tree, GdkEventButton *event, *************** *** 369,373 **** } ! iform = calloc(sizeof(struct inputform), 1); BROWSETAB(tab)->inputform = iform; --- 371,375 ---- } ! iform = new_inputform(); BROWSETAB(tab)->inputform = iform; *************** *** 1160,1200 **** } ! ! /* free the entry related struct inputform and data it refers to */ ! /* gtk2 checked (multiple destroy callbacks safety), confidence 0.95 */ ! void inputform_free(struct inputform *iform) ! { ! assert(iform); ! if (iform) { ! if(iform->olddn) { ! g_free(iform->olddn); ! iform->olddn = NULL; ! } ! ! if(iform->dn) { ! g_free(iform->dn); ! iform->dn = NULL; ! } ! ! if(iform->oldlist) { ! free_formlist(iform->oldlist); ! iform->oldlist = NULL; ! } ! ! if(iform->formlist) { ! free_formlist(iform->formlist); ! iform->formlist = NULL; ! } ! ! free(iform); ! } ! } ! ! ! GtkWidget *new_browsemode(struct tab *tab) { GtkWidget *ctreeroot, *browsemode_vbox, *spacer; GtkWidget *mainpane, *pane2_vbox, *pane1_scrwin, *pane2_scrwin; struct tab_browse *modeinfo; modeinfo = calloc(sizeof(struct tab_browse), 1); --- 1162,1172 ---- } ! struct tab *new_browsemode() { GtkWidget *ctreeroot, *browsemode_vbox, *spacer; GtkWidget *mainpane, *pane2_vbox, *pane1_scrwin, *pane2_scrwin; struct tab_browse *modeinfo; + struct tab *tab = g_malloc0(sizeof(struct tab)); + tab->type = BROWSE_MODE; modeinfo = calloc(sizeof(struct tab_browse), 1); *************** *** 1267,1271 **** g_string_assign(modeinfo->cur_dn, "some dummy string"); ! return(browsemode_vbox); } --- 1239,1250 ---- g_string_assign(modeinfo->cur_dn, "some dummy string"); ! /* prepare for proper cleanup */ ! gtk_signal_connect(GTK_OBJECT(browsemode_vbox), "destroy", ! GTK_SIGNAL_FUNC(destroy_browse_mode), ! (gpointer) tab); ! ! tab->content = browsemode_vbox; ! gtk_object_set_data(GTK_OBJECT(tab->content), "tab", tab); ! return tab; } *************** *** 1390,1395 **** ! void cleanup_browse_mode(struct tab *tab) { if(BROWSETAB(tab)->cur_dn) { --- 1369,1375 ---- ! static void destroy_browse_mode(GtkWidget *w, struct tab *tab) { + assert(tab); if(BROWSETAB(tab)->cur_dn) { *************** *** 1403,1406 **** --- 1383,1390 ---- } + g_free(tab->modeinfo); + tab->modeinfo = NULL; + + g_free(tab); } *************** *** 1679,1683 **** if (!IS_DN_ENTRY(entry)) return; ! iform = calloc(sizeof(struct inputform), 1); iform->dn = NULL; iform->server = server; --- 1663,1667 ---- if (!IS_DN_ENTRY(entry)) return; ! iform = new_inputform(); iform->dn = NULL; iform->server = server; *************** *** 1700,1704 **** } else { ! free(iform); } #endif /* HAVE_LDAP_STR2OBJECTCLASS */ --- 1684,1688 ---- } else { ! free_inputform(iform); } #endif /* HAVE_LDAP_STR2OBJECTCLASS */ *************** *** 1721,1725 **** /* GString *bigmessage = NULL; */ int written; - char message[512]; int ctx; --- 1705,1708 ---- *************** *** 1794,1801 **** written = fwrite(out->str, 1, out->len, outfile); if(written != out->len) { ! snprintf(message, sizeof(message), ! _("%1$d of %2$d bytes written"), ! written, out->len); ! error_popup(_("Save failed"), message); ldap_msgfree(res); --- 1777,1784 ---- written = fwrite(out->str, 1, out->len, outfile); if(written != out->len) { ! g_string_sprintf(gmessage, ! _("%1$d of %2$d bytes written"), ! written, out->len); ! error_popup(_("Save failed"), gmessage->str); ldap_msgfree(res); Index: browse.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/browse.h,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** browse.h 1 Oct 2003 22:31:06 -0000 1.26 --- browse.h 11 Oct 2003 21:35:29 -0000 1.27 *************** *** 1,5 **** /* GQ -- a GTK-based LDAP client ! Copyright (C) 1998-2001 Bert Vermeulen This program is released under the Gnu General Public License with --- 1,6 ---- /* GQ -- a GTK-based LDAP client ! Copyright (C) 1998-2003 Bert Vermeulen ! Copyright (C) 2002-2003 Peter Stamfest This program is released under the Gnu General Public License with *************** *** 138,144 **** void cleanup_browse_mode(struct tab *tab); ! GtkWidget *new_browsemode(struct tab *tab); ! ! void inputform_free(struct inputform *iform); void refresh_subtree(GtkCTree *ctree, --- 139,143 ---- void cleanup_browse_mode(struct tab *tab); ! struct tab *new_browsemode(); void refresh_subtree(GtkCTree *ctree, Index: common.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/common.h,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** common.h 9 Oct 2003 05:26:20 -0000 1.25 --- common.h 11 Oct 2003 21:35:29 -0000 1.26 *************** *** 70,74 **** --- 70,78 ---- struct tab { int type; + struct mainwin_data *win; /* what window does this tab + belong to */ GtkWidget *focus; + GtkWidget *content; /* what is the "content" + widget of the tab */ void *modeinfo; }; *************** *** 136,139 **** --- 140,149 ---- { if (x) g_free(x); (x) = NULL; } + #ifndef HAVE_REORDERABLE_G_STRING_SPRINTF + # undef g_string_sprintf + # define g_string_sprintf gq_g_string_sprintf + # define g_string_printf gq_g_string_sprintf + void gq_g_string_sprintf(GString *string, const gchar *format, ...); + #endif #endif Index: filter.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/filter.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** filter.c 9 Oct 2003 05:47:26 -0000 1.22 --- filter.c 11 Oct 2003 21:35:29 -0000 1.23 *************** *** 101,111 **** struct ldapserver *server; struct tab *tab; - int tabnum; char *filterstring, *searchstring, *servername, *searchbase, msg[192]; const char *filtername; /* find current tab */ ! tabnum = gtk_notebook_get_current_page(GTK_NOTEBOOK(mainwin.mainbook)); ! tab = g_list_nth_data(mainwin.tablist, tabnum); /* ignore if it's not a search mode tab */ --- 101,109 ---- struct ldapserver *server; struct tab *tab; char *filterstring, *searchstring, *servername, *searchbase, msg[192]; const char *filtername; /* find current tab */ ! tab = mainwin_get_current_tab(mainwin.mainbook); /* ignore if it's not a search mode tab */ *************** *** 229,233 **** gtk_widget_show(filternamebox); gtk_signal_connect_object(GTK_OBJECT(filternamebox), "activate", ! GTK_SIGNAL_FUNC(add_filter), GTK_OBJECT(filternamebox)); gtk_box_pack_start(GTK_BOX(vbox1), filternamebox, TRUE, TRUE, 0); --- 227,232 ---- gtk_widget_show(filternamebox); gtk_signal_connect_object(GTK_OBJECT(filternamebox), "activate", ! GTK_SIGNAL_FUNC(add_filter), ! GTK_OBJECT(filternamebox)); gtk_box_pack_start(GTK_BOX(vbox1), filternamebox, TRUE, TRUE, 0); *************** *** 272,280 **** GtkWidget *focusbox, *server_combo, *searchbase_combo; struct tab *tab; - int tabnum; /* find current tab */ ! tabnum = gtk_notebook_get_current_page(GTK_NOTEBOOK(mainwin.mainbook)); ! tab = g_list_nth_data(mainwin.tablist, tabnum); /* we're in luck if the current tab is a Search tab: just use this one */ --- 271,277 ---- GtkWidget *focusbox, *server_combo, *searchbase_combo; struct tab *tab; /* find current tab */ ! tab = mainwin_get_current_tab(mainwin.mainbook); /* we're in luck if the current tab is a Search tab: just use this one */ Index: input.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/input.c,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** input.c 11 Oct 2003 06:40:44 -0000 1.65 --- input.c 11 Oct 2003 21:35:29 -0000 1.66 *************** *** 69,72 **** --- 69,104 ---- + struct inputform *new_inputform() + { + struct inputform *n = g_malloc0(sizeof(struct inputform)); + return n; + } + + /* free the entry related struct inputform and data it refers to */ + /* gtk2 checked (multiple destroy callbacks safety), confidence 0.95 */ + void free_inputform(struct inputform *iform) + { + assert(iform); + if (iform) { + g_free_if(iform->olddn); + g_free_if(iform->dn); + + if(iform->oldlist) { + free_formlist(iform->oldlist); + iform->oldlist = NULL; + } + + if(iform->formlist) { + free_formlist(iform->formlist); + iform->formlist = NULL; + } + + g_free(iform); + } + } + + + + void create_form_window(struct inputform *iform) { *************** *** 894,898 **** gtk_widget_show(vbox); ! iform = calloc(sizeof(struct inputform), 1); iform->parent_window = edit_window; iform->target_vbox = vbox; --- 926,930 ---- gtk_widget_show(vbox); ! iform = new_inputform(); iform->parent_window = edit_window; iform->target_vbox = vbox; *************** *** 928,934 **** GList *formlist; struct inputform *iform; ! char *newdn; ! iform = calloc(sizeof(struct inputform), 1); iform->server = server; --- 960,966 ---- GList *formlist; struct inputform *iform; ! /* char *newdn; */ ! iform = new_inputform(); iform->server = server; *************** *** 945,948 **** --- 977,981 ---- iform->formlist = formlist; + /* FIXME: check if the following is OK */ #if 0 int i; *************** *** 959,975 **** gq_exploded_free(oldrdn); #else ! newdn = g_malloc(strlen(dn) + 1); ! /* strcpy(newdn, ","); */ /* Flawfinder: ignore */ ! strcpy(newdn, dn); /* Flawfinder: ignore */ #endif - - iform->dn = newdn; - create_form_window(iform); create_form_content(iform); build_inputform(iform); ! } ! else { ! free(iform); } --- 992,1006 ---- gq_exploded_free(oldrdn); #else ! g_free_and_dup(iform->dn, dn); #endif create_form_window(iform); create_form_content(iform); build_inputform(iform); ! } else { ! ! /* FIXME: check: does this leak memory from ! formfill_from_entry_objectclass and/or ! formlist_from_entry?? */ ! free_inputform(iform); } *************** *** 1138,1142 **** GtkCTreeNode *node; GList *formlist; - GList *tabs; struct ldapserver *server; struct formfill *ff; --- 1169,1172 ---- *************** *** 1240,1246 **** gq_exploded_free(rdn); ! for (tabs = g_list_first(mainwin.tablist) ; tabs ; ! tabs = g_list_next(tabs)) { ! tab = (struct tab *) tabs->data; if(tab->type == BROWSE_MODE) { ctree = BROWSETAB(tab)->ctreeroot; --- 1270,1277 ---- gq_exploded_free(rdn); ! for( i = 0 ; (tab = mainwin_get_tab_nth(&mainwin, i)) != NULL ; i++) { ! /* for (tabs = g_list_first(mainwin.tablist) ; tabs ; */ ! /* tabs = g_list_next(tabs)) { */ ! /* tab = (struct tab *) tabs->data; */ if(tab->type == BROWSE_MODE) { ctree = BROWSETAB(tab)->ctreeroot; Index: input.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/input.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** input.h 10 Oct 2003 06:58:59 -0000 1.15 --- input.h 11 Oct 2003 21:35:29 -0000 1.16 *************** *** 57,60 **** --- 57,67 ---- }; + + struct inputform *new_inputform(); + void free_inputform(struct inputform *iform); + /* old name */ + #define inputform_free free_inputform + + /* Maybe we will align attribute labels differently in the future.. */ #define LABEL_JUSTIFICATION 0.5 Index: mainwin.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/mainwin.c,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** mainwin.c 11 Oct 2003 13:15:24 -0000 1.41 --- mainwin.c 11 Oct 2003 21:35:29 -0000 1.42 *************** *** 1,5 **** /* GQ -- a GTK-based LDAP client ! Copyright (C) 1998-2001 Bert Vermeulen This program is released under the Gnu General Public License with --- 1,6 ---- /* GQ -- a GTK-based LDAP client ! Copyright (C) 1998-2003 Bert Vermeulen ! Copyright (C) 2002-2003 Peter Stamfest This program is released under the Gnu General Public License with *************** *** 22,25 **** --- 23,27 ---- */ + /* $Id$ */ #include <string.h> *************** *** 69,76 **** void go_to_page(struct tab *tab) { - gtk_notebook_set_page(GTK_NOTEBOOK(mainwin.mainbook), ! g_list_index(mainwin.tablist, tab)); ! } --- 71,77 ---- void go_to_page(struct tab *tab) { gtk_notebook_set_page(GTK_NOTEBOOK(mainwin.mainbook), ! gtk_notebook_page_num(GTK_NOTEBOOK(mainwin.mainbook), ! tab->content)); } *************** *** 172,175 **** --- 173,210 ---- } + /* Callback function called when a tab gets removed from the + notebook. */ + static void remove_tab(GtkContainer *notebook, + GtkWidget *content, + struct mainwin_data *win) + { + int thismode; + struct tab *tab = NULL; + int i; + + printf("REMOVED TAB 1\n"); + + tab = gtk_object_get_data(GTK_OBJECT(content), "tab"); + if (tab) { + printf("REMOVED TAB 2\n"); + thismode = tab->type; + g_hash_table_insert(win->lastofmode, (gpointer) thismode, NULL); + + /* try to find another tab with the same mode so we can put that + one into lastofmode... */ + for( i = 0 ; (tab = mainwin_get_tab_nth(win, i)) != NULL ; i++) { + if (tab->type == thismode) { + /* found one! */ + enter_last_of_mode(tab); + break; + } + } + } + + if (gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), 0) == NULL) { + gtk_widget_destroy(win->mainwin); + } + } + void create_mainwin(struct mainwin_data *win) { *************** *** 407,410 **** --- 442,450 ---- gtk_box_pack_end(GTK_BOX(main_vbox), win->statusbar, FALSE, FALSE, 5); gtk_widget_set_sensitive(win->statusbar, TRUE); + + gtk_signal_connect(GTK_OBJECT(win->mainbook), "switch-page", + GTK_SIGNAL_FUNC(switchpage_refocus), win); + gtk_signal_connect(GTK_OBJECT(win->mainbook), "remove", + GTK_SIGNAL_FUNC(remove_tab), win); new_modetab(win, SEARCH_MODE); *************** *** 412,426 **** new_modetab(win, SCHEMA_MODE | 32768); - gtk_signal_connect(GTK_OBJECT(win->mainbook), "switch-page", - GTK_SIGNAL_FUNC(switchpage_refocus), win); - gtk_widget_show(win->mainwin); } ! void new_modetab(struct mainwin_data *win, int mode) { ! GtkWidget *content, *label, *focusbox; struct tab *tab; int focus; --- 452,479 ---- new_modetab(win, SCHEMA_MODE | 32768); gtk_widget_show(win->mainwin); + } + + struct tab *mainwin_get_tab_nth(struct mainwin_data *win, int n) + { + GtkWidget *content = + gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->mainbook), n); + if (content == NULL) return NULL; + + return gtk_object_get_data(GTK_OBJECT(content), "tab"); } + struct tab *mainwin_get_current_tab(GtkWidget *notebook) + { + int tabnum = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)); + GtkWidget *content = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), + tabnum); + return gtk_object_get_data(GTK_OBJECT(content), "tab"); + } ! struct tab *new_modetab(struct mainwin_data *win, int mode) { ! GtkWidget *label, *focusbox; struct tab *tab; int focus; *************** *** 430,461 **** mode &= 32767; - tab = calloc(sizeof(struct tab), 1); - tab->type = mode; - switch(mode) { case SEARCH_MODE: label = gq_label_new(_("_Search")); ! content = new_searchmode(tab); break; case BROWSE_MODE: label = gq_label_new(_("_Browse")); ! content = new_browsemode(tab); break; #ifdef HAVE_LDAP_STR2OBJECTCLASS case SCHEMA_MODE: label = gq_label_new(_("S_chema")); ! content = new_schemamode(tab); break; #endif default: ! free(tab); ! return; } ! enter_last_of_mode(tab); gtk_widget_show(label); ! gtk_notebook_append_page(GTK_NOTEBOOK(win->mainbook), content, label); if(focus) { gtk_notebook_set_page(GTK_NOTEBOOK(win->mainbook), -1); --- 483,517 ---- mode &= 32767; switch(mode) { case SEARCH_MODE: label = gq_label_new(_("_Search")); ! tab = new_searchmode(); break; case BROWSE_MODE: label = gq_label_new(_("_Browse")); ! tab = new_browsemode(); break; #ifdef HAVE_LDAP_STR2OBJECTCLASS case SCHEMA_MODE: label = gq_label_new(_("S_chema")); ! tab = new_schemamode(); break; #endif default: ! return NULL; } ! gtk_object_set_data(GTK_OBJECT(tab->content), "tab", tab); ! ! tab->win = win; ! gtk_widget_show(label); ! gtk_notebook_append_page(GTK_NOTEBOOK(win->mainbook), ! tab->content, ! label); if(focus) { + enter_last_of_mode(tab); + gtk_notebook_set_page(GTK_NOTEBOOK(win->mainbook), -1); *************** *** 464,470 **** gtk_widget_grab_focus(focusbox); } ! ! win->tablist = g_list_append(win->tablist, tab); ! } --- 520,524 ---- gtk_widget_grab_focus(focusbox); } ! return tab; } *************** *** 475,479 **** struct tab *tab; ! tab = g_list_nth_data(win->tablist, pagenum); if(!tab) return; --- 529,533 ---- struct tab *tab; ! tab = mainwin_get_tab_nth(win, pagenum); if(!tab) return; *************** *** 487,491 **** gtk_editable_select_region(GTK_EDITABLE(focusbox), 0, -1); } - } --- 541,544 ---- *************** *** 493,511 **** void cleanup_all_tabs(struct mainwin_data *win) { - GList *tabs; - struct tab *tab; - /* don't waste time refocusing on disappearing tabs */ gtk_signal_disconnect_by_func(GTK_OBJECT(win->mainbook), GTK_SIGNAL_FUNC(switchpage_refocus), win); - - tabs = win->tablist; - while(tabs) { - tab = (struct tab *) tabs->data; - cleanup_tab(tab); - - tabs = tabs->next; - } - } --- 546,552 ---- *************** *** 513,579 **** void close_current_tab(struct mainwin_data *win) { ! GList *tl; ! int tabnum, thismode; ! struct tab *tab; - thismode = -1; tabnum = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->mainbook)); ! tab = g_list_nth_data(win->tablist, tabnum); ! ! if(tab) ! thismode = tab->type; ! ! cleanup_tab(tab); ! free(tab->modeinfo); ! free(tab); ! gtk_notebook_remove_page(GTK_NOTEBOOK(win->mainbook), tabnum); ! win->tablist = g_list_remove(win->tablist, tab); ! if(win->tablist == NULL) ! gtk_widget_destroy(win->mainwin); ! ! g_hash_table_insert(win->lastofmode, (gpointer) thismode, NULL); ! ! /* try to find another tab with the same mode so we can put that ! one into lastofmode... */ ! ! for (tl = win->tablist; tl; tl = tl->next) { ! if( ((struct tab *)(tl->data))->type == thismode) { ! /* found one! */ ! enter_last_of_mode( (struct tab *) tl->data); ! break; ! } ! } ! ! } ! ! ! void cleanup_tab(struct tab *tab) ! { ! switch(tab->type) { ! case SEARCH_MODE: ! cleanup_search_mode(tab); ! break; ! case BROWSE_MODE: ! cleanup_browse_mode(tab); ! break; ! #ifdef HAVE_LDAP_STR2OBJECTCLASS ! case SCHEMA_MODE: ! cleanup_schema_mode(); ! break; ! #endif ! } } - void update_serverlist(struct mainwin_data *win) { - GList *tabs; struct tab *tab; ! tabs = win->tablist; ! while(tabs) { ! tab = (struct tab *) tabs->data; switch(tab->type) { case SEARCH_MODE: --- 554,577 ---- void close_current_tab(struct mainwin_data *win) { ! int tabnum; ! GtkWidget *content; tabnum = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->mainbook)); ! content = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->mainbook), tabnum); ! /* for whatever reason: gtk_notebook_remove_page does not call ! the remove signal on the notebook. I consider this to be a GTK ! bug */ ! /* gtk_notebook_remove_page(GTK_NOTEBOOK(win->mainbook), tabnum); */ + gtk_widget_destroy(content); } void update_serverlist(struct mainwin_data *win) { struct tab *tab; + int i; ! for( i = 0 ; (tab = mainwin_get_tab_nth(win, i)) != NULL ; i++) { switch(tab->type) { case SEARCH_MODE: *************** *** 587,594 **** break; } - - tabs = tabs->next; } - } --- 585,589 ---- *************** *** 627,632 **** license_window = window = gtk_dialog_new(); - /* gtk_object_set_data(GTK_OBJECT(window), "close_func", */ - /* close_license_window); */ gtk_widget_set_usize(window, 540, 400); gtk_window_set_title(GTK_WINDOW(window), _("License")); --- 622,625 ---- *************** *** 732,736 **** GdkPixmap *gq_icon; GdkBitmap *gq_icon_mask; ! char title[32], about_text[512]; if (about_window) { --- 725,729 ---- GdkPixmap *gq_icon; GdkBitmap *gq_icon_mask; ! GString *about_text = NULL; if (about_window) { *************** *** 746,751 **** gtk_widget_realize(GTK_WIDGET(about_window)); /* gtk_container_border_width(GTK_CONTAINER(about_window), 12); */ ! snprintf(title, sizeof(title), _("About GQ")); ! gtk_window_set_title(GTK_WINDOW(about_window), title); gtk_window_set_policy(GTK_WINDOW(about_window), FALSE, FALSE, FALSE); --- 739,744 ---- gtk_widget_realize(GTK_WIDGET(about_window)); /* gtk_container_border_width(GTK_CONTAINER(about_window), 12); */ ! ! gtk_window_set_title(GTK_WINDOW(about_window), _("About GQ")); gtk_window_set_policy(GTK_WINDOW(about_window), FALSE, FALSE, FALSE); *************** *** 765,777 **** gtk_box_pack_start(GTK_BOX(hbox), pixmap, TRUE, TRUE, 10); ! snprintf(about_text, sizeof(about_text), ! "GQ %s\n\n\n%s\n\n" ! "GTK version %d.%d.%d\n" ! "GLib version %d.%d.%d\n", ! VERSION, about_blurb, ! gtk_major_version, gtk_minor_version, gtk_micro_version, ! glib_major_version, glib_minor_version, glib_micro_version); - about_label = gtk_label_new(about_text); gtk_label_set_justify(GTK_LABEL(about_label), GTK_JUSTIFY_LEFT); gtk_widget_show(about_label); --- 758,774 ---- gtk_box_pack_start(GTK_BOX(hbox), pixmap, TRUE, TRUE, 10); ! about_text = g_string_sized_new(512); ! ! g_string_sprintf(about_text, ! "GQ %s\n\n\n%s\n\n" ! "GTK version %d.%d.%d\n" ! "GLib version %d.%d.%d\n", ! VERSION, about_blurb, ! gtk_major_version, gtk_minor_version, gtk_micro_version, ! glib_major_version, glib_minor_version, glib_micro_version); ! ! about_label = gtk_label_new(about_text->str); ! g_string_free(about_text, TRUE); gtk_label_set_justify(GTK_LABEL(about_label), GTK_JUSTIFY_LEFT); gtk_widget_show(about_label); Index: mainwin.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/mainwin.h,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** mainwin.h 9 Oct 2003 05:47:26 -0000 1.19 --- mainwin.h 11 Oct 2003 21:35:29 -0000 1.20 *************** *** 1,5 **** /* GQ -- a GTK-based LDAP client ! Copyright (C) 1998-2001 Bert Vermeulen This program is released under the Gnu General Public License with --- 1,6 ---- /* GQ -- a GTK-based LDAP client ! Copyright (C) 1998-2003 Bert Vermeulen ! Copyright (C) 2002-2003 Peter Stamfest This program is released under the Gnu General Public License with *************** *** 40,44 **** struct mainwin_data { - GList *tablist; GtkWidget *mainwin; GtkWidget *mainbook; --- 41,44 ---- *************** *** 58,62 **** void gq_exit(GtkWidget *widget, struct mainwin_data *win); void create_mainwin(struct mainwin_data *); ! void new_modetab(struct mainwin_data *, int mode); void switchpage_refocus(GtkNotebook *notebook, GtkNotebookPage *page, int pagenum, struct mainwin_data *win); --- 58,62 ---- void gq_exit(GtkWidget *widget, struct mainwin_data *win); void create_mainwin(struct mainwin_data *); ! struct tab *new_modetab(struct mainwin_data *, int mode); void switchpage_refocus(GtkNotebook *notebook, GtkNotebookPage *page, int pagenum, struct mainwin_data *win); *************** *** 70,73 **** --- 70,77 ---- /* gboolean ctrl_b_hack(GtkWidget *widget, GdkEventKey *event, gpointer obj); */ /* gboolean ctrl_w_hack(GtkWidget *widget, GdkEventKey *event, gpointer obj); */ + + /* return the struct tab for the n'th tab in the gq main window win */ + struct tab *mainwin_get_tab_nth(struct mainwin_data *win, int n); + struct tab *mainwin_get_current_tab(GtkWidget *notebook); Index: schemabrowse.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/schemabrowse.c,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** schemabrowse.c 11 Oct 2003 12:32:11 -0000 1.23 --- schemabrowse.c 11 Oct 2003 21:35:30 -0000 1.24 *************** *** 90,95 **** LDAPSyntax *s); ! GtkWidget *new_schemamode(struct tab *tab) { GtkWidget *schemamode_vbox, *rightpane_vbox, *spacer; --- 90,96 ---- LDAPSyntax *s); + static void destroy_schema_mode(GtkWidget *w, struct tab *tab); ! struct tab *new_schemamode() { GtkWidget *schemamode_vbox, *rightpane_vbox, *spacer; *************** *** 98,101 **** --- 99,105 ---- struct tab_schema *modeinfo; + struct tab *tab = g_malloc0(sizeof(struct tab)); + tab->type = SCHEMA_MODE; + modeinfo = calloc(sizeof(struct tab_schema), 1); tab->modeinfo = modeinfo; *************** *** 144,148 **** gtk_widget_show(schemamode_vbox); ! return(schemamode_vbox); } --- 148,159 ---- gtk_widget_show(schemamode_vbox); ! ! gtk_signal_connect(GTK_OBJECT(schemamode_vbox), "destroy", ! GTK_SIGNAL_FUNC(destroy_schema_mode), ! tab); ! ! tab->content = schemamode_vbox; ! gtk_object_set_data(GTK_OBJECT(tab->content), "tab", tab); ! return tab; } *************** *** 1854,1862 **** #endif /* HAVE_LDAP_STR2OBJECTCLASS */ ! void cleanup_schema_mode(void) { ! /* the whole thing is stateless! */ ! } --- 1865,1877 ---- #endif /* HAVE_LDAP_STR2OBJECTCLASS */ ! static void destroy_schema_mode(GtkWidget *w, struct tab *tab) { + assert(tab); + /* the whole thing is (almost) stateless! */ ! g_free(tab->modeinfo); ! tab->modeinfo = NULL; ! ! g_free(tab); } Index: schemabrowse.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/schemabrowse.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** schemabrowse.h 11 Oct 2003 09:17:21 -0000 1.10 --- schemabrowse.h 11 Oct 2003 21:35:30 -0000 1.11 *************** *** 55,59 **** ! GtkWidget *new_schemamode(struct tab *tab); void popup_detail(enum schema_detail_type type, struct ldapserver *server, void *detail); --- 55,59 ---- ! struct tab *new_schemamode(); void popup_detail(enum schema_detail_type type, struct ldapserver *server, void *detail); Index: search.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/search.c,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** search.c 11 Oct 2003 06:40:44 -0000 1.44 --- search.c 11 Oct 2003 21:35:30 -0000 1.45 *************** *** 1,5 **** /* GQ -- a GTK-based LDAP client ! Copyright (C) 1998-2002 Bert Vermeulen This program is released under the Gnu General Public License with --- 1,6 ---- /* GQ -- a GTK-based LDAP client ! Copyright (C) 1998-2003 Bert Vermeulen ! Copyright (C) 2002-2003 Peter Stamfest This program is released under the Gnu General Public License with *************** *** 53,59 **** GdkEventButton *event, struct tab *tab); ! GtkWidget *new_searchmode(struct tab *tab) { GtkWidget *main_clist, *searchmode_vbox, *hbox1, *scrwin; --- 54,61 ---- GdkEventButton *event, struct tab *tab); + static void destroy_search_mode(GtkWidget *w, struct tab *tab); ! struct tab *new_searchmode() { GtkWidget *main_clist, *searchmode_vbox, *hbox1, *scrwin; *************** *** 63,67 **** struct tab_search *modeinfo; ! modeinfo = calloc(sizeof(struct tab_search), 1); tab->modeinfo = modeinfo; --- 65,72 ---- struct tab_search *modeinfo; ! struct tab *tab = g_malloc0(sizeof(struct tab)); ! tab->type = SEARCH_MODE; ! ! modeinfo = g_malloc0(sizeof(struct tab_search)); tab->modeinfo = modeinfo; *************** *** 150,154 **** gtk_widget_show(searchmode_vbox); ! return(searchmode_vbox); } --- 155,165 ---- gtk_widget_show(searchmode_vbox); ! gtk_signal_connect(GTK_OBJECT(searchmode_vbox), "destroy", ! GTK_SIGNAL_FUNC(destroy_search_mode), ! tab); ! ! tab->content = searchmode_vbox; ! gtk_object_set_data(GTK_OBJECT(tab->content), "tab", tab); ! return tab; } *************** *** 968,972 **** ! void cleanup_search_mode(struct tab *tab) { GtkWidget *main_clist; --- 979,983 ---- ! static void destroy_search_mode(GtkWidget *w, struct tab *tab) { GtkWidget *main_clist; *************** *** 974,977 **** --- 985,990 ---- struct resultset *cur_resultset; + assert(tab); + cur_resultset = SEARCHTAB(tab)->cur_resultset; if(cur_resultset) { *************** *** 996,999 **** --- 1009,1016 ---- } + g_free(tab->modeinfo); + tab->modeinfo = NULL; + + g_free(tab); } Index: search.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/search.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** search.h 11 Oct 2003 06:40:44 -0000 1.10 --- search.h 11 Oct 2003 21:35:30 -0000 1.11 *************** *** 56,60 **** }; ! GtkWidget *new_searchmode(struct tab *tab); void servername_changed_callback(struct tab *tab); gint searchbase_button_pressed(GtkWidget *widget, GdkEventButton *event, struct tab *tab); --- 56,60 ---- }; ! struct tab *new_searchmode(); void servername_changed_callback(struct tab *tab); gint searchbase_button_pressed(GtkWidget *widget, GdkEventButton *event, struct tab *tab); |