diff options
author | waker <wakeroid@gmail.com> | 2011-10-16 13:21:14 +0200 |
---|---|---|
committer | waker <wakeroid@gmail.com> | 2011-10-16 13:21:14 +0200 |
commit | e3a336388fe2a90c295180c0784bc394f74ea938 (patch) | |
tree | 66f395fd1ae8a263d5134903a2bc1c7fe94cef34 /plugins | |
parent | 19b8f9a97a3415a74192aece4b78845f00ed3408 (diff) |
added support for auto-resizing playlist columns
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/gtkui/ddblistview.c | 16 | ||||
-rw-r--r-- | plugins/gtkui/ddblistview.h | 1 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.c | 1 |
3 files changed, 17 insertions, 1 deletions
diff --git a/plugins/gtkui/ddblistview.c b/plugins/gtkui/ddblistview.c index 21a2af92..30dce7b9 100644 --- a/plugins/gtkui/ddblistview.c +++ b/plugins/gtkui/ddblistview.c @@ -57,7 +57,7 @@ G_DEFINE_TYPE (DdbListview, ddb_listview, GTK_TYPE_TABLE); struct _DdbListviewColumn { char *title; - int width; + float width; int minheight; struct _DdbListviewColumn *next; void *user_data; @@ -318,6 +318,7 @@ ddb_listview_init(DdbListview *listview) listview->last_header_motion_ev = -1; //is it subject to remove? listview->prev_header_x = -1; listview->header_prepare = 0; + listview->header_width = 0; listview->columns = NULL; listview->groups = NULL; @@ -2317,6 +2318,19 @@ ddb_listview_header_configure_event (GtkWidget *widget, if (height != a.height) { gtk_widget_set_size_request (widget, -1, height); } + + if (ps->header_width == 0) { + ps->header_width = a.width; + } + else if (ps->header_width != a.width && deadbeef->conf_get_int ("gtkui.autoresize_columns", 0)) { + float ratio = (float)a.width / ps->header_width; + ps->header_width = a.width; + struct _DdbListviewColumn *c; + for (c = ps->columns; c; c = c->next) { + c->width *= ratio; + } + } + return FALSE; } diff --git a/plugins/gtkui/ddblistview.h b/plugins/gtkui/ddblistview.h index f3f9121c..a43dbcc3 100644 --- a/plugins/gtkui/ddblistview.h +++ b/plugins/gtkui/ddblistview.h @@ -138,6 +138,7 @@ struct _DdbListview { float last_header_motion_ev; //is it subject to remove? int prev_header_x; int header_prepare; + int header_width; // previous width before resize struct _DdbListviewColumn *columns; struct _DdbListviewGroup *groups; diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index 709280d6..935d5871 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -1354,6 +1354,7 @@ static const char settings_dlg[] = "property \"Custom status icon\" entry gtkui.custom_tray_icon \"" TRAY_ICON "\" ;\n" "property \"Run gtk_init with --sync (debug mode)\" checkbox gtkui.sync 0;\n" "property \"Add separators between plugin context menu items\" checkbox gtkui.action_separators 0;\n" + "property \"Auto-resize columns to fit the main window\" checkbox gtkui.autoresize_columns 0;\n" ; // define plugin interface |