comparison audacious/prefswin.c @ 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 ff71f891265b
children ae173b6e65a3
comparison
equal deleted inserted replaced
1174:6ae15616b516 1175:d03157b6b5dd
88 const gchar *tag; 88 const gchar *tag;
89 } 89 }
90 TitleFieldTag; 90 TitleFieldTag;
91 91
92 static GtkWidget *prefswin = NULL; 92 static GtkWidget *prefswin = NULL;
93 static GtkWidget *category_treeview = NULL;
94 static GtkWidget *category_notebook = NULL;
93 95
94 static Category categories[] = { 96 static Category categories[] = {
95 {DATA_DIR "/images/appearance.png", N_("Appearance"), 1}, 97 {DATA_DIR "/images/appearance.png", N_("Appearance"), 1},
96 {DATA_DIR "/images/audio.png", N_("Audio"), 6}, 98 {DATA_DIR "/images/audio.png", N_("Audio"), 6},
97 {DATA_DIR "/images/connectivity.png", N_("Connectivity"), 5}, 99 {DATA_DIR "/images/connectivity.png", N_("Connectivity"), 5},
1797 1799
1798 selection = gtk_tree_view_get_selection(treeview); 1800 selection = gtk_tree_view_get_selection(treeview);
1799 1801
1800 g_signal_connect_swapped(selection, "changed", 1802 g_signal_connect_swapped(selection, "changed",
1801 G_CALLBACK(change_category), notebook); 1803 G_CALLBACK(change_category), notebook);
1804
1805 /* mark the treeview widget as available to third party plugins */
1806 category_treeview = GTK_WIDGET(treeview);
1802 } 1807 }
1803 1808
1804 static void 1809 static void
1805 mainwin_drag_data_received1(GtkWidget * widget, 1810 mainwin_drag_data_received1(GtkWidget * widget,
1806 GdkDragContext * context, 1811 GdkDragContext * context,
2071 widget2 = glade_xml_get_widget(xml, "category_notebook"); 2076 widget2 = glade_xml_get_widget(xml, "category_notebook");
2072 g_signal_connect_after(G_OBJECT(widget), "realize", 2077 g_signal_connect_after(G_OBJECT(widget), "realize",
2073 G_CALLBACK(on_category_view_realize), 2078 G_CALLBACK(on_category_view_realize),
2074 widget2); 2079 widget2);
2075 2080
2081 category_notebook = GTK_WIDGET(widget2);
2082
2076 /* plugin->input page */ 2083 /* plugin->input page */
2077 2084
2078 widget = glade_xml_get_widget(xml, "input_plugin_view"); 2085 widget = glade_xml_get_widget(xml, "input_plugin_view");
2079 widget2 = glade_xml_get_widget(xml, "input_plugin_prefs"); 2086 widget2 = glade_xml_get_widget(xml, "input_plugin_prefs");
2080 g_signal_connect(G_OBJECT(widget), "cursor-changed", 2087 g_signal_connect(G_OBJECT(widget), "cursor-changed",
2267 { 2274 {
2268 prefswin_set_skin_update(TRUE); 2275 prefswin_set_skin_update(TRUE);
2269 gtk_widget_show(prefswin); 2276 gtk_widget_show(prefswin);
2270 } 2277 }
2271 2278
2272 2279 /*
2273 2280 * Public APIs for adding new pages to the prefs window.
2274 2281 *
2282 * Basically, the concept here is that third party components can register themselves in the root
2283 * preferences window.
2284 *
2285 * From a usability standpoint this makes the application look more "united", instead of cluttered
2286 * and malorganised. Hopefully this option will be used further in the future.
2287 *
2288 * - nenolod
2289 */
2290 gboolean
2291 prefswin_pane_new(GtkWidget *container, gchar *name, gchar *imgurl)
2292 {
2293 GtkTreeModel *model;
2294 GtkTreeIter iter;
2295 GdkPixbuf *img = NULL;
2296 GtkTreeView *treeview = GTK_TREE_VIEW(category_treeview);
2297 gint id;
2298
2299 if (treeview == NULL || container == NULL || category_notebook == NULL)
2300 return FALSE;
2301
2302 model = gtk_tree_view_get_model(treeview);
2303
2304 if (model == NULL)
2305 return FALSE;
2306
2307 id = gtk_notebook_append_page(GTK_NOTEBOOK(category_notebook), container, NULL);
2308
2309 if (id == -1)
2310 return FALSE;
2311
2312 if (imgurl != NULL)
2313 img = gdk_pixbuf_new_from_file(imgurl, NULL);
2314
2315 gtk_list_store_append(GTK_LIST_STORE(model), &iter);
2316 gtk_list_store_set(GTK_LIST_STORE(model), &iter,
2317 CATEGORY_VIEW_COL_ICON, img,
2318 CATEGORY_VIEW_COL_NAME,
2319 name, CATEGORY_VIEW_COL_ID, id, -1);
2320
2321 if (img != NULL)
2322 g_object_unref(img);
2323
2324 return TRUE;
2325 }