[beast/wip/soundfont: 21/832] BEAST-GTK: Added necessary gui support for browsing sound fonts



commit e83087233de495f83266c86ef431ed40bae31608
Author: Stefan Westerfeld <stefan space twc de>
Date:   Mon Nov 8 23:29:45 2010 +0100

    BEAST-GTK: Added necessary gui support for browsing sound fonts

 beast-gtk/bstsoundfontpresetview.c |   47 +++++++++++
 beast-gtk/bstsoundfontpresetview.h |   52 ++++++++++++
 beast-gtk/bstsoundfontview.c       |  155 ++++++++++++++++++++++++++++++++++++
 beast-gtk/bstsoundfontview.h       |   55 +++++++++++++
 4 files changed, 309 insertions(+), 0 deletions(-)
---
diff --git a/beast-gtk/bstsoundfontpresetview.c b/beast-gtk/bstsoundfontpresetview.c
new file mode 100644
index 0000000..60ac02e
--- /dev/null
+++ b/beast-gtk/bstsoundfontpresetview.c
@@ -0,0 +1,47 @@
+/* BEAST - Bedevilled Audio System
+ * Copyright (C) 1998-2003 Tim Janik
+ * Copyright (C) 2009 Stefan Westerfeld
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * A copy of the GNU Lesser General Public License should ship along
+ * with this library; if not, see http://www.gnu.org/copyleft/.
+ */
+#include "bstsoundfontpresetview.h"
+
+/* --- functions --- */
+
+G_DEFINE_TYPE (BstSoundFontPresetView, bst_sound_font_preset_view, BST_TYPE_ITEM_VIEW);
+
+
+static void
+bst_sound_font_preset_view_class_init (BstSoundFontPresetViewClass *class)
+{
+  BstItemViewClass *item_view_class = BST_ITEM_VIEW_CLASS (class);
+
+  item_view_class->item_type = "BseSoundFontPreset";
+}
+
+static void
+bst_sound_font_preset_view_init (BstSoundFontPresetView *self)
+{
+  BstItemView *iview = BST_ITEM_VIEW (self);
+}
+
+GtkWidget*
+bst_sound_font_preset_view_new()
+{
+  GtkWidget *sound_font_preset_view;
+
+  sound_font_preset_view = gtk_widget_new (BST_TYPE_SOUND_FONT_PRESET_VIEW, NULL);
+
+  return sound_font_preset_view;
+}
diff --git a/beast-gtk/bstsoundfontpresetview.h b/beast-gtk/bstsoundfontpresetview.h
new file mode 100644
index 0000000..0afb027
--- /dev/null
+++ b/beast-gtk/bstsoundfontpresetview.h
@@ -0,0 +1,52 @@
+/* BEAST - Bedevilled Audio System
+ * Copyright (C) 1998-2003 Tim Janik
+ * Copyright (C) 2009 Stefan Westerfeld
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * A copy of the GNU Lesser General Public License should ship along
+ * with this library; if not, see http://www.gnu.org/copyleft/.
+ */
+
+#ifndef __BST_SOUND_FONT_PRESET_VIEW_H__
+#define __BST_SOUND_FONT_PRESET_VIEW_H__
+
+#include "bstitemview.h"
+
+G_BEGIN_DECLS
+
+/* --- Gtk+ type macros --- */
+#define        BST_TYPE_SOUND_FONT_PRESET_VIEW              (bst_sound_font_preset_view_get_type ())
+#define        BST_SOUND_FONT_PRESET_VIEW(object)           (GTK_CHECK_CAST ((object), 
BST_TYPE_SOUND_FONT_PRESET_VIEW, BstSoundFontPresetView))
+#define        BST_SOUND_FONT_PRESET_VIEW_CLASS(klass)      (GTK_CHECK_CLASS_CAST ((klass), 
BST_TYPE_SOUND_FONT_PRESET_VIEW, BstSoundFontPresetViewClass))
+#define        BST_IS_SOUND_FONT_PRESET_VIEW(object)        (GTK_CHECK_TYPE ((object), 
BST_TYPE_SOUND_FONT_PRESET_VIEW))
+#define        BST_IS_SOUND_FONT_PRESET_VIEW_CLASS(klass)   (GTK_CHECK_CLASS_TYPE ((klass), 
BST_TYPE_SOUND_FONT_PRESET_VIEW))
+#define BST_SOUND_FONT_PRESET_VIEW_GET_CLASS(obj)    (GTK_CHECK_GET_CLASS ((obj), 
BST_TYPE_SOUND_FONT_PRESET_VIEW, BstSoundFontPresetViewClass))
+
+
+typedef        struct  _BstSoundFontPresetView       BstSoundFontPresetView;
+typedef        struct  _BstSoundFontPresetViewClass  BstSoundFontPresetViewClass;
+struct _BstSoundFontPresetView
+{
+  BstItemView   parent_object;
+};
+
+struct _BstSoundFontPresetViewClass
+{
+  BstItemViewClass parent_class;
+};
+
+/* --- prototypes --- */
+
+GType          bst_sound_font_preset_view_get_type          (void);
+GtkWidget*     bst_sound_font_preset_view_new               (void);
+
+#endif /* __BST_SOUND_FONT_PRESET_VIEW_H__ */
diff --git a/beast-gtk/bstsoundfontview.c b/beast-gtk/bstsoundfontview.c
new file mode 100644
index 0000000..f2929d9
--- /dev/null
+++ b/beast-gtk/bstsoundfontview.c
@@ -0,0 +1,155 @@
+/* BEAST - Bedevilled Audio System
+ * Copyright (C) 1998-2003 Tim Janik
+ * Copyright (C) 2009 Stefan Westerfeld
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * A copy of the GNU Lesser General Public License should ship along
+ * with this library; if not, see http://www.gnu.org/copyleft/.
+ */
+#include "bstsoundfontview.h"
+#include "bstsoundfontpresetview.h"
+#include "bstfiledialog.h"
+
+/* --- prototypes --- */
+
+static void     sound_font_view_action_exec           (gpointer                data,
+                                                       gulong                  action);
+static gboolean sound_font_view_action_check          (gpointer                data,
+                                                       gulong                  action,
+                                                       guint64                 action_stamp);
+
+
+/* --- sound font actions --- */
+
+enum {
+  ACTION_LOAD_SOUND_FONT,
+  ACTION_LOAD_SOUND_FONT_LIB,
+  ACTION_DELETE_SOUND_FONT,
+  ACTION_SOUND_FONT_LAST
+};
+static const GxkStockAction sound_font_view_actions[] = {
+  { N_("Load..."),  NULL,       N_("Load a new sound font file from disk"),
+    ACTION_LOAD_SOUND_FONT,     BST_STOCK_LOAD,        },
+  { N_("Lib..."),   NULL,       N_("Load a sound font file from library paths"),
+    ACTION_LOAD_SOUND_FONT_LIB,        BST_STOCK_LOAD_LIB, },
+  { N_("Delete"),   NULL,       N_("Delete the currently selected sound font from project"),
+    ACTION_DELETE_SOUND_FONT,   BST_STOCK_TRASHCAN, },
+};
+
+
+/* --- functions --- */
+
+G_DEFINE_TYPE (BstSoundFontView, bst_sound_font_view, BST_TYPE_ITEM_VIEW);
+
+static void
+bst_sound_font_view_class_init (BstSoundFontViewClass *class)
+{
+  BstItemViewClass *item_view_class = BST_ITEM_VIEW_CLASS (class);
+
+  item_view_class->item_type = "BseSoundFont";
+}
+
+static void
+sound_font_selection_changed (BstSoundFontView *self)
+{
+  BstItemView *iview = BST_ITEM_VIEW (self);
+  bst_item_view_set_container (BST_ITEM_VIEW (self->preset_view), bst_item_view_get_current (iview));
+}
+
+static void
+bst_sound_font_view_init (BstSoundFontView *self)
+{
+  BstItemView *iview = BST_ITEM_VIEW (self);
+  /* complete GUI */
+  GxkRadget *radget = gxk_radget_complete (GTK_WIDGET (self), "beast", "sound-font-view", NULL);
+  gxk_widget_publish_actions (self, "sound-font-view-actions",
+                              G_N_ELEMENTS (sound_font_view_actions), sound_font_view_actions,
+                              NULL, sound_font_view_action_check, sound_font_view_action_exec);
+  /* setup tree view */
+  GtkTreeView *tview = gxk_radget_find (radget, "tree-view");
+  bst_item_view_complete_tree (iview, tview);
+
+  g_object_connect (gtk_tree_view_get_selection (tview),
+                    "swapped_object_signal::changed", sound_font_selection_changed, self,
+                    NULL);
+
+
+  /* setup preset view */
+  GtkTreeView *pview = gxk_radget_find (radget, "preset-view");
+  self->preset_view = BST_SOUND_FONT_PRESET_VIEW (bst_sound_font_preset_view_new());
+  bst_item_view_complete_tree (BST_ITEM_VIEW (self->preset_view), pview);
+}
+
+GtkWidget*
+bst_sound_font_view_new (SfiProxy sfrepo)
+{
+  GtkWidget *sound_font_view;
+
+  g_return_val_if_fail (BSE_IS_SOUND_FONT_REPO (sfrepo), NULL);
+
+  sound_font_view = gtk_widget_new (BST_TYPE_SOUND_FONT_VIEW, NULL);
+  bst_item_view_set_container (BST_ITEM_VIEW (sound_font_view), sfrepo);
+
+  return sound_font_view;
+}
+
+SfiProxy
+bst_sound_font_view_get_preset (BstSoundFontView *self)
+{
+  return bst_item_view_get_current (BST_ITEM_VIEW (self->preset_view));
+}
+
+static void
+sound_font_view_action_exec (gpointer                data,
+                             gulong                  action)
+{
+  BstSoundFontView *self = BST_SOUND_FONT_VIEW (data);
+  BstItemView *item_view = BST_ITEM_VIEW (self);
+  SfiProxy sfrepo = item_view->container;
+  switch (action)
+    {
+      SfiProxy item;
+    case ACTION_LOAD_SOUND_FONT:
+      bst_file_dialog_popup_load_sound_font (item_view, BST_ITEM_VIEW (self)->container, FALSE);
+      break;
+    case ACTION_LOAD_SOUND_FONT_LIB:
+      bst_file_dialog_popup_load_sound_font (item_view, BST_ITEM_VIEW (self)->container, TRUE);
+      break;
+    case ACTION_DELETE_SOUND_FONT:
+      item = bst_item_view_get_current (BST_ITEM_VIEW (self));
+      bse_sound_font_repo_remove_sound_font (sfrepo, item);
+      break;
+    default:
+      break;
+    }
+  gxk_widget_update_actions_downwards (self);
+}
+
+static gboolean
+sound_font_view_action_check (gpointer                data,
+                              gulong                  action,
+                              guint64                 action_stamp)
+{
+  BstSoundFontView *self = BST_SOUND_FONT_VIEW (data);
+  BstItemView *item_view = BST_ITEM_VIEW (self);
+
+  switch (action)
+    {
+    case ACTION_LOAD_SOUND_FONT:
+    case ACTION_LOAD_SOUND_FONT_LIB:
+      return TRUE;
+    case ACTION_DELETE_SOUND_FONT:
+      return bst_item_view_get_current (item_view) != 0;
+    default:
+      return FALSE;
+    }
+}
diff --git a/beast-gtk/bstsoundfontview.h b/beast-gtk/bstsoundfontview.h
new file mode 100644
index 0000000..bf0e27f
--- /dev/null
+++ b/beast-gtk/bstsoundfontview.h
@@ -0,0 +1,55 @@
+/* BEAST - Bedevilled Audio System
+ * Copyright (C) 1998-2003 Tim Janik
+ * Copyright (C) 2009 Stefan Westerfeld
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * A copy of the GNU Lesser General Public License should ship along
+ * with this library; if not, see http://www.gnu.org/copyleft/.
+ */
+
+#ifndef __BST_SOUND_FONT_VIEW_H__
+#define __BST_SOUND_FONT_VIEW_H__
+
+#include "bstitemview.h"
+#include "bstsoundfontpresetview.h"
+
+G_BEGIN_DECLS
+
+/* --- Gtk+ type macros --- */
+#define        BST_TYPE_SOUND_FONT_VIEW              (bst_sound_font_view_get_type ())
+#define        BST_SOUND_FONT_VIEW(object)           (GTK_CHECK_CAST ((object), BST_TYPE_SOUND_FONT_VIEW, 
BstSoundFontView))
+#define        BST_SOUND_FONT_VIEW_CLASS(klass)      (GTK_CHECK_CLASS_CAST ((klass), 
BST_TYPE_SOUND_FONT_VIEW, BstSoundFontViewClass))
+#define        BST_IS_SOUND_FONT_VIEW(object)        (GTK_CHECK_TYPE ((object), BST_TYPE_SOUND_FONT_VIEW))
+#define        BST_IS_SOUND_FONT_VIEW_CLASS(klass)   (GTK_CHECK_CLASS_TYPE ((klass), 
BST_TYPE_SOUND_FONT_VIEW))
+#define BST_SOUND_FONT_VIEW_GET_CLASS(obj)    (GTK_CHECK_GET_CLASS ((obj), BST_TYPE_SOUND_FONT_VIEW, 
BstSoundFontViewClass))
+
+
+typedef        struct  _BstSoundFontView             BstSoundFontView;
+typedef        struct  _BstSoundFontViewClass        BstSoundFontViewClass;
+struct _BstSoundFontView
+{
+  BstItemView              parent_object;
+  BstSoundFontPresetView   *preset_view;
+};
+
+struct _BstSoundFontViewClass
+{
+  BstItemViewClass parent_class;
+};
+
+/* --- prototypes --- */
+
+GType          bst_sound_font_view_get_type          (void);
+GtkWidget*     bst_sound_font_view_new               (SfiProxy            sfont_repo);
+SfiProxy       bst_sound_font_view_get_preset        (BstSoundFontView   *self);
+
+#endif /* __BST_SOUND_FONT_VIEW_H__ */


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