ocarina: Remove more commented out and disabled code
- The old header functions - The old callback header file - The old shortcut registering system - The old main() code Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
3b705515c2
commit
18e0daeb17
|
@ -1,6 +0,0 @@
|
|||
#ifndef OCARINA_CALLBACK_H
|
||||
#define OCARINA_CALLBACK_H
|
||||
|
||||
void setup_callbacks();
|
||||
|
||||
#endif /* OCARINA_CALLBACK_H */
|
|
@ -1,12 +0,0 @@
|
|||
#ifndef OCARINA_SHORTCUT_H
|
||||
#define OCARINA_SHORTCUT_H
|
||||
|
||||
#include <ocarina/ocarina.h>
|
||||
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
void register_shortcut(string, void (*)());
|
||||
gboolean handle_shortcut(GtkWidget *, GdkEvent *, gpointer);
|
||||
|
||||
#endif /* OCARINA_SHORTCUT_H */
|
|
@ -1,54 +0,0 @@
|
|||
// Copyright (c) 2011 Bryan Schumaker
|
||||
#include <ocarina/header.h>
|
||||
#include <libsaria/index.h>
|
||||
#include <libsaria/print.h>
|
||||
#include "header.h"
|
||||
|
||||
#include <list>
|
||||
using namespace std;
|
||||
|
||||
static list<GtkWidget *>entries;
|
||||
|
||||
static GtkWidget *find_current_entry()
|
||||
{
|
||||
list<GtkWidget *>::iterator it;
|
||||
for (it = entries.begin(); it != entries.end(); it++) {
|
||||
if (gtk_widget_get_mapped(*it))
|
||||
return *it;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void focus_entry()
|
||||
{
|
||||
GtkWidget *entry = find_current_entry();
|
||||
if (entry != NULL)
|
||||
gtk_widget_grab_focus(entry);
|
||||
}
|
||||
|
||||
static void do_filter(GtkWidget *entry)
|
||||
{
|
||||
string text = gtk_entry_get_text(GTK_ENTRY(entry));
|
||||
//libsaria::index::filter(text);
|
||||
}
|
||||
|
||||
static void destroyed(GtkWidget *entry)
|
||||
{
|
||||
entries.remove(entry);
|
||||
}
|
||||
|
||||
GtkWidget *get_entry()
|
||||
{
|
||||
GtkWidget *entry = gtk_entry_new();
|
||||
GTK_CONNECT(entry, "changed", do_filter, NULL);
|
||||
GTK_CONNECT(entry, "destroy", destroyed, NULL);
|
||||
entries.push_back(entry);
|
||||
return entry;
|
||||
}
|
||||
|
||||
bool entry_focused()
|
||||
{
|
||||
GtkWidget *entry = find_current_entry();
|
||||
return gtk_widget_is_focus(entry);
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
// Copyright (c) 2011 Bryan Schumaker
|
||||
#include <ocarina/header.h>
|
||||
#include <ocarina/button.h>
|
||||
#include <ocarina/shortcut.h>
|
||||
#include "header.h"
|
||||
|
||||
GtkWidget *get_header()
|
||||
{
|
||||
GtkWidget *header = gtk_vbox_new(FALSE, 0);
|
||||
GtkWidget *sep = gtk_hseparator_new();
|
||||
GtkWidget *content = gtk_hbox_new(FALSE, 0);
|
||||
|
||||
box_pack_start(content, get_entry(), TRUE, TRUE, 0);
|
||||
//box_pack_start(content, make_open_button(), FALSE, FALSE, 0);
|
||||
box_pack_start(content, make_random_button(), FALSE, FALSE, 0);
|
||||
box_pack_start(content, make_volume_button(), FALSE, FALSE, 0);
|
||||
|
||||
box_pack_start(header, content, FALSE, FALSE, 0);
|
||||
box_pack_start(header, sep, FALSE, FALSE, 0);
|
||||
|
||||
gtk_widget_show_all(header);
|
||||
|
||||
return header;
|
||||
}
|
||||
|
||||
void header_init()
|
||||
{
|
||||
register_shortcut("slash", focus_entry);
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
#ifndef OCARINA_HEADER_PRIVATE_H
|
||||
#define OCARINA_HEADER_PRIVATE_H
|
||||
|
||||
#include <ocarina/header.h>
|
||||
|
||||
GtkWidget *get_entry();
|
||||
void focus_entry();
|
||||
|
||||
#endif /* OCARINA_HEADER_PRIVATE_H */
|
|
@ -7,21 +7,6 @@
|
|||
#include <ocarina/ocarina.h>
|
||||
#include <ocarina/window.h>
|
||||
#include <ocarina/body.h>
|
||||
/*#include <version.h>
|
||||
#include <ocarina/callback.h>
|
||||
#include <ocarina/body.h>
|
||||
#include <ocarina/header.h>
|
||||
#include <ocarina/footer.h>
|
||||
#include <ocarina/ocarina.h>
|
||||
#include <ocarina/settings.h>
|
||||
#include <ocarina/window.h>
|
||||
#include <ocarina/library.h>
|
||||
#include <ocarina/queue.h>
|
||||
|
||||
#include <libsaria/audio.h>
|
||||
#include <libsaria/libsaria.h>
|
||||
#include <libsaria/print.h>
|
||||
#include <libsaria/idle.h>*/
|
||||
|
||||
static string path_prefix;
|
||||
static bool using_idle = false;
|
||||
|
@ -64,18 +49,6 @@ namespace ocarina
|
|||
return res;
|
||||
}
|
||||
|
||||
/*void init(int argc, char **argv)
|
||||
{
|
||||
window::init("Ocarina " + vers_str(), full_path("images/ocarina.png"));
|
||||
window_add(get_tabs());
|
||||
settings_init();
|
||||
ocarina::library::init();
|
||||
ocarina::queue::init();
|
||||
header_init();
|
||||
footer_init();
|
||||
idle_add();
|
||||
}
|
||||
*/
|
||||
void quit()
|
||||
{
|
||||
gtk_main_quit();
|
||||
|
@ -111,21 +84,5 @@ int main(int argc, char **argv)
|
|||
gtk_main();
|
||||
libsaria::quit();
|
||||
|
||||
/* setup_callbacks();
|
||||
|
||||
g_thread_init(NULL);
|
||||
gdk_threads_init();
|
||||
|
||||
gtk_init(&argc, &argv);
|
||||
ocarina::init(argc, argv);
|
||||
ocarina::init_pipe();
|
||||
|
||||
if (argc > 1)
|
||||
libsaria::audio::load(argv[1]);
|
||||
|
||||
gdk_threads_enter();
|
||||
gtk_main();
|
||||
gdk_threads_leave();
|
||||
libsaria::quit();*/
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
// Copyright (c) 2011 Bryan Schumaker
|
||||
#include <gdk/gdk.h>
|
||||
#include <ocarina/shortcut.h>
|
||||
#include <ocarina/window.h>
|
||||
#include <ocarina/header.h>
|
||||
#include <libsaria/print.h>
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
static map<string, void (*)()> shortcut_map;
|
||||
|
||||
void register_shortcut(string key, void (*func)())
|
||||
{
|
||||
shortcut_map[key] = func;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns FALSE to allow other functions to run
|
||||
* Returns TRUE if other handlers should not be run
|
||||
*/
|
||||
gboolean handle_shortcut(GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||
{
|
||||
string key = gdk_keyval_name(event->key.keyval);
|
||||
map<string, void (*)()>::iterator it;
|
||||
|
||||
if (key == "Escape") {
|
||||
//window_focus();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Don't run shortcuts if user is filtering */
|
||||
if (entry_focused() == true)
|
||||
return FALSE;
|
||||
|
||||
it = shortcut_map.find(key);
|
||||
if (it == shortcut_map.end()) {
|
||||
println("No function registered for key: %s", key.c_str());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
it->second();
|
||||
return TRUE;
|
||||
}
|
Loading…
Reference in New Issue