summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--callbacks.c36
-rw-r--r--gtkplaylist.c42
-rw-r--r--gtkplaylist.h1
-rw-r--r--main.c12
-rw-r--r--search.c10
5 files changed, 74 insertions, 27 deletions
diff --git a/callbacks.c b/callbacks.c
index b0d5005e..47f7b538 100644
--- a/callbacks.c
+++ b/callbacks.c
@@ -771,14 +771,8 @@ on_playlist_save_as_activate (GtkMenuItem *menuitem,
}
-gboolean
-on_seekbar_configure_event (GtkWidget *widget,
- GdkEventConfigure *event,
- gpointer user_data)
-{
-
- return FALSE;
-}
+static GdkPixmap *seekbar_backbuf;
+static GdkPixmap *volumebar_backbuf;
enum
{
@@ -835,8 +829,9 @@ seekbar_draw (GtkWidget *widget) {
if (!widget) {
return;
}
+ gdk_draw_rectangle (seekbar_backbuf, widget->style->bg_gc[0], TRUE, 0, 0, widget->allocation.width, widget->allocation.height);
cairo_t *cr;
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (seekbar_backbuf);
if (!cr) {
return;
}
@@ -879,12 +874,30 @@ seekbar_draw (GtkWidget *widget) {
cairo_destroy (cr);
}
+void
+seekbar_expose (GtkWidget *widget, int x, int y, int w, int h) {
+ gdk_draw_drawable (widget->window, widget->style->black_gc, seekbar_backbuf, x, y, x, y, w, h);
+}
+
+gboolean
+on_seekbar_configure_event (GtkWidget *widget,
+ GdkEventConfigure *event,
+ gpointer user_data)
+{
+ if (seekbar_backbuf) {
+ g_object_unref (seekbar_backbuf);
+ seekbar_backbuf = NULL;
+ }
+ seekbar_backbuf = gdk_pixmap_new (widget->window, widget->allocation.width, widget->allocation.height, -1);
+ seekbar_draw (widget);
+ return FALSE;
+}
gboolean
on_seekbar_expose_event (GtkWidget *widget,
GdkEventExpose *event,
gpointer user_data)
{
- seekbar_draw (widget);
+ seekbar_expose (widget, event->area.x, event->area.y, event->area.width, event->area.height);
return FALSE;
}
@@ -897,6 +910,7 @@ on_seekbar_motion_notify_event (GtkWidget *widget,
if (seekbar_moving) {
seekbar_move_x = event->x;
seekbar_draw (widget);
+ seekbar_expose (widget, 0, 0, widget->allocation.width, widget->allocation.height);
}
return FALSE;
}
@@ -909,6 +923,7 @@ on_seekbar_button_press_event (GtkWidget *widget,
seekbar_moving = 1;
seekbar_move_x = event->x;
seekbar_draw (widget);
+ seekbar_expose (widget, 0, 0, widget->allocation.width, widget->allocation.height);
return FALSE;
}
@@ -920,6 +935,7 @@ on_seekbar_button_release_event (GtkWidget *widget,
{
seekbar_moving = 0;
seekbar_draw (widget);
+ seekbar_expose (widget, 0, 0, widget->allocation.width, widget->allocation.height);
float time = event->x * playlist_current.duration / (widget->allocation.width-8);
if (time < 0) {
time = 0;
diff --git a/gtkplaylist.c b/gtkplaylist.c
index 4cf4ead4..2048a9a0 100644
--- a/gtkplaylist.c
+++ b/gtkplaylist.c
@@ -71,6 +71,10 @@ float fontheight = 11;
// playlist row height
int rowheight = 17;
+// header widget font/height
+const char *header_fontface = "DejaVu Sans";
+float header_fontheight = 11; // must be set as widget_height-2
+
const char *colnames[pl_ncolumns] = {
"Playing",
"Artist / Album",
@@ -115,6 +119,12 @@ gtkpl_set_cairo_font (cairo_t *cr) {
cairo_set_font_size (cr, fontheight);
}
+void
+gtkpl_set_cairo_header_font (cairo_t *cr) {
+ cairo_select_font_face (cr, header_fontface, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
+ cairo_set_font_size (cr, header_fontheight);
+}
+
int
gtkpl_fit_text (cairo_t *cr, char *out, int *dotpos, int len, const char *in, int width) {
int l = strlen (in);
@@ -424,8 +434,8 @@ on_playlist_configure_event (GtkWidget *widget,
GdkEventConfigure *event,
gpointer user_data)
{
- extern void main_playlist_init (GtkWidget *widget);
- main_playlist_init (widget);
+// extern void main_playlist_init (GtkWidget *widget);
+// main_playlist_init (widget);
GTKPL_PROLOGUE;
gtkpl_configure (ps);
return FALSE;
@@ -438,6 +448,12 @@ gtkpl_expose (gtkplaylist_t *ps, int x, int y, int w, int h) {
}
void
+gtkpl_expose_header (gtkplaylist_t *ps, int x, int y, int w, int h) {
+ GtkWidget *widget = ps->header;
+ gdk_draw_drawable (widget->window, widget->style->black_gc, ps->backbuf_header, x, y, x, y, w, h);
+}
+
+void
gtkpl_select_single (gtkplaylist_t *ps, int sel) {
if (!ps->multisel) {
return;
@@ -1145,33 +1161,36 @@ gtkpl_header_draw (gtkplaylist_t *ps) {
int h = widget->allocation.height;
const char *detail = "toolbar";
+ // fill background
+ gdk_draw_rectangle (ps->backbuf_header, widget->style->bg_gc[0], TRUE, 0, 0, widget->allocation.width, widget->allocation.height);
for (int i = 0; i < pl_ncolumns; i++) {
if (x >= widget->allocation.width) {
break;
}
w = ps->colwidths[i];
if (w > 0) {
- gtk_paint_box (widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, NULL, detail, x, 0, w - 2, h);
- gtk_paint_vline (widget->style, widget->window, GTK_STATE_NORMAL, NULL, NULL, NULL, 0, h, x+w - 2);
+ gtk_paint_box (widget->style, ps->backbuf_header, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, NULL, detail, x, 0, w - 2, h);
+ gtk_paint_vline (widget->style, ps->backbuf_header, GTK_STATE_NORMAL, NULL, NULL, NULL, 0, h, x+w - 2);
}
x += w;
}
if (x < widget->allocation.width) {
- gtk_paint_box (widget->style, widget->window, GTK_STATE_INSENSITIVE, GTK_SHADOW_OUT, NULL, NULL, detail, x, 0, widget->allocation.width-x, h);
+ gtk_paint_box (widget->style, ps->backbuf_header, GTK_STATE_INSENSITIVE, GTK_SHADOW_OUT, NULL, NULL, detail, x, 0, widget->allocation.width-x, h);
}
cairo_t *cr;
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (ps->backbuf_header);
if (!cr) {
return;
}
x = 0;
+ gtkpl_set_cairo_header_font (cr);
for (int i = 0; i < pl_ncolumns; i++) {
if (x >= widget->allocation.width) {
break;
}
w = ps->colwidths[i];
if (w > 0) {
- cairo_move_to (cr, x + 5, 15);
+ cairo_move_to (cr, x + 5, widget->allocation.height/2 + header_fontheight/3);
if (!ps->header_fitted[i]) {
gtkpl_fit_text (cr, ps->colnames_fitted[i], NULL, pl_colname_max, colnames[i], ps->colwidths[i]-10);
ps->header_fitted[i] = 1;
@@ -1190,6 +1209,7 @@ on_header_expose_event (GtkWidget *widget,
{
GTKPL_PROLOGUE;
gtkpl_header_draw (ps);
+ gtkpl_expose_header (ps, event->area.x, event->area.y, event->area.width, event->area.height);
return FALSE;
}
@@ -1199,6 +1219,13 @@ on_header_configure_event (GtkWidget *widget,
GdkEventConfigure *event,
gpointer user_data)
{
+ GTKPL_PROLOGUE;
+ if (ps->backbuf_header) {
+ g_object_unref (ps->backbuf_header);
+ ps->backbuf_header = NULL;
+ }
+ ps->backbuf_header = gdk_pixmap_new (widget->window, widget->allocation.width, widget->allocation.height, -1);
+ gtkpl_header_draw (ps);
return FALSE;
}
@@ -1254,6 +1281,7 @@ on_header_motion_notify_event (GtkWidget *widget,
ps->fmtcache[cidx+2] = 0;
}
gtkpl_header_draw (ps);
+ gtkpl_expose_header (ps, 0, 0, ps->header->allocation.width, ps->header->allocation.height);
gtkpl_draw_playlist (ps, 0, 0, ps->playlist->allocation.width, ps->playlist->allocation.height);
gtkpl_expose (ps, 0, 0, ps->playlist->allocation.width, ps->playlist->allocation.height);
}
diff --git a/gtkplaylist.h b/gtkplaylist.h
index bffb489f..d8ff62e9 100644
--- a/gtkplaylist.h
+++ b/gtkplaylist.h
@@ -59,6 +59,7 @@ typedef struct {
GtkWidget *header;
GtkWidget *scrollbar;
GdkPixmap *backbuf;
+ GdkPixmap *backbuf_header;
// parameters
playItem_t **pcurr; // pointer to current item
int *pcount; // pointer to count of items in list
diff --git a/main.c b/main.c
index d02725b8..c141875d 100644
--- a/main.c
+++ b/main.c
@@ -35,6 +35,7 @@
#include "streamer.h"
GtkWidget *mainwin;
+GtkWidget *searchwin;
gtkplaylist_t main_playlist;
gtkplaylist_t search_playlist;
@@ -93,9 +94,12 @@ update_songinfo (void) {
if (songpos != last_songpos) {
void seekbar_draw (GtkWidget *widget);
+ void seekbar_expose (GtkWidget *widget, int x, int y, int w, int h);
if (mainwin) {
GDK_THREADS_ENTER();
- seekbar_draw (lookup_widget (mainwin, "seekbar"));
+ GtkWidget *widget = lookup_widget (mainwin, "seekbar");
+ seekbar_draw (widget);
+ seekbar_expose (widget, 0, 0, widget->allocation.width, widget->allocation.height);
GDK_THREADS_LEAVE();
last_songpos = songpos;
}
@@ -238,6 +242,12 @@ main (int argc, char *argv[]) {
pl_load (defpl);
mainwin = create_mainwin ();
+ searchwin = create_searchwin ();
+ gtk_window_set_transient_for (GTK_WINDOW (searchwin), GTK_WINDOW (mainwin));
+ extern void main_playlist_init (GtkWidget *widget);
+ main_playlist_init (lookup_widget (mainwin, "playlist"));
+ extern void search_playlist_init (GtkWidget *widget);
+ search_playlist_init (lookup_widget (mainwin, "searchlist"));
gtk_widget_show (mainwin);
gtk_main ();
mainwin = NULL;
diff --git a/search.c b/search.c
index 505e7e20..848bd91c 100644
--- a/search.c
+++ b/search.c
@@ -35,18 +35,12 @@
#include "messagepump.h"
#include "messages.h"
-GtkWidget *searchwin = NULL;
+extern GtkWidget *searchwin;
struct playItem_s *search_current = NULL;
int search_count = 0;
void
search_start (void) {
- if (!searchwin) {
- searchwin = create_searchwin ();
- extern GtkWidget *mainwin;
- gtk_window_set_transient_for (GTK_WINDOW (searchwin), GTK_WINDOW (mainwin));
- }
-
gtk_entry_set_text (GTK_ENTRY (lookup_widget (searchwin, "searchentry")), "");
gtk_widget_show (searchwin);
gtk_window_present (GTK_WINDOW (searchwin));
@@ -185,8 +179,6 @@ on_searchlist_configure_event (GtkWidget *widget,
GdkEventConfigure *event,
gpointer user_data)
{
- extern void search_playlist_init (GtkWidget *widget);
- search_playlist_init (widget);
GTKPL_PROLOGUE;
gtkpl_configure (ps);
return FALSE;