[Monodevelop-patches-list] r1057 - in trunk/MonoDevelop/gdldock: gdl sources/gdl

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Sat Feb 28 15:34:58 EST 2004


Author: tberman
Date: 2004-02-28 15:34:58 -0500 (Sat, 28 Feb 2004)
New Revision: 1057

Modified:
   trunk/MonoDevelop/gdldock/gdl/gdl-api.xml
   trunk/MonoDevelop/gdldock/sources/gdl/gdl-dock-item-grip.c
   trunk/MonoDevelop/gdldock/sources/gdl/gdl-dock-item.h
Log:
adding behavior's for Cant Close and Cant Iconify.

i prolly should get gustavo to review this patch, but im happy i got it working, so i'll commit anyway.


Modified: trunk/MonoDevelop/gdldock/gdl/gdl-api.xml
===================================================================
--- trunk/MonoDevelop/gdldock/gdl/gdl-api.xml	2004-02-28 18:49:02 UTC (rev 1056)
+++ trunk/MonoDevelop/gdldock/gdl/gdl-api.xml	2004-02-28 20:34:58 UTC (rev 1057)
@@ -17,6 +17,8 @@
       <member cname="GDL_DOCK_ITEM_BEH_CANT_DOCK_LEFT" name="CantDockLeft" value="1 &lt;&lt; 6" />
       <member cname="GDL_DOCK_ITEM_BEH_CANT_DOCK_RIGHT" name="CantDockRight" value="1 &lt;&lt; 7" />
       <member cname="GDL_DOCK_ITEM_BEH_CANT_DOCK_CENTER" name="CantDockCenter" value="1 &lt;&lt; 8" />
+      <member cname="GDL_DOCK_ITEM_BEH_CANT_CLOSE" name="CantClose" value="1 &lt;&lt; 9" />
+      <member cname="GDL_DOCK_ITEM_BEH_CANT_ICONIFY" name="CantIconify" value="1 &lt;&lt; 10" />
     </enum>
     <enum name="DockItemFlags" cname="GdlDockItemFlags" type="enum" hidden="1">
       <member cname="GDL_DOCK_IN_DRAG" name="InDrag" value="1 &lt;&lt; GDL_DOCK_OBJECT_FLAGS_SHIFT" />

Modified: trunk/MonoDevelop/gdldock/sources/gdl/gdl-dock-item-grip.c
===================================================================
--- trunk/MonoDevelop/gdldock/sources/gdl/gdl-dock-item-grip.c	2004-02-28 18:49:02 UTC (rev 1056)
+++ trunk/MonoDevelop/gdldock/sources/gdl/gdl-dock-item-grip.c	2004-02-28 20:34:58 UTC (rev 1057)
@@ -58,16 +58,36 @@
 {
     GtkWidget *widget = GTK_WIDGET (grip);
     gint       border = GTK_CONTAINER (grip)->border_width;
+    gint       alloc_height;
+    gint       alloc_width;
 
+    pango_layout_get_pixel_size (grip->_priv->title_layout, &alloc_width, &alloc_height);
+    if (GTK_WIDGET_VISIBLE (grip->_priv->close_button)) {
+        if (grip->_priv->close_button->allocation.height > alloc_height) {
+            alloc_height = grip->_priv->close_button->allocation.height;
+	}
+	if (grip->_priv->close_button->allocation.width > alloc_width) {
+            alloc_width  = grip->_priv->close_button->allocation.width;
+	}
+    }
+    if (GTK_WIDGET_VISIBLE (grip->_priv->iconify_button)) {
+        if (grip->_priv->iconify_button->allocation.height > alloc_height) {
+	    alloc_height = grip->_priv->iconify_button->allocation.height;
+	}
+	if (grip->_priv->iconify_button->allocation.width > alloc_width) {
+	    alloc_width = grip->_priv->iconify_button->allocation.width;
+	}
+    }
+
     area->x      = widget->allocation.x + border;
     area->y      = widget->allocation.y + border;
     area->width  = (widget->allocation.width -
                     2 * border -
-                    2 * grip->_priv->close_button->allocation.width);
-    area->height = grip->_priv->close_button->allocation.height;
+                    2 * alloc_width);
+    area->height = alloc_height;
 
     if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
-        area->x += 2 * grip->_priv->close_button->allocation.width;
+        area->x += 2 * alloc_width;
 }
   
 static gint
@@ -355,16 +375,30 @@
     grip = GDL_DOCK_ITEM_GRIP (data);
 
     g_object_get (master, "long_name", &name, "stock_id", &stock_id, NULL);
