GitLab repository storage has been migrated to hashed layout. Please contact Infrastructure team if you notice any issues with repositories or hooks.

Commit 01d2a205 authored by GMT 1999 Andy Thomas's avatar GMT 1999 Andy Thomas Committed by Andy Thomas

New app/dialog_handler.c app/dialog_handler.h


Sun Jan 10 22:41:51 GMT 1999 Andy Thomas <alt@picnic.demon.co.uk>

	New
	* app/dialog_handler.c
	* app/dialog_handler.h

	Changed
	* app/disp_callbacks.c
	* app/gradient_select.c
	* app/tools.c
	* app/interface.c
	* app/patterns.c
	* app/gimpbrushlist.c
	* app/palette.c
	* app/layers_dialog.c
	* app/devices.c
	* app/errorconsole.c

	Can now hide/show all main dialogs using the TAB key in any window.
	However....
	there is a bug in gtk that causes the Gimp the crash if you show
	and then hide a lot of dialogs (eg if you have all dialogs visible
	and press the TAB key repeatedly). I have email-ed an example to
	the gtk bug list.
	Also I can't seem to be able to catch the SHIFT-TAB combination
	(suggestions welcome ;-) so the first press of the tab hide all
	dialogs the second press reshows only the toolbox and the third
	press reshows all. Comments please if you find this behaviour
	non-intuitive.
