summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/gtkui/callbacks.c1
-rw-r--r--plugins/gtkui/callbacks.h4
-rw-r--r--plugins/gtkui/deadbeef.glade78
-rw-r--r--plugins/gtkui/gtkui.c34
-rw-r--r--plugins/gtkui/hotkeys.c55
-rw-r--r--plugins/gtkui/hotkeys.h3
-rw-r--r--plugins/gtkui/interface.c36
7 files changed, 177 insertions, 34 deletions
diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c
index 3cffb5c1..90924f4d 100644
--- a/plugins/gtkui/callbacks.c
+++ b/plugins/gtkui/callbacks.c
@@ -1022,3 +1022,4 @@ on_menu_bar1_activate (GtkMenuItem *menuitem,
action_toggle_menu_handler_cb (NULL);
}
+
diff --git a/plugins/gtkui/callbacks.h b/plugins/gtkui/callbacks.h
index f0bd66e5..5a147945 100644
--- a/plugins/gtkui/callbacks.h
+++ b/plugins/gtkui/callbacks.h
@@ -1291,3 +1291,7 @@ on_ctmapping_reset_clicked (GtkButton *button,
void
on_hotkeys_actions_clicked (GtkButton *button,
gpointer user_data);
+
+void
+on_hotkeys_defaults_clicked (GtkButton *button,
+ gpointer user_data);
diff --git a/plugins/gtkui/deadbeef.glade b/plugins/gtkui/deadbeef.glade
index 5616dd34..79596dda 100644
--- a/plugins/gtkui/deadbeef.glade
+++ b/plugins/gtkui/deadbeef.glade
@@ -5349,7 +5349,8 @@ SOCKS5_HOSTNAME</property>
<property name="visible">True</property>
<property name="label" translatable="yes">Use the Apply button to save your changes,
or the Revert button to undo your changes.
-The changes will NOT be saved if you don't press Apply.</property>
+The changes will NOT be saved
+if you don't press Apply.</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -5402,6 +5403,81 @@ The changes will NOT be saved if you don't press Apply.</property>
<signal name="clicked" handler="on_hotkeys_revert_clicked" last_modification_time="Sat, 24 Aug 2013 18:17:19 GMT"/>
</widget>
</child>
+
+ <child>
+ <widget class="GtkButton" id="hotkeys_defaults">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <signal name="clicked" handler="on_hotkeys_defaults_clicked" last_modification_time="Wed, 18 Sep 2013 20:23:37 GMT"/>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment26">
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">0</property>
+ <property name="right_padding">0</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox121">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">2</property>
+
+ <child>
+ <widget class="GtkImage" id="image638">
+ <property name="visible">True</property>
+ <property name="stock">gtk-revert-to-saved</property>
+ <property name="icon_size">4</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label146">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Defaults</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
</widget>
<packing>
<property name="padding">0</property>
diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c
index 894e1f85..8563c23c 100644
--- a/plugins/gtkui/gtkui.c
+++ b/plugins/gtkui/gtkui.c
@@ -64,6 +64,7 @@
#include "smclient/eggsmclient.h"
#endif
#include "actionhandlers.h"
+#include "hotkeys.h"
#define trace(...) { fprintf(stderr, __VA_ARGS__); }
//#define trace(fmt,...)
@@ -1038,38 +1039,7 @@ gtkui_thread (void *ctx) {
char checkpath[PATH_MAX];
snprintf (checkpath, sizeof (checkpath), "%s/config", deadbeef->get_config_dir ());
if (stat (checkpath, &st)) {
- printf ("file %s doesn't exist\n", checkpath);
- deadbeef->conf_set_str ("hotkey.key01", "\"Ctrl f\" 0 0 find");
- deadbeef->conf_set_str ("hotkey.key02", "\"Ctrl o\" 0 0 open_files");
- deadbeef->conf_set_str ("hotkey.key03", "\"Ctrl q\" 0 0 quit");
- deadbeef->conf_set_str ("hotkey.key04", "\"Ctrl n\" 0 0 new_playlist");
- deadbeef->conf_set_str ("hotkey.key05", "\"Ctrl a\" 0 0 select_all");
- deadbeef->conf_set_str ("hotkey.key06", "\"Escape\" 0 0 deselect_all");
- deadbeef->conf_set_str ("hotkey.key07", "\"Ctrl m\" 0 0 toggle_stop_after_current");
- deadbeef->conf_set_str ("hotkey.key08", "\"Ctrl j\" 0 0 jump_to_current_track");
- deadbeef->conf_set_str ("hotkey.key09", "\"F1\" 0 0 help");
- deadbeef->conf_set_str ("hotkey.key10", "\"Delete\" 1 0 remove_from_playlist");
- deadbeef->conf_set_str ("hotkey.key11", "\"Ctrl w\" 0 0 remove_current_playlist");
- deadbeef->conf_set_str ("hotkey.key11", "\"Ctrl w\" 0 0 remove_current_playlist");
- deadbeef->conf_set_str ("hotkey.key11", "\"Ctrl w\" 0 0 remove_current_playlist");
- deadbeef->conf_set_str ("hotkey.key14", "\"Return\" 0 0 play");
- deadbeef->conf_set_str ("hotkey.key15", "\"Ctrl p\" 0 0 toggle_pause");
- deadbeef->conf_set_str ("hotkey.key16", "\"Alt 1\" 0 0 playlist1");
- deadbeef->conf_set_str ("hotkey.key17", "\"Alt 2\" 0 0 playlist2");
- deadbeef->conf_set_str ("hotkey.key18", "\"Alt 3\" 0 0 playlist3");
- deadbeef->conf_set_str ("hotkey.key19", "\"Alt 4\" 0 0 playlist4");
- deadbeef->conf_set_str ("hotkey.key20", "\"Alt 5\" 0 0 playlist5");
- deadbeef->conf_set_str ("hotkey.key21", "\"Alt 6\" 0 0 playlist6");
- deadbeef->conf_set_str ("hotkey.key22", "\"Alt 7\" 0 0 playlist7");
- deadbeef->conf_set_str ("hotkey.key23", "\"Alt 8\" 0 0 playlist8");
- deadbeef->conf_set_str ("hotkey.key24", "\"Alt 9\" 0 0 playlist9");
- deadbeef->conf_set_str ("hotkey.key25", "\"Alt 0\" 0 0 playlist10");
- deadbeef->conf_set_str ("hotkey.key26", "z 0 0 prev");
- deadbeef->conf_set_str ("hotkey.key27", "x 0 0 play");
- deadbeef->conf_set_str ("hotkey.key28", "c 0 0 toggle_pause");
- deadbeef->conf_set_str ("hotkey.key29", "v 0 0 stop");
- deadbeef->conf_set_str ("hotkey.key30", "b 0 0 next");
- deadbeef->conf_set_str ("hotkey.key31", "n 0 0 playback_random");
+ gtkui_set_default_hotkeys ();
}
#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_events (GTK_WIDGET (mainwin), gtk_widget_get_events (GTK_WIDGET (mainwin)) | GDK_SCROLL_MASK);
diff --git a/plugins/gtkui/hotkeys.c b/plugins/gtkui/hotkeys.c
index 5b204a1c..0a3b2070 100644
--- a/plugins/gtkui/hotkeys.c
+++ b/plugins/gtkui/hotkeys.c
@@ -841,3 +841,58 @@ on_hotkeys_revert_clicked (GtkButton *button,
gtkui_hotkeys_changed = 0;
}
+void
+on_hotkeys_defaults_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ GtkWidget *dlg = gtk_message_dialog_new (GTK_WINDOW (prefwin), GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_YES_NO, _("All your custom-defined hotkeys will be lost."));
+ gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (prefwin));
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dlg), _("This operation cannot be undone. Proceed?"));
+ gtk_window_set_title (GTK_WINDOW (dlg), _("Warning"));
+ int response = gtk_dialog_run (GTK_DIALOG (dlg));
+ gtk_widget_destroy (dlg);
+ if (response != GTK_RESPONSE_YES) {
+ return;
+ }
+ gtkui_set_default_hotkeys ();
+}
+
+void
+gtkui_set_default_hotkeys (void) {
+ deadbeef->conf_remove_items ("hotkey.key");
+ deadbeef->conf_set_str ("hotkey.key01", "\"Ctrl f\" 0 0 find");
+ deadbeef->conf_set_str ("hotkey.key02", "\"Ctrl o\" 0 0 open_files");
+ deadbeef->conf_set_str ("hotkey.key03", "\"Ctrl q\" 0 0 quit");
+ deadbeef->conf_set_str ("hotkey.key04", "\"Ctrl n\" 0 0 new_playlist");
+ deadbeef->conf_set_str ("hotkey.key05", "\"Ctrl a\" 0 0 select_all");
+ deadbeef->conf_set_str ("hotkey.key06", "\"Escape\" 0 0 deselect_all");
+ deadbeef->conf_set_str ("hotkey.key07", "\"Ctrl m\" 0 0 toggle_stop_after_current");
+ deadbeef->conf_set_str ("hotkey.key08", "\"Ctrl j\" 0 0 jump_to_current_track");
+ deadbeef->conf_set_str ("hotkey.key09", "\"F1\" 0 0 help");
+ deadbeef->conf_set_str ("hotkey.key10", "\"Delete\" 1 0 remove_from_playlist");
+ deadbeef->conf_set_str ("hotkey.key11", "\"Ctrl w\" 0 0 remove_current_playlist");
+ deadbeef->conf_set_str ("hotkey.key11", "\"Ctrl w\" 0 0 remove_current_playlist");
+ deadbeef->conf_set_str ("hotkey.key11", "\"Ctrl w\" 0 0 remove_current_playlist");
+ deadbeef->conf_set_str ("hotkey.key14", "\"Return\" 0 0 play");
+ deadbeef->conf_set_str ("hotkey.key15", "\"Ctrl p\" 0 0 toggle_pause");
+ deadbeef->conf_set_str ("hotkey.key16", "\"Alt 1\" 0 0 playlist1");
+ deadbeef->conf_set_str ("hotkey.key17", "\"Alt 2\" 0 0 playlist2");
+ deadbeef->conf_set_str ("hotkey.key18", "\"Alt 3\" 0 0 playlist3");
+ deadbeef->conf_set_str ("hotkey.key19", "\"Alt 4\" 0 0 playlist4");
+ deadbeef->conf_set_str ("hotkey.key20", "\"Alt 5\" 0 0 playlist5");
+ deadbeef->conf_set_str ("hotkey.key21", "\"Alt 6\" 0 0 playlist6");
+ deadbeef->conf_set_str ("hotkey.key22", "\"Alt 7\" 0 0 playlist7");
+ deadbeef->conf_set_str ("hotkey.key23", "\"Alt 8\" 0 0 playlist8");
+ deadbeef->conf_set_str ("hotkey.key24", "\"Alt 9\" 0 0 playlist9");
+ deadbeef->conf_set_str ("hotkey.key25", "\"Alt 0\" 0 0 playlist10");
+ deadbeef->conf_set_str ("hotkey.key26", "z 0 0 prev");
+ deadbeef->conf_set_str ("hotkey.key27", "x 0 0 play");
+ deadbeef->conf_set_str ("hotkey.key28", "c 0 0 toggle_pause");
+ deadbeef->conf_set_str ("hotkey.key29", "v 0 0 stop");
+ deadbeef->conf_set_str ("hotkey.key30", "b 0 0 next");
+ deadbeef->conf_set_str ("hotkey.key31", "n 0 0 playback_random");
+ deadbeef->conf_save ();
+ hotkeys_load ();
+ gtkui_hotkeys_changed = 0;
+}
+
diff --git a/plugins/gtkui/hotkeys.h b/plugins/gtkui/hotkeys.h
index d066100b..48996c06 100644
--- a/plugins/gtkui/hotkeys.h
+++ b/plugins/gtkui/hotkeys.h
@@ -38,5 +38,8 @@ find_action_by_name (const char *command);
void
set_button_action_label (const char *act, int action_ctx, GtkWidget *button);
+void
+gtkui_set_default_hotkeys (void);
+
#endif // __GTKUI_HOTKEYS_H
diff --git a/plugins/gtkui/interface.c b/plugins/gtkui/interface.c
index 7338c732..44e4130d 100644
--- a/plugins/gtkui/interface.c
+++ b/plugins/gtkui/interface.c
@@ -1771,6 +1771,11 @@ create_prefwin (void)
GtkWidget *hbuttonbox4;
GtkWidget *hotkeys_apply;
GtkWidget *hotkeys_revert;
+ GtkWidget *hotkeys_defaults;
+ GtkWidget *alignment26;
+ GtkWidget *hbox121;
+ GtkWidget *image638;
+ GtkWidget *label146;
GtkWidget *label132;
GtkWidget *hpaned1;
GtkWidget *scrolledwindow2;
@@ -2558,7 +2563,7 @@ create_prefwin (void)
gtk_widget_show (hbox120);
gtk_box_pack_start (GTK_BOX (vbox36), hbox120, FALSE, FALSE, 0);
- label145 = gtk_label_new (_("Use the Apply button to save your changes,\nor the Revert button to undo your changes.\nThe changes will NOT be saved if you don't press Apply."));
+ label145 = gtk_label_new (_("Use the Apply button to save your changes,\nor the Revert button to undo your changes.\nThe changes will NOT be saved\nif you don't press Apply."));
gtk_widget_show (label145);
gtk_box_pack_start (GTK_BOX (hbox120), label145, FALSE, FALSE, 0);
@@ -2578,6 +2583,27 @@ create_prefwin (void)
gtk_container_add (GTK_CONTAINER (hbuttonbox4), hotkeys_revert);
gtk_widget_set_can_default(hotkeys_revert, TRUE);
+ hotkeys_defaults = gtk_button_new ();
+ gtk_widget_show (hotkeys_defaults);
+ gtk_container_add (GTK_CONTAINER (hbuttonbox4), hotkeys_defaults);
+ gtk_widget_set_can_default(hotkeys_defaults, TRUE);
+
+ alignment26 = gtk_alignment_new (0.5, 0.5, 0, 0);
+ gtk_widget_show (alignment26);
+ gtk_container_add (GTK_CONTAINER (hotkeys_defaults), alignment26);
+
+ hbox121 = gtk_hbox_new (FALSE, 2);
+ gtk_widget_show (hbox121);
+ gtk_container_add (GTK_CONTAINER (alignment26), hbox121);
+
+ image638 = gtk_image_new_from_stock ("gtk-revert-to-saved", GTK_ICON_SIZE_BUTTON);
+ gtk_widget_show (image638);
+ gtk_box_pack_start (GTK_BOX (hbox121), image638, FALSE, FALSE, 0);
+
+ label146 = gtk_label_new_with_mnemonic (_("_Defaults"));
+ gtk_widget_show (label146);
+ gtk_box_pack_start (GTK_BOX (hbox121), label146, FALSE, FALSE, 0);
+
label132 = gtk_label_new (_("Hotkeys"));
gtk_widget_show (label132);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), 6), label132);
@@ -2898,6 +2924,9 @@ create_prefwin (void)
g_signal_connect ((gpointer) hotkeys_revert, "clicked",
G_CALLBACK (on_hotkeys_revert_clicked),
NULL);
+ g_signal_connect ((gpointer) hotkeys_defaults, "clicked",
+ G_CALLBACK (on_hotkeys_defaults_clicked),
+ NULL);
g_signal_connect ((gpointer) pref_pluginlist, "cursor_changed",
G_CALLBACK (on_pref_pluginlist_cursor_changed),
NULL);
@@ -3069,6 +3098,11 @@ create_prefwin (void)
GLADE_HOOKUP_OBJECT (prefwin, hbuttonbox4, "hbuttonbox4");
GLADE_HOOKUP_OBJECT (prefwin, hotkeys_apply, "hotkeys_apply");
GLADE_HOOKUP_OBJECT (prefwin, hotkeys_revert, "hotkeys_revert");
+ GLADE_HOOKUP_OBJECT (prefwin, hotkeys_defaults, "hotkeys_defaults");
+ GLADE_HOOKUP_OBJECT (prefwin, alignment26, "alignment26");
+ GLADE_HOOKUP_OBJECT (prefwin, hbox121, "hbox121");
+ GLADE_HOOKUP_OBJECT (prefwin, image638, "image638");
+ GLADE_HOOKUP_OBJECT (prefwin, label146, "label146");
GLADE_HOOKUP_OBJECT (prefwin, label132, "label132");
GLADE_HOOKUP_OBJECT (prefwin, hpaned1, "hpaned1");
GLADE_HOOKUP_OBJECT (prefwin, scrolledwindow2, "scrolledwindow2");