gucharmap r1835 - trunk/gucharmap



Author: chpe
Date: Fri Jul 18 10:24:38 2008
New Revision: 1835
URL: http://svn.gnome.org/viewvc/gucharmap?rev=1835&view=rev

Log:
Add orientation property to GucharmapCharmap.


Modified:
   trunk/gucharmap/gucharmap-charmap.c
   trunk/gucharmap/gucharmap-charmap.h

Modified: trunk/gucharmap/gucharmap-charmap.c
==============================================================================
--- trunk/gucharmap/gucharmap-charmap.c	(original)
+++ trunk/gucharmap/gucharmap-charmap.c	Fri Jul 18 10:24:38 2008
@@ -31,6 +31,9 @@
 #include "gucharmap-private.h"
 
 struct _GucharmapCharmapPrivate {
+  GtkOrientation orientation;
+  GtkWidgetClass *paned_class;
+
   GtkWidget *notebook;
   GucharmapChaptersView *chapters_view;
   GucharmapChartable *chartable;
@@ -58,6 +61,7 @@
 
 enum {
   PROP_0,
+  PROP_ORIENTATION,
   PROP_CHAPTERS_MODEL,
   PROP_ACTIVE_CHAPTER,
   PROP_ACTIVE_CHARACTER,
@@ -72,7 +76,7 @@
 static void gucharmap_charmap_class_init (GucharmapCharmapClass *klass);
 static void gucharmap_charmap_init       (GucharmapCharmap *charmap);
 
-G_DEFINE_TYPE (GucharmapCharmap, gucharmap_charmap, GTK_TYPE_HPANED)
+G_DEFINE_TYPE (GucharmapCharmap, gucharmap_charmap, GTK_TYPE_PANED)
 
 static void
 gucharmap_charmap_finalize (GObject *object)
@@ -86,6 +90,8 @@
   if (priv->font_desc)
     pango_font_description_free (priv->font_desc);
 
+  g_type_class_unref (priv->paned_class);
+
   G_OBJECT_CLASS (gucharmap_charmap_parent_class)->finalize (object);
 }
 
@@ -99,6 +105,9 @@
   GucharmapCharmapPrivate *priv = charmap->priv;
 
   switch (prop_id) {
+    case PROP_ORIENTATION:
+      g_value_set_enum (value, gucharmap_charmap_get_orientation (charmap));
+      break;
     case PROP_CHAPTERS_MODEL:
       g_value_set_object (value, gucharmap_charmap_get_chapters_model (charmap));
       break;
@@ -136,6 +145,9 @@
   GucharmapCharmapPrivate *priv = charmap->priv;
 
   switch (prop_id) {
+    case PROP_ORIENTATION:
+      gucharmap_charmap_set_orientation (charmap, g_value_get_enum (value));
+      break;
     case PROP_CHAPTERS_MODEL:
       gucharmap_charmap_set_chapters_model (charmap, g_value_get_object (value));
       break;
@@ -163,9 +175,30 @@
 }
 
 static void
-gucharmap_charmap_class_init (GucharmapCharmapClass *clazz)
+gucharmap_charmap_size_request (GtkWidget *widget,
+                                GtkRequisition *requisition)
+{
+  GucharmapCharmap *charmap = GUCHARMAP_CHARMAP (widget);
+  GucharmapCharmapPrivate *priv = charmap->priv;
+
+  priv->paned_class->size_request (widget, requisition);
+}
+
+static void
+gucharmap_charmap_size_allocate (GtkWidget *widget,
+                                 GtkAllocation  *allocation)
 {
-  GObjectClass *object_class = G_OBJECT_CLASS (clazz);
+  GucharmapCharmap *charmap = GUCHARMAP_CHARMAP (widget);
+  GucharmapCharmapPrivate *priv = charmap->priv;
+
+  priv->paned_class->size_allocate (widget, allocation);
+}
+
+static void
+gucharmap_charmap_class_init (GucharmapCharmapClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
   _gucharmap_intl_ensure_initialized ();
 
@@ -173,6 +206,9 @@
   object_class->set_property = gucharmap_charmap_set_property;
   object_class->finalize = gucharmap_charmap_finalize;
 
+  widget_class->size_request = gucharmap_charmap_size_request;
+  widget_class->size_allocate = gucharmap_charmap_size_allocate;
+
   gucharmap_charmap_signals[STATUS_MESSAGE] =
       g_signal_new (I_("status-message"), gucharmap_charmap_get_type (),
                     G_SIGNAL_RUN_FIRST,
@@ -189,6 +225,18 @@
 
   g_object_class_install_property
     (object_class,
+     PROP_ORIENTATION,
+     g_param_spec_enum ("orientation", NULL, NULL,
+                        GTK_TYPE_ORIENTATION,
+                        GTK_ORIENTATION_HORIZONTAL,
+                        G_PARAM_READWRITE |
+                        G_PARAM_CONSTRUCT |
+                        G_PARAM_STATIC_NAME |
+                        G_PARAM_STATIC_NICK |
+                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property
+    (object_class,
      PROP_CHAPTERS_MODEL,
      g_param_spec_object ("chapters-model", NULL, NULL,
                          GUCHARMAP_TYPE_CHAPTERS_MODEL,
@@ -1172,6 +1220,47 @@
   return g_object_new (gucharmap_charmap_get_type (), NULL);
 }
 
+void
+gucharmap_charmap_set_orientation (GucharmapCharmap *charmap,
+                                   GtkOrientation orientation)
+{
+  GucharmapCharmapPrivate *priv;
+  GtkPaned *paned = GTK_PANED (charmap);
+
+  g_return_if_fail (GUCHARMAP_IS_CHARMAP (charmap));
+  priv = charmap->priv;
+
+  priv->orientation = orientation;
+
+  if (priv->paned_class)
+    g_type_class_unref (priv->paned_class);
+
+  switch (orientation) {
+    case GTK_ORIENTATION_HORIZONTAL:
+      priv->paned_class = g_type_class_ref (GTK_TYPE_HPANED);
+
+      paned->cursor_type = GDK_SB_H_DOUBLE_ARROW;
+      paned->orientation = GTK_ORIENTATION_VERTICAL;
+      break;
+    case GTK_ORIENTATION_VERTICAL:
+      priv->paned_class = g_type_class_ref (GTK_TYPE_VPANED);
+
+      paned->cursor_type = GDK_SB_V_DOUBLE_ARROW;
+      paned->orientation = GTK_ORIENTATION_HORIZONTAL;
+      break;
+  }
+
+  g_object_notify (G_OBJECT (charmap), "orientation");
+}
+
+GtkOrientation
+gucharmap_charmap_get_orientation (GucharmapCharmap *charmap)
+{
+  g_return_val_if_fail (GUCHARMAP_IS_CHARMAP (charmap), GTK_ORIENTATION_HORIZONTAL);
+
+  return charmap->priv->orientation;
+}
+
 /**
  * gucharmap_chartable_set_font_desc:
  * @chartable: a #GucharmapChartable

Modified: trunk/gucharmap/gucharmap-charmap.h
==============================================================================
--- trunk/gucharmap/gucharmap-charmap.h	(original)
+++ trunk/gucharmap/gucharmap-charmap.h	Fri Jul 18 10:24:38 2008
@@ -44,7 +44,7 @@
 
 struct _GucharmapCharmap
 {
-  GtkHPaned parent;
+  GtkPaned parent;
 
   /*< private >*/
   GucharmapCharmapPrivate *priv;
@@ -52,7 +52,7 @@
 
 struct _GucharmapCharmapClass
 {
-  GtkHPanedClass parent_class;
+  GtkPanedClass parent_class;
 
   void (* status_message) (GucharmapCharmap *charmap, const gchar *message);
   void (* link_clicked) (GucharmapCharmap *charmap, 
@@ -68,6 +68,10 @@
 
 GtkWidget *           gucharmap_charmap_new                (void);
 
+void           gucharmap_charmap_set_orientation (GucharmapCharmap *charmap,
+                                                  GtkOrientation orientation);
+GtkOrientation gucharmap_charmap_get_orientation (GucharmapCharmap *charmap);
+
 void      gucharmap_charmap_set_active_character (GucharmapCharmap *charmap,
                                                   gunichar           uc);
 gunichar  gucharmap_charmap_get_active_character (GucharmapCharmap *charmap);



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