parent 31fba3b3
Sun Jan 10 22:41:51 GMT 1999 Andy Thomas <alt@picnic.demon.co.uk>
New
* app/dialog_handler.c
* app/dialog_handler.h
Changed
* app/disp_callbacks.c
* app/gradient_select.c
* app/tools.c
* app/interface.c
* app/patterns.c
* app/gimpbrushlist.c
* app/palette.c
* app/layers_dialog.c
* app/devices.c
* app/errorconsole.c
Can now hide/show all main dialogs using the TAB key in any window.
However....
there is a bug in gtk that causes the Gimp the crash if you show
and then hide a lot of dialogs (eg if you have all dialogs visible
and press the TAB key repeatedly). I have email-ed an example to
the gtk bug list.
Also I can't seem to be able to catch the SHIFT-TAB combination
(suggestions welcome ;-) so the first press of the tab hide all
dialogs the second press reshows only the toolbox and the third
press reshows all. Comments please if you find this behaviour
non-intuitive.
Sun Jan 10 21:42:11 GMT 1999 Austin Donnelly <austin@greenend.org.uk>
* app/brush_select.c
......
......@@ -108,6 +108,8 @@ gimp_SOURCES = \
devices.c \
devices.h \
dialog_types.h \
dialog_handler.c \
dialog_handler.h \
disp_callbacks.c \
disp_callbacks.h \
docindex.c \
......
......@@ -29,6 +29,7 @@
#include "palette.h"
#include "session.h"
#include "tools.h"
#include "dialog_handler.h"
#include "libgimp/gimpintl.h"
......@@ -127,7 +128,10 @@ create_input_dialog (void)
if (!inputd)
{
inputd = gtk_input_dialog_new();
/* register this one only */
dialog_register(inputd);
gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG(inputd)->action_area), 2);
gtk_signal_connect (GTK_OBJECT(GTK_INPUT_DIALOG(inputd)->save_button),
......@@ -654,6 +658,9 @@ create_device_status (void)
deviceD = g_new (DeviceInfoDialog, 1);
deviceD->shell = gtk_dialog_new ();
/* register this one only */
dialog_register(deviceD->shell);
gtk_window_set_title (GTK_WINDOW(deviceD->shell), _("Device Status"));
gtk_window_set_policy (GTK_WINDOW (deviceD->shell), FALSE, FALSE, TRUE);
session_set_window_geometry (deviceD->shell, &device_status_session_info, TRUE);
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
* Copyright (C) 1999 Andy Thomas (alt@picnic.demon.co.uk)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "appenv.h"
#include "errors.h"
#include "general.h"
#include "dialog_handler.h"
static GSList * active_dialogs = NULL; /* List of dialogs that have
been created and are on
screen (may be hiddenalready).
*/
static gint doing_update = FALSE; /* Prevent multiple keypresse
from unsetting me.
*/
/* State of individual dialogs */
typedef struct _dialog_state DIALOGSTATE,*DIALOGSTATEP;
typedef enum {
WAS_HIDDEN,
WAS_SHOWING,
UNKNOWN,
} dialogstate;
struct _dialog_state {
GtkWidget *d;
dialogstate state;
};
/* This keeps track of the state the dialogs are in */
/* ie howmany times we have pressed the tab key */
typedef enum{
SHOW_ALL,
HIDE_ALL,
SHOW_TOOLBOX,
LAST_SHOW_STATE,
} ShowState;
static ShowState dialogs_showing = SHOW_ALL; /* Start off with all
dialogs showing
*/
static DIALOGSTATEP toolbox_shell = NULL; /* Copy of the shelll for the tool
box this has special behavour
so is not on the normal list.
*/
/* Private */
/* Hide all currently registered dialogs */
static void
dialog_hide_all()
{
GSList *list = active_dialogs;
DIALOGSTATEP dstate;
while (list)
{
dstate = (DIALOGSTATEP) list->data;
list = g_slist_next (list);
if(GTK_WIDGET_VISIBLE (dstate->d))
{
dstate->state = WAS_SHOWING;
gtk_widget_hide(dstate->d);
}
else
{
dstate->state = WAS_HIDDEN;
}
}
}
/* Show all currently registered dialogs */
static void
dialog_show_all()
{
GSList * list = active_dialogs;
DIALOGSTATEP dstate;
while (list)
{
dstate = (DIALOGSTATEP) list->data;
list = g_slist_next (list);
if(dstate->state == WAS_SHOWING && !GTK_WIDGET_VISIBLE (dstate->d))
gtk_widget_show(dstate->d);
}
}
/* Handle the tool box in a special way */
static void
dialog_show_toolbox()
{
if(toolbox_shell &&
toolbox_shell->state == WAS_SHOWING &&
!GTK_WIDGET_VISIBLE (toolbox_shell->d))
{
gtk_widget_show(toolbox_shell->d);
}
}
static void
dialog_hide_toolbox()
{
if(toolbox_shell && GTK_WIDGET_VISIBLE (toolbox_shell->d))
{
gtk_widget_hide(toolbox_shell->d);
toolbox_shell->state = WAS_SHOWING;
}
}
/* public */
/* Register a dialog that we can handle */
void
dialog_register(GtkWidget *dialog)
{
DIALOGSTATEP dstatep = g_new(DIALOGSTATE,1);
dstatep->d = dialog;
dstatep->state = UNKNOWN;
active_dialogs = g_slist_append (active_dialogs,dstatep);
}
void
dialog_register_toolbox(GtkWidget *dialog)
{
DIALOGSTATEP dstatep = g_new(DIALOGSTATE,1);
dstatep->d = dialog;
dstatep->state = UNKNOWN;
toolbox_shell = dstatep;
}
/* unregister dialog */
void
dialog_unregister(GtkWidget *dialog)
{
GSList * list = active_dialogs;
DIALOGSTATEP dstate = NULL;
while (list)
{
dstate = (DIALOGSTATEP) list->data;
list = g_slist_next (list);
if(dstate->d == dialog)
break;
}
if(dstate != NULL)
active_dialogs = g_slist_remove (active_dialogs,dstate);
}
/* Toggle showing of dialogs */
/* States:-
* SHOW_ALL -> HIDE_ALL -> SHOW_TOOLBOX -> SHOW_ALL ....
*/
void
dialog_toggle(gint leavetoolbox)
{
if(doing_update == FALSE)
doing_update = TRUE;
else
return;
switch(dialogs_showing)
{
case SHOW_ALL:
dialogs_showing = HIDE_ALL;
dialog_hide_all();
dialog_hide_toolbox();
break;
case HIDE_ALL:
dialogs_showing = SHOW_TOOLBOX;
dialog_show_toolbox();
break;
case SHOW_TOOLBOX:
dialogs_showing = SHOW_ALL;
dialog_show_all();
default:
break;
}
gdk_flush();
while (gtk_events_pending())
{
gtk_main_iteration();
gdk_flush();
}
doing_update = FALSE;
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
* Copyright (C) 1999 Andy Thomas
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __DIALOG_HANDLER_H_
#define __DIALOG_HANDLER_H_
void dialog_register(GtkWidget *dialog);
void dialog_register_toolbox(GtkWidget *dialog);
void dialog_unregister(GtkWidget *dialog);
void dialog_toggle();
#endif /* __DIALOG_HANDLER_H_ */
......@@ -32,7 +32,7 @@
#include "scroll.h"
#include "tools.h"
#include "gimage.h"
#include "dialog_handler.h"
#define HORIZONTAL 1
#define VERTICAL 2
......@@ -372,6 +372,11 @@ gdisplay_canvas_events (GtkWidget *canvas,
layer_select_init (gdisp->gimage, 1, kevent->time);
if (kevent->state & GDK_CONTROL_MASK && !gimage_is_empty (gdisp->gimage))
layer_select_init (gdisp->gimage, -1, kevent->time);
/* Hide or show all dialogs */
if (!kevent->state)
dialog_toggle();
return_val = TRUE;
break;
......
......@@ -32,7 +32,7 @@
#include "scroll.h"
#include "tools.h"
#include "gimage.h"
#include "dialog_handler.h"
#define HORIZONTAL 1
#define VERTICAL 2
......@@ -372,6 +372,11 @@ gdisplay_canvas_events (GtkWidget *canvas,
layer_select_init (gdisp->gimage, 1, kevent->time);
if (kevent->state & GDK_CONTROL_MASK && !gimage_is_empty (gdisp->gimage))
layer_select_init (gdisp->gimage, -1, kevent->time);
/* Hide or show all dialogs */
if (!kevent->state)
dialog_toggle();
return_val = TRUE;
break;
......
......@@ -32,7 +32,7 @@
#include "scroll.h"
#include "tools.h"
#include "gimage.h"
#include "dialog_handler.h"
#define HORIZONTAL 1
#define VERTICAL 2
......@@ -372,6 +372,11 @@ gdisplay_canvas_events (GtkWidget *canvas,
layer_select_init (gdisp->gimage, 1, kevent->time);
if (kevent->state & GDK_CONTROL_MASK && !gimage_is_empty (gdisp->gimage))
layer_select_init (gdisp->gimage, -1, kevent->time);
/* Hide or show all dialogs */
if (!kevent->state)
dialog_toggle();
return_val = TRUE;
break;
......
......@@ -442,6 +442,10 @@ create_toolbox ()
GtkAccelGroup *table;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
/* Register dialog */
dialog_register_toolbox(window);
gtk_window_set_wmclass (GTK_WINDOW (window), "toolbox", "Gimp");
gtk_window_set_title (GTK_WINDOW (window), _("The GIMP"));
session_set_window_geometry (window, &toolbox_session_info, TRUE);
......
......@@ -442,6 +442,10 @@ create_toolbox ()
GtkAccelGroup *table;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
/* Register dialog */
dialog_register_toolbox(window);
gtk_window_set_wmclass (GTK_WINDOW (window), "toolbox", "Gimp");
gtk_window_set_title (GTK_WINDOW (window), _("The GIMP"));
session_set_window_geometry (window, &toolbox_session_info, TRUE);
......
......@@ -31,6 +31,7 @@
#include "commands.h"
#include "session.h"
#include "dialog_handler.h"
#include "libgimp/gimpintl.h"
......@@ -202,6 +203,10 @@ error_console_create_window (void)
GtkWidget *menuitem;
error_console = gtk_dialog_new ();
/* register this one only */
dialog_register(error_console);
gtk_window_set_title (GTK_WINDOW (error_console), _("GIMP Error console"));
session_set_window_geometry (error_console, &error_console_session_info, TRUE);
/* The next line should disappear when setting the size works in SM */
......
......@@ -41,6 +41,7 @@
#include "gimpbrush.h"
#include "gimplistP.h"
#include "gimpbrushlistP.h"
#include "dialog_handler.h"
#include "libgimp/gimpintl.h"
......@@ -409,6 +410,9 @@ create_brush_dialog ()
{
/* Create the dialog... */
brush_select_dialog = brush_select_new (NULL,NULL,0.0,0,0);
/* register this one only */
dialog_register(brush_select_dialog->shell);
}
else
{
......
......@@ -53,6 +53,7 @@
#include "palette.h"
#include "session.h"
#include "actionarea.h"
#include "dialog_handler.h"
#include "libgimp/gimpintl.h"
......@@ -463,6 +464,7 @@ gsel_new_selection(gchar * title,
/* The shell and main vbox */
gsp->shell = gtk_dialog_new ();
gtk_window_set_wmclass (GTK_WINDOW (gsp->shell), "gradselection", "Gimp");
gtk_window_set_policy(GTK_WINDOW(gsp->shell), FALSE, TRUE, FALSE);
......@@ -567,7 +569,10 @@ grad_create_gradient_editor(void)
if(gradient_select_dialog == NULL)
{
gradient_select_dialog = gsel_new_selection(_("Gradients"),NULL);
/* register this one only */
dialog_register(gradient_select_dialog->shell);
session_set_window_geometry (gradient_select_dialog->shell, &gradient_select_session_info, TRUE);
}
else
......
......@@ -29,6 +29,7 @@
#include "palette.h"
#include "session.h"
#include "tools.h"
#include "dialog_handler.h"
#include "libgimp/gimpintl.h"
......@@ -127,7 +128,10 @@ create_input_dialog (void)
if (!inputd)
{
inputd = gtk_input_dialog_new();
/* register this one only */
dialog_register(inputd);
gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG(inputd)->action_area), 2);
gtk_signal_connect (GTK_OBJECT(GTK_INPUT_DIALOG(inputd)->save_button),
......@@ -654,6 +658,9 @@ create_device_status (void)
deviceD = g_new (DeviceInfoDialog, 1);
deviceD->shell = gtk_dialog_new ();
/* register this one only */
dialog_register(deviceD->shell);
gtk_window_set_title (GTK_WINDOW(deviceD->shell), _("Device Status"));
gtk_window_set_policy (GTK_WINDOW (deviceD->shell), FALSE, FALSE, TRUE);
session_set_window_geometry (deviceD->shell, &device_status_session_info, TRUE);
......
......@@ -53,6 +53,7 @@
#include "palette.h"
#include "session.h"
#include "actionarea.h"
#include "dialog_handler.h"
#include "libgimp/gimpintl.h"
......@@ -463,6 +464,7 @@ gsel_new_selection(gchar * title,
/* The shell and main vbox */
gsp->shell = gtk_dialog_new ();
gtk_window_set_wmclass (GTK_WINDOW (gsp->shell), "gradselection", "Gimp");
gtk_window_set_policy(GTK_WINDOW(gsp->shell), FALSE, TRUE, FALSE);
......@@ -567,7 +569,10 @@ grad_create_gradient_editor(void)
if(gradient_select_dialog == NULL)
{
gradient_select_dialog = gsel_new_selection(_("Gradients"),NULL);
/* register this one only */
dialog_register(gradient_select_dialog->shell);
session_set_window_geometry (gradient_select_dialog->shell, &gradient_select_session_info, TRUE);
}
else
......
......@@ -29,6 +29,7 @@
#include "palette.h"
#include "session.h"
#include "tools.h"
#include "dialog_handler.h"
#include "libgimp/gimpintl.h"
......@@ -127,7 +128,10 @@ create_input_dialog (void)
if (!inputd)
{
inputd = gtk_input_dialog_new();
/* register this one only */
dialog_register(inputd);
gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG(inputd)->action_area), 2);
gtk_signal_connect (GTK_OBJECT(GTK_INPUT_DIALOG(inputd)->save_button),
......@@ -654,6 +658,9 @@ create_device_status (void)
deviceD = g_new (DeviceInfoDialog, 1);
deviceD->shell = gtk_dialog_new ();
/* register this one only */
dialog_register(deviceD->shell);
gtk_window_set_title (GTK_WINDOW(deviceD->shell), _("Device Status"));
gtk_window_set_policy (GTK_WINDOW (deviceD->shell), FALSE, FALSE, TRUE);
session_set_window_geometry (deviceD->shell, &device_status_session_info, TRUE);
......
......@@ -59,6 +59,8 @@
#include "layer_pvt.h"
#include "dialog_handler.h"
#define PREVIEW_EVENT_MASK GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_ENTER_NOTIFY_MASK
#define BUTTON_EVENT_MASK GDK_EXPOSURE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | \
......@@ -309,7 +311,10 @@ lc_dialog_create (GimpImage* gimage)
if (lc_shell == NULL)
{
lc_shell = gtk_dialog_new ();
/* register this one only */
dialog_register(lc_shell);
gtk_window_set_title (GTK_WINDOW (lc_shell), _("Layers & Channels"));
gtk_window_set_wmclass (GTK_WINDOW (lc_shell), "layers_and_channels", "Gimp");
session_set_window_geometry (lc_shell, &lc_dialog_session_info, TRUE);
......
......@@ -40,6 +40,7 @@
#include "palette_entries.h"
#include "session.h"
#include "palette_select.h"
#include "dialog_handler.h"
#include "libgimp/gimpintl.h"
......@@ -1027,6 +1028,9 @@ palette_create()
top_level_palette = new_top_palette(TRUE);
/* top_level_palette = palette_new_selection(_("Palette"),NULL); */
session_set_window_geometry (top_level_palette->shell, &palette_session_info, TRUE);
/* register this one only */
dialog_register(top_level_palette->shell);
gtk_widget_show(top_level_palette->shell);
palette_scroll_clist_to_current(top_level_palette);
}
......
......@@ -442,6 +442,10 @@ create_toolbox ()
GtkAccelGroup *table;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
/* Register dialog */
dialog_register_toolbox(window);
gtk_window_set_wmclass (GTK_WINDOW (window), "toolbox", "Gimp");
gtk_window_set_title (GTK_WINDOW (window), _("The GIMP"));
session_set_window_geometry (window, &toolbox_session_info, TRUE);
......
......@@ -59,6 +59,8 @@
#include "layer_pvt.h"
#include "dialog_handler.h"
#define PREVIEW_EVENT_MASK GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_ENTER_NOTIFY_MASK
#define BUTTON_EVENT_MASK GDK_EXPOSURE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | \
......@@ -309,7 +311,10 @@ lc_dialog_create (GimpImage* gimage)
if (lc_shell == NULL)
{
lc_shell = gtk_dialog_new ();
/* register this one only */
dialog_register(lc_shell);
gtk_window_set_title (GTK_WINDOW (lc_shell), _("Layers & Channels"));
gtk_window_set_wmclass (GTK_WINDOW (lc_shell), "layers_and_channels", "Gimp");
session_set_window_geometry (lc_shell, &lc_dialog_session_info, TRUE);
......
......@@ -40,6 +40,7 @@
#include "palette_entries.h"
#include "session.h"
#include "palette_select.h"
#include "dialog_handler.h"
#include "libgimp/gimpintl.h"
......@@ -1027,6 +1028,9 @@ palette_create()
top_level_palette = new_top_palette(TRUE);
/* top_level_palette = palette_new_selection(_("Palette"),NULL); */
session_set_window_geometry (top_level_palette->shell, &palette_session_info, TRUE);
/* register this one only */
dialog_register(top_level_palette->shell);
gtk_widget_show(top_level_palette->shell);
palette_scroll_clist_to_current(top_level_palette);
}
......
......@@ -35,6 +35,7 @@
#include "general.h"
#include "gimprc.h"
#include "menus.h"
#include "dialog_handler.h"
#include "libgimp/gimpintl.h"
......@@ -307,6 +308,9 @@ create_pattern_dialog ()
{
/* Create the dialog... */
pattern_select_dialog = pattern_select_new (NULL,NULL);
/* register this one only */
dialog_register(pattern_select_dialog->shell);
}
else
{
......
......@@ -56,6 +56,7 @@
#include "threshold.h"
#include "tools.h"
#include "transform_tool.h"
#include "dialog_handler.h"
#include "config.h"
#include "libgimp/gimpintl.h"
......@@ -702,6 +703,10 @@ tools_options_dialog_new ()
/* The shell and main vbox */
options_shell = gtk_dialog_new ();
/* Register dialog */
dialog_register(options_shell);
gtk_window_set_wmclass (GTK_WINDOW (options_shell), "tool_options", "Gimp");
gtk_window_set_title (GTK_WINDOW (options_shell), _("Tool Options"));
gtk_window_set_policy (GTK_WINDOW (options_shell), FALSE, TRUE, TRUE);
......
......@@ -56,6 +56,7 @@
#include "threshold.h"
#include "tools.h"
#include "transform_tool.h"
#include "dialog_handler.h"
#include "config.h"
#include "libgimp/gimpintl.h"
......@@ -702,6 +703,10 @@ tools_options_dialog_new ()
/* The shell and main vbox */
options_shell = gtk_dialog_new ();
/* Register dialog */
dialog_register(options_shell);
gtk_window_set_wmclass (GTK_WINDOW (options_shell), "tool_options"