Author: danw
Date: 2005-04-07 17:48:46 -0400 (Thu, 07 Apr 2005)
New Revision: 42658

Added:
   trunk/stetic/glue/custom.c
   trunk/stetic/libstetic/wrapper/Custom.cs
   trunk/stetic/libstetic/wrapper/pixmaps/custom.png
Modified:
   trunk/stetic/ChangeLog
   trunk/stetic/glue/Makefile.am
   trunk/stetic/libstetic/Makefile.am
   trunk/stetic/libstetic/wrapper/Calendar.cs
   trunk/stetic/libstetic/wrapper/ComboBox.cs
   trunk/stetic/libstetic/wrapper/ScrolledWindow.cs
   trunk/stetic/libstetic/wrapper/Widget.cs
Log:
        * glue/custom.c: 
        * libstetic/wrapper/Custom.cs: 
        * libstetic/wrapper/pixmaps/custom.png: Add custom widgets (a bit
        kludgy at the moment).

        * libstetic/wrapper/Calendar.cs (GladeImport): handle "display_options"

        * libstetic/wrapper/ComboBox.cs (Items): tag this properly for
        glade import/export

        * libstetic/wrapper/ScrolledWindow.cs (AddPlaceholder): override
        this to add the placeholder in a viewport

        * libstetic/wrapper/Widget.cs (ParentWrapper): fix to not get into
        an infinite loop on toplevel windows.


Modified: trunk/stetic/ChangeLog
===================================================================
--- trunk/stetic/ChangeLog      2005-04-07 21:16:33 UTC (rev 42657)
+++ trunk/stetic/ChangeLog      2005-04-07 21:48:46 UTC (rev 42658)
@@ -1,5 +1,23 @@
 2005-04-07  Dan Winship  <[EMAIL PROTECTED]>
 
+       * glue/custom.c: 
+       * libstetic/wrapper/Custom.cs: 
+       * libstetic/wrapper/pixmaps/custom.png: Add custom widgets (a bit
+       kludgy at the moment).
+
+       * libstetic/wrapper/Calendar.cs (GladeImport): handle "display_options"
+
+       * libstetic/wrapper/ComboBox.cs (Items): tag this properly for
+       glade import/export
+
+       * libstetic/wrapper/ScrolledWindow.cs (AddPlaceholder): override
+       this to add the placeholder in a viewport
+
+       * libstetic/wrapper/Widget.cs (ParentWrapper): fix to not get into
+       an infinite loop on toplevel windows.
+
+2005-04-07  Dan Winship  <[EMAIL PROTECTED]>
+
        Add Toolbar and its children, plus a bunch of things I had to fix
        to get there.
        

Modified: trunk/stetic/glue/Makefile.am
===================================================================
--- trunk/stetic/glue/Makefile.am       2005-04-07 21:16:33 UTC (rev 42657)
+++ trunk/stetic/glue/Makefile.am       2005-04-07 21:48:46 UTC (rev 42658)
@@ -6,9 +6,6 @@
 libsteticglue_la_LIBADD = $(GTK_LIBS)
 
 libsteticglue_la_SOURCES =     \
+       custom.c                \
        paramspec.c             \
        value.c
-
-
-
-

Added: trunk/stetic/glue/custom.c
===================================================================
--- trunk/stetic/glue/custom.c  2005-04-07 21:16:33 UTC (rev 42657)
+++ trunk/stetic/glue/custom.c  2005-04-07 21:48:46 UTC (rev 42658)
@@ -0,0 +1,59 @@
+#include <gtk/gtkdrawingarea.h>
+
+/* This is done in C, because it's tiny, and it's much simpler to make
+ * glade import/export work if the registered name of the class is just
+ * "Custom", and GLib.Object won't let us do that.
+ */
+
+typedef struct {
+       GtkDrawingArea parent;
+} Custom;
+
+typedef struct {
+       GtkDrawingAreaClass parent_class;
+} CustomClass;
+
+GType custom_get_type (void);
+static void custom_realize (GtkWidget *widget);
+
+G_DEFINE_TYPE (Custom, custom, GTK_TYPE_DRAWING_AREA)
+
+static void
+custom_class_init (CustomClass *klass)
+{
+       GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+       widget_class->realize = custom_realize;
+}
+
+static void
+custom_init (Custom *custom)
+{
+       ;
+}
+
+/* from glade */
+static char * custom_bg_xpm[] = {
+"8 8 4 1",
+"      c None",
+".     c #BBBBBB",
+"+     c #D6D6D6",
+"@     c #6B5EFF",
+".+..+...",
+"+..@@@..",
+"[EMAIL PROTECTED]",
+"[EMAIL PROTECTED]",
+"[EMAIL PROTECTED]",
+".++@@@..",
+"..++....",
+"..++...."};
+
+static void
+custom_realize (GtkWidget *widget)
+{
+       GTK_WIDGET_CLASS (custom_parent_class)->realize (widget);
+
+       GdkPixmap *pixmap;
+       pixmap = gdk_pixmap_create_from_xpm_d (widget->window, NULL, NULL, 
custom_bg_xpm);
+       gdk_window_set_back_pixmap (widget->window, pixmap, FALSE);
+}

