ocarina: Add a settings tab for library management

Right now I just add an empty vbox to the page.  I eventually want to
show information about each library path.
This commit is contained in:
Bryan Schumaker 2011-09-10 09:42:34 -04:00
parent b8f977cc35
commit 62b86f5136
5 changed files with 79 additions and 3 deletions

17
include/ocarina/page.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef OCARINA_PAGE_H
#define OCARINA_PAGE_H
#include <ocarina/gtk.h>
class Page
{
private:
GtkWidget *table;
void add_content(GtkWidget *);
public:
Page(GtkWidget *);
~Page();
};
#endif /* OCARINA_PAGE_H */

View File

@ -1,6 +1,14 @@
#ifndef OCARINA_SETTINGS_H
#define OCARINA_SETTINGS_H
#include <ocarina/gtk.h>
#include <string>
using namespace std;
void settings_init();
void add_settings_page(string, GtkWidget *);
void library_settings_init();
#endif /* OCARINA_SETTINGS_H */

17
ocarina/body/page.cpp Normal file
View File

@ -0,0 +1,17 @@
#include <ocarina/page.h>
Page::Page(GtkWidget *content)
{
table = gtk_table_new(3, 1, FALSE);
add_content(content);
}
Page::~Page()
{
}
void Page::add_content(GtkWidget *content)
{
gtk_table_attach_defaults(GTK_TABLE(table), content, 0, 1, 1, 2);
}

View File

@ -0,0 +1,14 @@
#include <ocarina/settings.h>
#include <ocarina/gtk.h>
/* This is a gtk vbox */
static GtkWidget *library_settings = NULL;
void library_settings_init()
{
library_settings = gtk_vbox_new(FALSE, 0);
gtk_widget_show(library_settings);
add_settings_page("Library", library_settings);
}

View File

@ -3,13 +3,33 @@
#include <ocarina/body.h>
#include <ocarina/gtk.h>
static GtkWidget *settings_tabs = NULL;
void settings_init()
{
GtkWidget *tabs = gtk_notebook_new();
GtkWidget *image = gtk_image_new_from_stock(GTK_STOCK_PREFERENCES,
GTK_ICON_SIZE_MENU);
settings_tabs = gtk_notebook_new();
gtk_widget_show(image);
gtk_widget_show(tabs);
add_page(image, tabs, false);
gtk_widget_show(settings_tabs);
add_page(image, settings_tabs, false);
library_settings_init();
}
void add_settings_page(string label_text, GtkWidget *page)
{
GtkWidget *label = gtk_label_new(label_text.c_str());
GtkWidget *window = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(window),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(window),
page);
gtk_notebook_append_page(GTK_NOTEBOOK(settings_tabs), window, label);
gtk_widget_show(window);
gtk_widget_show(label);
}