ocarina: Clean out old gtk and button code
Now that I'm using gtk builder I don't need gtk convenience functions. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
22e64d64ca
commit
5a1b8555db
|
@ -1,42 +0,0 @@
|
|||
#ifndef OCARINA_BUTTON_H
|
||||
#define OCARINA_BUTTON_H
|
||||
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
#include <ocarina/ocarina.h>
|
||||
|
||||
GtkWidget *get_image(const gchar *stockid, GtkIconSize size);
|
||||
void change_button_image(GtkWidget *button, const char *stockid);
|
||||
|
||||
GtkWidget *make_button_data(const gchar *stockid,
|
||||
void (* func)(GtkWidget *, gpointer),
|
||||
gpointer data,
|
||||
bool show);
|
||||
|
||||
GtkWidget *make_button(const gchar *stockid,
|
||||
void (* func)(GtkWidget *, gpointer),
|
||||
bool show);
|
||||
|
||||
GtkWidget *make_larger_button(const gchar *stockid,
|
||||
void (* func)(GtkWidget *, gpointer),
|
||||
bool show);
|
||||
|
||||
GtkWidget *make_text_button(const gchar *stockid,
|
||||
string text,
|
||||
void (* func)(GtkWidget *, gpointer),
|
||||
bool show);
|
||||
|
||||
GtkWidget *make_toggle_button_data(const gchar *stockid,
|
||||
void (*func)(GtkWidget *, gpointer),
|
||||
gpointer data,
|
||||
bool show);
|
||||
|
||||
GtkWidget *make_toggle_button(const gchar *stockid,
|
||||
void (* func)(GtkWidget *, gpointer),
|
||||
bool show);
|
||||
|
||||
GtkWidget *make_random_button();
|
||||
GtkWidget *make_volume_button();
|
||||
|
||||
#endif /* OCARINA_BUTTON_H */
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (c) 2012 Bryan Schumaker
|
||||
#include <ocarina/ocarina.h>
|
||||
#include <ocarina/button.h>
|
||||
#include <ocarina/body.h>
|
||||
|
||||
#include <libsaria/audio.h>
|
||||
|
@ -53,7 +52,7 @@ static void slider_changed(GtkWidget *w, GtkScrollType s, gdouble v, gpointer d)
|
|||
libsaria::audio::seek_to(v);
|
||||
}
|
||||
|
||||
static void on_click_play(GtkWidget *b, gpointer d)
|
||||
/*static void on_click_play(GtkWidget *b, gpointer d)
|
||||
{
|
||||
libsaria::audio::play();
|
||||
}
|
||||
|
@ -76,17 +75,17 @@ static void on_click_prev(GtkWidget *b, gpointer d)
|
|||
static void on_click_next(GtkWidget *b, gpointer d)
|
||||
{
|
||||
libsaria::deck::next();
|
||||
}
|
||||
}*/
|
||||
|
||||
static GtkWidget *make_controls()
|
||||
{
|
||||
GtkWidget *box = gtk_hbox_new(FALSE, 0);
|
||||
|
||||
play_button = make_button(GTK_STOCK_MEDIA_PLAY, on_click_play, true);
|
||||
/*play_button = make_button(GTK_STOCK_MEDIA_PLAY, on_click_play, true);
|
||||
pause_button = make_button(GTK_STOCK_MEDIA_PAUSE, on_click_pause, false);
|
||||
stop_button = make_button(GTK_STOCK_MEDIA_STOP, on_click_stop, true);
|
||||
prev_button = make_button(GTK_STOCK_MEDIA_PREVIOUS, on_click_prev, true);
|
||||
next_button = make_button(GTK_STOCK_MEDIA_NEXT, on_click_next, true);
|
||||
next_button = make_button(GTK_STOCK_MEDIA_NEXT, on_click_next, true);*/
|
||||
|
||||
pos_label = gtk_label_new("");
|
||||
track_progress = gtk_hscale_new_with_range(0, 1, 1000000000);
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include <libsaria/library.h>
|
||||
#include <ocarina/ocarina.h>
|
||||
#include <ocarina/chooser.h>
|
||||
#include <ocarina/button.h>
|
||||
#include <ocarina/body.h>
|
||||
|
||||
struct library_info {
|
||||
|
@ -96,10 +95,10 @@ static void on_click_add(GtkWidget *b, gpointer d)
|
|||
}
|
||||
}
|
||||
|
||||
static void on_click_update(GtkWidget *b, gpointer d)
|
||||
/*static void on_click_update(GtkWidget *b, gpointer d)
|
||||
{
|
||||
println("Update button clicked");
|
||||
}
|
||||
}*/
|
||||
|
||||
static void row_activated(GtkWidget *treeview, GtkTreePath *path,
|
||||
GtkTreeViewColumn *col, gpointer data)
|
||||
|
@ -166,14 +165,14 @@ static gboolean key_pressed(GtkWidget *treeview, GdkEvent *event, gpointer data)
|
|||
static GtkWidget *button_row()
|
||||
{
|
||||
GtkWidget *button_row = gtk_vbox_new(FALSE, 0);
|
||||
GtkWidget *add = make_button(GTK_STOCK_ADD, on_click_add, true);
|
||||
GtkWidget *update = make_button(GTK_STOCK_REFRESH, on_click_update, true);
|
||||
//GtkWidget *add = make_button(GTK_STOCK_ADD, on_click_add, true);
|
||||
//GtkWidget *update = make_button(GTK_STOCK_REFRESH, on_click_update, true);
|
||||
|
||||
gtk_widget_set_tooltip_text(add, "Add path to library");
|
||||
gtk_widget_set_tooltip_text(update, "Update all library paths");
|
||||
//gtk_widget_set_tooltip_text(add, "Add path to library");
|
||||
//gtk_widget_set_tooltip_text(update, "Update all library paths");
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(button_row), add, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(button_row), update, FALSE, FALSE, 0);
|
||||
//gtk_box_pack_start(GTK_BOX(button_row), add, FALSE, FALSE, 0);
|
||||
//gtk_box_pack_start(GTK_BOX(button_row), update, FALSE, FALSE, 0);
|
||||
return button_row;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (c) 2012 Bryan Schumaker
|
||||
#include <ocarina/ocarina.h>
|
||||
#include <ocarina/button.h>
|
||||
#include <ocarina/body.h>
|
||||
|
||||
#include <libsaria/track.h>
|
||||
|
@ -63,7 +62,7 @@ static GtkWidget *make_tag_labels()
|
|||
return window;
|
||||
}
|
||||
|
||||
static void on_ban(GtkWidget *w, gpointer d)
|
||||
/*static void on_ban(GtkWidget *w, gpointer d)
|
||||
{
|
||||
bool banned = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ban));
|
||||
if (banned)
|
||||
|
@ -77,12 +76,12 @@ static void on_ban(GtkWidget *w, gpointer d)
|
|||
current->set_banned(banned);
|
||||
if (banned)
|
||||
libsaria::deck::next();
|
||||
}
|
||||
}*/
|
||||
|
||||
static GtkWidget *make_buttons()
|
||||
{
|
||||
GtkWidget *box = gtk_vbox_new(FALSE, 0);
|
||||
ban = make_toggle_button(GTK_STOCK_YES, on_ban, true);
|
||||
//ban = make_toggle_button(GTK_STOCK_YES, on_ban, true);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(box), ban, FALSE, FALSE, 0);
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2012 Bryan Schumaker
|
||||
#include <ocarina/ocarina.h>
|
||||
#include <ocarina/chooser.h>
|
||||
#include <ocarina/button.h>
|
||||
#include <ocarina/body.h>
|
||||
|
||||
#include <libsaria/libsaria.h>
|
||||
|
@ -15,14 +14,14 @@ static GtkWidget *action_box;
|
|||
static GtkWidget *open_button;
|
||||
static map<GtkWidget *, libsaria::Playlist *> tab_mapping;
|
||||
|
||||
static void on_click_open_file(GtkWidget *b, gpointer d)
|
||||
/*static void on_click_open_file(GtkWidget *b, gpointer d)
|
||||
{
|
||||
string file = ocarina::choose_file();
|
||||
if (file != "") {
|
||||
println("Playing file: " + file);
|
||||
libsaria::play_outside_song(file);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
static void on_page_reordered(GtkWidget *t, GtkWidget *page, guint num, gpointer d)
|
||||
{
|
||||
|
@ -44,7 +43,7 @@ namespace ocarina
|
|||
{
|
||||
tabs = gtk_notebook_new();
|
||||
action_box = gtk_vbox_new(FALSE, 0);
|
||||
open_button = make_larger_button(GTK_STOCK_OPEN, on_click_open_file, true);
|
||||
//open_button = make_larger_button(GTK_STOCK_OPEN, on_click_open_file, true);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(action_box), open_button, FALSE, FALSE, 0);
|
||||
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
// Copyright (c) 2011 Bryan Schumaker
|
||||
#include <ocarina/button.h>
|
||||
#include <ocarina/chooser.h>
|
||||
|
||||
#include <libsaria/audio.h>
|
||||
#include <libsaria/print.h>
|
||||
|
||||
static GtkWidget *get_button(void (* func)(GtkWidget *, gpointer),
|
||||
gpointer data,
|
||||
bool show)
|
||||
{
|
||||
GtkWidget *button = gtk_button_new();
|
||||
g_signal_connect(button, "clicked", G_CALLBACK(func), data);
|
||||
if (show == true)
|
||||
gtk_widget_show(button);
|
||||
return button;
|
||||
}
|
||||
|
||||
GtkWidget *get_image(const gchar *stockid, GtkIconSize size)
|
||||
{
|
||||
GtkWidget *img = gtk_image_new_from_stock(stockid, size);
|
||||
gtk_widget_show(img);
|
||||
return img;
|
||||
}
|
||||
|
||||
void change_button_image(GtkWidget *button, const gchar *stockid)
|
||||
{
|
||||
GtkWidget *image = get_image(stockid, GTK_ICON_SIZE_MENU);
|
||||
gtk_button_set_image(GTK_BUTTON(button), image);
|
||||
}
|
||||
|
||||
/*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),
|
||||
gpointer data,
|
||||
bool show)
|
||||
{
|
||||
GtkWidget *button = get_button(func, data, show);
|
||||
GtkWidget *image = get_image(stockid, GTK_ICON_SIZE_MENU);
|
||||
gtk_button_set_image(GTK_BUTTON(button), image);
|
||||
return button;
|
||||
}
|
||||
|
||||
GtkWidget *make_button(const gchar *stockid,
|
||||
void (* func)(GtkWidget *, gpointer),
|
||||
bool show)
|
||||
{
|
||||
return make_button_data(stockid, func, NULL, show);
|
||||
}
|
||||
|
||||
|
||||
GtkWidget *make_larger_button(const gchar *stockid,
|
||||
void (* func)(GtkWidget *, gpointer),
|
||||
bool show)
|
||||
{
|
||||
GtkWidget *button = get_button(func, NULL, show);
|
||||
GtkWidget *image = get_image(stockid, GTK_ICON_SIZE_BUTTON);
|
||||
gtk_container_add(GTK_CONTAINER(button), image);
|
||||
return button;
|
||||
}
|
||||
|
||||
GtkWidget *make_text_button(const gchar *stockid,
|
||||
string text,
|
||||
void (* func)(GtkWidget *, gpointer),
|
||||
bool show)
|
||||
{
|
||||
GtkWidget *button = get_button(func, NULL, show);
|
||||
// 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);
|
||||
gtk_widget_show(box);
|
||||
return button;
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
// Copyright (c) 2011 Bryan Schumaker
|
||||
#include <ocarina/button.h>
|
||||
|
||||
static GtkWidget *get_toggle_button(void (* func)(GtkWidget *, gpointer),
|
||||
gpointer data, bool show)
|
||||
{
|
||||
GtkWidget *button = gtk_toggle_button_new();
|
||||
g_signal_connect(button, "toggled", G_CALLBACK(func), data);
|
||||
if (show == true)
|
||||
gtk_widget_show(button);
|
||||
return button;
|
||||
}
|
||||
|
||||
GtkWidget *make_toggle_button_data(const gchar *stockid,
|
||||
void (* func)(GtkWidget *, gpointer),
|
||||
gpointer data,
|
||||
bool show)
|
||||
{
|
||||
GtkWidget *button = get_toggle_button(func, data, show);
|
||||
GtkWidget *image = get_image(stockid, GTK_ICON_SIZE_MENU);
|
||||
gtk_button_set_image(GTK_BUTTON(button), image);
|
||||
return button;
|
||||
}
|
||||
|
||||
GtkWidget *make_toggle_button(const gchar *stockid,
|
||||
void (* func)(GtkWidget *, gpointer),
|
||||
bool show)
|
||||
{
|
||||
return make_toggle_button_data(stockid, func, NULL, show);
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
// Copyright (c) 2011 Bryan Schumaker
|
||||
#include <libsaria/audio.h>
|
||||
#include <ocarina/button.h>
|
||||
|
||||
static void resize(GtkWidget *volume)
|
||||
{
|
||||
const gchar *icon = NULL;
|
||||
GList *list = gtk_container_get_children(GTK_CONTAINER(volume));
|
||||
gpointer ptr = g_list_nth_data(list, 0);
|
||||
GtkWidget *image = (GtkWidget *)ptr;
|
||||
|
||||
gtk_image_get_icon_name(GTK_IMAGE(image), &icon, NULL);
|
||||
gtk_image_set_from_icon_name(GTK_IMAGE(image),
|
||||
icon,
|
||||
GTK_ICON_SIZE_MENU);
|
||||
}
|
||||
|
||||
static void set_increment(GtkWidget *volume, double incr)
|
||||
{
|
||||
GtkAdjustment *adj = gtk_scale_button_get_adjustment(
|
||||
GTK_SCALE_BUTTON(volume));
|
||||
gtk_adjustment_set_page_increment(adj, incr);
|
||||
}
|
||||
|
||||
/*static void changed(GtkWidget *button, gdouble value, gpointer data)
|
||||
{
|
||||
//libsaria::audio::set_volume(value);
|
||||
resize(button);
|
||||
}*/
|
||||
|
||||
GtkWidget *make_volume_button()
|
||||
{
|
||||
GtkWidget *volume = gtk_volume_button_new();
|
||||
/*gtk_scale_button_set_value(GTK_SCALE_BUTTON(volume),
|
||||
libsaria::audio::get_volume());*/
|
||||
gtk_widget_show(volume);
|
||||
set_increment(volume, 0.05);
|
||||
resize(volume);
|
||||
//GTK_CONNECT(volume, "value-changed", changed, NULL);
|
||||
return volume;
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
// Copyright (c) 2011 Bryan Schumaker
|
||||
#include <ocarina/ocarina.h>
|
||||
|
||||
void box_pack_start(GtkWidget *box, GtkWidget *child, gboolean expand,
|
||||
gboolean fill, guint padding)
|
||||
{
|
||||
gtk_box_pack_start(GTK_BOX(box), child, expand, fill, padding);
|
||||
}
|
||||
|
||||
void box_pack_end(GtkWidget *box, GtkWidget *child, gboolean expand,
|
||||
gboolean fill, guint padding)
|
||||
{
|
||||
gtk_box_pack_end(GTK_BOX(box), child, expand, fill, padding);
|
||||
}
|
||||
|
||||
void container_add(GtkWidget *container, GtkWidget *widget)
|
||||
{
|
||||
gtk_container_add(GTK_CONTAINER(container), widget);
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (c) 2012 Bryan Schumaker
|
||||
#include <ocarina/playlist.h>
|
||||
#include <ocarina/button.h>
|
||||
#include <ocarina/body.h>
|
||||
|
||||
#include <libsaria/format.h>
|
||||
|
@ -10,7 +9,7 @@
|
|||
#include <sstream>
|
||||
using namespace std;
|
||||
|
||||
static void disable_playlist(GtkWidget *button, gpointer d)
|
||||
/*static void disable_playlist(GtkWidget *button, gpointer d)
|
||||
{
|
||||
libsaria::Playlist *plist = (libsaria::Playlist *)d;
|
||||
plist->set_disabled(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)));
|
||||
|
@ -20,7 +19,7 @@ static void delete_playlist(GtkWidget *button, gpointer d)
|
|||
{
|
||||
libsaria::Playlist *plist = (libsaria::Playlist *)d;
|
||||
libsaria::deck::delete_playlist(plist);
|
||||
}
|
||||
}*/
|
||||
|
||||
static void selected_foreach_list(GtkTreeModel *model, GtkTreePath *path,
|
||||
GtkTreeIter *iter, gpointer data)
|
||||
|
@ -160,7 +159,7 @@ namespace ocarina
|
|||
{
|
||||
GtkWidget *label_box = gtk_hbox_new(FALSE, 0);
|
||||
GtkWidget *entry_box = gtk_hbox_new(FALSE, 0);
|
||||
GtkWidget *close_button;
|
||||
//GtkWidget *close_button;
|
||||
|
||||
libsaria::PlaylistRenderer::set_playlist(p);
|
||||
|
||||
|
@ -184,22 +183,22 @@ namespace ocarina
|
|||
|
||||
if (!p->is_static()) {
|
||||
/* Make disable button for playlists */
|
||||
disable_button = make_toggle_button_data(GTK_STOCK_YES,
|
||||
/*disable_button = make_toggle_button_data(GTK_STOCK_YES,
|
||||
disable_playlist,
|
||||
p, true);
|
||||
p, true);*/
|
||||
gtk_box_pack_start(GTK_BOX(entry_box), disable_button, FALSE, FALSE, 0);
|
||||
|
||||
/* Make close button for tabs */
|
||||
close_button = make_button_data(GTK_STOCK_CLOSE, delete_playlist, p, true);
|
||||
gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE);
|
||||
//close_button = make_button_data(GTK_STOCK_CLOSE, delete_playlist, p, true);
|
||||
//gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE);
|
||||
gtk_rc_parse_string(
|
||||
"style \"close-button-style\"\n"
|
||||
"{\n"
|
||||
" GtkButton::inner-border = {0,0,0,0}\n"
|
||||
"}\n"
|
||||
"widget \"*.ocarina-close-button\" style \"close-button-style\"");
|
||||
gtk_widget_set_name(close_button, "ocarina-close-button");
|
||||
gtk_box_pack_start(GTK_BOX(label_box), close_button, FALSE, FALSE, 0);
|
||||
//gtk_widget_set_name(close_button, "ocarina-close-button");
|
||||
//gtk_box_pack_start(GTK_BOX(label_box), close_button, FALSE, FALSE, 0);
|
||||
}
|
||||
|
||||
gtk_widget_show_all(label_box);
|
||||
|
@ -232,10 +231,10 @@ namespace ocarina
|
|||
gtk_widget_set_sensitive(name, !disabled);
|
||||
gtk_widget_set_sensitive(number, !disabled);
|
||||
|
||||
if (disabled)
|
||||
/*if (disabled)
|
||||
change_button_image(disable_button, GTK_STOCK_NO);
|
||||
else
|
||||
change_button_image(disable_button, GTK_STOCK_YES);
|
||||
change_button_image(disable_button, GTK_STOCK_YES);*/
|
||||
}
|
||||
|
||||
}; /* Namespace: ocarina */
|
||||
|
|
|
@ -5,7 +5,6 @@ using namespace std;
|
|||
|
||||
#include <ocarina/settings.h>
|
||||
#include <ocarina/chooser.h>
|
||||
#include <ocarina/button.h>
|
||||
#include <ocarina/ocarina.h>
|
||||
|
||||
#include <libsaria/library.h>
|
||||
|
|
Loading…
Reference in New Issue