Commit 95a7f3d0 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Destroy visibility_widgets. (wbcg_toggle_visibility): New function.

2004-08-30  Morten Welinder  <terra@gnome.org>

	* src/workbook-control-gui.c (wbcg_finalize): Destroy
	visibility_widgets.
	(wbcg_toggle_visibility): New function.
	(wbcg_copy_toolbar_visibility): Reinstate.
	(workbook_control_gui_init): Initialize visibility_widgets.

	* src/wbcg-actions.c (GNM_ACTION_DEF): Use new
	wbcg_toggle_visibility.

	* src/wbc-gtk.c (wbc_gtk_create_status_area): Add status bar to
	visibility widgets.
	(cb_toolbar_activate): Simplify.
	(cb_add_menus_toolbars): Add toolbars to visibility widgets.
	(wbc_gtk_set_toggle_action_state): Also look in toolbar actions.
	Ick -- this gets uglier by the day.

	* src/workbook-control-gui-priv.h (struct WorkbookControlGUI):
	Replace statusbar member by visibility_widgets.
parent 378bb6b5
2004-08-30 Morten Welinder <terra@gnome.org>
* src/workbook-control-gui.c (wbcg_finalize): Destroy
visibility_widgets.
(wbcg_toggle_visibility): New function.
(wbcg_copy_toolbar_visibility): Reinstate.
(workbook_control_gui_init): Initialize visibility_widgets.
* src/wbcg-actions.c (GNM_ACTION_DEF): Use new
wbcg_toggle_visibility.
* src/wbc-gtk.c (wbc_gtk_create_status_area): Add status bar to
visibility widgets.
(cb_toolbar_activate): Simplify.
(cb_add_menus_toolbars): Add toolbars to visibility widgets.
(wbc_gtk_set_toggle_action_state): Also look in toolbar actions.
Ick -- this gets uglier by the day.
* src/workbook-control-gui-priv.h (struct WorkbookControlGUI):
Replace statusbar member by visibility_widgets.
2004-08-29 Jody Goldberg <jody@gnome.org> 2004-08-29 Jody Goldberg <jody@gnome.org>
* configure.in : post release bump to .90 to indicate transition to * configure.in : post release bump to .90 to indicate transition to
......
Gnumeric 1.3.3
Morten:
* Make new windows inherit toolbar visibility from parent.
--------------------------------------------------------------------------
Gnumeric 1.3.2 Gnumeric 1.3.2
Andreas: Andreas:
......
2004-08-30 Morten Welinder <terra@gnome.org>
* src/workbook-control-gui.c (wbcg_finalize): Destroy
visibility_widgets.
(wbcg_toggle_visibility): New function.
(wbcg_copy_toolbar_visibility): Reinstate.
(workbook_control_gui_init): Initialize visibility_widgets.
* src/wbcg-actions.c (GNM_ACTION_DEF): Use new
wbcg_toggle_visibility.
* src/wbc-gtk.c (wbc_gtk_create_status_area): Add status bar to
visibility widgets.
(cb_toolbar_activate): Simplify.
(cb_add_menus_toolbars): Add toolbars to visibility widgets.
(wbc_gtk_set_toggle_action_state): Also look in toolbar actions.
Ick -- this gets uglier by the day.
* src/workbook-control-gui-priv.h (struct WorkbookControlGUI):
Replace statusbar member by visibility_widgets.
2004-08-29 Jody Goldberg <jody@gnome.org> 2004-08-29 Jody Goldberg <jody@gnome.org>
* configure.in : post release bump to .90 to indicate transition to * configure.in : post release bump to .90 to indicate transition to
......
...@@ -108,13 +108,17 @@ wbc_gtk_create_status_area (WorkbookControlGUI *wbcg, GtkWidget *progress, ...@@ -108,13 +108,17 @@ wbc_gtk_create_status_area (WorkbookControlGUI *wbcg, GtkWidget *progress,
GtkWidget *status, GtkWidget *autoexpr) GtkWidget *status, GtkWidget *autoexpr)
{ {
WBCgtk *gtk = (WBCgtk *)wbcg; WBCgtk *gtk = (WBCgtk *)wbcg;
wbcg->statusbar = gtk->status_area = gtk_hbox_new (FALSE, 2); gtk->status_area = gtk_hbox_new (FALSE, 2);
gtk_box_pack_end (GTK_BOX (gtk->status_area), status, FALSE, TRUE, 0); gtk_box_pack_end (GTK_BOX (gtk->status_area), status, FALSE, TRUE, 0);
gtk_box_pack_end (GTK_BOX (gtk->status_area), autoexpr, FALSE, TRUE, 0); gtk_box_pack_end (GTK_BOX (gtk->status_area), autoexpr, FALSE, TRUE, 0);
gtk_box_pack_end (GTK_BOX (gtk->status_area), progress, TRUE, TRUE, 0); gtk_box_pack_end (GTK_BOX (gtk->status_area), progress, TRUE, TRUE, 0);
gtk_box_pack_end (GTK_BOX (gtk->everything), gtk_box_pack_end (GTK_BOX (gtk->everything),
gtk->status_area, FALSE, TRUE, 0); gtk->status_area, FALSE, TRUE, 0);
gtk_widget_show_all (gtk->status_area); gtk_widget_show_all (gtk->status_area);
g_hash_table_insert (wbcg->visibility_widgets,
g_strdup ("ViewStatusbar"),
g_object_ref (gtk->status_area));
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -801,6 +805,8 @@ wbc_gtk_set_toggle_action_state (WorkbookControlGUI const *wbcg, ...@@ -801,6 +805,8 @@ wbc_gtk_set_toggle_action_state (WorkbookControlGUI const *wbcg,
GtkAction *a = gtk_action_group_get_action (gtk->actions, action); GtkAction *a = gtk_action_group_get_action (gtk->actions, action);
if (a == NULL) if (a == NULL)
a = gtk_action_group_get_action (gtk->font_actions, action); a = gtk_action_group_get_action (gtk->font_actions, action);
if (a == NULL)
a = gtk_action_group_get_action (gtk->toolbar.actions, action);
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (a), state); gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (a), state);
} }
...@@ -1064,25 +1070,13 @@ cb_toolbar_activate (GtkToggleAction *action, WBCgtk *gtk) ...@@ -1064,25 +1070,13 @@ cb_toolbar_activate (GtkToggleAction *action, WBCgtk *gtk)
if (wbcg->updating_ui) if (wbcg->updating_ui)
return; return;
if (wbcg_ui_update_begin (wbcg)) { if (wbcg_ui_update_begin (wbcg)) {
char *name; const char *name = gtk_action_get_name (GTK_ACTION (action));
char const *tmp; gboolean visible = gtk_toggle_action_get_active (action);
GSList *ptr, *toolbars = gtk_ui_manager_get_toplevels (gtk->ui, GtkWidget *w = g_hash_table_lookup (wbcg->visibility_widgets,
GTK_UI_MANAGER_TOOLBAR); name);
if (w)
(visible ? gtk_widget_show : gtk_widget_hide) (w);
g_object_get (G_OBJECT (action),
"label", &name,
NULL);
if (name != NULL) {
for (ptr = toolbars ; ptr != NULL ; ptr = ptr->next) {
tmp = gtk_widget_get_name (ptr->data);
if (tmp != NULL && 0 == strcmp (tmp, name))
g_object_set (G_OBJECT (gtk_widget_get_parent (GTK_WIDGET (ptr->data))),
"visible", gtk_toggle_action_get_active (action),
NULL);
}
g_free (name);
}
g_slist_free (toolbars);
wbcg_ui_update_end (wbcg); wbcg_ui_update_end (wbcg);
} }
} }
...@@ -1112,6 +1106,10 @@ cb_add_menus_toolbars (G_GNUC_UNUSED GtkUIManager *ui, ...@@ -1112,6 +1106,10 @@ cb_add_menus_toolbars (G_GNUC_UNUSED GtkUIManager *ui,
char *toggle_name = g_strdup_printf ("ViewMenuToolbar%s", name); char *toggle_name = g_strdup_printf ("ViewMenuToolbar%s", name);
char *tooltip = g_strdup_printf (_("Show/Hide toolbar %s"), name); char *tooltip = g_strdup_printf (_("Show/Hide toolbar %s"), name);
g_hash_table_insert (wbcg->visibility_widgets,
g_strdup (toggle_name),
g_object_ref (box));
gtk_container_add (GTK_CONTAINER (box), w); gtk_container_add (GTK_CONTAINER (box), w);
g_object_connect (box, g_object_connect (box,
"signal::notify::visible", G_CALLBACK (cb_handlebox_visible), wbcg, "signal::notify::visible", G_CALLBACK (cb_handlebox_visible), wbcg,
......
...@@ -1074,7 +1074,7 @@ static GNM_ACTION_DEF (cb_align_bottom) ...@@ -1074,7 +1074,7 @@ static GNM_ACTION_DEF (cb_align_bottom)
static GNM_ACTION_DEF (cb_view_statusbar) static GNM_ACTION_DEF (cb_view_statusbar)
{ {
if (!wbcg->updating_ui) if (!wbcg->updating_ui)
wbcg_set_statusbar_visible (wbcg, -1); wbcg_toggle_visibility (wbcg, GTK_TOGGLE_ACTION (a));
} }
static GNM_ACTION_DEF (cb_merge_and_center) static GNM_ACTION_DEF (cb_merge_and_center)
......
...@@ -52,7 +52,9 @@ struct _WorkbookControlGUI { ...@@ -52,7 +52,9 @@ struct _WorkbookControlGUI {
GtkWidget *table; GtkWidget *table;
GtkWidget *auto_expr_label; GtkWidget *auto_expr_label;
GtkWidget *status_text; GtkWidget *status_text;
GtkWidget *statusbar;
/* Widgets whose visibility should be copied. */
GHashTable *visibility_widgets;
/* Edit area */ /* Edit area */
GtkWidget *selection_descriptor; /* A GtkEntry */ GtkWidget *selection_descriptor; /* A GtkEntry */
......
...@@ -1545,6 +1545,8 @@ wbcg_finalize (GObject *obj) ...@@ -1545,6 +1545,8 @@ wbcg_finalize (GObject *obj)
wbcg->font_desc = NULL; wbcg->font_desc = NULL;
} }
g_hash_table_destroy (wbcg->visibility_widgets);
(*parent_class->finalize) (obj); (*parent_class->finalize) (obj);
} }
...@@ -1661,6 +1663,7 @@ wbcg_set_status_text (WorkbookControlGUI *wbcg, char const *text) ...@@ -1661,6 +1663,7 @@ wbcg_set_status_text (WorkbookControlGUI *wbcg, char const *text)
gtk_label_set_text (GTK_LABEL (wbcg->status_text), text); gtk_label_set_text (GTK_LABEL (wbcg->status_text), text);
} }
#if 0
/* /*
* Input: -2 [no change], -1 [toggle], 0 [invisible], 1 [visible]. * Input: -2 [no change], -1 [toggle], 0 [invisible], 1 [visible].
* Output: -1 [no toolbar], 0 [was invisible], 1 [was visible]. * Output: -1 [no toolbar], 0 [was invisible], 1 [was visible].
...@@ -1700,24 +1703,44 @@ wbcg_set_statusbar_visible (WorkbookControlGUI *wbcg, int visible) ...@@ -1700,24 +1703,44 @@ wbcg_set_statusbar_visible (WorkbookControlGUI *wbcg, int visible)
"ViewStatusbar", "ViewStatusbar",
visible); visible);
} }
#endif
void static void
wbcg_copy_toolbar_visibility (WorkbookControlGUI *new_wbcg, set_visibility (WorkbookControlGUI *wbcg,
WorkbookControlGUI *wbcg) const char *action_name,
gboolean visible)
{ {
#if 0 GtkWidget *w = g_hash_table_lookup (wbcg->visibility_widgets, action_name);
int visible = wbcg_set_standard_toolbar_visible (wbcg, -2); if (w)
if (visible >= 0) wbcg_set_standard_toolbar_visible (new_wbcg, visible); (visible ? gtk_widget_show : gtk_widget_hide) (w);
wbcg_set_toggle_action_state (wbcg, action_name, visible);
}
visible = wbcg_set_format_toolbar_visible (wbcg, -2);
if (visible >= 0) wbcg_set_format_toolbar_visible (new_wbcg, visible);
visible = wbcg_set_object_toolbar_visible (wbcg, -2); void
if (visible >= 0) wbcg_set_object_toolbar_visible (new_wbcg, visible); wbcg_toggle_visibility (WorkbookControlGUI *wbcg, GtkToggleAction *action)
{
set_visibility (wbcg,
gtk_action_get_name (GTK_ACTION (action)),
gtk_toggle_action_get_active (action));
}
visible = wbcg_set_statusbar_visible (wbcg, -2); static void
if (visible >= 0) wbcg_set_statusbar_visible (new_wbcg, visible); cb_visibility (const char *action, GtkWidget *orig_widget, WorkbookControlGUI *new_wbcg)
#endif {
if (wbcg_ui_update_begin (new_wbcg)) {
set_visibility (new_wbcg, action, GTK_WIDGET_VISIBLE (orig_widget));
wbcg_ui_update_end (new_wbcg);
}
}
void
wbcg_copy_toolbar_visibility (WorkbookControlGUI *new_wbcg,
WorkbookControlGUI *wbcg)
{
g_hash_table_foreach (wbcg->visibility_widgets,
(GHFunc)cb_visibility,
new_wbcg);
} }
...@@ -2515,6 +2538,11 @@ workbook_control_gui_init (WorkbookControlGUI *wbcg) ...@@ -2515,6 +2538,11 @@ workbook_control_gui_init (WorkbookControlGUI *wbcg)
wbcg->rangesel = NULL; wbcg->rangesel = NULL;
wbcg->font_desc = NULL; wbcg->font_desc = NULL;
wbcg->visibility_widgets =
g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify)g_free,
(GDestroyNotify)g_object_unref);
/* Autosave */ /* Autosave */
wbcg->autosave_timer = 0; wbcg->autosave_timer = 0;
wbcg->autosave_minutes = 0; wbcg->autosave_minutes = 0;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "workbook-control.h" #include "workbook-control.h"
#include "gui-gnumeric.h" #include "gui-gnumeric.h"
#include <gtk/gtkwindow.h> #include <gtk/gtkwindow.h>
#include <gtk/gtktoggleaction.h>
#define WORKBOOK_CONTROL_GUI_TYPE (workbook_control_gui_get_type ()) #define WORKBOOK_CONTROL_GUI_TYPE (workbook_control_gui_get_type ())
#define WORKBOOK_CONTROL_GUI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WORKBOOK_CONTROL_GUI_TYPE, WorkbookControlGUI)) #define WORKBOOK_CONTROL_GUI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WORKBOOK_CONTROL_GUI_TYPE, WorkbookControlGUI))
...@@ -33,8 +34,8 @@ void wbcg_autosave_set (WorkbookControlGUI *wbcg, ...@@ -33,8 +34,8 @@ void wbcg_autosave_set (WorkbookControlGUI *wbcg,
int minutes, gboolean prompt); int minutes, gboolean prompt);
void wbcg_set_status_text (WorkbookControlGUI *wbcg, void wbcg_set_status_text (WorkbookControlGUI *wbcg,
char const *text); char const *text);
int wbcg_set_statusbar_visible (WorkbookControlGUI *wbcg, void wbcg_toggle_visibility (WorkbookControlGUI *wbcg,
int visible); GtkToggleAction *action);
void wbcg_copy_toolbar_visibility (WorkbookControlGUI *new_wbcg, void wbcg_copy_toolbar_visibility (WorkbookControlGUI *new_wbcg,
WorkbookControlGUI *wbcg); WorkbookControlGUI *wbcg);
......
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