[maemo-commits] [maemo-commits] r16879 - in projects/haf/trunk/gtk+: . gtk

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Fri Dec 5 15:41:41 EET 2008
Author: timj
Date: 2008-12-05 15:41:38 +0200 (Fri, 05 Dec 2008)
New Revision: 16879

Modified:
   projects/haf/trunk/gtk+/ChangeLog
   projects/haf/trunk/gtk+/gtk/gtkdialog.c
   projects/haf/trunk/gtk+/gtk/gtkenums.h
   projects/haf/trunk/gtk+/gtk/gtkwidget.c
   projects/haf/trunk/gtk+/gtk/gtkwidget.h
Log:
2008-12-05 14:38:56  Tim Janik  <timj at imendio.com>

        * gtk/gtkwidget.c, gtk/gtkwidget.h, gtk/gtkenums.h:
        moved hildon_gtk_widget_set_theme_size and HildonSizeType from Hildon here.

        * gtk/gtkdialog.c: automatically apply hildon sizing and theming to all
        standard gtk dialogs, fixes: NB#90867.



Modified: projects/haf/trunk/gtk+/ChangeLog
===================================================================
--- projects/haf/trunk/gtk+/ChangeLog	2008-12-05 13:39:01 UTC (rev 16878)
+++ projects/haf/trunk/gtk+/ChangeLog	2008-12-05 13:41:38 UTC (rev 16879)
@@ -1,3 +1,11 @@
+2008-12-05 14:38:56  Tim Janik  <timj at imendio.com>
+
+	* gtk/gtkwidget.c, gtk/gtkwidget.h, gtk/gtkenums.h:
+	moved hildon_gtk_widget_set_theme_size and HildonSizeType from Hildon here.
+
+	* gtk/gtkdialog.c: automatically apply hildon sizing and theming to all
+	standard gtk dialogs, fixes: NB#90867.
+
 2008-12-05  Michael Natterer  <mitch at imendio.com>
 
 	Merged from upstream trunk, fixes NB#91712:

Modified: projects/haf/trunk/gtk+/gtk/gtkdialog.c
===================================================================
--- projects/haf/trunk/gtk+/gtk/gtkdialog.c	2008-12-05 13:39:01 UTC (rev 16878)
+++ projects/haf/trunk/gtk+/gtk/gtkdialog.c	2008-12-05 13:41:38 UTC (rev 16879)
@@ -678,6 +678,10 @@
   if (response_id == GTK_RESPONSE_HELP)
     gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (dialog->action_area), child, TRUE);
 }
+#ifdef MAEMO_CHANGES
+  /* Buttons on a HildonDialog have fixed size */
+  #define HILDON_DIALOG_BUTTON_WIDTH 174
+#endif
 
 /**
  * gtk_dialog_add_button:
@@ -713,6 +717,8 @@
       response_id != GTK_RESPONSE_CLOSE)
     {
       gtk_widget_show (button);
+      hildon_gtk_widget_set_theme_size (button, HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_FINGER_HEIGHT);
+      g_object_set (button, "width-request", HILDON_DIALOG_BUTTON_WIDTH, NULL);
     }
     else
     {

Modified: projects/haf/trunk/gtk+/gtk/gtkenums.h
===================================================================
--- projects/haf/trunk/gtk+/gtk/gtkenums.h	2008-12-05 13:39:01 UTC (rev 16878)
+++ projects/haf/trunk/gtk+/gtk/gtkenums.h	2008-12-05 13:41:38 UTC (rev 16879)
@@ -559,6 +559,16 @@
   HILDON_UI_MODE_NORMAL,
   HILDON_UI_MODE_EDIT
 } HildonUIMode;
+
+typedef enum {
+   HILDON_SIZE_AUTO_WIDTH       = 0 << 0, /* set to automatic width */
+   HILDON_SIZE_HALFSCREEN_WIDTH = 1 << 0, /* set to 50% screen width */
+   HILDON_SIZE_FULLSCREEN_WIDTH = 2 << 0, /* set to 100% screen width */
+   HILDON_SIZE_AUTO_HEIGHT      = 0 << 2, /* set to automatic height */
+   HILDON_SIZE_FINGER_HEIGHT    = 1 << 2, /* set to finger height */
+   HILDON_SIZE_THUMB_HEIGHT     = 2 << 2, /* set to thumb height */
+   HILDON_SIZE_AUTO             = (HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_AUTO_HEIGHT)
+} HildonSizeType;
 #endif /* MAEMO_CHANGES */
 
 G_END_DECLS