Modified: trunk/stetic/libstetic/Makefile.am
===================================================================
--- trunk/stetic/libstetic/Makefile.am  2005-04-07 21:16:33 UTC (rev 42657)
+++ trunk/stetic/libstetic/Makefile.am  2005-04-07 21:48:46 UTC (rev 42658)
@@ -50,6 +50,7 @@
        wrapper/ComboBox.cs             \
        wrapper/ComboBoxEntry.cs        \
        wrapper/Container.cs            \
+       wrapper/Custom.cs               \
        wrapper/Dialog.cs               \
        wrapper/DrawingArea.cs          \
        wrapper/Entry.cs                \

Modified: trunk/stetic/libstetic/wrapper/Calendar.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Calendar.cs  2005-04-07 21:16:33 UTC (rev 
42657)
+++ trunk/stetic/libstetic/wrapper/Calendar.cs  2005-04-07 21:48:46 UTC (rev 
42658)
@@ -1,4 +1,5 @@
 using System;
+using System.Collections;
 
 namespace Stetic.Wrapper {
 
@@ -15,5 +16,28 @@
                                      "ShowWeekNumbers",
                                      "NoMonthChange");
                }
+
+               protected override void GladeImport (string className, string 
id, Hashtable props)
+               {
+                       string display_options = GladeUtils.ExtractProperty 
("display_options", props);
+                       base.GladeImport (className, id, props);
+
+                       if (display_options != null) {
+                               Gtk.CalendarDisplayOptions options = 0;
+
+                               if (display_options.IndexOf ("SHOW_HEADING") != 
-1)
+                                       options |= 
Gtk.CalendarDisplayOptions.ShowHeading;
+                               if (display_options.IndexOf ("SHOW_DAY_NAMES") 
!= -1)
+                                       options |= 
Gtk.CalendarDisplayOptions.ShowDayNames;
+                               if (display_options.IndexOf ("NO_MONTH_CHANGE") 
!= -1)
+                                       options |= 
Gtk.CalendarDisplayOptions.NoMonthChange;
+                               if (display_options.IndexOf 
("SHOW_WEEK_NUMBERS") != -1)
+                                       options |= 
Gtk.CalendarDisplayOptions.ShowWeekNumbers;
+                               if (display_options.IndexOf 
("WEEK_START_MONDAY") != -1)
+                                       options |= 
Gtk.CalendarDisplayOptions.WeekStartMonday;
+
+                               ((Gtk.Calendar)Wrapped).DisplayOptions = 
options;
+                       }
+               }
        }
 }

