Commit 75968dc3 authored by Andreas J. Guelzow's avatar Andreas J. Guelzow Committed by Andreas J. Guelzow

do not use GnomePropertyBox ditto

2002-04-11  Andreas J. Guelzow <aguelzow@taliesin.ca>

	* dialog-workbook-attr.c : do not use GnomePropertyBox
	* workbook-attr.glade : ditto
parent de9b68ab
......@@ -19,6 +19,7 @@ Andreas:
* Fix Sheet-Object-Checkbox configuration dialog.
* Fix Sheet-Object Arrow/Line configuration dialog.
* Fix Sheet-Object Fill configuration dialog.
* Fix workbook attribute dialog.
Jody:
* Add password dialog to support encrypted input.
......
2002-04-11 Andreas J. Guelzow <aguelzow@taliesin.ca>
* dialog-workbook-attr.c : do not use GnomePropertyBox
* workbook-attr.glade : ditto
2002-04-10 Andreas J. Guelzow <aguelzow@taliesin.ca>
* Makefile.am : added so-fill.glade
......
......@@ -37,6 +37,7 @@
#include <application.h>
#include <workbook-control.h>
#include <workbook-view.h>
#include <workbook-edit.h>
#include <workbook.h>
#include <commands.h>
......@@ -44,17 +45,20 @@
#include <libgnome/gnome-help.h>
#include <glade/glade.h>
#define WORKBOOK_ATTRIBUTE_KEY "workbook-attribute-dialog"
typedef struct _AttrState
{
GladeXML *gui;
GnomePropertyBox *dialog;
gint page_signal;
GtkWidget *dialog;
GtkWidget *notebook;
GtkWidget *ok_button;
GtkWidget *apply_button;
gboolean destroying;
WorkbookView *wbv;
WorkbookControlGUI *wbcg;
gboolean enable_edit;
struct {
GtkToggleButton *show_hsb;
GtkToggleButton *show_vsb;
......@@ -62,23 +66,18 @@ typedef struct _AttrState
GtkToggleButton *autocomplete;
GtkToggleButton *is_protected;
} view;
struct {
gboolean show_hsb;
gboolean show_vsb;
gboolean show_tabs;
gboolean autocomplete;
gboolean is_protected;
} old;
} AttrState;
/*****************************************************************************/
/* Some utility routines shared by all pages */
/*
* A utility routine to help mark the attributes as being changed
* VERY stupid for now.
*/
static void
attr_dialog_changed (AttrState *state)
{
/* Catch all the pseudo-events that take place while initializing */
if (state->enable_edit)
gnome_property_box_changed (state->dialog);
}
/* Default to the 'View' page but remember which page we were on between
* invocations */
static int attr_dialog_page = 0;
......@@ -89,16 +88,17 @@ static int attr_dialog_page = 0;
*/
static void
cb_page_select (GtkNotebook *notebook, GtkNotebookPage *page,
gint page_num, gpointer user_data)
gint page_num, AttrState *state)
{
attr_dialog_page = page_num;
if (!state->destroying)
attr_dialog_page = page_num;
}
/*****************************************************************************/
/* Handler for the apply button */
static void
cb_attr_dialog_dialog_apply (GtkObject *w, int page, AttrState *state)
cb_attr_dialog_dialog_apply (GtkWidget *button, AttrState *state)
{
state->wbv->show_horizontal_scrollbar =
gtk_toggle_button_get_active (state->view.show_hsb);
......@@ -114,15 +114,35 @@ cb_attr_dialog_dialog_apply (GtkObject *w, int page, AttrState *state)
wb_view_prefs_update (state->wbv);
}
static void
cb_attr_dialog_dialog_close (GtkWidget *button, AttrState *state)
{
state->destroying = TRUE;
gtk_widget_destroy (state->dialog);
}
static void
cb_attr_dialog_dialog_ok (GtkWidget *button, AttrState *state)
{
cb_attr_dialog_dialog_apply (button, state);
cb_attr_dialog_dialog_close (button, state);
}
/* Handler for destroy */
static gboolean
cb_attr_dialog_dialog_destroy (GtkObject *w, AttrState *state)
{
GnomePropertyBox *box = state->dialog;
g_return_val_if_fail (w != NULL, FALSE);
g_return_val_if_fail (state != NULL, FALSE);
wbcg_edit_detach_guru (state->wbcg);
g_signal_handler_disconnect (GTK_OBJECT (box->notebook),
state->page_signal);
g_object_unref (G_OBJECT (state->gui));
if (state->gui != NULL) {
g_object_unref (G_OBJECT (state->gui));
state->gui = NULL;
}
state->dialog = NULL;
g_free (state);
return FALSE;
......@@ -133,17 +153,30 @@ cb_attr_dialog_dialog_destroy (GtkObject *w, AttrState *state)
static void
cb_toggled (GtkWidget *widget, AttrState *state)
{
attr_dialog_changed (state);
gboolean changed = !((gtk_toggle_button_get_active (state->view.show_hsb)
== state->old.show_hsb) &&
(gtk_toggle_button_get_active (state->view.show_vsb)
== state->old.show_vsb) &&
(gtk_toggle_button_get_active (state->view.show_tabs)
== state->old.show_tabs) &&
(gtk_toggle_button_get_active (state->view.autocomplete)
== state->old.autocomplete) &&
(gtk_toggle_button_get_active (state->view.is_protected)
== state->old.is_protected));
gtk_widget_set_sensitive (state->ok_button, changed);
gtk_widget_set_sensitive (state->apply_button, changed);
}
static GtkToggleButton *
attr_dialog_init_toggle (AttrState *state, char const *name, gboolean val)
attr_dialog_init_toggle (AttrState *state, char const *name, gboolean val,
gboolean *storage)
{
GtkWidget *w = glade_xml_get_widget (state->gui, name);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), val);
g_signal_connect (G_OBJECT (w),
"toggled",
G_CALLBACK (cb_toggled), state);
*storage = val;
return GTK_TOGGLE_BUTTON (w);
}
......@@ -153,69 +186,77 @@ attr_dialog_init_view_page (AttrState *state)
{
state->view.show_hsb = attr_dialog_init_toggle (state,
"WorkbookView::show_horizontal_scrollbar",
state->wbv->show_horizontal_scrollbar);
state->wbv->show_horizontal_scrollbar,
&state->old.show_hsb);
state->view.show_vsb = attr_dialog_init_toggle (state,
"WorkbookView::show_vertical_scrollbar",
state->wbv->show_vertical_scrollbar);
state->wbv->show_vertical_scrollbar,
&state->old.show_vsb);
state->view.show_tabs = attr_dialog_init_toggle (state,
"WorkbookView::show_notebook_tabs",
state->wbv->show_notebook_tabs);
state->wbv->show_notebook_tabs,
&state->old.show_tabs);
state->view.autocomplete = attr_dialog_init_toggle (state,
"WorkbookView::do_auto_completion",
state->wbv->do_auto_completion);
state->wbv->do_auto_completion,
&state->old.autocomplete);
state->view.is_protected = attr_dialog_init_toggle (state,
"WorkbookView::workbook_protected",
state->wbv->is_protected);
state->wbv->is_protected,
&state->old.is_protected);
}
/*****************************************************************************/
/*
* NOTE: We have to set the dialog title here. Looks like <title> in glade
* file doesn't work for property dialogs.
*/
static void
attr_dialog_impl (AttrState *state)
{
GtkWidget *dialog = glade_xml_get_widget (state->gui, "WorkbookAttr");
g_return_if_fail (dialog != NULL);
gtk_window_set_title (GTK_WINDOW (dialog), _("Workbook Attributes"));
/* Initialize */
state->dialog = GNOME_PROPERTY_BOX (dialog);
state->enable_edit = FALSE; /* Enable below */
state->dialog = dialog;
state->notebook = glade_xml_get_widget (state->gui, "notebook");
state->destroying = FALSE;
attr_dialog_init_view_page (state);
/* Select the same page the last invocation used */
gtk_notebook_set_page (
GTK_NOTEBOOK (GNOME_PROPERTY_BOX (dialog)->notebook),
GTK_NOTEBOOK (state->notebook),
attr_dialog_page);
state->page_signal = g_signal_connect (
G_OBJECT (GNOME_PROPERTY_BOX (dialog)->notebook),
g_signal_connect (
G_OBJECT (state->notebook),
"switch_page",
G_CALLBACK (cb_page_select), NULL);
/* FIXME : do we have real docs for this ? */
gnumeric_pbox_init_help (dialog, "format-menu.html");
G_CALLBACK (cb_page_select), state);
state->ok_button = glade_xml_get_widget (state->gui, "ok_button");
g_signal_connect (G_OBJECT (state->ok_button),
"clicked",
G_CALLBACK (cb_attr_dialog_dialog_ok), state);
state->apply_button = glade_xml_get_widget (state->gui, "apply_button");
g_signal_connect (G_OBJECT (state->apply_button),
"clicked",
G_CALLBACK (cb_attr_dialog_dialog_apply), state);
g_signal_connect (G_OBJECT (glade_xml_get_widget (state->gui, "close_button")),
"clicked",
G_CALLBACK (cb_attr_dialog_dialog_close), state);
/* FIXME: Add correct helpfile address */
gnumeric_init_help_button (
glade_xml_get_widget (state->gui, "help_button"),
"workbook-attributes.html");
g_signal_connect (G_OBJECT (dialog),
"apply",
G_CALLBACK (cb_attr_dialog_dialog_apply), state);
g_signal_connect (G_OBJECT (dialog),
"destroy",
G_CALLBACK (cb_attr_dialog_dialog_destroy), state);
/* Ok, edit events from now on are real */
state->enable_edit = TRUE;
/* Make it modal */
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
cb_toggled (NULL, state);
/* Bring up the dialog */
gnumeric_dialog_show (state->wbcg, GTK_DIALOG (dialog), FALSE, TRUE);
wbcg_edit_attach_guru (state->wbcg, state->dialog);
gnumeric_keyed_dialog (state->wbcg, GTK_WINDOW (state->dialog),
WORKBOOK_ATTRIBUTE_KEY);
gtk_widget_show (state->dialog);
}
void
......@@ -226,6 +267,9 @@ dialog_workbook_attr (WorkbookControlGUI *wbcg)
g_return_if_fail (wbcg != NULL);
if (gnumeric_dialog_raise_if_exists (wbcg, WORKBOOK_ATTRIBUTE_KEY))
return;
gui = gnumeric_glade_xml_new (wbcg, "workbook-attr.glade");
if (gui == NULL)
return;
......
......@@ -2,17 +2,86 @@
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd" >
<glade-interface>
<requires lib="gnome" />
<widget class="GnomePropertyBox" id="WorkbookAttr">
<widget class="GtkDialog" id="WorkbookAttr">
<property name="visible">no</property>
<property name="modal">no</property>
<property name="allow_shrink">no</property>
<property name="allow_grow">no</property>
<property name="window-position">GTK_WIN_POS_NONE</property>
<child internal-child="notebook">
<widget class="GtkNotebook" id="notebook1">
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">
<property name="homogeneous">no</property>
<property name="spacing">0</property>
<property name="visible">yes</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area1">
<property name="layout_style">GTK_BUTTONBOX_END</property>
<property name="border_width">10</property>
<property name="homogeneous">yes</property>
<property name="spacing">5</property>
<property name="visible">yes</property>
<child>
<widget class="GtkButton" id="close_button">
<property name="can_default">yes</property>
<property name="can_focus">yes</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="visible">yes</property>
<property name="label">gtk-close</property>
<property name="use_stock">yes</property>
<property name="use_underline">yes</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="apply_button">
<property name="can_default">yes</property>
<property name="can_focus">yes</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="visible">yes</property>
<property name="label">gtk-apply</property>
<property name="use_stock">yes</property>
<property name="use_underline">yes</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="ok_button">
<property name="can_default">yes</property>
<property name="has_default">yes</property>
<property name="can_focus">yes</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="visible">yes</property>
<property name="label">gtk-ok</property>
<property name="use_stock">yes</property>
<property name="use_underline">yes</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="help_button">
<property name="can_default">yes</property>
<property name="can_focus">yes</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="visible">yes</property>
<property name="label">gtk-help</property>
<property name="use_stock">yes</property>
<property name="use_underline">yes</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">no</property>
<property name="fill">yes</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkNotebook" id="notebook">
<property name="can_focus">yes</property>
<property name="show_tabs">yes</property>
<property name="show_border">yes</property>
......@@ -192,4 +261,6 @@
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment