ocarina: Remove window.h and lots of gtk shortcuts
The shortcuts were hiding more than they probably should have, and I didn't have much using them. The only function in window.h that I'm going to use is init_window(), so I'll just declare it in ocarina.h. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
1ddcb9f2fc
commit
4585d90a32
|
@ -10,14 +10,12 @@ using namespace std;
|
|||
GtkWidget *get_widget(const string &);
|
||||
string lib_file(const string &);
|
||||
|
||||
void box_pack_start(GtkWidget *, GtkWidget *, gboolean, gboolean, guint);
|
||||
void box_pack_end(GtkWidget *, GtkWidget *, gboolean, gboolean, guint);
|
||||
void container_add(GtkWidget *, GtkWidget *);
|
||||
/* window.cpp */
|
||||
void init_window();
|
||||
|
||||
namespace ocarina
|
||||
{
|
||||
|
||||
void quit();
|
||||
void idle_add();
|
||||
void init_pipe();
|
||||
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
#ifndef OCARINA_WINDOW_H
|
||||
#define OCARINA_WINDOW_H
|
||||
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
void init_window();
|
||||
|
||||
namespace ocarina
|
||||
{
|
||||
namespace window
|
||||
{
|
||||
|
||||
void init();
|
||||
|
||||
void set_title(string);
|
||||
void set_icon(string);
|
||||
void set_content(GtkWidget *);
|
||||
|
||||
}; /* Namespace: window */
|
||||
/*void window_resize(int, int);
|
||||
void window_add(GtkWidget *);
|
||||
void window_focus();*/
|
||||
|
||||
}; /* Namespace: ocarina */
|
||||
|
||||
#endif
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (c) 2012 Bryan Schumaker
|
||||
#include <ocarina/ocarina.h>
|
||||
#include <ocarina/window.h>
|
||||
#include <ocarina/body.h>
|
||||
|
||||
static GtkWidget *content;
|
||||
|
@ -16,7 +15,7 @@ namespace ocarina
|
|||
gtk_box_pack_start(GTK_BOX(content), footer_init(), FALSE, FALSE, 0);
|
||||
|
||||
gtk_widget_show(content);
|
||||
window::set_content(content);
|
||||
//window::set_content(content);
|
||||
}
|
||||
|
||||
}; /* Namespace: ocarina */
|
||||
|
|
|
@ -29,12 +29,12 @@ void change_button_image(GtkWidget *button, const gchar *stockid)
|
|||
gtk_button_set_image(GTK_BUTTON(button), image);
|
||||
}
|
||||
|
||||
static GtkWidget *get_label(string text)
|
||||
/*static GtkWidget *get_label(string text)
|
||||
{
|
||||
GtkWidget *label = gtk_label_new(text.c_str());
|
||||
gtk_widget_show(label);
|
||||
return label;
|
||||
}
|
||||
}*/
|
||||
|
||||
GtkWidget *make_button_data(const gchar *stockid,
|
||||
void (* func)(GtkWidget *, gpointer),
|
||||
|
@ -71,13 +71,13 @@ GtkWidget *make_text_button(const gchar *stockid,
|
|||
bool show)
|
||||
{
|
||||
GtkWidget *button = get_button(func, NULL, show);
|
||||
GtkWidget *image = get_image(stockid, GTK_ICON_SIZE_BUTTON);
|
||||
GtkWidget *label = get_label(text);
|
||||
// GtkWidget *image = get_image(stockid, GTK_ICON_SIZE_BUTTON);
|
||||
// GtkWidget *label = get_label(text);
|
||||
GtkWidget *box = gtk_hbox_new(FALSE, 0);
|
||||
|
||||
box_pack_start(box, image, FALSE, FALSE, 0);
|
||||
box_pack_start(box, label, FALSE, FALSE, 0);
|
||||
container_add(button, box);
|
||||
// box_pack_start(box, image, FALSE, FALSE, 0);
|
||||
// box_pack_start(box, label, FALSE, FALSE, 0);
|
||||
// container_add(button, box);
|
||||
gtk_widget_show(box);
|
||||
return button;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include <libsaria/libsaria.h>
|
||||
|
||||
#include <ocarina/ocarina.h>
|
||||
#include <ocarina/window.h>
|
||||
|
||||
|
||||
/*#include <libsaria/libsaria.h>
|
||||
|
|
|
@ -45,8 +45,8 @@ static GtkWidget *alsa_devices = NULL;
|
|||
static void add_alsa_settings(GtkWidget *general)
|
||||
{
|
||||
//bool using_alsa = libsaria::audio::using_alsa();
|
||||
GtkWidget *alsa = gtk_hbox_new(FALSE, 0);
|
||||
GtkWidget *button = gtk_check_button_new_with_label("Use ALSA");
|
||||
//GtkWidget *alsa = gtk_hbox_new(FALSE, 0);
|
||||
//GtkWidget *button = gtk_check_button_new_with_label("Use ALSA");
|
||||
alsa_devices = gtk_combo_box_text_new();
|
||||
|
||||
//gtk_widget_set_sensitive(alsa_devices, using_alsa);
|
||||
|
@ -56,9 +56,9 @@ static void add_alsa_settings(GtkWidget *general)
|
|||
//GTK_CONNECT(button, "toggled", toggle_alsa, NULL);
|
||||
//GTK_CONNECT(alsa_devices, "changed", change_alsa_device, NULL);
|
||||
|
||||
box_pack_start(alsa, button, FALSE, FALSE, 0);
|
||||
box_pack_start(alsa, alsa_devices, TRUE, TRUE, 0);
|
||||
box_pack_start(general, alsa, FALSE, FALSE, 0);
|
||||
//box_pack_start(alsa, button, FALSE, FALSE, 0);
|
||||
//box_pack_start(alsa, alsa_devices, TRUE, TRUE, 0);
|
||||
//box_pack_start(general, alsa, FALSE, FALSE, 0);
|
||||
}
|
||||
|
||||
void general_settings_init()
|
||||
|
|
|
@ -15,19 +15,19 @@ using namespace std;
|
|||
static GtkWidget *library_settings = NULL;
|
||||
static map<GtkWidget *, string> widget_mapping;
|
||||
|
||||
static void on_click_add(GtkWidget *b, gpointer d)
|
||||
/*static void on_click_add(GtkWidget *b, gpointer d)
|
||||
{
|
||||
string dir = ocarina::choose_dir();
|
||||
if (dir != "" ) {
|
||||
println("Scanning dir: " + dir);
|
||||
//libsaria::library::add_path(dir);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
static void on_click_update(GtkWidget *b, gpointer d)
|
||||
/*static void on_click_update(GtkWidget *b, gpointer d)
|
||||
{
|
||||
//libsaria::library::update();
|
||||
}
|
||||
}*/
|
||||
|
||||
/*static void on_click_update_path(GtkWidget *b, GdkEvent *e, gpointer d)
|
||||
{
|
||||
|
@ -98,23 +98,23 @@ static void add_library_path(libsaria::LibraryPath *path)
|
|||
box_pack_start(library_settings, panel, FALSE, FALSE, 0);
|
||||
}*/
|
||||
|
||||
static GtkWidget *get_button_row()
|
||||
/*static GtkWidget *get_button_row()
|
||||
{
|
||||
GtkWidget *button_row = gtk_hbox_new(FALSE, 0);
|
||||
GtkWidget *add_button = make_text_button(GTK_STOCK_ADD,
|
||||
GtkWidget *button_row = gtk_hbox_new(FALSE, 0);*/
|
||||
/*GtkWidget *add_button = make_text_button(GTK_STOCK_ADD,
|
||||
"Add to Library",
|
||||
on_click_add,
|
||||
true);
|
||||
GtkWidget *update_button = make_text_button(GTK_STOCK_REFRESH,
|
||||
true);*/
|
||||
/*GtkWidget *update_button = make_text_button(GTK_STOCK_REFRESH,
|
||||
"Update Library",
|
||||
on_click_update,
|
||||
true);
|
||||
|
||||
box_pack_end(button_row, add_button, FALSE, FALSE, 0);
|
||||
box_pack_end(button_row, update_button, FALSE, FALSE, 0);
|
||||
true);*/
|
||||
|
||||
//box_pack_end(button_row, add_button, FALSE, FALSE, 0);
|
||||
//box_pack_end(button_row, update_button, FALSE, FALSE, 0);
|
||||
/*
|
||||
return button_row;
|
||||
}
|
||||
}*/
|
||||
|
||||
void library_refresh_remove(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
|
@ -134,7 +134,7 @@ void library_settings_refresh()
|
|||
add_library_path(path);
|
||||
}*/
|
||||
|
||||
box_pack_start(library_settings, get_button_row(), FALSE, FALSE, 0);
|
||||
//box_pack_start(library_settings, get_button_row(), FALSE, FALSE, 0);
|
||||
gtk_widget_show_all(library_settings);
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ void library_settings_init()
|
|||
{
|
||||
library_settings = gtk_vbox_new(FALSE, 0);
|
||||
|
||||
box_pack_start(library_settings, get_button_row(), FALSE, FALSE, 0);
|
||||
//box_pack_start(library_settings, get_button_row(), FALSE, FALSE, 0);
|
||||
gtk_widget_show_all(library_settings);
|
||||
add_settings_page("Library", library_settings);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include <version.h>
|
||||
#include <ocarina/playlist.h>
|
||||
#include <ocarina/ocarina.h>
|
||||
#include <ocarina/window.h>
|
||||
|
||||
#include <libsaria/audio.h>
|
||||
#include <libsaria/prefs.h>
|
||||
|
@ -12,21 +11,16 @@
|
|||
#include <sstream>
|
||||
using namespace std;
|
||||
|
||||
static GtkWidget *win;
|
||||
static int old_w, old_h;
|
||||
static bool ignore_configure_event = false;
|
||||
//static GtkWidget *win;
|
||||
//static int old_w, old_h;
|
||||
//static bool ignore_configure_event = false;
|
||||
|
||||
static void resize(int w, int h)
|
||||
/*static void resize(int w, int h)
|
||||
{
|
||||
gtk_window_resize(GTK_WINDOW(win), w, h);
|
||||
}
|
||||
|
||||
/*static void destroy(GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||
{
|
||||
ocarina::quit();
|
||||
}*/
|
||||
|
||||
static gboolean configure(GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||
/*static gboolean configure(GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||
{
|
||||
int w, h;
|
||||
int old_w = libsaria::prefs::get("ocarina.window.w");
|
||||
|
@ -49,9 +43,9 @@ static gboolean configure(GtkWidget *widget, GdkEvent *event, gpointer data)
|
|||
println("New (w,h): (%d, %d)", w, h);
|
||||
gtk_window_resize(GTK_WINDOW(win), w, h);
|
||||
return FALSE;
|
||||
}
|
||||
}*/
|
||||
|
||||
static void window_state(GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||
/*static void window_state(GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||
{
|
||||
bool maxed = false;
|
||||
bool maximized = libsaria::prefs::get("ocarina.window.maximized");
|
||||
|
@ -71,9 +65,9 @@ static void window_state(GtkWidget *widget, GdkEvent *event, gpointer data)
|
|||
libsaria::prefs::set("ocarina.window.w", old_w);
|
||||
libsaria::prefs::set("ocarina.window.h", old_h);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
static gboolean key_pressed(GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||
/*static gboolean key_pressed(GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||
{
|
||||
string key = gdk_keyval_name(event->key.keyval);
|
||||
GtkWidget *focus = gtk_window_get_focus(GTK_WINDOW(win));
|
||||
|
@ -97,9 +91,9 @@ static gboolean key_pressed(GtkWidget *widget, GdkEvent *event, gpointer data)
|
|||
else
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
}*/
|
||||
|
||||
static gboolean key_pressed_after(GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||
/*static gboolean key_pressed_after(GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||
{
|
||||
string key = gdk_keyval_name(event->key.keyval);
|
||||
println("Window handling key press (2): " + key);
|
||||
|
@ -119,24 +113,20 @@ static gboolean key_pressed_after(GtkWidget *widget, GdkEvent *event, gpointer d
|
|||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
}*/
|
||||
|
||||
namespace ocarina
|
||||
/*namespace ocarina
|
||||
{
|
||||
|
||||
void window::init()
|
||||
{
|
||||
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
//g_signal_connect(win, "destroy", G_CALLBACK(destroy), NULL);
|
||||
g_signal_connect(win, "configure-event", G_CALLBACK(configure), NULL);
|
||||
g_signal_connect(win, "window-state-event", G_CALLBACK(window_state), NULL);
|
||||
g_signal_connect(win, "key-press-event", G_CALLBACK(key_pressed), NULL);
|
||||
g_signal_connect_after(win, "key-press-event", G_CALLBACK(key_pressed_after), NULL);
|
||||
|
||||
set_title("Ocarina " + vers_str());
|
||||
//set_icon(lib_file("ocarina.png"));
|
||||
|
||||
old_w = libsaria::prefs::init("ocarina.window.w", 800);
|
||||
old_h = libsaria::prefs::init("ocarina.window.h", 600);
|
||||
resize(old_w, old_h);
|
||||
|
@ -147,22 +137,12 @@ namespace ocarina
|
|||
gtk_widget_show(win);
|
||||
}
|
||||
|
||||
void window::set_title(string title)
|
||||
{
|
||||
gtk_window_set_title(GTK_WINDOW(win), title.c_str());
|
||||
}
|
||||
|
||||
void window::set_icon(string path)
|
||||
{
|
||||
gtk_window_set_icon_from_file(GTK_WINDOW(win), path.c_str(), NULL);
|
||||
}
|
||||
|
||||
void window::set_content(GtkWidget *content)
|
||||
{
|
||||
gtk_container_add(GTK_CONTAINER(win), content);
|
||||
}
|
||||
|
||||
} /* Namespace: ocarina */
|
||||
} *//* Namespace: ocarina */
|
||||
|
||||
void init_window()
|
||||
{
|
||||
|
@ -170,8 +150,8 @@ void init_window()
|
|||
if (!window)
|
||||
return;
|
||||
|
||||
|
||||
g_signal_connect(window, "destroy", gtk_main_quit, NULL);
|
||||
gtk_window_set_title(GTK_WINDOW(window), ("Ocarina " + vers_str()).c_str());
|
||||
gtk_window_set_icon_from_file(GTK_WINDOW(window), lib_file("ocarina.png").c_str(), NULL);
|
||||
|
||||
g_signal_connect(window, "destroy", gtk_main_quit, NULL);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue