[mistelix] audio selection dialog
- From: Jordi Mas <jmas src gnome org>
- To: svn-commits-list gnome org
- Subject: [mistelix] audio selection dialog
- Date: Sat, 25 Apr 2009 14:05:15 -0400 (EDT)
commit a12881bc81e8ee1e7f6187d6b697d7922d8d1413
Author: Jordi Mas <jmas softcatala org>
Date: Sat Apr 25 20:03:08 2009 +0200
audio selection dialog
---
ChangeLog | 13 ++
po/POTFILES.in | 3 +-
src/Makefile.am | 5 +-
src/core/SlideShow.cs | 7 +-
src/datamodel/SlideShowProjectElement.cs | 10 +-
src/dialogs/AddSlideDialog.cs | 25 ++++-
src/dialogs/AudioSelectionDialog.cs | 79 +++++++++++
src/dialogs/PreferencesDialog.cs | 18 ++--
src/dialogs/ThemeSelectionDialog.cs | 59 +--------
src/mistelix.glade | 150 ++++++++++++++++++++-
src/widgets/{BrowseDirectory.cs => BrowseFile.cs} | 49 +++++--
11 files changed, 325 insertions(+), 93 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 16e7d4f..025a551 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2009-04-25 Jordi Mas <jmas softcatala org>
+
+ * src/Makefile.am: Audio selection dialog
+ * src/core/SlideShow.cs: Audio selection dialog
+ * src/datamodel/SlideShowProjectElement.cs: Audio selection dialog
+ * src/dialogs/AddSlideDialog.cs: Audio selection dialog
+ * src/dialogs/AudioSelectionDialog.cs: Audio selection dialog
+ * src/dialogs/PreferencesDialog.cs: Audio selection dialog
+ * src/dialogs/ThemeSelectionDialog.cs: Audio selection dialog
+ * src/mistelix.glade: Audio selection dialog
+ * src/widgets/BrowseFile.cs: Audio selection dialog
+ * src/dialogs/AudioSelectionDialog.cs: Audio selection dialog
+
2009-04-11 Jordi Mas <jmas softcatala org>
* src/dialogs/GtkDialog.cs: Make Destroy method virtual
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 44f588f..2fc7dbf 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -15,6 +15,7 @@ src/datamodel/ProjectBuilder.cs
src/datamodel/TextPosition.cs
src/dialogs/AboutDialog.cs
src/dialogs/AddSlideDialog.cs
+src/dialogs/AudioSelectionDialog.cs
src/dialogs/CheckDependenciesDialog.cs
src/dialogs/NewProjectDialog.cs
src/dialogs/ProjectPropertiesDialog.cs
@@ -23,7 +24,7 @@ src/mistelix.cs
src/mistelix.glade
src/mono-addins-strings.xml
src/widgets/AuthoringPaneView.cs
-src/widgets/BrowseDirectory.cs
+src/widgets/BrowseFile.cs
src/widgets/DirectoryView.cs
src/widgets/ProjectElementView.cs
src/widgets/SlideShowImageView.cs
diff --git a/src/Makefile.am b/src/Makefile.am
index b7fe565..40c440f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -54,7 +54,7 @@ MISTELIX_CSDISTFILES = \
$(srcdir)/core/Button.cs \
$(srcdir)/dialogs/ProjectPropertiesDialog.cs \
$(srcdir)/core/Preferences.cs \
- $(srcdir)/widgets/BrowseDirectory.cs \
+ $(srcdir)/widgets/BrowseFile.cs \
$(srcdir)/datamodel/Resolution.cs \
$(srcdir)/core/ThumbnailSizeManager.cs \
$(srcdir)/datamodel/TextPosition.cs \
@@ -67,7 +67,8 @@ MISTELIX_CSDISTFILES = \
$(srcdir)/datamodel/Effect.cs \
$(srcdir)/core/EffectManager.cs \
$(srcdir)/widgets/DataImageSurface.cs \
- $(srcdir)/core/ResolutionManager.cs
+ $(srcdir)/core/ResolutionManager.cs \
+ $(srcdir)/dialogs/AudioSelectionDialog.cs
ASSEMBLIES = \
$(MISTELIX_LIBS) \
diff --git a/src/core/SlideShow.cs b/src/core/SlideShow.cs
index e027fd6..95e2d59 100644
--- a/src/core/SlideShow.cs
+++ b/src/core/SlideShow.cs
@@ -68,12 +68,11 @@ namespace Mistelix.Core
lib.SlideShowCreateStream (project.FileToFullPath (outfile), project.Details.Type,
(uint) project.Details.Width, (uint) project.Details.Height, (uint) frames_sec, (uint) total_frames);
- if (audiofile != null) {
- Logger.Debug ("SlideShow.GenerateMPEG -> audiofile {0}", audiofile);
- lib.SlideShowAddAudio (audiofile);
+ if (AudioFile != null) {
+ Logger.Debug ("SlideShow.GenerateMPEG -> audiofile {0}", AudioFile);
+ lib.SlideShowAddAudio (AudioFile);
}
- // TODO: Select the transition for the slide
Transition transition;
Logger.Debug ("SlideShow.GenerateMPEG ->Images.Count {0}", images.Count);
diff --git a/src/datamodel/SlideShowProjectElement.cs b/src/datamodel/SlideShowProjectElement.cs
index 837286e..9421e55 100644
--- a/src/datamodel/SlideShowProjectElement.cs
+++ b/src/datamodel/SlideShowProjectElement.cs
@@ -38,9 +38,15 @@ namespace Mistelix.DataModel
[XmlInclude(typeof(SlideShow))]
public abstract class SlideShowProjectElement : VisibleProjectElement
{
- public string audiofile;
+ string audiofile;
public List <Image> images;
-
+
+ [XmlElementAttribute ("audiofile")]
+ public string AudioFile {
+ get { return audiofile;}
+ set { audiofile = value;}
+ }
+
protected SlideShowProjectElement ()
{
images = new List <Image> ();
diff --git a/src/dialogs/AddSlideDialog.cs b/src/dialogs/AddSlideDialog.cs
index 81f61a1..e299425 100644
--- a/src/dialogs/AddSlideDialog.cs
+++ b/src/dialogs/AddSlideDialog.cs
@@ -53,6 +53,8 @@ namespace Mistelix.Dialogs
SlideShow slide;
TransitionPreview drawing_area;
bool edit_mode;
+ string audiofile;
+ bool no_audio;
[Glade.Widget] Gtk.VBox left_vbox;
[Glade.Widget ("scrolledwindow_files")] Gtk.ScrolledWindow scrolledwin_files;
@@ -64,13 +66,13 @@ namespace Mistelix.Dialogs
[Glade.Widget] Gtk.HBox ctrls_hbox;
[Glade.Widget] Gtk.Button up_button;
[Glade.Widget] Gtk.Button down_button;
+ [Glade.Widget] Gtk.Button audio_button;
[Glade.Widget] Gtk.VBox vbox_dir;
[Glade.Widget] Gtk.ComboBox textposition_combo;
// TODO: Since allows editing probably should be renamed to SlideDialog
public AddSlideDialog () : base ("addslide")
{
-
LoadWindowPosition ();
image_view = new SlideShowImageView ();
@@ -80,6 +82,7 @@ namespace Mistelix.Dialogs
up_button.Clicked += new EventHandler (OnButtonUp);
down_button.Clicked += new EventHandler (OnButtonDown);
+ audio_button.Clicked += new EventHandler (OnButtonAudio);
file_view = new ImagesFileView ();
new DirectoryView (vbox_dir, new ChangeDirectoryEventHandler (OnDirectoryChanged),
@@ -126,6 +129,13 @@ namespace Mistelix.Dialogs
bool more;
SlideImage image;
more = image_view.Model.GetIterFirst (out iter);
+
+ if (no_audio)
+ slide.AudioFile = string.Empty;
+ else {
+ if (audiofile != null)
+ slide.AudioFile = audiofile;
+ }
while (more)
{
@@ -380,6 +390,19 @@ namespace Mistelix.Dialogs
Mistelix.Preferences.SetIntValue (Preferences.SlideWindowHeight, height);
Mistelix.Preferences.Save ();
}
+
+ void OnButtonAudio (object sender, EventArgs args)
+ {
+ AudioSelectionDialog dialog = new AudioSelectionDialog ();
+
+ if (slide != null)
+ dialog.Filename = slide.AudioFile;
+
+ if (dialog.Run () == ResponseType.Ok) {
+ audiofile = dialog.Filename;
+ no_audio = dialog.NoAudio;
+ }
+ }
}
// Transition preview
diff --git a/src/dialogs/AudioSelectionDialog.cs b/src/dialogs/AudioSelectionDialog.cs
new file mode 100644
index 0000000..67c4878
--- /dev/null
+++ b/src/dialogs/AudioSelectionDialog.cs
@@ -0,0 +1,79 @@
+//
+// Copyright (C) 2009 Jordi Mas i Hernandez, jmas softcatala org
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using Glade;
+using Gtk;
+using Mono.Unix;
+
+using Mistelix.Widgets;
+using Mistelix.DataModel;
+using Mistelix.Core;
+using Mistelix.Transitions;
+
+namespace Mistelix.Dialogs
+{
+ // Application preferences dialog
+ public class AudioSelectionDialog : GtkDialog
+ {
+ [Glade.Widget] Gtk.HBox audiofile_hbox;
+
+ Gtk.Button clean_button;
+ BrowseFile audiofile_browser;
+ string filename;
+ bool no_audio;
+
+ public AudioSelectionDialog () : base ("audioselection")
+ {
+ audiofile_browser = new BrowseFile (audiofile_hbox, null, true);
+ clean_button = new Gtk.Button (Catalog.GetString ("No audio"));
+ audiofile_hbox.Add (clean_button);
+ clean_button.Clicked += new EventHandler (OnButtonClean);
+
+ clean_button.ShowAll ();
+ }
+
+ public string Filename {
+ get { return filename; }
+ set { audiofile_browser.Filename = value; }
+ }
+
+ public bool NoAudio {
+ get { return no_audio; }
+ }
+
+ void OnOK (object sender, EventArgs args)
+ {
+ filename = audiofile_browser.Filename;
+
+ if (filename != null)
+ no_audio = false;
+ }
+
+ void OnButtonClean (object sender, EventArgs args)
+ {
+ audiofile_browser.Filename = string.Empty;
+ no_audio = true;
+ }
+ }
+}
diff --git a/src/dialogs/PreferencesDialog.cs b/src/dialogs/PreferencesDialog.cs
index 6df5292..460ad8f 100644
--- a/src/dialogs/PreferencesDialog.cs
+++ b/src/dialogs/PreferencesDialog.cs
@@ -50,7 +50,7 @@ namespace Mistelix.Dialogs
[Glade.Widget] Gtk.ComboBox textposition_combo;
[Glade.Widget] Gtk.SpinButton duration_spin;
- BrowseDirectory projectsdir, videosdir, imagesdir, audiodir;
+ BrowseFile projectsdir, videosdir, imagesdir, audiodir;
ListStore transition_store, thumbnail_store, textposition_store;
bool needs_repaint;
@@ -72,10 +72,10 @@ namespace Mistelix.Dialogs
textposition_combo.Model = textposition_store;
LoadTextPositionsIntoCombo ();
- projectsdir = new BrowseDirectory (projectsdir_hbox, Mistelix.Preferences.GetStringValue (Preferences.ProjectsDirectoryKey));
- videosdir = new BrowseDirectory (videosdir_hbox, Mistelix.Preferences.GetStringValue (Preferences.VideosDirectoryKey));
- imagesdir = new BrowseDirectory (imagesdir_hbox, Mistelix.Preferences.GetStringValue (Preferences.ImagesDirectoryKey));
- audiodir = new BrowseDirectory (audiodir_hbox, Mistelix.Preferences.GetStringValue (Preferences.AudioDirectoryKey));
+ projectsdir = new BrowseFile (projectsdir_hbox, Mistelix.Preferences.GetStringValue (Preferences.ProjectsDirectoryKey), false);
+ videosdir = new BrowseFile (videosdir_hbox, Mistelix.Preferences.GetStringValue (Preferences.VideosDirectoryKey), false);
+ imagesdir = new BrowseFile (imagesdir_hbox, Mistelix.Preferences.GetStringValue (Preferences.ImagesDirectoryKey), false);
+ audiodir = new BrowseFile (audiodir_hbox, Mistelix.Preferences.GetStringValue (Preferences.AudioDirectoryKey), false);
duration_spin.Value = Mistelix.Preferences.GetIntValue (Preferences.DefaultDurationKey);
@@ -151,10 +151,10 @@ namespace Mistelix.Dialogs
}
Mistelix.Preferences.SetIntValue (Preferences.DefaultDurationKey, (int) duration_spin.Value);
- Mistelix.Preferences.SetStringValue (Preferences.ProjectsDirectoryKey, projectsdir.Directory);
- Mistelix.Preferences.SetStringValue (Preferences.VideosDirectoryKey, videosdir.Directory);
- Mistelix.Preferences.SetStringValue (Preferences.ImagesDirectoryKey, imagesdir.Directory);
- Mistelix.Preferences.SetStringValue (Preferences.AudioDirectoryKey, audiodir.Directory);
+ Mistelix.Preferences.SetStringValue (Preferences.ProjectsDirectoryKey, projectsdir.Filename);
+ Mistelix.Preferences.SetStringValue (Preferences.VideosDirectoryKey, videosdir.Filename);
+ Mistelix.Preferences.SetStringValue (Preferences.ImagesDirectoryKey, imagesdir.Filename);
+ Mistelix.Preferences.SetStringValue (Preferences.AudioDirectoryKey, audiodir.Filename);
Mistelix.Preferences.Save ();
}
diff --git a/src/dialogs/ThemeSelectionDialog.cs b/src/dialogs/ThemeSelectionDialog.cs
index fff0f1d..54d24a3 100644
--- a/src/dialogs/ThemeSelectionDialog.cs
+++ b/src/dialogs/ThemeSelectionDialog.cs
@@ -38,63 +38,6 @@ namespace Mistelix.Dialogs
// Browse themes dialog
public class ThemeSelectionDialog : GtkDialog
{
- // Adds a text box + browse button into a given hbox parent configuring
- // the standard browsedirectory widget for the application
- // TODO: Consider mixing with BrowseDirectory class
- public class BrowseFile
- {
- public virtual event EventHandler FileSelectedChanged;
-
- Entry dirname;
- Gtk.Button browse;
- string directory;
-
- public BrowseFile (HBox parent, string directory)
- {
- dirname = new Entry ();
- browse = new Gtk.Button (Catalog.GetString ("Browse..."));
- this.directory = directory;
- browse.Clicked += new EventHandler (OnBrowse);
-
- parent.Add (dirname);
- parent.Add (browse);
-
- Gtk.Box.BoxChild box = (Gtk.Box.BoxChild) parent[browse];
- box.Expand = false;
- box.Fill = false;
-
- parent.ShowAll ();
- }
-
- public string Filename {
- get { return dirname.Text; }
- }
-
- void OnBrowse (object o, EventArgs args)
- {
- FileChooserDialog chooser_dialog = new FileChooserDialog (
- Catalog.GetString ("Open Location") , null, FileChooserAction.Open);
-
- Gtk.FileFilter filter = new Gtk.FileFilter ();
- filter.AddPixbufFormats ();
-
- chooser_dialog.Filter = filter;
- chooser_dialog.SetCurrentFolder (directory);
- chooser_dialog.AddButton (Stock.Cancel, ResponseType.Cancel);
- chooser_dialog.AddButton (Stock.Open, ResponseType.Ok);
- chooser_dialog.DefaultResponse = ResponseType.Ok;
- chooser_dialog.LocalOnly = false;
-
- if(chooser_dialog.Run () == (int) ResponseType.Ok) {
- dirname.Text = chooser_dialog.Filename;
-
- if (FileSelectedChanged != null)
- FileSelectedChanged (this, EventArgs.Empty);
- }
- chooser_dialog.Destroy ();
- }
- }
-
public class MenuBackgroundPreview : DrawingArea
{
Theme theme;
@@ -265,7 +208,7 @@ namespace Mistelix.Dialogs
selectbutton_drawing_area = new ButtonPreview (project);
highlightbutton_drawing_area = new ButtonPreview (project);
- browse_file = new BrowseFile (file_hbox, Mistelix.Preferences.GetStringValue (Preferences.ImagesDirectoryKey));
+ browse_file = new BrowseFile (file_hbox, Mistelix.Preferences.GetStringValue (Preferences.ImagesDirectoryKey), true);
color = author_label.Style.Background (StateType.Normal);
textview.ModifyBase (Gtk.StateType.Normal, color);
diff --git a/src/mistelix.glade b/src/mistelix.glade
index 3d26ba4..1d13d11 100644
--- a/src/mistelix.glade
+++ b/src/mistelix.glade
@@ -765,6 +765,25 @@
<property name="y_options">fill</property>
</packing>
</child>
+
+ <child>
+ <widget class="GtkButton" id="audio_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Select Audio...</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="padding">0</property>
@@ -837,7 +856,7 @@
<child>
<widget class="GtkLabel" id="save">
<property name="visible">True</property>
- <property name="label" translatable="yes">Save Slideshow</property>
+ <property name="label" translatable="yes">Save</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -4430,4 +4449,133 @@
</child>
</widget>
+<widget class="GtkDialog" id="audioselection">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Select audio</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
+ <property name="urgency_hint">False</property>
+ <property name="has_separator">True</property>
+
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox9">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area9">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+ <child>
+ <widget class="GtkButton" id="cancelbutton6">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-cancel</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-6</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="okbutton6">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-ok</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-5</property>
+ <signal name="clicked" handler="OnOK" last_modification_time="Fri, 31 Oct 2008 17:29:41 GMT"/>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkVBox" id="vbox39">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkLabel" id="label53">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Select an audio file for the slideshow</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="xpad">5</property>
+ <property name="ypad">5</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="audiofile_hbox">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <placeholder/>
+ </child>
+
+ <child>
+ <placeholder/>
+ </child>
+
+ <child>
+ <placeholder/>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
</glade-interface>
diff --git a/src/widgets/BrowseDirectory.cs b/src/widgets/BrowseFile.cs
similarity index 68%
rename from src/widgets/BrowseDirectory.cs
rename to src/widgets/BrowseFile.cs
index 8923287..5896ece 100644
--- a/src/widgets/BrowseDirectory.cs
+++ b/src/widgets/BrowseFile.cs
@@ -27,49 +27,68 @@ using Mono.Unix;
namespace Mistelix.Widgets
{
-
- // Adds a text box + browse button into a given hbox parent configuring
+ // Adds a text box + browse button into a given hbox parent configuring
// the standard browsedirectory widget for the application
- public class BrowseDirectory
+ public class BrowseFile
{
- Entry dirname;
+ Entry filename;
Button browse;
+ bool browse_file;
+ Gtk.FileFilter filter;
- public BrowseDirectory (HBox parent, string directory)
+ public virtual event EventHandler FileSelectedChanged;
+
+ public BrowseFile (HBox parent, string file, bool browse_file)
{
- dirname = new Entry ();
+ this.browse_file = browse_file;
+ filename = new Entry ();
browse = new Button (Catalog.GetString ("Browse..."));
- dirname.Text = directory;
+ Filename = file;
browse.Clicked += new EventHandler (OnBrowse);
- parent.Add (dirname);
+ parent.Add (filename);
parent.Add (browse);
Gtk.Box.BoxChild box = (Gtk.Box.BoxChild) parent[browse];
box.Expand = false;
box.Fill = false;
-
+
parent.ShowAll ();
}
- public string Directory {
- get { return dirname.Text; }
+ public string Filename {
+ get { return filename.Text; }
+ set {
+ if (value == null)
+ filename.Text = string.Empty;
+ else
+ filename.Text = value;
+ }
+ }
+
+ public Gtk.FileFilter Filter {
+ set { filter = value; }
}
void OnBrowse (object o, EventArgs args)
{
FileChooserDialog chooser_dialog = new FileChooserDialog (
- Catalog.GetString ("Open Location") , null, FileChooserAction.SelectFolder);
+ Catalog.GetString ("Open Location") , null,
+ browse_file ? FileChooserAction.Open : FileChooserAction.SelectFolder);
- chooser_dialog.SetCurrentFolder (dirname.Text);
+ chooser_dialog.SetCurrentFolder (filename.Text);
chooser_dialog.AddButton (Stock.Cancel, ResponseType.Cancel);
chooser_dialog.AddButton (Stock.Open, ResponseType.Ok);
chooser_dialog.DefaultResponse = ResponseType.Ok;
chooser_dialog.LocalOnly = false;
- if(chooser_dialog.Run () == (int) ResponseType.Ok)
- dirname.Text = chooser_dialog.Filename;
+ if (chooser_dialog.Run () == (int) ResponseType.Ok) {
+ filename.Text = chooser_dialog.Filename;
+
+ if (FileSelectedChanged != null)
+ FileSelectedChanged (this, EventArgs.Empty);
+ }
chooser_dialog.Destroy ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]