summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <waker@users.sourceforge.net>2013-09-18 22:03:28 +0200
committerGravatar Alexey Yakovenko <waker@users.sourceforge.net>2013-09-18 22:03:28 +0200
commit3d8d583773aaaed79382b3c7aac0f33e6b1f1e02 (patch)
tree6291f1447eaa5a43ac2d1bfd50b2950950ce3bb5
parent5f87651e3aa480a671ad3a0cb2cd1c93bcacb70f (diff)
gtkui: warn a user when he forgets to save hotkeys changes
-rw-r--r--plugins/gtkui/hotkeys.c26
-rw-r--r--plugins/gtkui/hotkeys.h2
-rw-r--r--plugins/gtkui/prefwin.c18
3 files changed, 36 insertions, 10 deletions
diff --git a/plugins/gtkui/hotkeys.c b/plugins/gtkui/hotkeys.c
index 142b0164..5b204a1c 100644
--- a/plugins/gtkui/hotkeys.c
+++ b/plugins/gtkui/hotkeys.c
@@ -63,6 +63,8 @@ typedef struct
#include "hotkeys.h"
#include "../../strdupa.h"
+int gtkui_hotkeys_changed = 0;
+
void
on_hotkeys_actions_cursor_changed (GtkTreeView *treeview,
gpointer user_data);
@@ -401,6 +403,7 @@ on_hotkeys_actions_clicked (GtkButton *button,
void
prefwin_init_hotkeys (GtkWidget *_prefwin) {
+ gtkui_hotkeys_changed = 0;
ctx_names[DDB_ACTION_CTX_MAIN] = _("Main");
ctx_names[DDB_ACTION_CTX_SELECTION] = _("Selection");
ctx_names[DDB_ACTION_CTX_PLAYLIST] = _("Playlist");
@@ -508,6 +511,7 @@ on_hotkeys_list_cursor_changed (GtkTreeView *treeview,
if (path) {
gtk_tree_path_free (path);
}
+ gtkui_hotkeys_changed = 1;
}
@@ -524,6 +528,7 @@ on_hotkey_add_clicked (GtkButton *button,
gtk_tree_view_set_cursor (GTK_TREE_VIEW (hotkeys), path, NULL, FALSE);
gtk_tree_path_free (path);
gtk_widget_grab_focus (hotkeys);
+ gtkui_hotkeys_changed = 1;
}
@@ -538,6 +543,7 @@ on_hotkey_remove_clicked (GtkButton *button,
GtkTreeIter iter;
gtk_tree_model_get_iter (GTK_TREE_MODEL (hkstore), &iter, path);
gtk_list_store_remove (hkstore, &iter);
+ gtkui_hotkeys_changed = 1;
}
@@ -589,16 +595,15 @@ on_hotkey_is_global_toggled (GtkToggleButton *togglebutton,
gpointer user_data)
{
// update the tree
- {
- GtkWidget *hotkeys = lookup_widget (prefwin, "hotkeys_list");
- GtkTreePath *path;
- gtk_tree_view_get_cursor (GTK_TREE_VIEW (hotkeys), &path, NULL);
- GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (hotkeys));
- GtkTreeIter iter;
- if (path && gtk_tree_model_get_iter (model, &iter, path)) {
- gtk_list_store_set (GTK_LIST_STORE (model), &iter, 3, gtk_toggle_button_get_active (togglebutton), -1);
- }
+ GtkWidget *hotkeys = lookup_widget (prefwin, "hotkeys_list");
+ GtkTreePath *path;
+ gtk_tree_view_get_cursor (GTK_TREE_VIEW (hotkeys), &path, NULL);
+ GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (hotkeys));
+ GtkTreeIter iter;
+ if (path && gtk_tree_model_get_iter (model, &iter, path)) {
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter, 3, gtk_toggle_button_get_active (togglebutton), -1);
}
+ gtkui_hotkeys_changed = 1;
}
typedef struct {
@@ -784,6 +789,7 @@ out:
gdk_display_keyboard_ungrab (display, GDK_CURRENT_TIME);
gdk_display_pointer_ungrab (display, GDK_CURRENT_TIME);
grabbed = 0;
+ gtkui_hotkeys_changed = 1;
return TRUE;
}
@@ -823,6 +829,7 @@ on_hotkeys_apply_clicked (GtkButton *button,
gpointer user_data)
{
hotkeys_save ();
+ gtkui_hotkeys_changed = 0;
}
@@ -831,5 +838,6 @@ on_hotkeys_revert_clicked (GtkButton *button,
gpointer user_data)
{
hotkeys_load ();
+ gtkui_hotkeys_changed = 0;
}
diff --git a/plugins/gtkui/hotkeys.h b/plugins/gtkui/hotkeys.h
index 591c1b78..d066100b 100644
--- a/plugins/gtkui/hotkeys.h
+++ b/plugins/gtkui/hotkeys.h
@@ -24,6 +24,8 @@
#ifndef __GTKUI_HOTKEYS_H
#define __GTKUI_HOTKEYS_H
+extern int gtkui_hotkeys_changed;
+
void
prefwin_init_hotkeys (GtkWidget *prefwin);
diff --git a/plugins/gtkui/prefwin.c b/plugins/gtkui/prefwin.c
index cc04cb2d..532bc7fa 100644
--- a/plugins/gtkui/prefwin.c
+++ b/plugins/gtkui/prefwin.c
@@ -340,7 +340,23 @@ on_preferences_activate (GtkMenuItem *menuitem,
prefwin_init_hotkeys (prefwin);
deadbeef->conf_unlock ();
- gtk_dialog_run (GTK_DIALOG (prefwin));
+ for (;;) {
+ gtk_dialog_run (GTK_DIALOG (prefwin));
+ if (gtkui_hotkeys_changed) {
+ GtkWidget *dlg = gtk_message_dialog_new (GTK_WINDOW (prefwin), GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_YES_NO, _("You modified the hotkeys settings, but didn't save your changes."));
+ gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (prefwin));
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dlg), _("Are you sure you want to continue without saving?"));
+ 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) {
+ break;
+ }
+ }
+ else {
+ break;
+ }
+ }
dsp_setup_free ();
gtk_widget_destroy (prefwin);
deadbeef->conf_save ();