[maemo-commits] [maemo-commits] r9346 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . libhildondesktop

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Thu Jan 25 15:41:19 EET 2007
Author: moimart
Date: 2007-01-25 15:41:18 +0200 (Thu, 25 Jan 2007)
New Revision: 9346

Modified:
   projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog
   projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hildon-desktop-panel-expandable.c
Log:

	* libhildondesktop/hildon-desktop-panel-expandable.c:
        - Fixed positioning in extended panel (GtkTable).
        - Fixed positioning in extended window.
        - Added scalability on-the-fly.
	* ChangeLog updated.



Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog
===================================================================
--- projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog	2007-01-25 13:09:51 UTC (rev 9345)
+++ projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog	2007-01-25 13:41:18 UTC (rev 9346)
@@ -1,5 +1,12 @@
 2007-01-24  Moises Martinez  <moises.martinez at nokia.com>
 
+	* libhildondesktop/hildon-desktop-panel-expandable.c:
+	- Fixed positioning in extended panel (GtkTable).
+	- Fixed positioning in extended window.
+	- Added scalability on-the-fly.
+
+2007-01-24  Moises Martinez  <moises.martinez at nokia.com>
+
 	* libhildondesktop/hildon-desktop-panel-expandable.c: 
 	- Fixed few wrong behaviors
 

Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hildon-desktop-panel-expandable.c
===================================================================
--- projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hildon-desktop-panel-expandable.c	2007-01-25 13:09:51 UTC (rev 9345)
+++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hildon-desktop-panel-expandable.c	2007-01-25 13:41:18 UTC (rev 9346)
@@ -87,6 +87,8 @@
 
 static void hildon_desktop_panel_expandable_arrow_toggled (GtkToggleButton *button, gpointer _panel);
 
+static void hildon_desktop_panel_expandable_resize_notify (HildonDesktopPanelExpandable *panel);
+
 static void 
 hildon_desktop_panel_expandable_class_init (HildonDesktopPanelExpandableClass *panel_class)
 {
@@ -124,8 +126,8 @@
 {
   panel->priv = HILDON_DESKTOP_PANEL_EXPANDABLE_GET_PRIVATE (panel);
 
+  panel->priv->items_p_row = 0;
   panel->priv->n_items = 0;
-
   panel->priv->items = NULL;
 
   panel->priv->extension_opened = FALSE;
@@ -153,12 +155,17 @@
 
   gtk_window_set_decorated (panel->priv->extension_window, FALSE);
 
-  panel->priv->extension_table = GTK_TABLE (gtk_table_new (1,panel->priv->items_p_row,FALSE));
+  panel->priv->extension_table = GTK_TABLE (gtk_table_new (1,panel->priv->items_p_row,TRUE));
 
   gtk_container_add (GTK_CONTAINER (panel->priv->extension_window),
 		     GTK_WIDGET (panel->priv->extension_table));
 
   gtk_widget_show (GTK_WIDGET (panel->priv->extension_table));
+
+  g_signal_connect (object,
+		    "notify::items_row",
+		    G_CALLBACK (hildon_desktop_panel_expandable_resize_notify),
+		    NULL);
   
   return object;
 }
@@ -212,6 +219,7 @@
 			   		      GParamSpec *pspec)
 {
   HildonDesktopPanelExpandable *panel;
+  guint new_items_p_row;
 
   g_assert (object && HILDON_DESKTOP_IS_PANEL_EXPANDABLE (object));
 
@@ -220,7 +228,12 @@
   switch (prop_id)
   {
     case PROP_ITEMS_P_ROW:
-      panel->priv->items_p_row = g_value_get_uint (value);
+      new_items_p_row =  g_value_get_uint (value);
+      
+      if (panel->priv->items_p_row != 0 && panel->priv->items_p_row != new_items_p_row)
+	g_object_notify (object,"items_row");
+      
+      panel->priv->items_p_row = new_items_p_row;
       break;
 
     default:
@@ -245,7 +258,7 @@
 		      (gpointer)ex_panel);
   }
 
