summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2012-11-11 21:07:11 +0100
committerGravatar waker <wakeroid@gmail.com>2012-11-11 21:07:11 +0100
commit436fdc5411f4d91ad289615364a3b9424202bfbb (patch)
treece84c43ae98b56dbbde405d9f62993db37819c24 /plugins
parent0172e3a51cd2a767d96ca1efb9560c8f2a697ec4 (diff)
gtkui: hotkeys impl WIP
Diffstat (limited to 'plugins')
-rw-r--r--plugins/gtkui/callbacks.c80
-rw-r--r--plugins/gtkui/gtkui.c111
-rw-r--r--plugins/gtkui/gtkui.h9
-rw-r--r--plugins/gtkui/prefwin.c5
4 files changed, 97 insertions, 108 deletions
diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c
index 919c5f54..64038df4 100644
--- a/plugins/gtkui/callbacks.c
+++ b/plugins/gtkui/callbacks.c
@@ -65,7 +65,7 @@ void
on_open_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
- open_files_handler (NULL, 0);
+ action_open_files_handler_cb (NULL);
}
@@ -73,14 +73,14 @@ void
on_add_files_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
- add_files_handler (NULL, 0);
+ action_add_files_handler_cb (NULL);
}
void
on_add_folders_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
- add_folders_handler (NULL, 0);
+ action_add_folders_handler_cb (NULL);
}
@@ -95,7 +95,7 @@ void
on_quit_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
- action_quit_handler (NULL, 0);
+ action_quit_handler_cb (NULL);
}
@@ -104,7 +104,7 @@ void
on_select_all1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
- action_select_all_handler (NULL, 0);
+ action_select_all_handler_cb (NULL);
}
@@ -549,60 +549,10 @@ on_find_activate (GtkMenuItem *menuitem,
}
void
-on_info_window_delete (GtkWidget *widget, GtkTextDirection previous_direction, GtkWidget **pwindow) {
- *pwindow = NULL;
- gtk_widget_hide (widget);
- gtk_widget_destroy (widget);
-}
-
-static void
-show_info_window (const char *fname, const char *title, GtkWidget **pwindow) {
- if (*pwindow) {
- return;
- }
- GtkWidget *widget = *pwindow = create_helpwindow ();
- g_object_set_data (G_OBJECT (widget), "pointer", pwindow);
- g_signal_connect (widget, "delete_event", G_CALLBACK (on_info_window_delete), pwindow);
- gtk_window_set_title (GTK_WINDOW (widget), title);
- gtk_window_set_transient_for (GTK_WINDOW (widget), GTK_WINDOW (mainwin));
- GtkWidget *txt = lookup_widget (widget, "helptext");
- GtkTextBuffer *buffer = gtk_text_buffer_new (NULL);
-
- FILE *fp = fopen (fname, "rb");
- if (fp) {
- fseek (fp, 0, SEEK_END);
- size_t s = ftell (fp);
- rewind (fp);
- char buf[s+1];
- if (fread (buf, 1, s, fp) != s) {
- fprintf (stderr, "error reading help file contents\n");
- const char *error = _("Failed while reading help file");
- gtk_text_buffer_set_text (buffer, error, strlen (error));
- }
- else {
- buf[s] = 0;
- gtk_text_buffer_set_text (buffer, buf, s);
- }
- fclose (fp);
- }
- else {
- const char *error = _("Failed to load help file");
- gtk_text_buffer_set_text (buffer, error, strlen (error));
- }
- gtk_text_view_set_buffer (GTK_TEXT_VIEW (txt), buffer);
- g_object_unref (buffer);
- gtk_widget_show (widget);
-}
-
-static GtkWidget *helpwindow;
-
-void
on_help1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
- char fname[PATH_MAX];
- snprintf (fname, sizeof (fname), "%s/%s", deadbeef->get_doc_dir (), _("help.txt"));
- show_info_window (fname, _("Help"), &helpwindow);
+ action_show_help_handler_cb (NULL);
}
static GtkWidget *aboutwindow;
@@ -615,7 +565,7 @@ on_about1_activate (GtkMenuItem *menuitem,
snprintf (s, sizeof (s), _("About DeaDBeeF %s"), VERSION);
char fname[PATH_MAX];
snprintf (fname, sizeof (fname), "%s/%s", deadbeef->get_doc_dir (), "about.txt");
- show_info_window (fname, s, &aboutwindow);
+ gtkui_show_info_window (fname, s, &aboutwindow);
}
static GtkWidget *changelogwindow;
@@ -628,7 +578,7 @@ on_changelog1_activate (GtkMenuItem *menuitem,
snprintf (s, sizeof (s), _("DeaDBeeF %s ChangeLog"), VERSION);
char fname[PATH_MAX];
snprintf (fname, sizeof (fname), "%s/%s", deadbeef->get_doc_dir (), "ChangeLog");
- show_info_window (fname, s, &changelogwindow);
+ gtkui_show_info_window (fname, s, &changelogwindow);
}
static GtkWidget *gplwindow;
@@ -639,7 +589,7 @@ on_gpl1_activate (GtkMenuItem *menuitem,
{
char fname[PATH_MAX];
snprintf (fname, sizeof (fname), "%s/%s", deadbeef->get_doc_dir (), "COPYING.GPLv2");
- show_info_window (fname, "GNU GENERAL PUBLIC LICENSE Version 2", &gplwindow);
+ gtkui_show_info_window (fname, "GNU GENERAL PUBLIC LICENSE Version 2", &gplwindow);
}
static GtkWidget *lgplwindow;
@@ -650,7 +600,7 @@ on_lgpl1_activate (GtkMenuItem *menuitem,
{
char fname[PATH_MAX];
snprintf (fname, sizeof (fname), "%s/%s", deadbeef->get_doc_dir (), "COPYING.LGPLv2.1");
- show_info_window (fname, "GNU LESSER GENERAL PUBLIC LICENSE Version 2.1", &lgplwindow);
+ gtkui_show_info_window (fname, "GNU LESSER GENERAL PUBLIC LICENSE Version 2.1", &lgplwindow);
}
gboolean
@@ -842,7 +792,7 @@ void
on_deselect_all1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
- action_deselect_all_handler (NULL, 0);
+ action_deselect_all_handler_cb (NULL);
}
@@ -872,11 +822,7 @@ void
on_new_playlist1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
- int pl = gtkui_add_new_playlist ();
- if (pl != -1) {
- deadbeef->plt_set_curr_idx (pl);
- deadbeef->conf_set_int ("playlist.current", pl);
- }
+ action_new_playlist_handler_cb (NULL);
}
@@ -989,7 +935,7 @@ on_translators1_activate (GtkMenuItem *menuitem,
snprintf (s, sizeof (s), _("DeaDBeeF Translators"));
char fname[PATH_MAX];
snprintf (fname, sizeof (fname), "%s/%s", deadbeef->get_doc_dir (), "translators.txt");
- show_info_window (fname, s, &translatorswindow);
+ gtkui_show_info_window (fname, s, &translatorswindow);
}
diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c
index 3e79274a..762b1371 100644
--- a/plugins/gtkui/gtkui.c
+++ b/plugins/gtkui/gtkui.c
@@ -794,27 +794,7 @@ void
on_add_location_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
- GtkWidget *dlg = create_addlocationdlg ();
- gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_OK);
- int res = gtk_dialog_run (GTK_DIALOG (dlg));
- if (res == GTK_RESPONSE_OK) {
- GtkEntry *entry = GTK_ENTRY (lookup_widget (dlg, "addlocation_entry"));
- if (entry) {
- const char *text = gtk_entry_get_text (entry);
- if (text) {
- ddb_playlist_t *plt = deadbeef->plt_get_curr ();
- if (!deadbeef->pl_add_files_begin (plt)) {
- deadbeef->plt_add_file (plt, text, NULL, NULL);
- deadbeef->pl_add_files_end ();
- playlist_refresh ();
- }
- if (plt) {
- deadbeef->plt_unref (plt);
- }
- }
- }
- }
- gtk_widget_destroy (dlg);
+ action_add_location_handler_cb (NULL);
}
static gboolean
@@ -1102,6 +1082,7 @@ gtkui_thread (void *ctx) {
deadbeef->conf_set_str ("hotkey.key6", "\"Escape\" 0 0 deselect_all");
deadbeef->conf_set_str ("hotkey.key7", "\"Ctrl m\" 0 0 toggle_stop_after_current");
deadbeef->conf_set_str ("hotkey.key8", "\"Ctrl j\" 0 0 jump_to_current_track");
+ deadbeef->conf_set_str ("hotkey.key9", "\"F1\" 0 0 help");
}
// construct mainwindow widgets
@@ -1299,6 +1280,53 @@ gtkui_playlist_set_curr (int playlist) {
deadbeef->conf_set_int ("playlist.current", playlist);
}
+void
+on_gtkui_info_window_delete (GtkWidget *widget, GtkTextDirection previous_direction, GtkWidget **pwindow) {
+ *pwindow = NULL;
+ gtk_widget_hide (widget);
+ gtk_widget_destroy (widget);
+}
+
+void
+gtkui_show_info_window (const char *fname, const char *title, GtkWidget **pwindow) {
+ if (*pwindow) {
+ return;
+ }
+ GtkWidget *widget = *pwindow = create_helpwindow ();
+ g_object_set_data (G_OBJECT (widget), "pointer", pwindow);
+ g_signal_connect (widget, "delete_event", G_CALLBACK (on_gtkui_info_window_delete), pwindow);
+ gtk_window_set_title (GTK_WINDOW (widget), title);
+ gtk_window_set_transient_for (GTK_WINDOW (widget), GTK_WINDOW (mainwin));
+ GtkWidget *txt = lookup_widget (widget, "helptext");
+ GtkTextBuffer *buffer = gtk_text_buffer_new (NULL);
+
+ FILE *fp = fopen (fname, "rb");
+ if (fp) {
+ fseek (fp, 0, SEEK_END);
+ size_t s = ftell (fp);
+ rewind (fp);
+ char buf[s+1];
+ if (fread (buf, 1, s, fp) != s) {
+ fprintf (stderr, "error reading help file contents\n");
+ const char *error = _("Failed while reading help file");
+ gtk_text_buffer_set_text (buffer, error, strlen (error));
+ }
+ else {
+ buf[s] = 0;
+ gtk_text_buffer_set_text (buffer, buf, s);
+ }
+ fclose (fp);
+ }
+ else {
+ const char *error = _("Failed to load help file");
+ gtk_text_buffer_set_text (buffer, error, strlen (error));
+ }
+ gtk_text_view_set_buffer (GTK_TEXT_VIEW (txt), buffer);
+ g_object_unref (buffer);
+ gtk_widget_show (widget);
+}
+
+
static int
gtkui_start (void) {
fprintf (stderr, "gtkui plugin compiled for gtk version: %d.%d.%d\n", GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
@@ -1447,10 +1475,10 @@ static DB_plugin_action_t action_delete_from_disk = {
};
static DB_plugin_action_t action_add_location = {
- .title = "File/[stub] Add Location",
+ .title = "File/Add Location",
.name = "add_location",
.flags = DB_ACTION_COMMON,
- .callback = NULL,
+ .callback = action_add_location_handler,
.next = &action_delete_from_disk
};
@@ -1458,7 +1486,7 @@ static DB_plugin_action_t action_add_folders = {
.title = "File/Add Folder(s)",
.name = "add_folders",
.flags = DB_ACTION_COMMON,
- .callback = add_folders_handler,
+ .callback = action_add_folders_handler,
.next = &action_add_location
};
@@ -1466,7 +1494,7 @@ static DB_plugin_action_t action_add_files = {
.title = "File/Add File(s)",
.name = "add_files",
.flags = DB_ACTION_COMMON,
- .callback = add_files_handler,
+ .callback = action_add_files_handler,
.next = &action_add_folders
};
@@ -1474,7 +1502,7 @@ static DB_plugin_action_t action_open_files = {
.title = "File/Open File(s)",
.name = "open_files",
.flags = DB_ACTION_COMMON,
- .callback = open_files_handler,
+ .callback = action_open_files_handler,
.next = &action_add_files
};
@@ -1488,10 +1516,10 @@ static DB_plugin_action_t action_track_properties = {
};
static DB_plugin_action_t action_show_help = {
- .title = "Help/[stub] Show help page",
+ .title = "Help/Show help page",
.name = "help",
.flags = DB_ACTION_COMMON,
- .callback = NULL,
+ .callback = action_show_help_handler,
.next = &action_track_properties
};
@@ -1567,12 +1595,21 @@ static DB_plugin_action_t action_load_playlist = {
.next = &action_save_playlist
};
+static DB_plugin_action_t action_remove_current_playlist = {
+ .title = "File/Remove current playlist",
+ .name = "remove_current_playlist",
+ .flags = DB_ACTION_COMMON,
+ .callback = action_remove_current_playlist_handler,
+ .next = &action_load_playlist
+};
+
+
static DB_plugin_action_t action_new_playlist = {
- .title = "File/[stub] New Playlist",
+ .title = "File/New Playlist",
.name = "new_playlist",
.flags = DB_ACTION_COMMON,
- .callback = NULL,
- .next = &action_load_playlist
+ .callback = action_new_playlist_handler,
+ .next = &action_remove_current_playlist
};
static DB_plugin_action_t action_toggle_eq = {
@@ -1600,26 +1637,26 @@ static DB_plugin_action_t action_show_eq = {
};
static DB_plugin_action_t action_toggle_mainwin = {
- .title = "[stub] Show\\/Hide Player Window",
+ .title = "Show\\/Hide Player Window",
.name = "toggle_player_window",
.flags = DB_ACTION_COMMON,
- .callback = NULL,
+ .callback = action_toggle_mainwin_handler,
.next = &action_show_eq
};
static DB_plugin_action_t action_hide_mainwin = {
- .title = "[stub] Hide Player Window",
+ .title = "Hide Player Window",
.name = "hide_player_window",
.flags = DB_ACTION_COMMON,
- .callback = NULL,
+ .callback = action_hide_mainwin_handler,
.next = &action_toggle_mainwin
};
static DB_plugin_action_t action_show_mainwin = {
- .title = "[stub] Show Player Window",
+ .title = "Show Player Window",
.name = "show_player_window",
.flags = DB_ACTION_COMMON,
- .callback = NULL,
+ .callback = action_show_mainwin_handler,
.next = &action_hide_mainwin
};
diff --git a/plugins/gtkui/gtkui.h b/plugins/gtkui/gtkui.h
index 56f57e8d..9b5ac899 100644
--- a/plugins/gtkui/gtkui.h
+++ b/plugins/gtkui/gtkui.h
@@ -152,4 +152,13 @@ redraw_queued_tracks_cb (gpointer plt);
extern DB_playItem_t * (*gtkui_original_plt_load) (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname, int *pabort, int (*cb)(DB_playItem_t *it, void *data), void *user_data);
+void
+mainwin_toggle_visible (void);
+
+void
+gtkui_show_info_window (const char *fname, const char *title, GtkWidget **pwindow);
+
+void
+on_gtkui_info_window_delete (GtkWidget *widget, GtkTextDirection previous_direction, GtkWidget **pwindow);
+
#endif
diff --git a/plugins/gtkui/prefwin.c b/plugins/gtkui/prefwin.c
index ca14c4ea..a344523e 100644
--- a/plugins/gtkui/prefwin.c
+++ b/plugins/gtkui/prefwin.c
@@ -971,9 +971,6 @@ on_auto_name_playlist_from_folder_toggled
deadbeef->conf_set_int ("gtkui.name_playlist_from_folder", active);
}
-void
-on_info_window_delete (GtkWidget *widget, GtkTextDirection previous_direction, GtkWidget **pwindow);
-
static void
show_copyright_window (const char *text, const char *title, GtkWidget **pwindow) {
if (*pwindow) {
@@ -981,7 +978,7 @@ show_copyright_window (const char *text, const char *title, GtkWidget **pwindow)
}
GtkWidget *widget = *pwindow = create_helpwindow ();
g_object_set_data (G_OBJECT (widget), "pointer", pwindow);
- g_signal_connect (widget, "delete_event", G_CALLBACK (on_info_window_delete), pwindow);
+ g_signal_connect (widget, "delete_event", G_CALLBACK (on_gtkui_info_window_delete), pwindow);
gtk_window_set_title (GTK_WINDOW (widget), title);
gtk_window_set_transient_for (GTK_WINDOW (widget), GTK_WINDOW (prefwin));
GtkWidget *txt = lookup_widget (widget, "helptext");