From 289b127b10515834267f85927079877b9d7c61c9 Mon Sep 17 00:00:00 2001 From: Mike Kestner Date: Fri, 28 Jan 2005 16:03:27 +0000 Subject: [PATCH] 2005-01-28 Mike Kestner * gtk/Dialog.custom : add a params array for button info to the ctor. * gtk/FileChooserDialog.custom : add a params array for button info to both ctors. Chain them to IntPtr.Zero. * gtk/Gtk.metadata : hide the ellipsis ctors for the dialog types. [Fixes #71818] * sample/GtkDemo/DemoDialog.cs : make the InteractiveDialog use the new Dialog ctor as it does in the c version. svn path=/trunk/gtk-sharp/; revision=39713 --- ChangeLog | 10 ++ doc/en/Gtk/Dialog.xml | 14 ++- doc/en/Gtk/FileChooserDialog.xml | 191 ++++++++++++++++--------------- gtk/Dialog.custom | 10 +- gtk/FileChooserDialog.custom | 20 ++-- gtk/Gtk.metadata | 4 +- sample/GtkDemo/DemoDialog.cs | 76 +++++------- 7 files changed, 169 insertions(+), 156 deletions(-) diff --git a/ChangeLog b/ChangeLog index 00787148a..3919d4b58 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-01-28 Mike Kestner + + * gtk/Dialog.custom : add a params array for button info to the ctor. + * gtk/FileChooserDialog.custom : add a params array for button info to + both ctors. Chain them to IntPtr.Zero. + * gtk/Gtk.metadata : hide the ellipsis ctors for the dialog types. + [Fixes #71818] + * sample/GtkDemo/DemoDialog.cs : make the InteractiveDialog use the + new Dialog ctor as it does in the c version. + 2005-01-27 Mike Kestner * gtk/NodeSelection.cs : use new GetSelectedRows() overload. diff --git a/doc/en/Gtk/Dialog.xml b/doc/en/Gtk/Dialog.xml index 48247a4a7..ce87cb31a 100644 --- a/doc/en/Gtk/Dialog.xml +++ b/doc/en/Gtk/Dialog.xml @@ -304,20 +304,22 @@ namespace GtkDialogSample - + Constructor + Creates a new dialog box. - an object of type . - an object of type . - an object of type . - an object of type . + a title + a parent , or for an unparented dialog. + dialog characteristic such as modality and destruction policy. + a list of button text/response pairs if desired. + a Creates a new with the specified title and parent widget. The argument can be used to make the dialog modal () @@ -532,4 +534,4 @@ namespace GtkDialogSample - \ No newline at end of file + diff --git a/doc/en/Gtk/FileChooserDialog.xml b/doc/en/Gtk/FileChooserDialog.xml index 2b6dbd9d7..2afa027c5 100644 --- a/doc/en/Gtk/FileChooserDialog.xml +++ b/doc/en/Gtk/FileChooserDialog.xml @@ -10,7 +10,7 @@ Gtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details. A dialog box for choosing files. - Similar to but in a dialog. + Similar to but in a dialog. Gtk.Dialog @@ -74,7 +74,7 @@ Unselects all the files in the current folder of a file chooser. - + @@ -88,11 +88,11 @@ - Sets as the current filename for + Sets as the current filename for the file chooser; If the file name isn't in the current folder of the file chooser, then the current folder of the file chooser will be changed to the folder containing - . + . a a , true if both the @@ -100,12 +100,12 @@ selected successfully, false otherwise. This is equivalent to a sequence of - - followed by . + + followed by . Note that the file must exist, or nothing will be done except for the directory change. To pre-enter a filename for the user, as in - a save-as dialog, use . + a save-as dialog, use . @@ -125,7 +125,7 @@ a a - See also . + See also . @@ -177,9 +177,9 @@ - Selects the file at . If the URI doesn't refer to a + Selects the file at . If the URI doesn't refer to a file in the current folder of the file chooser, then the current folder of - the file chooser will be changed to the folder that's part of . + the file chooser will be changed to the folder that's part of . a a , true if both the @@ -199,10 +199,10 @@ - Removes from the list of filters that the user can select between. + Removes from the list of filters that the user can select between. a - + @@ -241,7 +241,7 @@ If the file name isn't in the current folder of the file chooser, then the current folder of the file chooser will - be changed to the folder containing . + be changed to the folder containing . @@ -276,7 +276,7 @@ - Adds to the list of filters that the + Adds to the list of filters that the user can select between. a @@ -299,7 +299,7 @@ Removes a folder from a file chooser's list of shortcut folders. a a - See also . + See also . @@ -313,7 +313,7 @@ - Unselects the file referred to by . + Unselects the file referred to by . a @@ -354,7 +354,7 @@ - Sets the file referred to by as the + Sets the file referred to by as the current file for the the file chooser. a @@ -364,13 +364,13 @@ If the file name isn't in the current folder of the file chooser, then the current folder of the file chooser will be changed to the folder containing - . This is equivalent to a sequence of - - followed by . + . This is equivalent to a sequence of + + followed by . Note that the file must exist, or nothing will be done except for the directory change. To pre-enter a filename for the user, as in - a save-as dialog, use . + a save-as dialog, use . @@ -452,51 +452,6 @@ - - - Constructor - - - - - - - - Public constructor. - a , title for the dialog - a , parent window - a , the action this dialog should be doing - a - - - - - - - Constructor - - - - - - - - - Makes a new file chooser dialog with a specific - file chooser backend - a - a - a - a , the backend name - a - - This is especially useful if you use - to allow - non-local files and you use a more expressive vfs, such as gnome-vfs, - to load files. - - - Property @@ -591,10 +546,10 @@ accessible through the operating systems native file file system and therefore the application only needs to worry about the filename functions in - , like - , + , like + , rather than the URI functions like - . + . @@ -607,7 +562,7 @@ - Sets whether the preview widget set by + Sets whether the preview widget set by should be shown for the current filename. a @@ -710,8 +665,8 @@ a This is only relevant if the action is set to be - or - . + or + . It cannot be set with either of the folder actions. @@ -730,26 +685,26 @@ a - + To implement a preview, after setting the preview widget, you connect to the - + signal, and check - or - + or + on each change. If you can display a preview of the new file, update your widget and set the preview active using - + Otherwise, set the preview inactive. - + When there is no application-supplied preview widget, or the application-supplied preview widget is not active, the file chooser may display an internally generated preview of the current file or it may display no preview at all. - + @@ -768,8 +723,8 @@ For example, an option to create a new folder might be shown if the action is - but not if the action is - . + but not if the action is + . @@ -867,7 +822,7 @@ This event is fired every time the selected file changes. - + @@ -905,23 +860,22 @@ selected file changes. - You should use this signal if you want your file chooser to have + You should use this signal if you want your file chooser to have a preview widget. - - Once you have installed a preview widget with - , you should update it when this + Once you have installed a preview widget with + , you should update it when this signal is emitted. You can use the properties - or - + or + to get the name of the file to preview. Your widget may not be able to preview all kinds of files; your callback - must set to inform the file + must set to inform the file chooser about whether the preview was generated successfully or not. - + TODO: insert example from gtkfilechooser-preview in gtk+ docs. - + @@ -947,5 +901,60 @@ + + + Constructor + + + + To be added + a + To be added + + + + + Constructor + + + + + + + + + Creates a file chooser dialog. + a title + a parent for the dialog, or . + an action, for example save or open. + a list of button text/response pairs for buttons to be added to the dialog, if desired. + a + + + + + + Constructor + + + + + + + + + + Creates a file chooser dialog with a specific file chooser backend + a title + a parent for the dialog, or . + an action, for example save or open. + a , the backend name + a list of button text/response pairs for buttons to be added to the dialog, if desired. + + This is especially useful if you use to allow + non-local files and you use a more expressive vfs, such as gnome-vfs, to load files. + + + diff --git a/gtk/Dialog.custom b/gtk/Dialog.custom index 597e828ae..d56821084 100644 --- a/gtk/Dialog.custom +++ b/gtk/Dialog.custom @@ -24,10 +24,9 @@ // Boston, MA 02111-1307, USA. -// Manually wrap until we figure out how to gen ellipses. [DllImport("libgtk-win32-2.0-0.dll")] static extern IntPtr gtk_dialog_new_with_buttons (string title, IntPtr i, int flags, IntPtr dummy); -public Dialog (string title, Gtk.Window parent, Gtk.DialogFlags flags) : base(IntPtr.Zero) +public Dialog (string title, Gtk.Window parent, Gtk.DialogFlags flags, params object[] button_data) : base(IntPtr.Zero) { if (GetType() != typeof (Dialog)) { GLib.Value[] vals = new GLib.Value [1]; @@ -42,10 +41,11 @@ public Dialog (string title, Gtk.Window parent, Gtk.DialogFlags flags) : base(In DestroyWithParent = true; if ((flags & DialogFlags.NoSeparator) > 0) HasSeparator = false; - return; - } + } else + Raw = gtk_dialog_new_with_buttons (title, parent.Handle, (int) flags, IntPtr.Zero); - Raw = gtk_dialog_new_with_buttons (title, parent.Handle, (int) flags, IntPtr.Zero); + for (int i = 0; i < button_data.Length - 1; i += 2) + AddButton ((string) button_data [i], (int) button_data [i + 1]); } [DllImport("gtksharpglue-2")] diff --git a/gtk/FileChooserDialog.custom b/gtk/FileChooserDialog.custom index 60ea8a200..170faabaf 100644 --- a/gtk/FileChooserDialog.custom +++ b/gtk/FileChooserDialog.custom @@ -23,7 +23,7 @@ [DllImport("libgtk-win32-2.0-0.dll")] static extern IntPtr gtk_file_chooser_dialog_new(string title, IntPtr parent, int action, IntPtr nil); - public FileChooserDialog (string title, Window parent, FileChooserAction action) + public FileChooserDialog (string title, Window parent, FileChooserAction action, params object[] button_data) : base (IntPtr.Zero) { if (GetType () != typeof (FileChooserDialog)) { CreateNativeObject (new string[0], new GLib.Value[0]); @@ -31,15 +31,17 @@ if (parent != null) TransientFor = parent; Action = action; - return; - } - Raw = gtk_file_chooser_dialog_new (title, parent == null ? IntPtr.Zero : parent.Handle, (int)action, IntPtr.Zero); + } else + Raw = gtk_file_chooser_dialog_new (title, parent == null ? IntPtr.Zero : parent.Handle, (int)action, IntPtr.Zero); + + for (int i = 0; i < button_data.Length - 1; i += 2) + AddButton ((string) button_data [i], (int) button_data [i + 1]); } [DllImport("libgtk-win32-2.0-0.dll")] static extern IntPtr gtk_file_chooser_dialog_new_with_backend(string title, IntPtr parent, int action, string backend, IntPtr nil); - public FileChooserDialog (string title, Window parent, FileChooserAction action, string backend) + public FileChooserDialog (string title, Window parent, FileChooserAction action, string backend, params object[] button_data) : base (IntPtr.Zero) { if (GetType () != typeof (FileChooserDialog)) { CreateNativeObject (new string[] { "file-system-backend" }, new GLib.Value[] { new GLib.Value (backend) } ); @@ -47,9 +49,11 @@ if (parent != null) TransientFor = parent; Action = action; - return; - } - Raw = gtk_file_chooser_dialog_new_with_backend (title, parent == null ? IntPtr.Zero : parent.Handle, (int)action, backend, IntPtr.Zero); + } else + Raw = gtk_file_chooser_dialog_new_with_backend (title, parent == null ? IntPtr.Zero : parent.Handle, (int)action, backend, IntPtr.Zero); + + for (int i = 0; i < button_data.Length - 1; i += 2) + AddButton ((string) button_data [i], (int) button_data [i + 1]); } [DllImport ("libgtk-win32-2.0-0.dll")] diff --git a/gtk/Gtk.metadata b/gtk/Gtk.metadata index 4188c14f7..0f3f6a385 100644 --- a/gtk/Gtk.metadata +++ b/gtk/Gtk.metadata @@ -158,7 +158,7 @@ Removed FocusChildSet 1 - 1 + 1 Respond GtkResponseType GtkResponseType @@ -170,6 +170,8 @@ ClipboardCut ClipboardPasted 1 + 1 + 1 1 GObject Activated diff --git a/sample/GtkDemo/DemoDialog.cs b/sample/GtkDemo/DemoDialog.cs index 5e0025d62..e7114897c 100644 --- a/sample/GtkDemo/DemoDialog.cs +++ b/sample/GtkDemo/DemoDialog.cs @@ -10,12 +10,6 @@ * Dialog widgets are used to pop up a transient window for user feedback. */ -// TODO: - Couldn't find a good equivalent to gtk_dialog_new_with_buttons -// in InteractiveDialogClicked -// - Check how to handle response type. Can we make the button to have -// the binding to the cancel signal automagicly like in -// gtk_dialog_new_with_buttons or should we just use the if ? - using System; using Gtk; @@ -102,49 +96,41 @@ namespace GtkDemo private void InteractiveDialogClicked (object o, EventArgs args) { - using (MessageDialog dialog = new MessageDialog (this, - DialogFlags.Modal | DialogFlags.DestroyWithParent, - MessageType.Question, - ButtonsType.Ok, - null)) { + Dialog dialog = new Dialog ("Interactive Dialog", this, DialogFlags.Modal | DialogFlags.DestroyWithParent, Gtk.Stock.Ok, ResponseType.Ok, "_Non-stock Button", ResponseType.Cancel); + + HBox hbox = new HBox (false, 8); + hbox.BorderWidth = 8; + dialog.VBox.PackStart (hbox, false, false, 0); + + Table table = new Table (2, 2, false); + table.RowSpacing = 4; + table.ColumnSpacing = 4; + hbox.PackStart (table, false, false, 0); + + Label label = new Label ("_Entry1"); + table.Attach (label, 0, 1, 0, 1); + Entry localEntry1 = new Entry(); + localEntry1.Text = entry1.Text; + table.Attach (localEntry1, 1, 2, 0, 1); + label.MnemonicWidget = localEntry1; + + label = new Label ("E_ntry2"); + table.Attach (label, 0, 1, 1, 2); + Entry localEntry2 = new Entry(); + localEntry2.Text = entry2.Text; + table.Attach (localEntry2, 1, 2, 1, 2); + label.MnemonicWidget = localEntry2; - dialog.AddButton ("_Non-stock Button", (int) ResponseType.Cancel); - - HBox hbox = new HBox (false, 8); - hbox.BorderWidth = 8; - dialog.VBox.PackStart (hbox, false, false, 0); - - Table table = new Table (2, 2, false); - table.RowSpacing = 4; - table.ColumnSpacing = 4; - hbox.PackStart (table, false, false, 0); - - Label label = new Label ("_Entry1"); - table.Attach (label, 0, 1, 0, 1); - Entry localEntry1 = new Entry(); - localEntry1.Text = entry1.Text; - table.Attach (localEntry1, 1, 2, 0, 1); - label.MnemonicWidget = localEntry1; - - label = new Label ("E_ntry2"); - table.Attach (label, 0, 1, 1, 2); - Entry localEntry2 = new Entry(); - localEntry2.Text = entry2.Text; - table.Attach (localEntry2, 1, 2, 1, 2); - label.MnemonicWidget = localEntry2; - - hbox.ShowAll (); + hbox.ShowAll (); - ResponseType response = (ResponseType) dialog.Run (); + ResponseType response = (ResponseType) dialog.Run (); - if (response == ResponseType.Ok) - { - entry1.Text = localEntry1.Text; - entry2.Text = localEntry2.Text; - } + if (response == ResponseType.Ok) { + entry1.Text = localEntry1.Text; + entry2.Text = localEntry2.Text; + } - dialog.Hide (); - } + dialog.Destroy (); } } }