[gnome-web-photo/webkit] Split PhotoOffscreenWindow in its own files



commit 4059c65f2b3dfcb13a4da4ec16a0b48ca3fa2967
Author: Vincent Untz <vuntz gnome org>
Date:   Wed Feb 16 11:24:21 2011 +0100

    Split PhotoOffscreenWindow in its own files

 src/Makefile.am              |    6 ++-
 src/gnome-web-photo.c        |   82 +----------------------------------------
 src/photo-offscreen-window.c |   82 ++++++++++++++++++++++++++++++++++++++++++
 src/photo-offscreen-window.h |   55 ++++++++++++++++++++++++++++
 4 files changed, 143 insertions(+), 82 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index d310681..9df9dc3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,7 +1,9 @@
 bin_PROGRAMS = gnome-web-photo
 
-gnome_web_photo_SOURCES = \
-	gnome-web-photo.c
+gnome_web_photo_SOURCES =		\
+	gnome-web-photo.c		\
+	photo-offscreen-window.c	\
+	photo-offscreen-window.h
 
 gnome_web_photo_CPPFLAGS = \
 	$(DEPENDENCY_CFLAGS)			\
diff --git a/src/gnome-web-photo.c b/src/gnome-web-photo.c
index 2a68638..3476fc5 100644
--- a/src/gnome-web-photo.c
+++ b/src/gnome-web-photo.c
@@ -29,12 +29,6 @@
  *   gtk_widget_set_size_request()).
  */
 
-/* Build with either:
- *    gcc -g -Wall -DHAVE_GNOME3 `pkg-config --cflags --libs gtk+-3.0 webkitgtk-3.0` gnome-web-photo.c -o gnome-web-photo
- * or:
- *    gcc -g -Wall `pkg-config --cflags --libs gconf-2.0 gtk+-2.0 webkit-1.0` gnome-web-photo.c -o gnome-web-photo
- */
-
 #include "config.h"
 
 #include <glib.h>
@@ -49,6 +43,8 @@
 #include <gconf/gconf-client.h>
 #endif
 
+#include "photo-offscreen-window.h"
+
 #ifdef HAVE_GNOME3
 #define GSETTINGS_DESKTOP_INTERFACE  "org.gnome.desktop.interface"
 #define GSETTINGS_VARIABLE_FONT_KEY  "document-font-name"
@@ -67,10 +63,6 @@
 #define MAX_WIDTH       2048
 #define DEFAULT_WIDTH   1024
 
-/* Value to keep in sync with the one from cairo:
- * MAX_IMAGE_SIZE in cairo-image-surface.c */
-#define MAX_HEIGHT      32767
-
 #define DEFAULT_THUMBNAIL_SIZE  256
 
 typedef enum
@@ -343,76 +335,6 @@ _prepare_webkit (WebKitWebView     *webview,
 }
 
 
-/******************************************\
- * GtkOffscreenWindow with limited height *
-\******************************************/
-
-/* This is a GtkOffscreenWindow with a maximum height.
- * See comment above gtk_widget_set_size_request() call to understand why we
- * need this. */
-
-typedef struct _PhotoOffscreenWindow      PhotoOffscreenWindow;
-typedef struct _PhotoOffscreenWindowClass PhotoOffscreenWindowClass;
-
-struct _PhotoOffscreenWindow
-{
-  GtkOffscreenWindow parent_object;
-};
-
-struct _PhotoOffscreenWindowClass
-{
-  GtkOffscreenWindowClass parent_class;
-};
-
-GType photo_offscreen_window_get_type (void) G_GNUC_CONST;	
-
-G_DEFINE_TYPE (PhotoOffscreenWindow, photo_offscreen_window, GTK_TYPE_OFFSCREEN_WINDOW)
-
-#ifdef HAVE_GNOME3
-static void
-photo_offscreen_window_get_preferred_height (GtkWidget *widget,
-                                             gint      *minimum,
-                                             gint      *natural)
-{
-  GTK_WIDGET_CLASS (photo_offscreen_window_parent_class)->get_preferred_height (widget, minimum, natural);
-
-  *minimum = MIN (*minimum, MAX_HEIGHT);
-  *natural = MIN (*natural, MAX_HEIGHT);
-}
-#else
-static void
-photo_offscreen_window_size_request (GtkWidget      *widget,
-                                     GtkRequisition *requisition)
-{
-  GTK_WIDGET_CLASS (photo_offscreen_window_parent_class)->size_request (widget, requisition);
-
-  requisition->height = MIN (requisition->height, MAX_HEIGHT);
-}
-#endif
-
-static void
-photo_offscreen_window_class_init (PhotoOffscreenWindowClass *class)
-{
-  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
-
-#ifdef HAVE_GNOME3
-  widget_class->get_preferred_height = photo_offscreen_window_get_preferred_height;
-#else
-  widget_class->size_request = photo_offscreen_window_size_request;
-#endif
-}
-
-static void
-photo_offscreen_window_init (PhotoOffscreenWindow *window)
-{
-}
-
-static GtkWidget *
-photo_offscreen_window_new (void)
-{
-  return g_object_new (photo_offscreen_window_get_type (), NULL);
-}
-
 /************\
  *   Core   *
 \************/
