From becf7f94bc21dd1352b5701b03ba0e7669d947a1 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sun, 5 Jan 2014 22:10:02 -0500 Subject: [PATCH] gui: Begin implementing the gui This adds the ocarina6.glade file and code for clicking the library import button. Signed-off-by: Anna Schumaker --- .gitignore | 1 + config | 13 +- gui/Sconscript | 9 + gui/main.cpp | 15 ++ gui/ocarina6.glade | 612 +++++++++++++++++++++------------------------ gui/wires.cpp | 85 +++++++ include/ocarina.h | 12 + tests/Sconscript | 2 - 8 files changed, 412 insertions(+), 337 deletions(-) create mode 100644 gui/Sconscript create mode 100644 gui/main.cpp create mode 100644 gui/wires.cpp create mode 100644 include/ocarina.h diff --git a/.gitignore b/.gitignore index 9bb91710..24214ff0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ *.test *.glade~ gui/#* +gui/ocarina .sconsign.dblite diff --git a/config b/config index 63adc747..db346942 100644 --- a/config +++ b/config @@ -4,6 +4,7 @@ import os # Configuration variables CONFIG_VERSION = 6.0 CONFIG_DEBUG = True +CONFIG_TESTING = False # Set up default environment @@ -31,7 +32,9 @@ class Config: def reconfigure(self): env.Replace( CCFLAGS = self.ENV ) - if self.TEST: env.Append( CCFLAGS = [ "-DCONFIG_TEST" ]) + if self.TEST == True: + print "Testing enabled" + env.Append( CCFLAGS = [ "-DCONFIG_TEST" ]) def reset(self, TEST = False): self.AUDIO = False @@ -53,4 +56,10 @@ Export("env", "CONFIG") # Import SConscript files include = SConscript("include/Sconscript") design = SConscript("design/Sconscript") -tests = SConscript("tests/Sconscript") + +gui = SConscript("gui/Sconscript") + +Default("gui") +if CONFIG_TESTING == True: + tests = SConscript("tests/Sconscript") + Depends(gui, tests) diff --git a/gui/Sconscript b/gui/Sconscript new file mode 100644 index 00000000..1f3f5dcd --- /dev/null +++ b/gui/Sconscript @@ -0,0 +1,9 @@ +#!/usr/bin/python +Import("env", "CONFIG") + +CONFIG.package("gtkmm-3.0") +CONFIG.AUDIO = True + +lib = SConscript("../lib/Sconscript"); + +env.Program("ocarina", Glob("*.cpp") + SConscript("../lib/Sconscript")) diff --git a/gui/main.cpp b/gui/main.cpp new file mode 100644 index 00000000..7d63e44a --- /dev/null +++ b/gui/main.cpp @@ -0,0 +1,15 @@ +/* + * Copyright 2014 (c) Anna Schumaker. + */ +#include + +int main(int argc, char **argv) +{ + Gtk::Window *window; + + Gtk::Main ocarina(argc, argv); + window = connect_wires(); + + Gtk::Main::run(*window); + return 0; +} diff --git a/gui/ocarina6.glade b/gui/ocarina6.glade index 79be1e25..80d63193 100644 --- a/gui/ocarina6.glade +++ b/gui/ocarina6.glade @@ -12,43 +12,17 @@ inode/directory - - True - False - gtk-refresh - - - True - False - gtk-convert - - + - + + + + + - + - - - /home/anna/Music - 42 - - - - - - - - - - - Favorite - - - Banned - - 100 @@ -71,185 +45,18 @@ True True - True - True left - - True - True - left - - - True - False - Library tracks here :) - - - - - True - False - vertical - - - True - False - 1 - Library - - - False - True - 0 - - - - - True - False - 1 - 0 - - - False - True - 1 - - - - - False - - - - - True - False - List of recent songs here! - - - 1 - - - - - True - False - vertical - - - True - False - 1 - Recent - - - False - True - 0 - - - - - True - False - 1 - 0 - - - False - True - 1 - - - - - 1 - False - - - - - - - True - False - True - True - Play Queue - center - 90 - - - True - False - - - - - True - False - - - True - True - o_playlists - - - - - - 150 - Playlist - - - - 0 - - - - - - - False - True - 0 - - - - - - - - 1 - - - - - True - False - True - True - Playlists - 90 - - - 1 - True - False - - - - + True False vertical - + True False select-folder + False filefilter1 @@ -259,13 +66,59 @@ - + True False - + True - False + True + in + + + True + True + o_collection_dirs + True + + + + + + 20 + + + + 1 + + + + + + + 50 + Size + + + + 3 + + + + + + + Path + + + + 2 + + + + + + True @@ -274,12 +127,143 @@ - - Import + True - True - True - image9 + False + vertical + True + + + True + True + True + + + True + False + True + + + True + False + gtk-ok + + + False + True + 0 + + + + + True + False + OK + center + + + False + True + 1 + + + + + + + False + True + 0 + + + + + True + True + True + + + True + False + True + + + True + False + gtk-refresh + + + False + True + 0 + + + + + True + False + Update + center + + + False + True + 1 + + + + + + + False + True + 1 + + + + + True + True + True + + + True + False + True + + + True + False + gtk-convert + + + False + True + 0 + + + + + True + False + Import + center + + + False + True + 1 + + + + + + + False + True + 2 + + False @@ -287,35 +271,6 @@ 1 - - - gtk-ok - True - True - True - True - - - False - True - 2 - - - - - Update All - True - True - True - image8 - 0.46000000834465027 - - - False - True - 3 - - False @@ -323,61 +278,42 @@ 1 + + + + + True + False - + True - True - o_directories - - - - - - Path - - - - 0 - - - - - - - 1 - Files - - - - 1 - - - - + False + gtk-harddisk + 1 - True + False True - 2 + 0 + + + + + True + False + 1 + Collection +Manager + right + + + False + True + 1 - 2 - - - - - True - False - True - True - Directories - 90 - - - 2 - True False @@ -398,6 +334,7 @@ True False vertical + True True @@ -663,54 +600,63 @@ - + True - False - start - True - False - vertical + True - + True False - 0 - <span size='xx-large'>A Random Song Title</span> - True + + + True + False + vertical + + + True + False + 0 + <span size='xx-large'>A Random Song Title</span> + True + + + True + True + 0 + + + + + True + False + 0 + <span size='x-large'>By: Some Artist</span> + True + + + False + True + 1 + + + + + True + False + 0 + <span size='x-large'>From: Some Album</span> + True + + + True + True + 2 + + + + - - True - True - 0 - - - - - True - False - 0 - <span size='x-large'>By: Some Artist</span> - True - - - False - True - 1 - - - - - True - False - 0 - <span size='x-large'>From: Some Album</span> - True - - - True - True - 2 - @@ -724,7 +670,7 @@ False True - 1 + 2 @@ -735,7 +681,7 @@ False True - 2 + 3 @@ -743,7 +689,7 @@ True False - + False @@ -780,7 +726,7 @@ False True - 3 + 4 diff --git a/gui/wires.cpp b/gui/wires.cpp new file mode 100644 index 00000000..1da9607b --- /dev/null +++ b/gui/wires.cpp @@ -0,0 +1,85 @@ +/* + * Copyright 2014 (c) Anna Schumaker. + */ +#include +#include + +#include +#include + +static Glib::RefPtr builder; +void enable_idle(); + +/* + * Collection manager functions + */ +static void on_collection_ok() +{ + print("OK clicked!\n"); +} + +static void on_collection_update() +{ + print("Update clicked!\n"); + //library :: update_all(); + enable_idle(); +} + +static void on_collection_import() +{ + print("Import clicked!\n"); + library :: import(); + enable_idle(); +} + + + +/* + * Idle func + */ +bool on_idle() +{ + Gtk::ProgressBar *prog; + bool ret = idle::run_task(); + + builder->get_widget("o_idle_progress", prog); + if (ret == false) + prog->hide(); + else { + prog->show(); + prog->set_fraction(idle::get_progress()); + } + return ret; +} + +void enable_idle() +{ + Glib::signal_idle().connect(sigc::ptr_fun(on_idle)); +} + + +/* + * Ocarina functions + */ +static void connect_button(Glib::RefPtr &builder, + const std::string &name, void (*func)()) +{ + Gtk::Button *button; + builder->get_widget(name, button); + button->signal_clicked().connect(sigc::ptr_fun(func)); +} + +Gtk::Window *connect_wires() +{ + Gtk::Window *window; + builder = Gtk::Builder::create(); + builder->add_from_file("gui/ocarina6.glade"); + builder->get_widget("o_window", window); + + /* Collection manager */ + connect_button(builder, "o_collection_ok", on_collection_ok); + connect_button(builder, "o_collection_update", on_collection_update); + connect_button(builder, "o_collection_import", on_collection_import); + + return window; +} diff --git a/include/ocarina.h b/include/ocarina.h new file mode 100644 index 00000000..a1defe15 --- /dev/null +++ b/include/ocarina.h @@ -0,0 +1,12 @@ +/* + * Copyright 2014 (c) Anna Schumaker. + */ +#ifndef OCARINA_H +#define OCARINA_H + +#include + +/* wires.cpp */ +Gtk::Window *connect_wires(); + +#endif /* OCARINA_H */ diff --git a/tests/Sconscript b/tests/Sconscript index 20258b8b..8b6c1f0b 100644 --- a/tests/Sconscript +++ b/tests/Sconscript @@ -62,5 +62,3 @@ scripts = [ "print", "file", "database", "index", "filter", "idle", "playlist", for s in scripts: CONFIG.reset(TEST = True) SConscript("%s/Sconscript" % s) - -Default("tests")