Modified: projects/haf/trunk/gtk+/gtk/gtkwidget.c
===================================================================
--- projects/haf/trunk/gtk+/gtk/gtkwidget.c	2008-12-05 13:39:01 UTC (rev 16878)
+++ projects/haf/trunk/gtk+/gtk/gtkwidget.c	2008-12-05 13:41:38 UTC (rev 16879)
@@ -10690,6 +10690,65 @@
   g_return_if_fail (GTK_IS_WIDGET (widget));
   g_signal_emit(widget, widget_signals[INSENSITIVE_PRESS], 0);
 }
+
+#define HILDON_HEIGHT_FINGER    70
+
+#define HILDON_HEIGHT_THUMB     105
+
+#define HILDON_WIDTH_FULLSCREEN (gdk_screen_get_width (gdk_screen_get_default ()))
+
+#define HILDON_WIDTH_HALFSCREEN (HILDON_WIDTH_FULLSCREEN / 2)
+
+/**
+ * hildon_gtk_widget_set_theme_size:
+ * @widget: A #GtkWidget
+ * @size: Flags indicating the size of the widget
+ *
+ * This function sets the requested size of a widget.
+ *
+ * Since: maemo 2.0
+ * Stability: Unstable
+ **/
+void
+hildon_gtk_widget_set_theme_size (GtkWidget      *widget,
+                                  HildonSizeType  size)
+{
+  gint width = -1;
+  gint height = -1;
+  gchar *widget_name = NULL;
+
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+
+  /* Requested height */
+  if (size & HILDON_SIZE_FINGER_HEIGHT)
+    {
+      height = HILDON_HEIGHT_FINGER;
+      widget_name = "-finger";
+    }
+  else if (size & HILDON_SIZE_THUMB_HEIGHT)
+    {
+      height = HILDON_HEIGHT_THUMB;
+      widget_name = "-thumb";
+    }
+
+  if (widget_name)
+    widget_name = g_strconcat (g_type_name (GTK_WIDGET_TYPE (widget)),
+                               widget_name, NULL);
+
+    /* Requested width */
+  if (size & HILDON_SIZE_HALFSCREEN_WIDTH)
+    width = HILDON_WIDTH_HALFSCREEN;
+  else if (size & HILDON_SIZE_FULLSCREEN_WIDTH)
+    width = HILDON_WIDTH_FULLSCREEN;
+
+  gtk_widget_set_size_request (widget, width, height);
+
+  if (widget_name)
+    {
+      gtk_widget_set_name (widget, widget_name);
+      g_free (widget_name);
+    }
+}
 #endif /* MAEMO_CHANGES */
 
 

Modified: projects/haf/trunk/gtk+/gtk/gtkwidget.h
===================================================================
--- projects/haf/trunk/gtk+/gtk/gtkwidget.h	2008-12-05 13:39:01 UTC (rev 16878)
+++ projects/haf/trunk/gtk+/gtk/gtkwidget.h	2008-12-05 13:41:38 UTC (rev 16879)
@@ -851,6 +851,9 @@
 						GtkWidgetTapAndHoldFlags  flags);
 
 void gtk_widget_insensitive_press ( GtkWidget *widget );
+
+void hildon_gtk_widget_set_theme_size           (GtkWidget      *widget,
+                                                 HildonSizeType  size);
 #endif /* MAEMO_CHANGES */
 
 G_END_DECLS


More information about the maemo-commits mailing list