2008-07-29 Claudio Saavedra <csaavedra@igalia.com>
[hildon] / src / hildon-window.c
index a9904c5..bb0b79e 100644 (file)
@@ -206,6 +206,11 @@ hildon_window_toggle_menu                       (HildonWindow * self,
                                                 guint32 time);
 
 static gboolean
+hildon_window_toggle_menu_real                  (HildonWindow * self,
+                                                guint button,
+                                                guint32 time);
+
+static gboolean
 hildon_window_escape_timeout                    (gpointer data);
 
 static GdkFilterReturn
@@ -231,6 +236,9 @@ paint_toolbar                                   (GtkWidget *widget,
                                                  GdkEventExpose * event, 
                                                  gboolean fullscreen);
 
+static void
+hildon_window_unset_program_real                (HildonWindow *self);
+
 enum
 {
     PROP_0,
@@ -275,6 +283,10 @@ hildon_window_class_init                        (HildonWindowClass * window_clas
     /* To the container */
     container_class->forall             = hildon_window_forall;
 
+    /* To this class */
+    window_class->unset_program         = hildon_window_unset_program_real;
+    window_class->toggle_menu           = hildon_window_toggle_menu_real;
+
     /* gtkobject stuff*/
     GTK_OBJECT_CLASS (window_class)->destroy = hildon_window_destroy; 
 
@@ -1272,7 +1284,13 @@ hildon_window_menu_popup_func                   (GtkMenu *menu,
     gtk_widget_style_get (GTK_WIDGET (menu), "horizontal-offset", x,
             "vertical-offset", y, NULL);
 
-    *x += window_x;
+    if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
+    {
+        *x = GTK_WIDGET (widget)->allocation.width + window_x - GTK_WIDGET (menu)->allocation.width - *x;
+    }
+    else
+        *x += window_x;
+
     *y += window_y;
 
 }
@@ -1287,7 +1305,11 @@ hildon_window_menu_popup_func_full              (GtkMenu *menu,
     gtk_widget_style_get (GTK_WIDGET (menu), "horizontal-offset", x,
             "vertical-offset", y, NULL);
 
-    *x = MAX (0, *x);
+    if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
+        *x = GTK_WIDGET (widget)->allocation.width - GTK_WIDGET (menu)->allocation.width - *x;
+    else
+        *x = MAX (0, *x);
+
     *y = MAX (0, *y);
 }
 
@@ -1338,10 +1360,10 @@ hildon_window_set_program                       (HildonWindow *self,
 
 /*
  * Unsets the program to which the window belongs. This should only be called
- * by hildon_program_add_window
+ * by hildon_program_remove_window
  */
-void G_GNUC_INTERNAL
-hildon_window_unset_program                     (HildonWindow *self)
+static void
+hildon_window_unset_program_real                (HildonWindow *self)
 {
     HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (self);
 
@@ -1365,6 +1387,15 @@ hildon_window_unset_program                     (HildonWindow *self)
     priv->program = NULL;
 }
 
+void G_GNUC_INTERNAL
+hildon_window_unset_program                     (HildonWindow *self)
+{
+    g_return_if_fail (HILDON_IS_WINDOW (self));
+
+    if (HILDON_WINDOW_GET_CLASS (self)->unset_program != NULL)
+        HILDON_WINDOW_GET_CLASS (self)->unset_program (self);
+}
+
 /*
  * Sets whether or not the program to which this window belongs is
  * killable. This is used by the HildonProgram to signify to the
@@ -1530,13 +1561,31 @@ detach_menu_func                                (GtkWidget *attach_widget,
     /* FIXME Why is this even needed here? */
 }
 
+static gboolean
+hildon_window_toggle_menu                       (HildonWindow *self,
+                                                guint button,
+                                                guint32 time)
+{
+    g_return_val_if_fail (HILDON_IS_WINDOW (self), FALSE);
+
+    if (HILDON_WINDOW_GET_CLASS (self)->toggle_menu != NULL)
+    {
+        return HILDON_WINDOW_GET_CLASS (self)->toggle_menu (self, button, time);
+    }
+    else
+    {
+        return FALSE;
+    }
+}
+
+
 /*
  * Toggles the display of the HildonWindow menu.
  * Returns whether or not something was done (whether or not we had a menu
  * to toggle)
  */
 static gboolean
-hildon_window_toggle_menu                       (HildonWindow * self,
+hildon_window_toggle_menu_real                  (HildonWindow * self,
                                                 guint button,
                                                 guint32 time)
 {