2000-06-09 Michael Natterer <mitch@gimp.org> Cursor patch II: This is only the logic inside the cursor system and not yet used. * app/cursorutil.[ch]: [gimp]_change_win_cursor() take lots of parameters now and compose cursors from up to three cursor bitmaps/masks. * app/gdisplay.[ch]: As a test, create a hardcoded example cursor if "Cursor Mode" is set to "Tool Icon with Crosshair" in prefs. * app/curves.c * app/dialog_handler.c * app/scroll.c: changed the calls to the win_cursor function. * app/tools.[ch]: added a cursor and a toggle cursor to the ToolInfo structure of all tools. * app/toolsF.h: new ToolType TOOL_TYPE_NONE. * app/gimpdnd.c * app/interface.c: check for silly filenames in the file dnd callback. Closes #13733. * Makefile.am * cursors/bucket_fill_small.xbm * cursors/bucket_fill_small_mask.xbm * cursors/crop_small.xbm * cursors/crop_small_mask.xbm * cursors/crosshair_small.xbm * cursors/crosshair_small_mask.xbm * cursors/ellipse_select_small.xbm * cursors/ellipse_select_small_mask.xbm * cursors/eraser_small.xbm * cursors/eraser_small_mask.xbm * cursors/free_select_small.xbm * cursors/free_select_small_mask.xbm * cursors/fuzzy_select_small.xbm * cursors/fuzzy_select_small_mask.xbm * cursors/intersect.xbm * cursors/intersect_mask.xbm * cursors/minus.xbm * cursors/minus_mask.xbm * cursors/move.xbm * cursors/move_mask.xbm * cursors/paintbrush_small.xbm * cursors/paintbrush_small_mask.xbm * cursors/pencil_small.xbm * cursors/pencil_small_mask.xbm * cursors/plus.xbm * cursors/plus_mask.xbm * cursors/rect_select_small.xbm * cursors/rect_select_small_mask.xbm * cursors/resize_small.xbm * cursors/resize_small_mask.xbm * cursors/zoom.xbm * cursors/zoom_mask.xbm * cursors/zoom_small.xbm * cursors/zoom_small_mask.xbm: new files extracted from Tigert's gimp-tool-cursors.xcf created at GimpCon. Tigert, I'll commit the xcf as soon as I've added empty layers with the names of the cursors that are missing. * cursors/mouse.xbm * cursors/mouse_mask.xbm: made it 32x32 to allow for cursor composition.
298 lines
6.2 KiB
C
298 lines
6.2 KiB
C
/* 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.
|
|
*/
|
|
#define __DIALOG_HANDLER_C__ 1
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <gmodule.h>
|
|
|
|
#include "cursorutil.h"
|
|
#include "dialog_handler.h"
|
|
|
|
/* State of individual dialogs */
|
|
|
|
typedef enum
|
|
{
|
|
INVISIBLE,
|
|
VISIBLE,
|
|
UNKNOWN
|
|
} VisibilityState;
|
|
|
|
typedef struct _DialogState DialogState;
|
|
|
|
struct _DialogState
|
|
{
|
|
GtkWidget *dialog;
|
|
VisibilityState saved_state;
|
|
};
|
|
|
|
/* This keeps track of the state the dialogs are in
|
|
* ie how many times we have pressed the tab key
|
|
*/
|
|
typedef enum
|
|
{
|
|
SHOW_ALL,
|
|
HIDE_ALL,
|
|
SHOW_TOOLBOX,
|
|
LAST_SHOW_STATE
|
|
} ShowState;
|
|
|
|
/* Start off with all dialogs showing */
|
|
static ShowState dialogs_showing = SHOW_ALL;
|
|
|
|
/* Prevent multiple keypresses from unsetting me. */
|
|
static gboolean doing_update = FALSE;
|
|
|
|
/* List of dialogs that have been created and are on screen
|
|
* (may be hidden already).
|
|
*/
|
|
static GSList * active_dialogs = NULL;
|
|
|
|
/* Those have a special behaviour */
|
|
static DialogState * toolbox_shell = NULL;
|
|
static DialogState * fileload_shell = NULL;
|
|
|
|
/* Private */
|
|
|
|
/* Hide all currently registered dialogs */
|
|
|
|
static void
|
|
dialog_hide_all (void)
|
|
{
|
|
DialogState *dstate;
|
|
GSList *list;
|
|
|
|
for (list = active_dialogs; list; list = g_slist_next (list))
|
|
{
|
|
dstate = (DialogState *) list->data;
|
|
|
|
if (GTK_WIDGET_VISIBLE (dstate->dialog))
|
|
{
|
|
dstate->saved_state = VISIBLE;
|
|
gtk_widget_hide (dstate->dialog);
|
|
}
|
|
else
|
|
{
|
|
dstate->saved_state = INVISIBLE;
|
|
}
|
|
}
|
|
}
|
|
|
|
/* Show all currently registered dialogs */
|
|
|
|
static void
|
|
dialog_show_all (void)
|
|
{
|
|
DialogState *dstate;
|
|
GSList *list;
|
|
|
|
for (list = active_dialogs; list; list = g_slist_next (list))
|
|
{
|
|
dstate = (DialogState *) list->data;
|
|
|
|
if (dstate->saved_state == VISIBLE && !GTK_WIDGET_VISIBLE (dstate->dialog))
|
|
gtk_widget_show(dstate->dialog);
|
|
}
|
|
}
|
|
|
|
/* Handle the tool box in a special way */
|
|
|
|
static void
|
|
dialog_hide_toolbox (void)
|
|
{
|
|
if (toolbox_shell && GTK_WIDGET_VISIBLE (toolbox_shell->dialog))
|
|
{
|
|
gtk_widget_hide (toolbox_shell->dialog);
|
|
toolbox_shell->saved_state = VISIBLE;
|
|
}
|
|
}
|
|
|
|
/* public */
|
|
|
|
void
|
|
dialog_show_toolbox (void)
|
|
{
|
|
if (toolbox_shell &&
|
|
toolbox_shell->saved_state == VISIBLE &&
|
|
!GTK_WIDGET_VISIBLE (toolbox_shell->dialog))
|
|
{
|
|
gtk_widget_show (toolbox_shell->dialog);
|
|
}
|
|
}
|
|
|
|
/* Set hourglass cursor on all currently registered dialogs */
|
|
|
|
void
|
|
dialog_idle_all (void)
|
|
{
|
|
DialogState *dstate;
|
|
GSList *list;
|
|
|
|
for (list = active_dialogs; list; list = g_slist_next (list))
|
|
{
|
|
dstate = (DialogState *) list->data;
|
|
|
|
if(GTK_WIDGET_VISIBLE (dstate->dialog))
|
|
{
|
|
change_win_cursor (dstate->dialog->window, GDK_WATCH,
|
|
TOOL_TYPE_NONE, CURSOR_MODIFIER_NONE, FALSE);
|
|
}
|
|
}
|
|
|
|
if (toolbox_shell && GTK_WIDGET_VISIBLE (toolbox_shell->dialog))
|
|
{
|
|
change_win_cursor (toolbox_shell->dialog->window, GDK_WATCH,
|
|
TOOL_TYPE_NONE, CURSOR_MODIFIER_NONE, FALSE);
|
|
}
|
|
|
|
if (fileload_shell && GTK_WIDGET_VISIBLE (fileload_shell->dialog))
|
|
{
|
|
change_win_cursor (fileload_shell->dialog->window, GDK_WATCH,
|
|
TOOL_TYPE_NONE, CURSOR_MODIFIER_NONE, FALSE);
|
|
}
|
|
}
|
|
|
|
/* And remove the hourglass again. */
|
|
|
|
void
|
|
dialog_unidle_all (void)
|
|
{
|
|
DialogState *dstate;
|
|
GSList *list;
|
|
|
|
for (list = active_dialogs; list; list = g_slist_next (list))
|
|
{
|
|
dstate = (DialogState *) list->data;
|
|
|
|
if (GTK_WIDGET_VISIBLE (dstate->dialog))
|
|
{
|
|
unset_win_cursor (dstate->dialog->window);
|
|
}
|
|
}
|
|
|
|
if (toolbox_shell && GTK_WIDGET_VISIBLE (toolbox_shell->dialog))
|
|
{
|
|
unset_win_cursor (toolbox_shell->dialog->window);
|
|
}
|
|
|
|
if (fileload_shell && GTK_WIDGET_VISIBLE (fileload_shell->dialog))
|
|
{
|
|
unset_win_cursor (fileload_shell->dialog->window);
|
|
}
|
|
}
|
|
|
|
/* Register a dialog that we can handle */
|
|
|
|
G_MODULE_EXPORT
|
|
void
|
|
dialog_register (GtkWidget *dialog)
|
|
{
|
|
DialogState *dstate;
|
|
|
|
dstate = g_new (DialogState, 1);
|
|
|
|
dstate->dialog = dialog;
|
|
dstate->saved_state = UNKNOWN;
|
|
|
|
active_dialogs = g_slist_append (active_dialogs, dstate);
|
|
}
|
|
|
|
void
|
|
dialog_register_toolbox (GtkWidget *dialog)
|
|
{
|
|
toolbox_shell = g_new (DialogState, 1);
|
|
|
|
toolbox_shell->dialog = dialog;
|
|
toolbox_shell->saved_state = UNKNOWN;
|
|
}
|
|
|
|
void
|
|
dialog_register_fileload (GtkWidget *dialog)
|
|
{
|
|
fileload_shell = g_new (DialogState, 1);
|
|
|
|
fileload_shell->dialog = dialog;
|
|
fileload_shell->saved_state = UNKNOWN;
|
|
}
|
|
|
|
/* unregister dialog */
|
|
|
|
G_MODULE_EXPORT
|
|
void
|
|
dialog_unregister (GtkWidget *dialog)
|
|
{
|
|
DialogState *dstate = NULL;
|
|
GSList *list;
|
|
|
|
for (list = active_dialogs; list; list = g_slist_next (list))
|
|
{
|
|
dstate = (DialogState *) list->data;
|
|
|
|
if (dstate->dialog == dialog)
|
|
break;
|
|
}
|
|
|
|
if (dstate != NULL)
|
|
{
|
|
active_dialogs = g_slist_remove (active_dialogs, dstate);
|
|
g_free (dstate);
|
|
}
|
|
}
|
|
|
|
/* Toggle showing of dialogs
|
|
*
|
|
* States:-
|
|
* SHOW_ALL -> HIDE_ALL -> SHOW_TOOLBOX -> SHOW_ALL ....
|
|
*/
|
|
|
|
void
|
|
dialog_toggle (void)
|
|
{
|
|
if (doing_update)
|
|
return;
|
|
|
|
doing_update = TRUE;
|
|
|
|
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;
|
|
}
|