[Gtk-sharp-list] Overloading the AddButton method of the Gtk.Dialog and Gtk.MessageDialog

Philip Van Hoof spamfrommailing@freax.org
12 May 2003 04:23:59 +0200


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


This patch overloads the AddButton method so that you can pass a
Stock-argument in stead of only a string.


Gtk-documentation :
[http://developer.gnome.org/doc/API/2.0/gtk/GtkDialog.html]

GtkWidget*  gtk_dialog_add_button (GtkDialog *dialog, const gchar
*button_text, gint response_id);

Adds a button with the given text (or a stock button, if button_text is
a stock ID) and sets things up so that clicking the button will emit the
"response" signal with the given response_id. The button is appended to
the end of the dialog's action area. The button widget is returned, but
usually you don't need it.

So this patch implements the "(or a stock button, if button_text is a
stock ID)"-part of that documentation ...


[root@pluisje gtk]# cvs diff -u >
	/home/freax/Dialog_AddButton_w_Stock.diff

cvs server: Diffing .
[root@pluisje gtk]# pwd
/home/freax/cvs/gtk-sharp/gtk
[root@pluisje gtk]#

Usage:

{
  Gtk.Dialog a;

  a = new  Dialog ("test", win, DialogFlags.Modal);
  a.AddButton(Gtk.Stock.Add, 2);
  a.Run();
}

hf.

-- 
Philip Van Hoof a.k.a. freax
me at freax dot org
http://www.freax.be -- http://www.freax.eu.org -- http://www.freax.org



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

Index: Dialog.custom
===================================================================
RCS file: /mono/gtk-sharp/gtk/Dialog.custom,v
retrieving revision 1.3
diff -u -r1.3 Dialog.custom
--- Dialog.custom	22 Feb 2003 04:34:56 -0000	1.3
+++ Dialog.custom	12 May 2003 02:16:51 -0000
@@ -17,6 +17,16 @@
 	Raw = gtk_dialog_new_with_buttons (title, parent.Handle, (int) flags, IntPtr.Zero);
 }
 
+[DllImport("libgtk-win32-2.0-0.dll")]
+static extern IntPtr gtk_dialog_add_button(IntPtr raw, Stock s, int response_id);
+
+/// <summary> AddButtons Method </summary>
+public Gtk.Widget AddButton(Stock s, int response_id) {
+	IntPtr raw_ret = gtk_dialog_add_button(Handle, s, response_id);
+	Gtk.Widget ret = (Gtk.Widget) GLib.Object.GetObject(raw_ret);
+	return ret;
+}
+
 [DllImport("gtksharpglue")]
 static extern IntPtr gtksharp_dialog_get_vbox (IntPtr i);
 public Gtk.VBox VBox {
@@ -28,4 +38,3 @@
 public Gtk.VBox ActionArea {
 	get { return new Gtk.VBox (gtksharp_dialog_get_action_area (this.Handle)); }
 }
-

--=-XfkOwpt1lz8kGqfnmCS5--