diff --git a/src/photo-offscreen-window.c b/src/photo-offscreen-window.c
new file mode 100644
index 0000000..1448d64
--- /dev/null
+++ b/src/photo-offscreen-window.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2011 Novell, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1, 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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.
+ *
+ * Authors:
+ *   Vincent Untz <vuntz gnome org>
+ */
+
+#include "config.h"
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include "photo-offscreen-window.h"
+
+/* Value to keep in sync with the one from cairo:
+ * MAX_IMAGE_SIZE in cairo-image-surface.c */
+#define MAX_SIZE        32767
+
+/* This is a GtkOffscreenWindow with a maximum height.
+ * See comment above gtk_widget_set_size_request() call to understand why we
+ * need this. */
+
+G_DEFINE_TYPE (PhotoOffscreenWindow, photo_offscreen_window, GTK_TYPE_OFFSCREEN_WINDOW)
+
+#ifdef HAVE_GNOME3
+static void
+photo_offscreen_window_get_preferred_height (GtkWidget *widget,
+                                             gint      *minimum,
+                                             gint      *natural)
+{
+  GTK_WIDGET_CLASS (photo_offscreen_window_parent_class)->get_preferred_height (widget, minimum, natural);
+
+  *minimum = MIN (*minimum, MAX_SIZE);
+  *natural = MIN (*natural, MAX_SIZE);
+}
+#else
+static void
+photo_offscreen_window_size_request (GtkWidget      *widget,
+                                     GtkRequisition *requisition)
+{
+  GTK_WIDGET_CLASS (photo_offscreen_window_parent_class)->size_request (widget, requisition);
+
+  requisition->height = MIN (requisition->height, MAX_SIZE);
+}
+#endif
+
+static void
+photo_offscreen_window_class_init (PhotoOffscreenWindowClass *class)
+{
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
+
+#ifdef HAVE_GNOME3
+  widget_class->get_preferred_height = photo_offscreen_window_get_preferred_height;
+#else
+  widget_class->size_request = photo_offscreen_window_size_request;
+#endif
+}
+
+static void
+photo_offscreen_window_init (PhotoOffscreenWindow *window)
+{
+}
+
+GtkWidget *
+photo_offscreen_window_new (void)
+{
+  return g_object_new (photo_offscreen_window_get_type (), NULL);
+}
diff --git a/src/photo-offscreen-window.h b/src/photo-offscreen-window.h
new file mode 100644
index 0000000..5b85b4f
--- /dev/null
+++ b/src/photo-offscreen-window.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2011 Novell, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1, 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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.
+ *
+ * Authors:
+ *   Vincent Untz <vuntz gnome org>
+ */
+
+#ifndef _PHOTO_OFFSCREEN_WINDOW_H_
+#define _PHOTO_OFFSCREEN_WINDOW_H_
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define PHOTO_TYPE_OFFSCREEN_WINDOW             (photo_offscreen_window_get_type ())
+#define PHOTO_OFFSCREEN_WINDOW(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), PHOTO_TYPE_OFFSCREEN_WINDOW, PhotoOffscreenWindow))
+#define PHOTO_OFFSCREEN_WINDOW_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), PHOTO_TYPE_OFFSCREEN_WINDOW, PhotoOffscreenWindowClass))
+#define PHOTO_IS_OFFSCREEN_WINDOW(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PHOTO_TYPE_OFFSCREEN_WINDOW))
+#define PHOTO_IS_OFFSCREEN_WINDOW_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), PHOTO_TYPE_OFFSCREEN_WINDOW))
+#define PHOTO_OFFSCREEN_WINDOW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj), PHOTO_TYPE_OFFSCREEN_WINDOW, PhotoOffscreenWindowClass))
+
+typedef struct _PhotoOffscreenWindow      PhotoOffscreenWindow;
+typedef struct _PhotoOffscreenWindowClass PhotoOffscreenWindowClass;
+
+struct _PhotoOffscreenWindow
+{
+  GtkOffscreenWindow parent_object;
+};
+
+struct _PhotoOffscreenWindowClass
+{
+  GtkOffscreenWindowClass parent_class;
+};
+
+GType photo_offscreen_window_get_type (void) G_GNUC_CONST;
+
+GtkWidget *photo_offscreen_window_new (void);
+
+G_END_DECLS
+
+#endif /* _PHOTO_OFFSCREEN_WINDOW_H_ */



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