-  if ((ex_panel->priv->n_items+1) >= ex_panel->priv->items_p_row)
+  if ((ex_panel->priv->n_items+1) > ex_panel->priv->items_p_row)
   {
     GtkWidget *arrow =  hildon_desktop_panel_expandable_add_arrow (ex_panel);
 
@@ -278,8 +291,8 @@
 
   g_debug ("Adding button in expandable extension");
 
-  n_rows = ((panel->priv->n_items+1)/panel->priv->items_p_row) + 
-	   ((((panel->priv->n_items+1) % panel->priv->items_p_row) > 0) ? 1 : 0);
+  n_rows = (((panel->priv->n_items+1)/panel->priv->items_p_row) + 
+	   ((((panel->priv->n_items+1) % panel->priv->items_p_row) > 0) ? 1 : 0)) - 1;
 	
   g_object_get (panel->priv->extension_table, "n-rows", &table_rows, NULL);
 
@@ -293,14 +306,20 @@
   top_attach    = n_rows-1;
   bottom_attach = n_rows;
 
-  left_attach  = ((panel->priv->n_items+1) % panel->priv->items_p_row) - 1;
-  right_attach = left_attach + 2;
+  if ((panel->priv->n_items % panel->priv->items_p_row) == 0)
+    left_attach = 0;
+  else 
+    left_attach = (((panel->priv->n_items+1) % panel->priv->items_p_row)+1);
 
-  gtk_table_attach_defaults (panel->priv->extension_table,
-		  	     GTK_WIDGET (item),
-		  	     left_attach, right_attach,
-			     top_attach, bottom_attach);
+  right_attach = left_attach + 1;
 
+  gtk_table_attach (panel->priv->extension_table,
+		    GTK_WIDGET (item),
+		    left_attach, right_attach,
+		    top_attach, bottom_attach,
+		    GTK_SHRINK, GTK_SHRINK,
+		    0,0);
+
   panel->priv->n_items++;
 }
 
@@ -368,6 +387,7 @@
   {
     gtk_image_set_from_pixbuf (GTK_IMAGE(arrow_image), arrow_pixbuf);
     gdk_pixbuf_unref (arrow_pixbuf);
+    g_debug ("%s: %d, setting pixbuf for arrow",__FILE__,__LINE__);
   }
   else
   if (error)
@@ -391,13 +411,40 @@
 static void 
 hildon_desktop_panel_expandable_arrow_toggled (GtkToggleButton *button, gpointer _panel)
 {
-  /*gint p_width, p_height;*/
+  gint p_width, p_height, p_x, p_y;
+  guint _offset = 1;
+  GdkWindow *window;
   HildonDesktopPanelExpandable *panel = HILDON_DESKTOP_PANEL_EXPANDABLE (_panel);
 
   panel->priv->extension_opened = !panel->priv->extension_opened;
 
   if (panel->priv->extension_opened)
   {
+    window = gtk_widget_get_parent_window (GTK_WIDGET (panel));
+
+    gdk_window_get_geometry (window, 
+		    	     &p_x, &p_y,
+			     &p_width, &p_height,
+			     NULL);
+
+    gtk_window_set_default_size (panel->priv->extension_window,
+		    		 p_width,p_height);
+
+    if (HILDON_DESKTOP_PANEL (panel)->orient == GTK_ORIENTATION_VERTICAL)
+    {
+      if (p_x != 0) 
+	_offset *= -1;
+      
+      gtk_window_move (panel->priv->extension_window, p_x + p_width*_offset,p_y);
+    }
+    else
+    { 
+      if (p_y != 0)
+	_offset *= -1;
+
+      gtk_window_move (panel->priv->extension_window, p_x, p_y + p_height*_offset);
+    }
+	  
     gtk_widget_show (GTK_WIDGET (panel->priv->extension_window));
 
     /*TODO: Positioning and sizing of the window */
@@ -408,3 +455,16 @@
   } 
 }
 
+static void 
+hildon_desktop_panel_expandable_resize_notify (HildonDesktopPanelExpandable *panel)
+{
+  guint n_rows;
+
+  g_object_get (panel->priv->extension_table, "n-rows", &n_rows, NULL);
+	
+  gtk_table_resize (panel->priv->extension_table,
+		    n_rows,
+		    panel->priv->items_p_row);
+
+  hildon_desktop_panel_expandable_arrange_items (panel);  
+}


More information about the maemo-commits mailing list