[Gtk-sharp-list] Calendar customizations

Gonzalo Paniagua Javier gonzalo@ximian.com
22 Mar 2003 18:30:28 +0100


--=-qdqtMF33zC78ot8CPebD
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi!

I've added a GetDate overload that returns a DateTime.

Also Lee asked me to make DisplayOptions a property instead of a method.

Here are the patches.

Ok to commit?

-Gonzalo


--=-qdqtMF33zC78ot8CPebD
Content-Disposition: attachment; filename=calendar.patch
Content-Type: text/x-patch; name=calendar.patch; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Index: api/gtk-api.xml
===================================================================
RCS file: /cvs/public/gtk-sharp/api/gtk-api.xml,v
retrieving revision 1.26
diff -u -r1.26 gtk-api.xml
--- api/gtk-api.xml	22 Feb 2003 04:34:55 -0000	1.26
+++ api/gtk-api.xml	22 Mar 2003 17:30:01 -0000
@@ -1816,7 +1816,7 @@
       <method name="ClearMarks" cname="gtk_calendar_clear_marks">
         <return-type type="void"/>
       </method>
-      <method name="DisplayOptions" cname="gtk_calendar_display_options">
+      <method name="DisplayOptions" cname="gtk_calendar_display_options" hidden="1">
         <return-type type="void"/>
         <parameters>
           <parameter type="GtkCalendarDisplayOptions" name="flags"/>
Index: sample/CalendarApp.cs
===================================================================
RCS file: /cvs/public/gtk-sharp/sample/CalendarApp.cs,v
retrieving revision 1.1
diff -u -r1.1 CalendarApp.cs
--- sample/CalendarApp.cs	22 Mar 2003 16:37:03 -0000	1.1
+++ sample/CalendarApp.cs	22 Mar 2003 17:30:03 -0000
@@ -16,7 +16,9 @@
 		public static Calendar CreateCalendar ()
 		{
 			Calendar cal = new Calendar();
-			cal.DisplayOptions (CalendarDisplayOptions.ShowHeading | CalendarDisplayOptions.ShowDayNames | CalendarDisplayOptions.ShowWeekNumbers);
+			cal.DisplayOptions = CalendarDisplayOptions.ShowHeading    |
+					     CalendarDisplayOptions.ShowDayNames   |
+					     CalendarDisplayOptions.ShowWeekNumbers;
 			return cal;
 		}
 
@@ -37,11 +39,7 @@
 		static void DaySelected (object obj, EventArgs args)
 		{
 			Calendar activatedCalendar = (Calendar) obj;
-			uint year, month, day;
-			activatedCalendar.GetDate(out year, out month, out day);
-			// The month is zero-based, so tweak it before output
-			Console.WriteLine ("Selected date: {0}/{1}/{2}",
-					   year, month+1, day);
+			Console.WriteLine (activatedCalendar.GetDate ().ToString ("yyyy/MM/dd"));
 		}
 
 		static void Window_Delete (object obj, DeleteEventArgs args)
Index: sources/Gtk.metadata
===================================================================
RCS file: /cvs/public/gtk-sharp/sources/Gtk.metadata,v
retrieving revision 1.44
diff -u -r1.44 Gtk.metadata
--- sources/Gtk.metadata	21 Feb 2003 03:44:42 -0000	1.44
+++ sources/Gtk.metadata	22 Mar 2003 17:30:04 -0000
@@ -1528,6 +1528,17 @@
     </attribute>
   </data>
 </rule>
+<rule>
+  <class name="GtkCalendar">
+    <method>DisplayOptions</method>
+  </class>
+  <data>
+    <attribute target="method">
+      <name>hidden</name>
+      <value>1</value>
+    </attribute>
+  </data>
+</rule>
 
 <!-- overloads -->
 <rule>

--=-qdqtMF33zC78ot8CPebD
Content-Disposition: attachment; filename=Calendar.custom
Content-Type: text/plain; name=Calendar.custom; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

// Gtk.TreeSelection.Custom - Gtk TreeSelection calss customizations
//
// Author:
//	 Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
// (c) 2003 Ximian, Inc. (http://www.ximian.com)
//
// This code is inserted after the automatically generated code.


                /// <summary> GetSelected Method </summary>
                /// <remarks> To be completed </remarks>

                public DateTime GetDate ()
		{
			uint year, month, day;
			GetDate (out year, out month, out day);
			return new DateTime ((int) year, (int) month + 1, (int) day);
                }

		[DllImport("libgtk-win32-2.0-0.dll")]
		static extern void gtk_calendar_display_options (IntPtr raw, int flags);

		public Gtk.CalendarDisplayOptions DisplayOptions {
			set {
				gtk_calendar_display_options (Handle, (int) value);
			}
		}

--=-qdqtMF33zC78ot8CPebD--