[gq-commit] gq/src browse.c,1.88,1.89 input.c,1.76,1.77 input.h,1.16,1.17
Status: Beta
Brought to you by:
sur5r
From: <sta...@us...> - 2003-10-24 19:19:50
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv16177 Modified Files: browse.c input.c input.h Log Message: * Save/Restore the state of the input form in the right pane of browse tabs Index: browse.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/browse.c,v retrieving revision 1.88 retrieving revision 1.89 diff -C2 -d -r1.88 -r1.89 *** browse.c 23 Oct 2003 05:46:23 -0000 1.88 --- browse.c 24 Oct 2003 19:17:47 -0000 1.89 *************** *** 398,401 **** --- 398,402 ---- static void browse_save_snapshot(char *state_name, struct tab *tab) { + char *tmp; state_value_set_list(state_name, "open-path", BROWSETAB(tab)->cur_path); *************** *** 405,408 **** --- 406,423 ---- gtk_paned_get_position(GTK_PANED(BROWSETAB(tab)->mainpane))); #endif + /* the state of the show empty attributes toggle button */ + + + tmp = g_malloc(strlen(state_name) + 10); + strcpy(tmp, state_name); + strcat(tmp, ".input"); + + if (BROWSETAB(tab)->inputform) { + save_input_snapshot(BROWSETAB(tab)->inputform, tmp); + } else { + rm_value(tmp); + } + + g_free(tmp); } *************** *** 425,428 **** --- 440,444 ---- int gutter = state_value_get_int(state_name, "gutter-pos", -1); const GList *path = state_value_get_list(state_name, "open-path"); + char *tmp; struct ldapserver *server = NULL; *************** *** 480,483 **** --- 496,509 ---- gtk_paned_set_position(GTK_PANED(BROWSETAB(tab)->mainpane), gutter); } + + tmp = g_malloc(strlen(state_name) + 10); + strcpy(tmp, state_name); + strcat(tmp, ".input"); + + if (BROWSETAB(tab)->inputform) { + restore_input_snapshot(BROWSETAB(tab)->inputform, tmp); + } + + g_free(tmp); } Index: input.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/input.c,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** input.c 24 Oct 2003 19:15:34 -0000 1.76 --- input.c 24 Oct 2003 19:17:47 -0000 1.77 *************** *** 104,110 **** --- 104,199 ---- } + void save_input_snapshot(struct inputform *iform, const char *state_name) + { + int hide; + GtkWidget *w; + + assert(iform); + assert(state_name); + + hide = iform->hide_status; + state_value_set_int(state_name, "hide-empty-attributes", hide); + + w = iform->scwin; + if (w) { + GtkAdjustment *adj; + int percent; + + /* saving and restoring the "upper" value works around a + problem due to the fact that when restoring the inputfrom + in the usual case (during mainwin init) the widgets are + not yet shown and the upper value of the adjustments are + not set yet (= still zero). In order to be able to + restore a value it must be between the lower and upper + values. If both are zero this cannot work. */ + adj = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(w)); + percent = adj->value / adj->upper * 100.0; + state_value_set_int(state_name, "scrolled-window-x", percent); + /* state_value_set_int(state_name, "scrolled-window-x-upper", adj->upper); */ + + adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(w)); + percent = adj->value / adj->upper * 100.0; + state_value_set_int(state_name, "scrolled-window-y", percent); + /* state_value_set_int(state_name, "scrolled-window-y-upper", adj->upper); */ + } + } + + struct snapshot_info { + struct inputform *iform; + int x, y; + }; + + static void vp_pos(GtkWidget *vp, struct snapshot_info *si) + { + GtkAdjustment *adj; + + adj = gtk_viewport_get_hadjustment(GTK_VIEWPORT(vp)); + gtk_adjustment_set_value(adj, si->x * adj->upper / 100.0); + + adj = gtk_viewport_get_vadjustment(GTK_VIEWPORT(vp)); + gtk_adjustment_set_value(adj, si->y * adj->upper / 100.0); + + gtk_signal_disconnect_by_func(GTK_OBJECT(vp), vp_pos, si); + g_free(si); + } + void restore_input_snapshot(struct inputform *iform, const char *state_name) + { + int hide; + GtkWidget *w; + + assert(iform); + assert(state_name); + + hide = state_value_get_int(state_name, "hide-empty-attributes", 0); + + w = iform->hide_attr_button; + if (w) { + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(w), hide); + } + w = iform->scwin; + if (w) { + GtkAdjustment *adj; + int x, y; + struct snapshot_info *si; + + w = GTK_BIN(w)->child; + adj = gtk_viewport_get_hadjustment(GTK_VIEWPORT(w)); + x = state_value_get_int(state_name, "scrolled-window-x", 0); + + adj = gtk_viewport_get_vadjustment(GTK_VIEWPORT(w)); + y = state_value_get_int(state_name, "scrolled-window-y", 0); + + si = g_malloc0(sizeof(struct snapshot_info)); + si->iform = iform; + si->x = x; + si->y = y; + + gtk_signal_connect(GTK_OBJECT(w), "realize", vp_pos, si); + } + } + void create_form_window(struct inputform *iform) { *************** *** 291,294 **** --- 380,384 ---- /* scrolled window with vbox2 inside */ scwin = gtk_scrolled_window_new(NULL, NULL); + iform->scwin = scwin; gtk_container_border_width(GTK_CONTAINER(scwin), 0); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scwin), Index: input.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/input.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** input.h 11 Oct 2003 21:35:29 -0000 1.16 --- input.h 24 Oct 2003 19:17:47 -0000 1.17 *************** *** 32,35 **** --- 32,36 ---- GtkWidget *parent_window; GtkWidget *target_vbox; + GtkWidget *scwin; GtkWidget *new_attr_button; GtkWidget *hide_attr_button; *************** *** 63,66 **** --- 64,69 ---- #define inputform_free free_inputform + void save_input_snapshot(struct inputform *iform, const char *state_name); + void restore_input_snapshot(struct inputform *iform, const char *state_name); /* Maybe we will align attribute labels differently in the future.. */ |