mirror of https://github.com/GNOME/gimp.git
app/widgets/Makefile.am app/widgets/widgets-types.h added GimpWindow class
2008-04-28 Sven Neumann <sven@gimp.org> * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpwindow.[ch]: added GimpWindow class and moved key-press-event handler from GimpDock to this class. * app/widgets/gimpdock.[ch]: * app/display/gimpdisplayshell.[ch]: derive from GimpWindow. svn path=/trunk/; revision=25541
This commit is contained in:
parent
ada10e7577
commit
f23d046965
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2008-04-28 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/widgets/Makefile.am
|
||||
* app/widgets/widgets-types.h
|
||||
* app/widgets/gimpwindow.[ch]: added GimpWindow class and moved
|
||||
key-press-event handler from GimpDock to this class.
|
||||
|
||||
* app/widgets/gimpdock.[ch]:
|
||||
* app/display/gimpdisplayshell.[ch]: derive from GimpWindow.
|
||||
|
||||
2008-04-28 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/base/hue-saturation.c (hue_saturation): applied patch from
|
||||
|
|
|
@ -140,7 +140,7 @@ static const guint8 * gimp_display_shell_get_icc_profile
|
|||
gsize *len);
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GimpDisplayShell, gimp_display_shell, GTK_TYPE_WINDOW,
|
||||
G_DEFINE_TYPE_WITH_CODE (GimpDisplayShell, gimp_display_shell, GIMP_TYPE_WINDOW,
|
||||
G_IMPLEMENT_INTERFACE (GIMP_TYPE_PROGRESS,
|
||||
gimp_display_shell_progress_iface_init)
|
||||
G_IMPLEMENT_INTERFACE (GIMP_TYPE_COLOR_MANAGED,
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
#define __GIMP_DISPLAY_SHELL_H__
|
||||
|
||||
|
||||
#include <gtk/gtkwindow.h>
|
||||
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets/gimpwindow.h"
|
||||
|
||||
|
||||
/* Apply to a float the same rounding mode used in the renderer */
|
||||
#define PROJ_ROUND(coord) ((gint) RINT (coord))
|
||||
|
@ -63,7 +63,7 @@ typedef struct _GimpDisplayShellClass GimpDisplayShellClass;
|
|||
|
||||
struct _GimpDisplayShell
|
||||
{
|
||||
GtkWindow parent_instance;
|
||||
GimpWindow parent_instance;
|
||||
|
||||
GimpDisplay *display;
|
||||
|
||||
|
@ -196,7 +196,7 @@ struct _GimpDisplayShell
|
|||
|
||||
struct _GimpDisplayShellClass
|
||||
{
|
||||
GtkWindowClass parent_class;
|
||||
GimpWindowClass parent_class;
|
||||
|
||||
void (* scaled) (GimpDisplayShell *shell);
|
||||
void (* scrolled) (GimpDisplayShell *shell);
|
||||
|
|
|
@ -329,6 +329,8 @@ libappwidgets_a_sources = \
|
|||
gimpwidgets-constructors.h \
|
||||
gimpwidgets-utils.c \
|
||||
gimpwidgets-utils.h \
|
||||
gimpwindow.c \
|
||||
gimpwindow.h \
|
||||
gtkwrapbox.c \
|
||||
gtkwrapbox.h \
|
||||
gtkhwrapbox.c \
|
||||
|
|
|
@ -79,9 +79,6 @@ static void gimp_dock_destroy (GtkObject *object);
|
|||
|
||||
static gboolean gimp_dock_delete_event (GtkWidget *widget,
|
||||
GdkEventAny *event);
|
||||
static gboolean gimp_dock_key_press_event (GtkWidget *widget,
|
||||
GdkEventKey *kevent);
|
||||
|
||||
static void gimp_dock_style_set (GtkWidget *widget,
|
||||
GtkStyle *prev_style);
|
||||
|
||||
|
@ -91,7 +88,7 @@ static void gimp_dock_real_book_removed (GimpDock *dock,
|
|||
GimpDockbook *dockbook);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpDock, gimp_dock, GTK_TYPE_WINDOW)
|
||||
G_DEFINE_TYPE (GimpDock, gimp_dock, GIMP_TYPE_WINDOW)
|
||||
|
||||
#define parent_class gimp_dock_parent_class
|
||||
|
||||
|
@ -132,7 +129,6 @@ gimp_dock_class_init (GimpDockClass *klass)
|
|||
gtk_object_class->destroy = gimp_dock_destroy;
|
||||
|
||||
widget_class->delete_event = gimp_dock_delete_event;
|
||||
widget_class->key_press_event = gimp_dock_key_press_event;
|
||||
widget_class->style_set = gimp_dock_style_set;
|
||||
|
||||
klass->setup = NULL;
|
||||
|
@ -326,42 +322,6 @@ gimp_dock_delete_event (GtkWidget *widget,
|
|||
return retval;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_dock_key_press_event (GtkWidget *widget,
|
||||
GdkEventKey *event)
|
||||
{
|
||||
GtkWindow *window = GTK_WINDOW (widget);
|
||||
GtkWidget *focus = gtk_window_get_focus (window);
|
||||
gboolean handled = FALSE;
|
||||
|
||||
/* we're overriding the GtkWindow implementation here to give
|
||||
* the focus widget precedence over unmodified accelerators
|
||||
* before the accelerator activation scheme.
|
||||
*/
|
||||
|
||||
/* text widgets get all key events first */
|
||||
if (G_UNLIKELY (GTK_IS_EDITABLE (focus) || GTK_IS_TEXT_VIEW (focus)))
|
||||
handled = gtk_window_propagate_key_event (window, event);
|
||||
|
||||
/* invoke control/alt accelerators */
|
||||
if (! handled && event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))
|
||||
handled = gtk_window_activate_key (window, event);
|
||||
|
||||
/* invoke focus widget handlers */
|
||||
if (! handled)
|
||||
handled = gtk_window_propagate_key_event (window, event);
|
||||
|
||||
/* invoke non-(control/alt) accelerators */
|
||||
if (! handled && ! (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)))
|
||||
handled = gtk_window_activate_key (window, event);
|
||||
|
||||
/* chain up, bypassing gtk_window_key_press(), to invoke binding set */
|
||||
if (! handled)
|
||||
handled = GTK_WIDGET_CLASS (g_type_class_peek (g_type_parent (GTK_TYPE_WINDOW)))->key_press_event (widget, event);
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_dock_style_set (GtkWidget *widget,
|
||||
GtkStyle *prev_style)
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#define __GIMP_DOCK_H__
|
||||
|
||||
|
||||
#include <gtk/gtkwindow.h>
|
||||
#include "widgets/gimpwindow.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_DOCK (gimp_dock_get_type ())
|
||||
|
@ -38,7 +38,7 @@ typedef struct _GimpDockClass GimpDockClass;
|
|||
|
||||
struct _GimpDock
|
||||
{
|
||||
GtkWindow parent_instance;
|
||||
GimpWindow parent_instance;
|
||||
|
||||
GimpDialogFactory *dialog_factory;
|
||||
GimpContext *context;
|
||||
|
@ -53,7 +53,7 @@ struct _GimpDock
|
|||
|
||||
struct _GimpDockClass
|
||||
{
|
||||
GtkWindowClass parent_class;
|
||||
GimpWindowClass parent_class;
|
||||
|
||||
/* virtual functions */
|
||||
void (* setup) (GimpDock *dock,
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpwindow.c
|
||||
*
|
||||
* 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 "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "gimpwindow.h"
|
||||
|
||||
|
||||
static gboolean gimp_window_key_press_event (GtkWidget *widget,
|
||||
GdkEventKey *kevent);
|
||||
|
||||
G_DEFINE_TYPE (GimpWindow, gimp_window, GTK_TYPE_WINDOW)
|
||||
|
||||
|
||||
static void
|
||||
gimp_window_class_init (GimpWindowClass *klass)
|
||||
{
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
widget_class->key_press_event = gimp_window_key_press_event;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_window_init (GimpWindow *window)
|
||||
{
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_window_key_press_event (GtkWidget *widget,
|
||||
GdkEventKey *event)
|
||||
{
|
||||
GtkWindow *window = GTK_WINDOW (widget);
|
||||
GtkWidget *focus = gtk_window_get_focus (window);
|
||||
gboolean handled = FALSE;
|
||||
|
||||
/* we're overriding the GtkWindow implementation here to give
|
||||
* the focus widget precedence over unmodified accelerators
|
||||
* before the accelerator activation scheme.
|
||||
*/
|
||||
|
||||
/* text widgets get all key events first */
|
||||
if (G_UNLIKELY (GTK_IS_EDITABLE (focus) || GTK_IS_TEXT_VIEW (focus)))
|
||||
handled = gtk_window_propagate_key_event (window, event);
|
||||
|
||||
/* invoke control/alt accelerators */
|
||||
if (! handled && event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))
|
||||
handled = gtk_window_activate_key (window, event);
|
||||
|
||||
/* invoke focus widget handlers */
|
||||
if (! handled)
|
||||
handled = gtk_window_propagate_key_event (window, event);
|
||||
|
||||
/* invoke non-(control/alt) accelerators */
|
||||
if (! handled && ! (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)))
|
||||
handled = gtk_window_activate_key (window, event);
|
||||
|
||||
/* chain up, bypassing gtk_window_key_press(), to invoke binding set */
|
||||
if (! handled)
|
||||
handled = GTK_WIDGET_CLASS (g_type_class_peek (g_type_parent (GTK_TYPE_WINDOW)))->key_press_event (widget, event);
|
||||
|
||||
return handled;
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpwindow.h
|
||||
*
|
||||
* 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 __GIMP_WINDOW_H__
|
||||
#define __GIMP_WINDOW_H__
|
||||
|
||||
|
||||
#include <gtk/gtkwindow.h>
|
||||
|
||||
|
||||
#define GIMP_TYPE_WINDOW (gimp_window_get_type ())
|
||||
#define GIMP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_WINDOW, GimpWindow))
|
||||
#define GIMP_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_WINDOW, GimpWindowClass))
|
||||
#define GIMP_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_WINDOW))
|
||||
#define GIMP_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_WINDOW))
|
||||
#define GIMP_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_WINDOW, GimpWindowClass))
|
||||
|
||||
|
||||
typedef struct _GimpWindowClass GimpWindowClass;
|
||||
|
||||
struct _GimpWindow
|
||||
{
|
||||
GtkWindow parent_instance;
|
||||
};
|
||||
|
||||
struct _GimpWindowClass
|
||||
{
|
||||
GtkWindowClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_window_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
#endif /* __GIMP_WINDOW_H__ */
|
|
@ -180,6 +180,7 @@ typedef struct _GimpTemplateEditor GimpTemplateEditor;
|
|||
typedef struct _GimpThumbBox GimpThumbBox;
|
||||
typedef struct _GimpUnitStore GimpUnitStore;
|
||||
typedef struct _GimpUnitComboBox GimpUnitComboBox;
|
||||
typedef struct _GimpWindow GimpWindow;
|
||||
|
||||
|
||||
/* views */
|
||||
|
|
Loading…
Reference in New Issue