Modified: trunk/stetic/libstetic/wrapper/ComboBox.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/ComboBox.cs  2005-04-07 21:16:33 UTC (rev 
42657)
+++ trunk/stetic/libstetic/wrapper/ComboBox.cs  2005-04-07 21:48:46 UTC (rev 
42658)
@@ -34,7 +34,7 @@
 
                [Editor (typeof (Stetic.Editor.Text))]
                [Description ("Items", "The items to display in the Combo Box, 
one per line")]
-               [GladeProperty]
+               [GladeProperty (Name = "items")]
                public string Items {
                        get {
                                return items;

Added: trunk/stetic/libstetic/wrapper/Custom.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Custom.cs    2005-04-07 21:16:33 UTC (rev 
42657)
+++ trunk/stetic/libstetic/wrapper/Custom.cs    2005-04-07 21:48:46 UTC (rev 
42658)
@@ -0,0 +1,109 @@
+using System;
+using System.Collections;
+using System.Runtime.InteropServices;
+
+namespace Stetic {
+       public class Custom : Gtk.DrawingArea {
+               static Custom ()
+               {
+                       GLib.ObjectManager.RegisterType (GType, typeof 
(Stetic.Custom));
+               }
+
+               public Custom (IntPtr raw) : base(raw) {}
+               public Custom () : base (IntPtr.Zero) {}
+
+               ~Custom () { Dispose (); }
+
+               [DllImport("libsteticglue")]
+               static extern IntPtr custom_get_type();
+
+               public static new GLib.GType GType { 
+                       get {
+                               return new GLib.GType (custom_get_type ());
+                       }
+               }
+       }
+}
+
+namespace Stetic.Wrapper {
+
+       [ObjectWrapper ("Custom Widget", "custom.png", 
ObjectWrapperType.Widget)]
+       public class Custom : DrawingArea {
+
+               public static new Type WrappedType = typeof (Stetic.Custom);
+
+               static new void Register (Type type)
+               {
+                       AddItemGroup (type, "Custom Widget Properties",
+                                     "CreationFunction",
+                                     "String1",
+                                     "String2",
+                                     "Int1",
+                                     "Int2");
+               }
+
+               string creationFunction, string1, string2, int1 = "0", int2 = 
"0";
+
+               [GladeProperty (Name = "creation_function")]
+               public string CreationFunction {
+                       get {
+                               return creationFunction;
+                       }
+                       set {
+                               creationFunction = value;
+                       }
+               }
+
+               [GladeProperty (Name = "string1")]
+               public string String1 {
+                       get {
+                               return string1;
+                       }
+                       set {
+                               string1 = value;
+                       }
+               }
+
+               [GladeProperty (Name = "string2")]
+               public string String2 {
+                       get {
+                               return string2;
+                       }
+                       set {
+                               string2 = value;
+                       }
+               }
+
+               // This is sort of lame. But the properties were actually 
int-valued,
+               // they would need GladeProxies. We should move all of these 
into
+               // custom.c anyway.
+
+               [GladeProperty (Name = "int1")]
+               public string Int1 {
+                       get {
+                               return int1;
+                       }
+                       set {
+                               try {
+                                       int1 = Int32.Parse (value).ToString ();
+                               } catch {
+                                       int1 = "0";
+                               }
+                       }
+               }
+
+               [GladeProperty (Name = "int2")]
+               public string Int2 {
+                       get {
+                               return int2;
+                       }
+                       set {
+                               try {
+                                       int2 = Int32.Parse (value).ToString ();
+                               } catch {
+                                       int2 = "0";
+                               }
+                       }
+               }
+       }
+}

Modified: trunk/stetic/libstetic/wrapper/ScrolledWindow.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/ScrolledWindow.cs    2005-04-07 21:16:33 UTC 
(rev 42657)
+++ trunk/stetic/libstetic/wrapper/ScrolledWindow.cs    2005-04-07 21:48:46 UTC 
(rev 42658)
@@ -42,5 +42,14 @@
                        else
                                scwin.AddWithViewport (newChild);
                }
+
+               public override Placeholder AddPlaceholder ()
+               {
+                       Gtk.ScrolledWindow scwin = (Gtk.ScrolledWindow)Wrapped;
+
+                       Placeholder ph = CreatePlaceholder ();
+                       scwin.AddWithViewport (ph);
+                       return ph;
+               }
        }
 }

Modified: trunk/stetic/libstetic/wrapper/Widget.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Widget.cs    2005-04-07 21:16:33 UTC (rev 
42657)
+++ trunk/stetic/libstetic/wrapper/Widget.cs    2005-04-07 21:48:46 UTC (rev 
42658)
@@ -66,7 +66,7 @@
 
                public Stetic.Wrapper.Container ParentWrapper {
                        get {
-                               Gtk.Widget parent = Wrapped;
+                               Gtk.Widget parent = Wrapped.Parent;
                                Container wrapper = null;
                                while (wrapper == null && parent != null) {
                                        wrapper = 
Stetic.Wrapper.Container.Lookup (parent);

Added: trunk/stetic/libstetic/wrapper/pixmaps/custom.png
===================================================================
(Binary files differ)


Property changes on: trunk/stetic/libstetic/wrapper/pixmaps/custom.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to