Commit ffaa3e6b authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Show statusbar. (check_underlines): New code to debug underline

2004-04-07  Morten Welinder  <terra@gnome.org>

	* src/wbc-gtk.c (wbc_gtk_create_status_area): Show statusbar.
	(check_underlines): New code to debug underline collisions.
	(wbc_gtk_init): Show everything here.

	* src/workbook-control-gui.c (wbcg_set_toolbar_visible): Update
	menus too.
	(wbcg_copy_toolbar_visibility): New function.
	(show_gui): Call gtk_widget_show, not gtk_widget_show_all, so as
	not to interfere with toolbar visibility.

	* src/wbcg-actions.c (cb_view_standard_toolbar,
	cb_view_format_toolbar, cb_view_object_toolbar,
	cb_view_statusbar): Only do something when we're not already
	updating the ui.
	(var actions): Fix underline collissions.
parent d983b047
2004-04-07 Morten Welinder <terra@gnome.org>
* src/wbc-gtk.c (wbc_gtk_create_status_area): Show statusbar.
(check_underlines): New code to debug underline collisions.
(wbc_gtk_init): Show everything here.
* src/workbook-control-gui.c (wbcg_set_toolbar_visible): Update
menus too.
(wbcg_copy_toolbar_visibility): New function.
(show_gui): Call gtk_widget_show, not gtk_widget_show_all, so as
not to interfere with toolbar visibility.
* src/wbcg-actions.c (cb_view_standard_toolbar,
cb_view_format_toolbar, cb_view_object_toolbar,
cb_view_statusbar): Only do something when we're not already
updating the ui.
(var actions): Fix underline collissions.
2004-04-07 J.H.M. Dassen (Ray) <jdassen@debian.org>
* configure.in: substitute WARN_CFLAGS as
......@@ -10,7 +28,6 @@
(cb_handlebox_popup): Remove this.
(cb_handlebox_dock_status): Fiddle with style to work around
gtk_handle_box bug.
* src/workbook-control-gui.c (wbcg_set_standard_toolbar_visible,
wbcg_set_format_toolbar_visible, wbcg_set_object_toolbar_visible,
wbcg_set_statusbar_visible): New functions.
......
2004-04-07 Morten Welinder <terra@gnome.org>
* src/wbc-gtk.c (wbc_gtk_create_status_area): Show statusbar.
(check_underlines): New code to debug underline collisions.
(wbc_gtk_init): Show everything here.
* src/workbook-control-gui.c (wbcg_set_toolbar_visible): Update
menus too.
(wbcg_copy_toolbar_visibility): New function.
(show_gui): Call gtk_widget_show, not gtk_widget_show_all, so as
not to interfere with toolbar visibility.
* src/wbcg-actions.c (cb_view_standard_toolbar,
cb_view_format_toolbar, cb_view_object_toolbar,
cb_view_statusbar): Only do something when we're not already
updating the ui.
(var actions): Fix underline collissions.
2004-04-07 J.H.M. Dassen (Ray) <jdassen@debian.org>
* configure.in: substitute WARN_CFLAGS as
......@@ -10,7 +28,6 @@
(cb_handlebox_popup): Remove this.
(cb_handlebox_dock_status): Fiddle with style to work around
gtk_handle_box bug.
* src/workbook-control-gui.c (wbcg_set_standard_toolbar_visible,
wbcg_set_format_toolbar_visible, wbcg_set_object_toolbar_visible,
wbcg_set_statusbar_visible): New functions.
......
2004-04-07 Morten Welinder <terra@gnome.org>
* dialog-view.c (cb_view_ok_clicked): Copy toolbar visibility.
2004-04-01 Christian Neumair <chris@gnome-de.org>
* Makefile.am: Revert accidential commit.
......
......@@ -50,7 +50,9 @@ static void
cb_view_ok_clicked (G_GNUC_UNUSED GtkWidget *button,
ViewState *state)
{
WorkbookControl *wbc = WORKBOOK_CONTROL (state->wbcg);
WorkbookControlGUI *wbcg = state->wbcg;
WorkbookControl *wbc = WORKBOOK_CONTROL (wbcg);
WorkbookControl *new_wbc;
gboolean shared;
GdkScreen *screen = NULL;
GSList *buttons = gtk_radio_button_get_group (state->location_elsewhere);
......@@ -78,7 +80,7 @@ cb_view_ok_clicked (G_GNUC_UNUSED GtkWidget *button,
g_strdup_printf (_("Display \"%s\" could not be opened."),
name);
gtk_widget_destroy (state->dialog);
gnumeric_notice (state->wbcg, GTK_MESSAGE_ERROR, error_str);
gnumeric_notice (wbcg, GTK_MESSAGE_ERROR, error_str);
g_free (error_str);
return;
}
......@@ -91,11 +93,17 @@ cb_view_ok_clicked (G_GNUC_UNUSED GtkWidget *button,
gtk_widget_destroy (state->dialog);
(void) wb_control_wrapper_new
new_wbc = wb_control_wrapper_new
(wbc,
shared ? wb_control_view (wbc) : NULL,
wb_control_workbook (wbc),
screen);
if (IS_WORKBOOK_CONTROL_GUI (new_wbc)) {
/* What else would it be? */
WorkbookControlGUI *new_wbcg = WORKBOOK_CONTROL_GUI (new_wbc);
wbcg_copy_toolbar_visibility (new_wbcg, wbcg);
}
}
static void
......
......@@ -45,6 +45,7 @@
#include <gtk/gtkactiongroup.h>
#include <gtk/gtkuimanager.h>
#include <gtk/gtkstatusbar.h>
#include <gtk/gtkaccellabel.h>
#include <gtk/gtklabel.h>
#include <gtk/gtktoggleaction.h>
#include <gtk/gtkstock.h>
......@@ -54,6 +55,9 @@
#include <glib/gi18n.h>
#include <errno.h>
#define CHECK_MENU_UNDERLINES
struct _WBCgtk {
WorkbookControlGUI base;
......@@ -107,6 +111,7 @@ wbc_gtk_create_status_area (WorkbookControlGUI *wbcg, GtkWidget *progress,
gtk_box_pack_end (GTK_BOX (gtk->status_area), progress, TRUE, TRUE, 0);
gtk_box_pack_end (GTK_BOX (gtk->everything),
gtk->status_area, FALSE, TRUE, 0);
gtk_widget_show_all (gtk->status_area);
}
/*****************************************************************************/
......@@ -822,6 +827,75 @@ cb_handlebox_dock_status (GtkHandleBox *hb,
gtk_toolbar_set_show_arrow (toolbar, attached);
}
#ifdef CHECK_MENU_UNDERLINES
static const char *
get_accel_label (GtkMenuItem *item, char *key)
{
GList *children = gtk_container_get_children (GTK_CONTAINER (item));
GList *l;
const char *res = NULL;
*key = 0;
for (l = children; l; l = l->next) {
GtkWidget *w = l->data;
if (GTK_IS_ACCEL_LABEL (w)) {
const char *label = gtk_label_get_label (GTK_LABEL (w));
*key = 0;
while (*label) {
if (*label == '_') {
*key = g_ascii_toupper (label[1]);
break;
}
label++;
}
res = gtk_label_get_text (GTK_LABEL (w));
break;
}
}
g_list_free (children);
return res;
}
static void
check_underlines (GtkWidget *w, const char *path)
{
GList *children = gtk_container_get_children (GTK_CONTAINER (w));
GHashTable *used = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify)g_free);
GList *l;
for (l = children; l; l = l->next) {
GtkMenuItem *item = GTK_MENU_ITEM (l->data);
GtkWidget *sub = gtk_menu_item_get_submenu (item);
char key;
const char *label = get_accel_label (item, &key);
if (sub) {
char *newpath = g_strconcat (path, *path ? "->" : "", label, NULL);
check_underlines (sub, newpath);
g_free (newpath);
}
if (key) {
const char *prev = g_hash_table_lookup (used, GINT_TO_POINTER ((int)key));
if (prev)
g_warning ("In the `%s' menu, the key `%c' is used for both `%s' and `%s'.",
path, key, prev, label);
else
g_hash_table_insert (used, GINT_TO_POINTER ((int)key), g_strdup (label));
}
}
g_list_free (children);
g_hash_table_destroy (used);
}
#endif
static void
cb_add_menus_toolbars (G_GNUC_UNUSED GtkUIManager *ui,
GtkWidget *w, WBCgtk *gtk)
......@@ -1005,8 +1079,14 @@ wbc_gtk_init (GObject *obj)
wbc_gtk_reload_recent_file_menu (wbcg);
gtk_ui_manager_ensure_update (gtk->ui);
gtk_widget_show (gtk->everything);
gtk_widget_show_all (gtk->everything);
gtk_container_add (GTK_CONTAINER (wbcg->toplevel), gtk->everything);
#ifdef CHECK_MENU_UNDERLINES
gtk_container_foreach (GTK_CONTAINER (gtk->menu_zone),
(GtkCallback)check_underlines,
(gpointer)"");
#endif
}
static void
......
......@@ -1302,19 +1302,23 @@ static GNM_ACTION_DEF (cb_align_bottom)
static GNM_ACTION_DEF (cb_view_standard_toolbar)
{
wbcg_set_standard_toolbar_visible (wbcg, -1);
if (!wbcg->updating_ui)
wbcg_set_standard_toolbar_visible (wbcg, -1);
}
static GNM_ACTION_DEF (cb_view_format_toolbar)
{
wbcg_set_format_toolbar_visible (wbcg, -1);
if (!wbcg->updating_ui)
wbcg_set_format_toolbar_visible (wbcg, -1);
}
static GNM_ACTION_DEF (cb_view_object_toolbar)
{
wbcg_set_object_toolbar_visible (wbcg, -1);
if (!wbcg->updating_ui)
wbcg_set_object_toolbar_visible (wbcg, -1);
}
static GNM_ACTION_DEF (cb_view_statusbar)
{
wbcg_set_statusbar_visible (wbcg, -1);
if (!wbcg->updating_ui)
wbcg_set_statusbar_visible (wbcg, -1);
}
static GNM_ACTION_DEF (cb_merge_cells)
......@@ -1587,7 +1591,7 @@ static GtkActionEntry actions[] = {
{ "FileSummary", GTK_STOCK_PROPERTIES, N_("Proper_ties..."),
NULL, N_("Edit descriptive information"),
G_CALLBACK (cb_file_summary) },
{ "FilePreferences", GTK_STOCK_PREFERENCES, N_("Preferen_ces..."),
{ "FilePreferences", GTK_STOCK_PREFERENCES, N_("Pre_ferences..."),
NULL, N_("Change Gnumeric Preferences"),
G_CALLBACK (cb_file_preferences) },
{ "FileClose", GTK_STOCK_CLOSE, NULL,
......@@ -2129,7 +2133,7 @@ static GtkToggleActionEntry toggle_actions[] = {
N_("Toggle visibility of standard toolbar"),
G_CALLBACK (cb_view_standard_toolbar), TRUE },
{ "ViewFormatToolbar", NULL,
N_("View F_ormat Toolbar"), NULL,
N_("View Fo_rmat Toolbar"), NULL,
N_("Toggle visibility of format toolbar"),
G_CALLBACK (cb_view_format_toolbar), TRUE },
{ "ViewObjectToolbar", NULL,
......
......@@ -1655,63 +1655,88 @@ wbcg_set_status_text (WorkbookControlGUI *wbcg, char const *text)
* Output: -1 [no toolbar], 0 [was invisible], 1 [was visible].
*/
static int
wbcg_set_toolbar_visible (GtkWidget *w, int visible)
wbcg_set_toolbar_visible (WorkbookControlGUI *wbcg, GtkWidget *w,
const char *action, int visible)
{
gboolean is_visible;
gboolean was_visible;
if (w == NULL)
return -1;
g_print ("length=%d\n",
g_list_length (gtk_container_get_children (w)));
was_visible = GTK_WIDGET_VISIBLE (w);
if (visible != -2 && wbcg_ui_update_begin (wbcg)) {
if (visible == -1)
visible = !was_visible;
is_visible = GTK_WIDGET_VISIBLE (w);
switch (visible) {
case -1:
if (is_visible)
gtk_widget_hide (w);
else
if (visible)
gtk_widget_show (w);
break;
case 0:
gtk_widget_hide (w);
break;
case 1:
gtk_widget_show (w);
break;
default:
; /* Nothing */
else
gtk_widget_hide (w);
wbcg_set_toggle_action_state (wbcg, action, visible);
wbcg_ui_update_end (wbcg);
}
return is_visible;
return was_visible;
}
int
wbcg_set_standard_toolbar_visible (WorkbookControlGUI *wbcg, int visible)
{
g_return_val_if_fail (IS_WORKBOOK_CONTROL_GUI (wbcg), -1);
return wbcg_set_toolbar_visible (wbcg->standard_toolbar, visible);
return wbcg_set_toolbar_visible (wbcg,
wbcg->standard_toolbar,
"ViewStandardToolbar",
visible);
}
int
wbcg_set_format_toolbar_visible (WorkbookControlGUI *wbcg, int visible)
{
g_return_val_if_fail (IS_WORKBOOK_CONTROL_GUI (wbcg), -1);
return wbcg_set_toolbar_visible (wbcg->format_toolbar, visible);
return wbcg_set_toolbar_visible (wbcg,
wbcg->format_toolbar,
"ViewFormatToolbar",
visible);
}
int
wbcg_set_object_toolbar_visible (WorkbookControlGUI *wbcg, int visible)
{
g_return_val_if_fail (IS_WORKBOOK_CONTROL_GUI (wbcg), -1);
return wbcg_set_toolbar_visible (wbcg->object_toolbar, visible);
return wbcg_set_toolbar_visible (wbcg,
wbcg->object_toolbar,
"ViewObjectToolbar",
visible);
}
int
wbcg_set_statusbar_visible (WorkbookControlGUI *wbcg, int visible)
{
g_return_val_if_fail (IS_WORKBOOK_CONTROL_GUI (wbcg), -1);
return wbcg_set_toolbar_visible (wbcg->statusbar, visible);
return wbcg_set_toolbar_visible (wbcg,
wbcg->statusbar,
"ViewStatusbar",
visible);
}
void
wbcg_copy_toolbar_visibility (WorkbookControlGUI *new_wbcg,
WorkbookControlGUI *wbcg)
{
int visible;
visible = wbcg_set_standard_toolbar_visible (wbcg, -2);
if (visible >= 0) wbcg_set_standard_toolbar_visible (new_wbcg, 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);
if (visible >= 0) wbcg_set_object_toolbar_visible (new_wbcg, visible);
visible = wbcg_set_statusbar_visible (wbcg, -2);
if (visible >= 0) wbcg_set_statusbar_visible (new_wbcg, visible);
}
......@@ -1907,7 +1932,7 @@ show_gui (WorkbookControlGUI *wbcg)
}
x_geometry = NULL;
gtk_widget_show_all (GTK_WIDGET (wbcg->toplevel));
gtk_widget_show (GTK_WIDGET (wbcg->toplevel));
/* rehide headers if necessary */
if (wb_control_cur_sheet (WORKBOOK_CONTROL (wbcg))) {
......
......@@ -40,6 +40,9 @@ int wbcg_set_object_toolbar_visible (WorkbookControlGUI *wbcg,
int visible);
int wbcg_set_statusbar_visible (WorkbookControlGUI *wbcg,
int visible);
void wbcg_copy_toolbar_visibility (WorkbookControlGUI *new_wbcg,
WorkbookControlGUI *wbcg);
void wbcg_toggle_end_mode (WorkbookControlGUI *wbcg);
void wbcg_set_end_mode (WorkbookControlGUI *wbcg, gboolean flag);
......
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