gimp r25541 - in trunk: . app/display app/widgets



Author: neo
Date: Mon Apr 28 16:30:55 2008
New Revision: 25541
URL: http://svn.gnome.org/viewvc/gimp?rev=25541&view=rev

Log:
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.



Added:
   trunk/app/widgets/gimpwindow.c
   trunk/app/widgets/gimpwindow.h
Modified:
   trunk/ChangeLog
   trunk/app/display/gimpdisplayshell.c
   trunk/app/display/gimpdisplayshell.h
   trunk/app/widgets/Makefile.am
   trunk/app/widgets/gimpdock.c
   trunk/app/widgets/gimpdock.h
   trunk/app/widgets/widgets-types.h

Modified: trunk/app/display/gimpdisplayshell.c
==============================================================================
--- trunk/app/display/gimpdisplayshell.c	(original)
+++ trunk/app/display/gimpdisplayshell.c	Mon Apr 28 16:30:55 2008
@@ -140,7 +140,7 @@
                                                     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,

Modified: trunk/app/display/gimpdisplayshell.h
==============================================================================
--- trunk/app/display/gimpdisplayshell.h	(original)
+++ trunk/app/display/gimpdisplayshell.h	Mon Apr 28 16:30:55 2008
@@ -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 @@
 
 struct _GimpDisplayShell
 {
-  GtkWindow          parent_instance;
+  GimpWindow         parent_instance;
 
   GimpDisplay       *display;
 
@@ -196,7 +196,7 @@
 
 struct _GimpDisplayShellClass
 {
-  GtkWindowClass  parent_class;
+  GimpWindowClass    parent_class;
 
   void (* scaled)    (GimpDisplayShell *shell);
   void (* scrolled)  (GimpDisplayShell *shell);

Modified: trunk/app/widgets/Makefile.am
==============================================================================
--- trunk/app/widgets/Makefile.am	(original)
+++ trunk/app/widgets/Makefile.am	Mon Apr 28 16:30:55 2008
@@ -329,6 +329,8 @@
 	gimpwidgets-constructors.h	\
 	gimpwidgets-utils.c		\
 	gimpwidgets-utils.h		\
+	gimpwindow.c			\
+	gimpwindow.h			\
 	gtkwrapbox.c			\
 	gtkwrapbox.h			\
 	gtkhwrapbox.c			\

Modified: trunk/app/widgets/gimpdock.c
==============================================================================
--- trunk/app/widgets/gimpdock.c	(original)
+++ trunk/app/widgets/gimpdock.c	Mon Apr 28 16:30:55 2008
@@ -79,9 +79,6 @@
 
 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 @@
                                               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 @@
   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 @@
   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)

Modified: trunk/app/widgets/gimpdock.h
==============================================================================
--- trunk/app/widgets/gimpdock.h	(original)
+++ trunk/app/widgets/gimpdock.h	Mon Apr 28 16:30:55 2008
@@ -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 @@
 
 struct _GimpDock
 {
-  GtkWindow          parent_instance;
+  GimpWindow         parent_instance;
 
   GimpDialogFactory *dialog_factory;
   GimpContext       *context;
@@ -53,7 +53,7 @@
 
 struct _GimpDockClass
 {
-  GtkWindowClass parent_class;
+  GimpWindowClass    parent_class;
 
   /*  virtual functions  */
   void    (* setup)        (GimpDock       *dock,

Added: trunk/app/widgets/gimpwindow.c
==============================================================================
--- (empty file)
+++ trunk/app/widgets/gimpwindow.c	Mon Apr 28 16:30:55 2008
@@ -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;
+}

Added: trunk/app/widgets/gimpwindow.h
==============================================================================
--- (empty file)
+++ trunk/app/widgets/gimpwindow.h	Mon Apr 28 16:30:55 2008
@@ -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__ */

Modified: trunk/app/widgets/widgets-types.h
==============================================================================
--- trunk/app/widgets/widgets-types.h	(original)
+++ trunk/app/widgets/widgets-types.h	Mon Apr 28 16:30:55 2008
@@ -180,6 +180,7 @@
 typedef struct _GimpThumbBox                 GimpThumbBox;
 typedef struct _GimpUnitStore                GimpUnitStore;
 typedef struct _GimpUnitComboBox             GimpUnitComboBox;
+typedef struct _GimpWindow                   GimpWindow;
 
 
 /*  views  */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]