-    if (name) {
+    if (name && grip->_priv->title_layout) {
         g_object_unref (grip->_priv->title_layout);
         grip->_priv->title_layout = NULL;
         g_free (name);
     }
-    if (stock_id) {
+    if (stock_id && grip->_priv->title_layout) {
         g_object_unref (grip->_priv->icon_pixbuf);
         grip->_priv->icon_pixbuf = NULL;
         g_free (stock_id);
     }
+    if (grip->_priv->close_button && grip->item) {
+        if (GDL_DOCK_ITEM_CANT_CLOSE (grip->item)) {
+	    gtk_widget_hide (GTK_WIDGET (grip->_priv->close_button));
+	} else {
+	    gtk_widget_show (GTK_WIDGET (grip->_priv->close_button));
+	}
+    }
+    if (grip->_priv->iconify_button && grip->item) {
+        if (GDL_DOCK_ITEM_CANT_ICONIFY (grip->item)) {
+	    gtk_widget_hide (GTK_WIDGET (grip->_priv->iconify_button));
+	} else {
+	    gtk_widget_show (GTK_WIDGET (grip->_priv->iconify_button));
+	}
+    }
 
     gtk_widget_queue_resize (GTK_WIDGET (grip));
 }
@@ -426,6 +460,9 @@
                 g_signal_connect (grip->item, "notify::stock_id",
                                   G_CALLBACK (gdl_dock_item_grip_item_notify),
                                   grip);
+		g_signal_connect (grip->item, "notify::behavior",
+		                  G_CALLBACK (gdl_dock_item_grip_item_notify),
+				  grip);
             }
             break;
         default:
@@ -626,6 +663,8 @@
     GdlDockItemGrip *grip;
     GdkRectangle     title_rect;
     gchar           *stock_id;
+    gchar           *name;
+    gint             layout_height;
 
     g_return_if_fail (GDL_IS_DOCK_ITEM_GRIP (widget));
     g_return_if_fail (requisition != NULL);
@@ -636,19 +675,35 @@
     requisition->width = container->border_width * 2;
     requisition->height = container->border_width * 2;
 
+    if (!grip->_priv->title_layout) {
+        g_object_get (G_OBJECT (grip->item), "long_name", &name, NULL);
+        grip->_priv->title_layout = gtk_widget_create_pango_layout (widget,
+                                                                    name);
+        g_free (name);
+    }
+
+    pango_layout_get_pixel_size (grip->_priv->title_layout, NULL, &layout_height);
+
     if (GTK_WIDGET_VISIBLE (grip->_priv->close_button)) {
         gtk_widget_size_request (grip->_priv->close_button, &child_requisition);
 
         requisition->width += child_requisition.width;
-        requisition->height += child_requisition.height;
+	if (child_requisition.height > layout_height) {
+            layout_height = child_requisition.height;
+	}
     }
     
     if (GTK_WIDGET_VISIBLE (grip->_priv->iconify_button)) {
         gtk_widget_size_request (grip->_priv->iconify_button, &child_requisition);
 
         requisition->width += child_requisition.width;
+	if (child_requisition.height > layout_height) {
+	    layout_height = child_requisition.height;
+	}
     }
 
+    requisition->height += layout_height;
+
     gdl_dock_item_grip_get_title_area (grip, &title_rect);
     requisition->width += title_rect.width;
 
@@ -704,6 +759,7 @@
     }
 
     if (GTK_WIDGET_VISIBLE (grip->_priv->iconify_button)) {
+        gtk_widget_size_request (grip->_priv->close_button, &button_requisition);
         if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
             child_allocation.x = (allocation->width -
                                   container->border_width -

Modified: trunk/MonoDevelop/gdldock/sources/gdl/gdl-dock-item.h
===================================================================
--- trunk/MonoDevelop/gdldock/sources/gdl/gdl-dock-item.h	2004-02-28 18:49:02 UTC (rev 1056)
+++ trunk/MonoDevelop/gdldock/sources/gdl/gdl-dock-item.h	2004-02-28 20:34:58 UTC (rev 1057)
@@ -53,7 +53,9 @@
     GDL_DOCK_ITEM_BEH_CANT_DOCK_BOTTOM = 1 << 5,
     GDL_DOCK_ITEM_BEH_CANT_DOCK_LEFT   = 1 << 6,
     GDL_DOCK_ITEM_BEH_CANT_DOCK_RIGHT  = 1 << 7,
-    GDL_DOCK_ITEM_BEH_CANT_DOCK_CENTER = 1 << 8
+    GDL_DOCK_ITEM_BEH_CANT_DOCK_CENTER = 1 << 8,
+    GDL_DOCK_ITEM_BEH_CANT_CLOSE       = 1 << 9,
+    GDL_DOCK_ITEM_BEH_CANT_ICONIFY     = 1 << 10
 } GdlDockItemBehavior;
 
 typedef enum {
@@ -119,6 +121,12 @@
 
 #define GDL_DOCK_ITEM_HAS_GRIP(item) (GDL_DOCK_ITEM_GET_CLASS (item)->has_grip)
 
+#define GDL_DOCK_ITEM_CANT_CLOSE(item) \
+    (((item)->behavior & GDL_DOCK_ITEM_BEH_CANT_CLOSE) != 0)
+
+#define GDL_DOCK_ITEM_CANT_ICONIFY(item) \
+    (((item)->behavior & GDL_DOCK_ITEM_BEH_CANT_ICONIFY) != 0)
+
 /* public interface */
  
 GtkWidget     *gdl_dock_item_new               (const gchar         *name,




More information about the Monodevelop-patches-list mailing list