summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <waker@users.sourceforge.net>2014-06-17 21:47:03 +0200
committerGravatar Alexey Yakovenko <waker@users.sourceforge.net>2014-06-17 21:47:03 +0200
commitd390a25a61f2f9ba17938079a704f38a60e4f149 (patch)
treefda5ed591ca4f5f293c31db884796ae12e7bd0e8 /plugins
parent1b1b61f2de8f438ab9dc00c09f9ffeab41f5539c (diff)
gtkui: better custom title configuration using context menu
Diffstat (limited to 'plugins')
-rw-r--r--plugins/gtkui/actionhandlers.c2
-rw-r--r--plugins/gtkui/deadbeef.glade117
-rw-r--r--plugins/gtkui/interface.c61
-rw-r--r--plugins/gtkui/interface.h1
-rw-r--r--plugins/gtkui/plcommon.c98
5 files changed, 269 insertions, 10 deletions
diff --git a/plugins/gtkui/actionhandlers.c b/plugins/gtkui/actionhandlers.c
index f9fa9ecc..ad4bf04c 100644
--- a/plugins/gtkui/actionhandlers.c
+++ b/plugins/gtkui/actionhandlers.c
@@ -434,7 +434,7 @@ action_add_location_handler_cb (void *user_data) {
DB_playItem_t *tail = deadbeef->plt_get_last (plt, PL_MAIN);
DB_playItem_t *it = deadbeef->plt_insert_file2 (0, plt, tail, text, NULL, NULL, NULL);
if (it && deadbeef->conf_get_int ("gtkui.location_set_custom_title", 0)) {
- deadbeef->pl_replace_meta (it, "DDB:CUSTOM_TITLE", gtk_entry_get_text (GTK_ENTRY (ct)));
+ deadbeef->pl_replace_meta (it, ":CUSTOM_TITLE", gtk_entry_get_text (GTK_ENTRY (ct)));
}
if (tail) {
deadbeef->pl_item_unref (tail);
diff --git a/plugins/gtkui/deadbeef.glade b/plugins/gtkui/deadbeef.glade
index f4bb6c8e..fc2fefbb 100644
--- a/plugins/gtkui/deadbeef.glade
+++ b/plugins/gtkui/deadbeef.glade
@@ -8724,4 +8724,121 @@ Descending</property>
</child>
</widget>
+<widget class="GtkDialog" id="setcustomtitledlg">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Set Custom Title</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">True</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
+ <property name="urgency_hint">False</property>
+ <property name="has_separator">True</property>
+
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox16">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area15">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+ <child>
+ <widget class="GtkButton" id="cancelbutton11">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-cancel</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-6</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="okbutton11">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-ok</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-5</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox123">
+ <property name="border_width">12</property>
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">8</property>
+
+ <child>
+ <widget class="GtkCheckButton" id="set_custom_title">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Set custom title</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="custom_title">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">•</property>
+ <property name="activates_default">False</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
</glade-interface>
diff --git a/plugins/gtkui/interface.c b/plugins/gtkui/interface.c
index 3f70035a..7f5ce942 100644
--- a/plugins/gtkui/interface.c
+++ b/plugins/gtkui/interface.c
@@ -4397,3 +4397,64 @@ create_select_action (void)
return select_action;
}
+GtkWidget*
+create_setcustomtitledlg (void)
+{
+ GtkWidget *setcustomtitledlg;
+ GtkWidget *dialog_vbox16;
+ GtkWidget *hbox123;
+ GtkWidget *set_custom_title;
+ GtkWidget *custom_title;
+ GtkWidget *dialog_action_area15;
+ GtkWidget *cancelbutton11;
+ GtkWidget *okbutton11;
+
+ setcustomtitledlg = gtk_dialog_new ();
+ gtk_window_set_title (GTK_WINDOW (setcustomtitledlg), _("Set Custom Title"));
+ gtk_window_set_modal (GTK_WINDOW (setcustomtitledlg), TRUE);
+ gtk_window_set_type_hint (GTK_WINDOW (setcustomtitledlg), GDK_WINDOW_TYPE_HINT_DIALOG);
+
+ dialog_vbox16 = gtk_dialog_get_content_area (GTK_DIALOG (setcustomtitledlg));
+ gtk_widget_show (dialog_vbox16);
+
+ hbox123 = gtk_hbox_new (FALSE, 8);
+ gtk_widget_show (hbox123);
+ gtk_box_pack_start (GTK_BOX (dialog_vbox16), hbox123, TRUE, TRUE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox123), 12);
+
+ set_custom_title = gtk_check_button_new_with_mnemonic (_("Set custom title"));
+ gtk_widget_show (set_custom_title);
+ gtk_box_pack_start (GTK_BOX (hbox123), set_custom_title, FALSE, FALSE, 0);
+
+ custom_title = gtk_entry_new ();
+ gtk_widget_show (custom_title);
+ gtk_box_pack_start (GTK_BOX (hbox123), custom_title, TRUE, TRUE, 0);
+ gtk_entry_set_invisible_char (GTK_ENTRY (custom_title), 8226);
+
+ dialog_action_area15 = gtk_dialog_get_action_area (GTK_DIALOG (setcustomtitledlg));
+ gtk_widget_show (dialog_action_area15);
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area15), GTK_BUTTONBOX_END);
+
+ cancelbutton11 = gtk_button_new_from_stock ("gtk-cancel");
+ gtk_widget_show (cancelbutton11);
+ gtk_dialog_add_action_widget (GTK_DIALOG (setcustomtitledlg), cancelbutton11, GTK_RESPONSE_CANCEL);
+ gtk_widget_set_can_default(cancelbutton11, TRUE);
+
+ okbutton11 = gtk_button_new_from_stock ("gtk-ok");
+ gtk_widget_show (okbutton11);
+ gtk_dialog_add_action_widget (GTK_DIALOG (setcustomtitledlg), okbutton11, GTK_RESPONSE_OK);
+ gtk_widget_set_can_default(okbutton11, TRUE);
+
+ /* Store pointers to all widgets, for use by lookup_widget(). */
+ GLADE_HOOKUP_OBJECT_NO_REF (setcustomtitledlg, setcustomtitledlg, "setcustomtitledlg");
+ GLADE_HOOKUP_OBJECT_NO_REF (setcustomtitledlg, dialog_vbox16, "dialog_vbox16");
+ GLADE_HOOKUP_OBJECT (setcustomtitledlg, hbox123, "hbox123");
+ GLADE_HOOKUP_OBJECT (setcustomtitledlg, set_custom_title, "set_custom_title");
+ GLADE_HOOKUP_OBJECT (setcustomtitledlg, custom_title, "custom_title");
+ GLADE_HOOKUP_OBJECT_NO_REF (setcustomtitledlg, dialog_action_area15, "dialog_action_area15");
+ GLADE_HOOKUP_OBJECT (setcustomtitledlg, cancelbutton11, "cancelbutton11");
+ GLADE_HOOKUP_OBJECT (setcustomtitledlg, okbutton11, "okbutton11");
+
+ return setcustomtitledlg;
+}
+
diff --git a/plugins/gtkui/interface.h b/plugins/gtkui/interface.h
index 9321b1d1..dc9ead7c 100644
--- a/plugins/gtkui/interface.h
+++ b/plugins/gtkui/interface.h
@@ -20,3 +20,4 @@ GtkWidget* create_ctmappingdlg (void);
GtkWidget* create_ctmappingeditdlg (void);
GtkWidget* create_button_properties (void);
GtkWidget* create_select_action (void);
+GtkWidget* create_setcustomtitledlg (void);
diff --git a/plugins/gtkui/plcommon.c b/plugins/gtkui/plcommon.c
index 2347540b..a6077929 100644
--- a/plugins/gtkui/plcommon.c
+++ b/plugins/gtkui/plcommon.c
@@ -32,6 +32,7 @@
#include "actions.h"
#include "search.h"
#include "actionhandlers.h"
+#include "../../strdupa.h"
#define min(x,y) ((x)<(y)?(x):(y))
//#define trace(...) { fprintf(stderr, __VA_ARGS__); }
@@ -466,6 +467,70 @@ on_remove2_activate (GtkMenuItem *menuitem,
deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, 0, 0);
}
+static void
+on_toggle_set_custom_title (GtkToggleButton *togglebutton, gpointer user_data) {
+ gboolean active = gtk_toggle_button_get_active (togglebutton);
+ deadbeef->conf_set_int ("gtkui.location_set_custom_title", active);
+
+ GtkWidget *ct = lookup_widget (GTK_WIDGET (user_data), "custom_title");
+ gtk_widget_set_sensitive (ct, active);
+
+ deadbeef->conf_save ();
+}
+
+void
+on_set_custom_title_activate (GtkMenuItem *menuitem, gpointer user_data)
+{
+ DdbListview *lv = user_data;
+ int idx = lv->binding->cursor ();
+ if (idx < 0) {
+ return;
+ }
+ DdbListviewIter it = lv->binding->get_for_idx (idx);
+ if (!it) {
+ return;
+ }
+
+ GtkWidget *dlg = create_setcustomtitledlg ();
+ GtkWidget *sct = lookup_widget (dlg, "set_custom_title");
+ GtkWidget *ct = lookup_widget (dlg, "custom_title");
+ if (deadbeef->conf_get_int ("gtkui.location_set_custom_title", 0)) {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sct), TRUE);
+ gtk_widget_set_sensitive (ct, TRUE);
+ }
+ else {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sct), FALSE);
+ gtk_widget_set_sensitive (ct, FALSE);
+ }
+ deadbeef->pl_lock ();
+ const char *custom_title = deadbeef->pl_find_meta ((DB_playItem_t *)it, ":CUSTOM_TITLE");
+ if (custom_title) {
+ custom_title = strdupa (custom_title);
+ }
+ else {
+ custom_title = "";
+ }
+ deadbeef->pl_unlock ();
+
+ g_signal_connect ((gpointer) sct, "toggled",
+ G_CALLBACK (on_toggle_set_custom_title),
+ dlg);
+ gtk_entry_set_text (GTK_ENTRY (ct), custom_title);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_OK);
+ gint response = gtk_dialog_run (GTK_DIALOG (dlg));
+ if (response == GTK_RESPONSE_OK) {
+ if (it && deadbeef->conf_get_int ("gtkui.location_set_custom_title", 0)) {
+ deadbeef->pl_replace_meta ((DB_playItem_t *)it, ":CUSTOM_TITLE", gtk_entry_get_text (GTK_ENTRY (ct)));
+ }
+ else {
+ deadbeef->pl_delete_meta ((DB_playItem_t *)it, ":CUSTOM_TITLE");
+ }
+ }
+ gtk_widget_destroy (dlg);
+ lv->binding->unref (it);
+}
+
void
on_remove_from_disk_activate (GtkMenuItem *menuitem,
gpointer user_data)
@@ -553,12 +618,13 @@ list_context_menu (DdbListview *listview, DdbListviewIter it, int idx) {
GtkWidget *playlist_menu;
GtkWidget *add_to_playback_queue1;
GtkWidget *remove_from_playback_queue1;
- GtkWidget *separator9;
+ GtkWidget *separator;
GtkWidget *remove2;
GtkWidget *remove_from_disk;
GtkWidget *separator8;
GtkWidget *properties1;
GtkWidget *reload_metadata;
+ GtkWidget *set_custom_title;
playlist_menu = gtk_menu_new ();
add_to_playback_queue1 = gtk_menu_item_new_with_mnemonic (_("Add To Playback Queue"));
@@ -579,10 +645,10 @@ list_context_menu (DdbListview *listview, DdbListviewIter it, int idx) {
gtk_container_add (GTK_CONTAINER (playlist_menu), reload_metadata);
g_object_set_data (G_OBJECT (reload_metadata), "ps", listview);
- separator9 = gtk_separator_menu_item_new ();
- gtk_widget_show (separator9);
- gtk_container_add (GTK_CONTAINER (playlist_menu), separator9);
- gtk_widget_set_sensitive (separator9, FALSE);
+ separator = gtk_separator_menu_item_new ();
+ gtk_widget_show (separator);
+ gtk_container_add (GTK_CONTAINER (playlist_menu), separator);
+ gtk_widget_set_sensitive (separator, FALSE);
remove2 = gtk_menu_item_new_with_mnemonic (_("Remove"));
gtk_widget_show (remove2);
@@ -598,10 +664,10 @@ list_context_menu (DdbListview *listview, DdbListviewIter it, int idx) {
g_object_set_data (G_OBJECT (remove_from_disk), "ps", listview);
}
- separator8 = gtk_separator_menu_item_new ();
- gtk_widget_show (separator8);
- gtk_container_add (GTK_CONTAINER (playlist_menu), separator8);
- gtk_widget_set_sensitive (separator8, FALSE);
+ separator = gtk_separator_menu_item_new ();
+ gtk_widget_show (separator);
+ gtk_container_add (GTK_CONTAINER (playlist_menu), separator);
+ gtk_widget_set_sensitive (separator, FALSE);
int selected_count = 0;
DB_playItem_t *pit = deadbeef->pl_get_first (PL_MAIN);
@@ -729,6 +795,17 @@ list_context_menu (DdbListview *listview, DdbListviewIter it, int idx) {
gtk_widget_set_sensitive (separator8, FALSE);
}
+ set_custom_title = gtk_menu_item_new_with_mnemonic (_("Set Custom Title"));
+ gtk_widget_show (set_custom_title);
+ gtk_container_add (GTK_CONTAINER (playlist_menu), set_custom_title);
+ if (selected_count != 1) {
+ gtk_widget_set_sensitive (GTK_WIDGET (set_custom_title), FALSE);
+ }
+
+ separator = gtk_separator_menu_item_new ();
+ gtk_widget_show (separator);
+ gtk_container_add (GTK_CONTAINER (playlist_menu), separator);
+ gtk_widget_set_sensitive (separator, FALSE);
properties1 = gtk_menu_item_new_with_mnemonic (_("Track Properties"));
gtk_widget_show (properties1);
@@ -752,6 +829,9 @@ list_context_menu (DdbListview *listview, DdbListviewIter it, int idx) {
G_CALLBACK (on_remove_from_disk_activate),
NULL);
}
+ g_signal_connect ((gpointer) set_custom_title, "activate",
+ G_CALLBACK (on_set_custom_title_activate),
+ listview);
g_signal_connect ((gpointer) properties1, "activate",
G_CALLBACK (main_properties_activate),
NULL);