diff options
author | 2009-12-24 03:24:29 +0200 | |
---|---|---|
committer | 2009-12-24 12:15:53 +0100 | |
commit | 0f95bf371655ed2c743d024bc2dfab51402f7d3a (patch) | |
tree | e26a0e56484090e2b3e936d81b08addad37dd60c /plugins/gtkui/gtkplaylist.c | |
parent | 5f008bc7ad0770ca920a9340839510c46c3dcd3b (diff) |
playlist header context menu implementation
Diffstat (limited to 'plugins/gtkui/gtkplaylist.c')
-rw-r--r-- | plugins/gtkui/gtkplaylist.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/plugins/gtkui/gtkplaylist.c b/plugins/gtkui/gtkplaylist.c index 272246d6..0ae46f9a 100644 --- a/plugins/gtkui/gtkplaylist.c +++ b/plugins/gtkui/gtkplaylist.c @@ -54,8 +54,8 @@ extern DB_functions_t *deadbeef; // defined in gtkui.c -//#define trace(...) { fprintf(stderr, __VA_ARGS__); } -#define trace(fmt,...) +#define trace(...) { fprintf(stderr, __VA_ARGS__); } +//#define trace(fmt,...) // debug function for gdk_draw_drawable static inline void @@ -69,6 +69,8 @@ extern GtkWidget *mainwin; extern GtkStatusIcon *trayicon; extern gtkplaylist_t main_playlist; +extern gtkplaylist_t *last_playlist; + static GtkWidget *theme_treeview; // orange on dark color scheme @@ -1476,18 +1478,18 @@ on_header_motion_notify_event (GtkWidget *widget, return FALSE; } -int +gtkpl_column_t* gtkpl_get_column_for_click (gtkplaylist_t *pl, int click_x) { int x = -pl->hscrollpos; - int i = 0; gtkpl_column_t *c; - for (c = pl->columns; c; c = c->next, i++) { + for (c = pl->columns; c; c = c->next) { int w = c->width; if (click_x >= x && click_x < x + w) { - return i; + return c; } + x += w; } - return -1; + return NULL; } gboolean @@ -1525,8 +1527,10 @@ on_header_button_press_event (GtkWidget *widget, } } else if (event->button == 3) { + ps->active_column = gtkpl_get_column_for_click (ps, event->x); GtkWidget *menu = create_headermenu (); - gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, widget, 0, gtk_get_current_event_time()); + last_playlist = ps; + gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, widget, 3, gtk_get_current_event_time()); } prev_header_x = -1; last_header_motion_ev = -1; @@ -1792,16 +1796,13 @@ gtkpl_column_update_config (gtkplaylist_t *pl, gtkpl_column_t *c, int idx) { void gtkpl_column_rewrite_config (gtkplaylist_t *pl) { char key[128]; - char value[128]; snprintf (key, sizeof (key), "%s.column.", pl->title); deadbeef->conf_remove_items (key); gtkpl_column_t *c; int i = 0; for (c = pl->columns; c; c = c->next, i++) { - snprintf (key, sizeof (key), "%s.column.%d", pl->title, i); - snprintf (value, sizeof (value), "\"%s\" \"%s\" %d %d %d", c->title, c->format ? c->format : "", c->id, c->width, c->align_right); - deadbeef->conf_set_str (key, value); + gtkpl_column_update_config (pl, c, i); } } |