changeset 1175:d03157b6b5dd trunk

[svn] prefswin_page_new(): This commit allows third party plugins to register directly into the preferences panel. This concept originates from Winamp3/Wasabi.Player (I always thought it was cool, myself, so here it is.)
author nenolod
date Sun, 11 Jun 2006 20:11:40 -0700
parents 6ae15616b516
children 6549a4c58e15
files ChangeLog audacious/Makefile.in audacious/prefswin.c audacious/prefswin.h
diffstat 4 files changed, 67 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Jun 11 17:28:56 2006 -0700
+++ b/ChangeLog	Sun Jun 11 20:11:40 2006 -0700
@@ -1,3 +1,12 @@
+2006-06-12 00:28:56 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [1258]
+  - update README a bit
+  
+
+  Changes:        Modified:
+  +76 -84         trunk/README  
+
+
 2006-06-11 21:57:36 +0000  William Pitcock <nenolod@nenolod.net>
   revision [1256]
   - fix spelling
--- a/audacious/Makefile.in	Sun Jun 11 17:28:56 2006 -0700
+++ b/audacious/Makefile.in	Sun Jun 11 20:11:40 2006 -0700
@@ -26,7 +26,8 @@
 HEADERS = \
 	input.h \
 	output.h \
-	plugin.h
+	plugin.h \
+	prefswin.h
 
 SOURCES = \
 	build_stamp.c \
--- a/audacious/prefswin.c	Sun Jun 11 17:28:56 2006 -0700
+++ b/audacious/prefswin.c	Sun Jun 11 20:11:40 2006 -0700
@@ -90,6 +90,8 @@
 TitleFieldTag;
 
 static GtkWidget *prefswin = NULL;
+static GtkWidget *category_treeview = NULL;
+static GtkWidget *category_notebook = NULL;
 
 static Category categories[] = {
     {DATA_DIR "/images/appearance.png", N_("Appearance"), 1},
@@ -1799,6 +1801,9 @@
 
     g_signal_connect_swapped(selection, "changed",
                              G_CALLBACK(change_category), notebook);
+
+    /* mark the treeview widget as available to third party plugins */
+    category_treeview = GTK_WIDGET(treeview);
 }
 
 static void
@@ -2073,6 +2078,8 @@
                            G_CALLBACK(on_category_view_realize),
                            widget2);
 
+    category_notebook = GTK_WIDGET(widget2);
+
     /* plugin->input page */
 
     widget = glade_xml_get_widget(xml, "input_plugin_view");
@@ -2269,6 +2276,50 @@
     gtk_widget_show(prefswin);
 }
 
-
-
-
+/*
+ * Public APIs for adding new pages to the prefs window.
+ *
+ * Basically, the concept here is that third party components can register themselves in the root
+ * preferences window.
+ *
+ * From a usability standpoint this makes the application look more "united", instead of cluttered
+ * and malorganised. Hopefully this option will be used further in the future.
+ *
+ *    - nenolod
+ */
+gboolean
+prefswin_pane_new(GtkWidget *container, gchar *name, gchar *imgurl)
+{
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+    GdkPixbuf *img = NULL;
+    GtkTreeView *treeview = GTK_TREE_VIEW(category_treeview);
+    gint id;
+
+    if (treeview == NULL || container == NULL || category_notebook == NULL)
+	return FALSE;
+
+    model = gtk_tree_view_get_model(treeview);
+
+    if (model == NULL)
+        return FALSE;
+
+    id = gtk_notebook_append_page(GTK_NOTEBOOK(category_notebook), container, NULL);
+
+    if (id == -1)
+        return FALSE;
+
+    if (imgurl != NULL)
+        img = gdk_pixbuf_new_from_file(imgurl, NULL);
+
+    gtk_list_store_append(GTK_LIST_STORE(model), &iter);
+    gtk_list_store_set(GTK_LIST_STORE(model), &iter, 
+                       CATEGORY_VIEW_COL_ICON, img,
+                       CATEGORY_VIEW_COL_NAME,
+                       name, CATEGORY_VIEW_COL_ID, id, -1);
+
+    if (img != NULL)
+        g_object_unref(img);
+
+    return TRUE;
+}
--- a/audacious/prefswin.h	Sun Jun 11 17:28:56 2006 -0700
+++ b/audacious/prefswin.h	Sun Jun 11 20:11:40 2006 -0700
@@ -22,4 +22,6 @@
 void create_prefs_window(void);
 void show_prefs_window(void);
 
+gboolean prefswin_page_new(GtkWidget *container, gchar *name, gchar *imgurl);
+
 #endif