[beast/wip/soundfont: 16/832] BEAST-GTK: added file dialog support for loading sound fonts



commit 435db8626f4ce3485fb1f8345fa77111ebcdfcba
Author: Stefan Westerfeld <stefan space twc de>
Date:   Mon Nov 8 23:12:33 2010 +0100

    BEAST-GTK: added file dialog support for loading sound fonts

 beast-gtk/bstfiledialog.c |   47 +++++++++++++++++++++++++++++++++++++++++++++
 beast-gtk/bstfiledialog.h |   35 +++++++++++++++++++--------------
 2 files changed, 67 insertions(+), 15 deletions(-)
---
diff --git a/beast-gtk/bstfiledialog.c b/beast-gtk/bstfiledialog.c
index ccc652d..25e5337 100644
--- a/beast-gtk/bstfiledialog.c
+++ b/beast-gtk/bstfiledialog.c
@@ -244,6 +244,16 @@ bst_file_dialog_global_wave (void)
 }
 
 static BstFileDialog*
+bst_file_dialog_global_sound_font (void)
+{
+  static BstFileDialog *singleton = NULL;
+  if (!singleton)
+    singleton = g_object_new (BST_TYPE_FILE_DIALOG, NULL);
+  return singleton;
+}
+
+
+static BstFileDialog*
 bst_file_dialog_global_effect (void)
 {
   static BstFileDialog *singleton = NULL;
@@ -333,6 +343,7 @@ bst_file_dialog_set_mode (BstFileDialog    *self,
   /* handle tree visibility */
   switch (mode & BST_FILE_DIALOG_MODE_MASK)
     {
+    case BST_FILE_DIALOG_LOAD_SOUND_FONT:
     case BST_FILE_DIALOG_LOAD_WAVE:
       g_free (self->search_path);
       self->search_path = g_strdup (bse_server_get_sample_path (BSE_SERVER));
@@ -341,6 +352,7 @@ bst_file_dialog_set_mode (BstFileDialog    *self,
       gxk_notebook_set_current_page_widget (GTK_NOTEBOOK (self->notebook), self->fpage);
       g_object_set (self->notebook, "show_border", TRUE, "show_tabs", TRUE, NULL);
       break;
+    case BST_FILE_DIALOG_LOAD_SOUND_FONT_LIB:
     case BST_FILE_DIALOG_LOAD_WAVE_LIB:
       g_free (self->search_path);
       self->search_path = g_strdup (bse_server_get_sample_path (BSE_SERVER));
@@ -783,6 +795,37 @@ bst_file_dialog_load_wave (BstFileDialog *self,
 }
 
 GtkWidget*
+bst_file_dialog_popup_load_sound_font (gpointer parent_widget,
+                                      SfiProxy sound_font_repo,
+                                      gboolean show_lib)
+{
+  BstFileDialog *self = bst_file_dialog_global_sound_font ();
+  GtkWidget *widget = GTK_WIDGET (self);
+
+  bst_file_dialog_set_mode (self, parent_widget,
+                           show_lib ? BST_FILE_DIALOG_LOAD_SOUND_FONT_LIB : BST_FILE_DIALOG_LOAD_SOUND_FONT,
+                           _("Load Sound Font"), sound_font_repo);
+  gxk_widget_showraise (widget);
+
+  return widget;
+}
+
+static gboolean
+bst_file_dialog_load_sound_font (BstFileDialog *self,
+                                const gchar   *file_name)
+{
+  BseErrorType error;
+
+  gxk_status_printf (0, NULL, _("Loading sound font `%s'"), file_name);
+  error = bse_sound_font_repo_load_file (self->proxy, file_name);
+  bst_status_eprintf (error, _("Loading sound font `%s'"), file_name);
+  if (error)
+    sfi_error (_("Failed to load sound font \"%s\": %s"), file_name, bse_error_blurb (error));
+
+  return TRUE;
+}
+
+GtkWidget*
 bst_file_dialog_create (void)
 {
   BstFileDialog *self = g_object_new (BST_TYPE_FILE_DIALOG, NULL);
@@ -920,6 +963,10 @@ bst_file_dialog_activate (BstFileDialog *self)
     case BST_FILE_DIALOG_LOAD_WAVE_LIB:
       popdown = bst_file_dialog_load_wave (self, file_name);
       break;
+    case BST_FILE_DIALOG_LOAD_SOUND_FONT:
+    case BST_FILE_DIALOG_LOAD_SOUND_FONT_LIB:
+      popdown = bst_file_dialog_load_sound_font (self, file_name);
+      break;
     }
   if (swin)
     gxk_status_window_pop ();
diff --git a/beast-gtk/bstfiledialog.h b/beast-gtk/bstfiledialog.h
index 9965512..7c41fee 100644
--- a/beast-gtk/bstfiledialog.h
+++ b/beast-gtk/bstfiledialog.h
@@ -39,21 +39,23 @@ typedef struct  _BstFileDialogClass BstFileDialogClass;
 
 /* --- structures --- */
 typedef enum {
-  BST_FILE_DIALOG_OPEN_PROJECT    = 0x0001,
-  BST_FILE_DIALOG_MERGE_PROJECT           = 0x0002,
-  BST_FILE_DIALOG_SAVE_PROJECT    = 0x0003,
-  BST_FILE_DIALOG_IMPORT_MIDI     = 0x0004,
-  BST_FILE_DIALOG_SELECT_FILE     = 0x0008,
-  BST_FILE_DIALOG_SELECT_DIR      = 0x0009,
-  BST_FILE_DIALOG_LOAD_WAVE       = 0x0011,
-  BST_FILE_DIALOG_LOAD_WAVE_LIB           = 0x0012,
-  BST_FILE_DIALOG_MERGE_EFFECT     = 0x0021,
-  BST_FILE_DIALOG_MERGE_INSTRUMENT = 0x0022,
-  BST_FILE_DIALOG_SAVE_EFFECT      = 0x0023,
-  BST_FILE_DIALOG_SAVE_INSTRUMENT  = 0x0024,
-  BST_FILE_DIALOG_MODE_MASK       = 0x00ff,
-  BST_FILE_DIALOG_ALLOW_DIRS      = 0x1000,
-  BST_FILE_DIALOG_FLAG_MASK       = 0xff00
+  BST_FILE_DIALOG_OPEN_PROJECT       = 0x0001,
+  BST_FILE_DIALOG_MERGE_PROJECT              = 0x0002,
+  BST_FILE_DIALOG_SAVE_PROJECT       = 0x0003,
+  BST_FILE_DIALOG_IMPORT_MIDI        = 0x0004,
+  BST_FILE_DIALOG_SELECT_FILE        = 0x0008,
+  BST_FILE_DIALOG_SELECT_DIR         = 0x0009,
+  BST_FILE_DIALOG_LOAD_WAVE          = 0x0011,
+  BST_FILE_DIALOG_LOAD_WAVE_LIB              = 0x0012,
+  BST_FILE_DIALOG_LOAD_SOUND_FONT     = 0x0013,
+  BST_FILE_DIALOG_LOAD_SOUND_FONT_LIB = 0x0014,
+  BST_FILE_DIALOG_MERGE_EFFECT       = 0x0021,
+  BST_FILE_DIALOG_MERGE_INSTRUMENT    = 0x0022,
+  BST_FILE_DIALOG_SAVE_EFFECT        = 0x0023,
+  BST_FILE_DIALOG_SAVE_INSTRUMENT     = 0x0024,
+  BST_FILE_DIALOG_MODE_MASK          = 0x00ff,
+  BST_FILE_DIALOG_ALLOW_DIRS         = 0x1000,
+  BST_FILE_DIALOG_FLAG_MASK          = 0xff00
 } BstFileDialogMode;
 struct _BstFileDialog
 {
@@ -109,6 +111,9 @@ GtkWidget*  bst_file_dialog_popup_select_dir        (gpointer          parent_widget);
 GtkWidget*     bst_file_dialog_popup_load_wave         (gpointer          parent_widget,
                                                         SfiProxy          wave_repo,
                                                         gboolean          show_lib);
+GtkWidget*     bst_file_dialog_popup_load_sound_font   (gpointer          parent_widget,
+                                                         SfiProxy          sound_font_repo,
+                                                         gboolean          show_lib);
 void           bst_file_dialog_set_mode                (BstFileDialog    *self,
                                                         gpointer          parent_widget,
                                                         BstFileDialogMode mode,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]