From 6b02d9c5cbddff869d5d7c7ab18547bf7ea7fc30 Mon Sep 17 00:00:00 2001 From: waker Date: Sat, 17 Aug 2013 21:59:14 +0200 Subject: gtkui: added GUI configuration for content type mapping --- deadbeef.h | 2 +- plugins/gtkui/Makefile.am | 1 + plugins/gtkui/callbacks.h | 20 +++ plugins/gtkui/ctmapping.c | 298 +++++++++++++++++++++++++++++++++ plugins/gtkui/ctmapping.h | 26 +++ plugins/gtkui/deadbeef.glade | 383 +++++++++++++++++++++++++++++++++++++++---- plugins/gtkui/interface.c | 155 ++++++++++++++++- plugins/gtkui/interface.h | 1 + plugins/gtkui/prefwin.c | 13 -- po/POTFILES.in | 1 + 10 files changed, 851 insertions(+), 49 deletions(-) create mode 100644 plugins/gtkui/ctmapping.c create mode 100644 plugins/gtkui/ctmapping.h diff --git a/deadbeef.h b/deadbeef.h index 36078014..8a98ff4e 100644 --- a/deadbeef.h +++ b/deadbeef.h @@ -97,7 +97,7 @@ extern "C" { // default values for some common config variables should go here // network.ctmapping : content-type to plugin mapping -#define DDB_DEFAULT_CTMAPPING "{audio/mpeg, stdmpg, ffmpeg}, {audio/x-mpeg, stdmpg, ffmpeg}, {application/ogg, stdogg, ffmpeg}, {audio/ogg, stdogg, ffmpeg}, {audio/aac, aac, ffmpeg}, {audio/aacp, aac, ffmpeg}, {audio/wma, wma, ffmpeg}" +#define DDB_DEFAULT_CTMAPPING "audio/mpeg {stdmpg ffmpeg} audio/x-mpeg {stdmpg ffmpeg} application/ogg {stdogg ffmpeg} audio/ogg {stdogg ffmpeg} audio/aac {aac ffmpeg} audio/aacp {aac ffmpeg} audio/wma {wma ffmpeg}" //////////////////////////// // playlist structures diff --git a/plugins/gtkui/Makefile.am b/plugins/gtkui/Makefile.am index 7979bec9..d6de80e8 100644 --- a/plugins/gtkui/Makefile.am +++ b/plugins/gtkui/Makefile.am @@ -42,6 +42,7 @@ GTKUI_SOURCES = gtkui.c gtkui.h\ hotkeys.c hotkeys.h\ actionhandlers.c actionhandlers.h\ pltmenu.c\ + ctmapping.c ctmapping.h\ $(SM_SOURCES) sdkdir = $(pkgincludedir) diff --git a/plugins/gtkui/callbacks.h b/plugins/gtkui/callbacks.h index aa0f51e3..c5b2ff6a 100644 --- a/plugins/gtkui/callbacks.h +++ b/plugins/gtkui/callbacks.h @@ -1262,3 +1262,23 @@ on_menu_bar1_activate (GtkMenuItem *menuitem, void on_edit_content_type_mapping_clicked (GtkButton *button, gpointer user_data); + +void +on_ctmapping_add_clicked (GtkButton *button, + gpointer user_data); + +void +on_ctmapping_remove_clicked (GtkButton *button, + gpointer user_data); + +void +on_ctmapping_edit_clicked (GtkButton *button, + gpointer user_data); + +void +on_button3_clicked (GtkButton *button, + gpointer user_data); + +void +on_ctmapping_reset_clicked (GtkButton *button, + gpointer user_data); diff --git a/plugins/gtkui/ctmapping.c b/plugins/gtkui/ctmapping.c new file mode 100644 index 00000000..df149dbb --- /dev/null +++ b/plugins/gtkui/ctmapping.c @@ -0,0 +1,298 @@ +/* + DeaDBeeF -- the music player + Copyright (C) 2009-2012 Alexey Yakovenko and other contributors + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source distribution. +*/ +#ifdef HAVE_CONFIG_H +# include +#endif +#include +#include +#include +#include +#include +#include "../../gettext.h" +#include "gtkui.h" +#include "support.h" +#include "interface.h" +#include "callbacks.h" +#include "parser.h" +#include "ctmapping.h" + +static GtkWidget *ctmapping_dlg; + +static void +ctmapping_fill (GtkWidget *dlg) { + GtkTreeView *tree = GTK_TREE_VIEW (lookup_widget (dlg, "ctmappinglist")); + GtkTreeModel *mdl = gtk_tree_view_get_model (tree); + gtk_list_store_clear (GTK_LIST_STORE (mdl)); + + char mapstr[2048]; + deadbeef->conf_get_str ("network.ctmapping", DDB_DEFAULT_CTMAPPING, mapstr, sizeof (mapstr)); + + const char *p = mapstr; + char t[MAX_TOKEN]; + char ct[MAX_TOKEN]; + char plugins[MAX_TOKEN*5]; + for (;;) { + p = gettoken (p, t); + + if (!p) { + break; + } + strcpy (ct, t); + + p = gettoken (p, t); + if (!p || strcmp (t, "{")) { + break; + } + + plugins[0] = 0; + for (;;) { + p = gettoken (p, t); + if (!p || !strcmp (t, "}")) { + break; + } + + if (plugins[0] != 0) { + strcat (plugins, " "); + } + strcat (plugins, t); + } + + GtkTreeIter it; + gtk_list_store_append (GTK_LIST_STORE (mdl), &it); + gtk_list_store_set (GTK_LIST_STORE (mdl), &it, 0, ct, 1, plugins, -1); + } +} + +static void +ctmapping_apply (void) { + GtkTreeView *tree = GTK_TREE_VIEW (lookup_widget (ctmapping_dlg, "ctmappinglist")); + GtkTreeModel *model = GTK_TREE_MODEL (gtk_tree_view_get_model (tree)); + + char mapstr[2048] = ""; + int s = sizeof (mapstr); + char *p = mapstr; + + GtkTreeIter iter; + gboolean res = gtk_tree_model_get_iter_first (model, &iter); + while (res) { + GValue key = {0,}; + gtk_tree_model_get_value (model, &iter, 0, &key); + const char *skey = g_value_get_string (&key); + GValue val = {0,}; + gtk_tree_model_get_value (model, &iter, 1, &val); + const char *sval = g_value_get_string (&val); + + int l = snprintf (p, s, "%s {%s} ", skey, sval); + p += l; + s -= l; + + res = gtk_tree_model_iter_next (model, &iter); + if (s <= 0) { + break; + } + } + deadbeef->conf_set_str ("network.ctmapping", mapstr); +} + +void +on_edit_content_type_mapping_clicked (GtkButton *button, + gpointer user_data) +{ + GtkWidget *dlg = create_ctmappingdlg (); + gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (mainwin)); + ctmapping_dlg = dlg; + + GtkTreeView *tree = GTK_TREE_VIEW (lookup_widget (dlg, "ctmappinglist")); + GtkCellRenderer *rend_text = gtk_cell_renderer_text_new (); + GtkListStore *store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); + GtkTreeViewColumn *col = gtk_tree_view_column_new_with_attributes (_("Content-Type"), rend_text, "text", 0, NULL); + gtk_tree_view_append_column (tree, col); + col = gtk_tree_view_column_new_with_attributes (_("Plugins"), rend_text, "text", 1, NULL); + gtk_tree_view_append_column (tree, col); + + + gtk_tree_view_set_model (tree, GTK_TREE_MODEL (store)); + + ctmapping_fill (dlg); + + for (;;) { + int response = gtk_dialog_run (GTK_DIALOG (dlg)); + if (response == GTK_RESPONSE_OK) { + ctmapping_apply (); + } + else if (response == GTK_RESPONSE_APPLY) { + ctmapping_apply (); + continue; + } + break; + } + gtk_widget_destroy (dlg); + ctmapping_dlg = NULL; +} + +static int +validate_ct (const char *s) { + if (*s == 0) { + return 1; + } + while (*s) { + if (*s != '/' && !isalnum (*s) && *s != '-') { + return 1; + } + s++; + } + return 0; +} + +static int +validate_plugid (const char *s) { + if (*s == 0) { + return 1; + } + while (*s) { + if (!isalnum (*s) && *s != ' ') { + return 1; + } + s++; + } + return 0; +} + +void +on_ctmapping_add_clicked (GtkButton *button, + gpointer user_data) +{ + GtkWidget *dlg = create_ctmappingeditdlg (); + for (;;) { + int response = gtk_dialog_run (GTK_DIALOG (dlg)); + if (response == GTK_RESPONSE_OK) { + GtkTreeView *treeview = GTK_TREE_VIEW (lookup_widget (ctmapping_dlg, "ctmappinglist")); + GtkWidget *ct = lookup_widget (dlg, "content_type"); + GtkWidget *plugins = lookup_widget (dlg, "plugins"); + + const char *ct_text = gtk_entry_get_text (GTK_ENTRY (ct)); + const char *plugins_text = gtk_entry_get_text (GTK_ENTRY (plugins)); + // validate for non-empty without spaces, only [a-z0-9], - and / allowed in ct, + // only [a-z0-9] and spaces allowed in plugins + if (validate_ct (ct_text) || validate_plugid (plugins_text)) { + GtkWidget *dlg_err = gtk_message_dialog_new (GTK_WINDOW (dlg), GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, _("Invalid value(s).")); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dlg_err), _("Content-type and Plugins fields must be non-empty, and comply with the rules.\nExample content-type: 'audio/mpeg'.\nExample plugin ids: 'stdmpg ffmpeg'.\nSpaces must be used as separators in plugin ids list.\nContent type should be only letters, numbers and '-' sign.\nPlugin id can contain only letters and numbers.")); + gtk_window_set_transient_for (GTK_WINDOW (dlg_err), GTK_WINDOW (dlg)); + gtk_window_set_title (GTK_WINDOW (dlg_err), _("Error")); + gtk_dialog_run (GTK_DIALOG (dlg_err)); + gtk_widget_destroy (dlg_err); + continue; + } + + GtkTreeModel *store = gtk_tree_view_get_model (treeview); + GtkTreeIter iter; + gtk_list_store_append (GTK_LIST_STORE (store), &iter); + gtk_list_store_set (GTK_LIST_STORE (store), &iter, 0, gtk_entry_get_text (GTK_ENTRY (ct)), 1, gtk_entry_get_text (GTK_ENTRY (plugins)), -1); + } + break; + } + gtk_widget_destroy (dlg); +} + + +void +on_ctmapping_remove_clicked (GtkButton *button, + gpointer user_data) +{ + GtkTreeView *treeview = GTK_TREE_VIEW (lookup_widget (ctmapping_dlg, "ctmappinglist")); + GtkTreePath *path; + GtkTreeViewColumn *col; + gtk_tree_view_get_cursor (treeview, &path, &col); + if (!path || !col) { + GtkWidget *dlg = gtk_message_dialog_new (GTK_WINDOW (ctmapping_dlg), GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, _("Nothing is selected.")); + gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (ctmapping_dlg)); + gtk_window_set_title (GTK_WINDOW (dlg), _("Error")); + gtk_dialog_run (GTK_DIALOG (dlg)); + gtk_widget_destroy (dlg); + return; + } + +// GtkWidget *dlg = gtk_message_dialog_new (GTK_WINDOW (ctmapping_dlg), GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_YES_NO, _("Really delete the selected content type?")); +// gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (ctmapping_dlg)); +// gtk_window_set_title (GTK_WINDOW (dlg), _("Warning")); +// gint response = gtk_dialog_run (GTK_DIALOG (dlg)); +// +// if (response == GTK_RESPONSE_YES) { + GtkTreeModel *store = gtk_tree_view_get_model (treeview); + GtkTreeIter iter; + gtk_tree_model_get_iter (store, &iter, path); + gtk_list_store_remove (GTK_LIST_STORE (store), &iter); +// } +// gtk_widget_destroy (dlg); +} + + +void +on_ctmapping_edit_clicked (GtkButton *button, + gpointer user_data) +{ + GtkTreeView *treeview = GTK_TREE_VIEW (lookup_widget (ctmapping_dlg, "ctmappinglist")); + GtkTreePath *path; + GtkTreeViewColumn *col; + gtk_tree_view_get_cursor (treeview, &path, &col); + if (!path || !col) { + GtkWidget *dlg = gtk_message_dialog_new (GTK_WINDOW (ctmapping_dlg), GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, _("Nothing is selected.")); + gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (ctmapping_dlg)); + gtk_window_set_title (GTK_WINDOW (dlg), _("Error")); + gtk_dialog_run (GTK_DIALOG (dlg)); + gtk_widget_destroy (dlg); + return; + } + + GtkWidget *dlg = create_ctmappingeditdlg (); + + GtkTreeModel *store = gtk_tree_view_get_model (treeview); + GtkTreeIter iter; + gtk_tree_model_get_iter (store, &iter, path); + GValue value = {0,}; + gtk_tree_model_get_value (store, &iter, 0, &value); + const char *svalue = g_value_get_string (&value); + GtkWidget *ct = lookup_widget (dlg, "content_type"); + gtk_entry_set_text (GTK_ENTRY (ct), svalue); + GValue value2 = {0,}; + gtk_tree_model_get_value (store, &iter, 1, &value2); + svalue = g_value_get_string (&value2); + GtkWidget *plugins = lookup_widget (dlg, "plugins"); + gtk_entry_set_text (GTK_ENTRY (plugins), svalue); + + int response = gtk_dialog_run (GTK_DIALOG (dlg)); + if (response == GTK_RESPONSE_OK) { + gtk_list_store_set (GTK_LIST_STORE (store), &iter, 0, gtk_entry_get_text (GTK_ENTRY (ct)), 1, gtk_entry_get_text (GTK_ENTRY (plugins)), -1); + } + gtk_widget_destroy (dlg); +} + + +void +on_ctmapping_reset_clicked (GtkButton *button, + gpointer user_data) +{ + deadbeef->conf_set_str ("network.ctmapping", DDB_DEFAULT_CTMAPPING); + ctmapping_fill (ctmapping_dlg); +} + diff --git a/plugins/gtkui/ctmapping.h b/plugins/gtkui/ctmapping.h new file mode 100644 index 00000000..3412e003 --- /dev/null +++ b/plugins/gtkui/ctmapping.h @@ -0,0 +1,26 @@ +/* + DeaDBeeF -- the music player + Copyright (C) 2009-2012 Alexey Yakovenko and other contributors + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source distribution. +*/ +#ifndef __CTMAPPING_H +#define __CTMAPPING_H + +#endif diff --git a/plugins/gtkui/deadbeef.glade b/plugins/gtkui/deadbeef.glade index 704f6050..05b5b2e8 100644 --- a/plugins/gtkui/deadbeef.glade +++ b/plugins/gtkui/deadbeef.glade @@ -7714,6 +7714,8 @@ Descending + 492 + 328 True Content-Type Mapping GTK_WINDOW_TOPLEVEL @@ -7789,33 +7791,214 @@ Descending - + 12 True False 8 - + True True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT + False + False + True + GTK_JUSTIFY_LEFT + GTK_WRAP_WORD + False + 8 + 8 + 0 + 8 + 8 + 0 + This table defines the binding between network stream content types and DeaDBeeF decoder plugins. For example, mp3 files can have content type "audio/x-mpeg", and need to be decoded by DeaDBeeF's own "stdmpg" plugin, or "ffmpeg" plugin. + + + 0 + False + True + + + + + + True + False + 8 - + True True - True - False - False - True - False - False - False + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + False + True + False + False + False + + + + 0 + True + True + + + + + + True + False + 8 + + + + True + True + gtk-add + True + GTK_RELIEF_NORMAL + True + + + + 0 + False + False + + + + + + True + True + gtk-remove + True + GTK_RELIEF_NORMAL + True + + + + 0 + False + False + + + + + + True + True + gtk-edit + True + GTK_RELIEF_NORMAL + True + + + + 0 + False + False + + + + + + True + True + GTK_RELIEF_NORMAL + True + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-revert-to-saved + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Reset to defaults + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + + + + 0 + False + False + + + + + 0 + False + True + @@ -7824,21 +8007,111 @@ Descending True + + + 0 + True + True + + + + + + + + 300 + 140 + True + Edit Content-Type Mapping + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + True + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + False + True + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + -6 + + - + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + True + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 12 + True + False + 8 + + + True False 8 - + True - True - gtk-add - True - GTK_RELIEF_NORMAL - True + Content-Type: + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -7848,13 +8121,54 @@ Descending - + True True - gtk-remove - True - GTK_RELIEF_NORMAL - True + True + True + 0 + + True + + False + + + 0 + True + True + + + + + 0 + False + True + + + + + + True + False + 8 + + + + True + Plugins: + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -7864,18 +8178,21 @@ Descending - + True True - gtk-edit - True - GTK_RELIEF_NORMAL - True + True + True + 0 + + True + + False 0 - False - False + True + True diff --git a/plugins/gtkui/interface.c b/plugins/gtkui/interface.c index 0b1cb8c0..2ebef8ea 100644 --- a/plugins/gtkui/interface.c +++ b/plugins/gtkui/interface.c @@ -3997,6 +3997,8 @@ create_ctmappingdlg (void) { GtkWidget *ctmappingdlg; GtkWidget *dialog_vbox12; + GtkWidget *vbox41; + GtkWidget *textview1; GtkWidget *hbox110; GtkWidget *scrolledwindow11; GtkWidget *ctmappinglist; @@ -4004,12 +4006,18 @@ create_ctmappingdlg (void) GtkWidget *ctmapping_add; GtkWidget *ctmapping_remove; GtkWidget *ctmapping_edit; + GtkWidget *ctmapping_reset; + GtkWidget *alignment25; + GtkWidget *hbox113; + GtkWidget *image628; + GtkWidget *label139; GtkWidget *dialog_action_area11; GtkWidget *ctmapping_apply; GtkWidget *ctmapping_cancel; GtkWidget *ctmapping_ok; ctmappingdlg = gtk_dialog_new (); + gtk_widget_set_size_request (ctmappingdlg, 492, 328); gtk_window_set_title (GTK_WINDOW (ctmappingdlg), _("Content-Type Mapping")); gtk_window_set_position (GTK_WINDOW (ctmappingdlg), GTK_WIN_POS_MOUSE); gtk_window_set_modal (GTK_WINDOW (ctmappingdlg), TRUE); @@ -4018,10 +4026,26 @@ create_ctmappingdlg (void) dialog_vbox12 = gtk_dialog_get_content_area (GTK_DIALOG (ctmappingdlg)); gtk_widget_show (dialog_vbox12); + vbox41 = gtk_vbox_new (FALSE, 8); + gtk_widget_show (vbox41); + gtk_box_pack_start (GTK_BOX (dialog_vbox12), vbox41, TRUE, TRUE, 0); + gtk_container_set_border_width (GTK_CONTAINER (vbox41), 12); + + textview1 = gtk_text_view_new (); + gtk_widget_show (textview1); + gtk_box_pack_start (GTK_BOX (vbox41), textview1, FALSE, TRUE, 0); + gtk_text_view_set_editable (GTK_TEXT_VIEW (textview1), FALSE); + gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (textview1), GTK_WRAP_WORD); + gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (textview1), FALSE); + gtk_text_view_set_pixels_above_lines (GTK_TEXT_VIEW (textview1), 8); + gtk_text_view_set_pixels_below_lines (GTK_TEXT_VIEW (textview1), 8); + gtk_text_view_set_left_margin (GTK_TEXT_VIEW (textview1), 8); + gtk_text_view_set_right_margin (GTK_TEXT_VIEW (textview1), 8); + gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview1)), _("This table defines the binding between network stream content types and DeaDBeeF decoder plugins. For example, mp3 files can have content type \"audio/x-mpeg\", and need to be decoded by DeaDBeeF's own \"stdmpg\" plugin, or \"ffmpeg\" plugin."), -1); + hbox110 = gtk_hbox_new (FALSE, 8); gtk_widget_show (hbox110); - gtk_box_pack_start (GTK_BOX (dialog_vbox12), hbox110, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (hbox110), 12); + gtk_box_pack_start (GTK_BOX (vbox41), hbox110, TRUE, TRUE, 0); scrolledwindow11 = gtk_scrolled_window_new (NULL, NULL); gtk_widget_show (scrolledwindow11); @@ -4049,6 +4073,26 @@ create_ctmappingdlg (void) gtk_widget_show (ctmapping_edit); gtk_box_pack_start (GTK_BOX (vbox39), ctmapping_edit, FALSE, FALSE, 0); + ctmapping_reset = gtk_button_new (); + gtk_widget_show (ctmapping_reset); + gtk_box_pack_start (GTK_BOX (vbox39), ctmapping_reset, FALSE, FALSE, 0); + + alignment25 = gtk_alignment_new (0.5, 0.5, 0, 0); + gtk_widget_show (alignment25); + gtk_container_add (GTK_CONTAINER (ctmapping_reset), alignment25); + + hbox113 = gtk_hbox_new (FALSE, 2); + gtk_widget_show (hbox113); + gtk_container_add (GTK_CONTAINER (alignment25), hbox113); + + image628 = gtk_image_new_from_stock ("gtk-revert-to-saved", GTK_ICON_SIZE_BUTTON); + gtk_widget_show (image628); + gtk_box_pack_start (GTK_BOX (hbox113), image628, FALSE, FALSE, 0); + + label139 = gtk_label_new_with_mnemonic (_("Reset to defaults")); + gtk_widget_show (label139); + gtk_box_pack_start (GTK_BOX (hbox113), label139, FALSE, FALSE, 0); + dialog_action_area11 = gtk_dialog_get_action_area (GTK_DIALOG (ctmappingdlg)); gtk_widget_show (dialog_action_area11); gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area11), GTK_BUTTONBOX_END); @@ -4068,9 +4112,24 @@ create_ctmappingdlg (void) gtk_dialog_add_action_widget (GTK_DIALOG (ctmappingdlg), ctmapping_ok, GTK_RESPONSE_OK); gtk_widget_set_can_default(ctmapping_ok, TRUE); + g_signal_connect ((gpointer) ctmapping_add, "clicked", + G_CALLBACK (on_ctmapping_add_clicked), + NULL); + g_signal_connect ((gpointer) ctmapping_remove, "clicked", + G_CALLBACK (on_ctmapping_remove_clicked), + NULL); + g_signal_connect ((gpointer) ctmapping_edit, "clicked", + G_CALLBACK (on_ctmapping_edit_clicked), + NULL); + g_signal_connect ((gpointer) ctmapping_reset, "clicked", + G_CALLBACK (on_ctmapping_reset_clicked), + NULL); + /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (ctmappingdlg, ctmappingdlg, "ctmappingdlg"); GLADE_HOOKUP_OBJECT_NO_REF (ctmappingdlg, dialog_vbox12, "dialog_vbox12"); + GLADE_HOOKUP_OBJECT (ctmappingdlg, vbox41, "vbox41"); + GLADE_HOOKUP_OBJECT (ctmappingdlg, textview1, "textview1"); GLADE_HOOKUP_OBJECT (ctmappingdlg, hbox110, "hbox110"); GLADE_HOOKUP_OBJECT (ctmappingdlg, scrolledwindow11, "scrolledwindow11"); GLADE_HOOKUP_OBJECT (ctmappingdlg, ctmappinglist, "ctmappinglist"); @@ -4078,6 +4137,11 @@ create_ctmappingdlg (void) GLADE_HOOKUP_OBJECT (ctmappingdlg, ctmapping_add, "ctmapping_add"); GLADE_HOOKUP_OBJECT (ctmappingdlg, ctmapping_remove, "ctmapping_remove"); GLADE_HOOKUP_OBJECT (ctmappingdlg, ctmapping_edit, "ctmapping_edit"); + GLADE_HOOKUP_OBJECT (ctmappingdlg, ctmapping_reset, "ctmapping_reset"); + GLADE_HOOKUP_OBJECT (ctmappingdlg, alignment25, "alignment25"); + GLADE_HOOKUP_OBJECT (ctmappingdlg, hbox113, "hbox113"); + GLADE_HOOKUP_OBJECT (ctmappingdlg, image628, "image628"); + GLADE_HOOKUP_OBJECT (ctmappingdlg, label139, "label139"); GLADE_HOOKUP_OBJECT_NO_REF (ctmappingdlg, dialog_action_area11, "dialog_action_area11"); GLADE_HOOKUP_OBJECT (ctmappingdlg, ctmapping_apply, "ctmapping_apply"); GLADE_HOOKUP_OBJECT (ctmappingdlg, ctmapping_cancel, "ctmapping_cancel"); @@ -4086,3 +4150,90 @@ create_ctmappingdlg (void) return ctmappingdlg; } +GtkWidget* +create_ctmappingeditdlg (void) +{ + GtkWidget *ctmappingeditdlg; + GtkWidget *dialog_vbox13; + GtkWidget *vbox40; + GtkWidget *hbox111; + GtkWidget *label137; + GtkWidget *content_type; + GtkWidget *hbox112; + GtkWidget *label138; + GtkWidget *plugins; + GtkWidget *dialog_action_area12; + GtkWidget *cancelbutton8; + GtkWidget *okbutton8; + + ctmappingeditdlg = gtk_dialog_new (); + gtk_widget_set_size_request (ctmappingeditdlg, 300, 140); + gtk_window_set_title (GTK_WINDOW (ctmappingeditdlg), _("Edit Content-Type Mapping")); + gtk_window_set_modal (GTK_WINDOW (ctmappingeditdlg), TRUE); + gtk_window_set_type_hint (GTK_WINDOW (ctmappingeditdlg), GDK_WINDOW_TYPE_HINT_DIALOG); + + dialog_vbox13 = gtk_dialog_get_content_area (GTK_DIALOG (ctmappingeditdlg)); + gtk_widget_show (dialog_vbox13); + + vbox40 = gtk_vbox_new (FALSE, 8); + gtk_widget_show (vbox40); + gtk_box_pack_start (GTK_BOX (dialog_vbox13), vbox40, TRUE, TRUE, 0); + gtk_container_set_border_width (GTK_CONTAINER (vbox40), 12); + + hbox111 = gtk_hbox_new (FALSE, 8); + gtk_widget_show (hbox111); + gtk_box_pack_start (GTK_BOX (vbox40), hbox111, FALSE, TRUE, 0); + + label137 = gtk_label_new (_("Content-Type:")); + gtk_widget_show (label137); + gtk_box_pack_start (GTK_BOX (hbox111), label137, FALSE, FALSE, 0); + + content_type = gtk_entry_new (); + gtk_widget_show (content_type); + gtk_box_pack_start (GTK_BOX (hbox111), content_type, TRUE, TRUE, 0); + gtk_entry_set_invisible_char (GTK_ENTRY (content_type), 8226); + + hbox112 = gtk_hbox_new (FALSE, 8); + gtk_widget_show (hbox112); + gtk_box_pack_start (GTK_BOX (vbox40), hbox112, FALSE, TRUE, 0); + + label138 = gtk_label_new (_("Plugins:")); + gtk_widget_show (label138); + gtk_box_pack_start (GTK_BOX (hbox112), label138, FALSE, FALSE, 0); + + plugins = gtk_entry_new (); + gtk_widget_show (plugins); + gtk_box_pack_start (GTK_BOX (hbox112), plugins, TRUE, TRUE, 0); + gtk_entry_set_invisible_char (GTK_ENTRY (plugins), 8226); + + dialog_action_area12 = gtk_dialog_get_action_area (GTK_DIALOG (ctmappingeditdlg)); + gtk_widget_show (dialog_action_area12); + gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area12), GTK_BUTTONBOX_END); + + cancelbutton8 = gtk_button_new_from_stock ("gtk-cancel"); + gtk_widget_show (cancelbutton8); + gtk_dialog_add_action_widget (GTK_DIALOG (ctmappingeditdlg), cancelbutton8, GTK_RESPONSE_CANCEL); + gtk_widget_set_can_default(cancelbutton8, TRUE); + + okbutton8 = gtk_button_new_from_stock ("gtk-ok"); + gtk_widget_show (okbutton8); + gtk_dialog_add_action_widget (GTK_DIALOG (ctmappingeditdlg), okbutton8, GTK_RESPONSE_OK); + gtk_widget_set_can_default(okbutton8, TRUE); + + /* Store pointers to all widgets, for use by lookup_widget(). */ + GLADE_HOOKUP_OBJECT_NO_REF (ctmappingeditdlg, ctmappingeditdlg, "ctmappingeditdlg"); + GLADE_HOOKUP_OBJECT_NO_REF (ctmappingeditdlg, dialog_vbox13, "dialog_vbox13"); + GLADE_HOOKUP_OBJECT (ctmappingeditdlg, vbox40, "vbox40"); + GLADE_HOOKUP_OBJECT (ctmappingeditdlg, hbox111, "hbox111"); + GLADE_HOOKUP_OBJECT (ctmappingeditdlg, label137, "label137"); + GLADE_HOOKUP_OBJECT (ctmappingeditdlg, content_type, "content_type"); + GLADE_HOOKUP_OBJECT (ctmappingeditdlg, hbox112, "hbox112"); + GLADE_HOOKUP_OBJECT (ctmappingeditdlg, label138, "label138"); + GLADE_HOOKUP_OBJECT (ctmappingeditdlg, plugins, "plugins"); + GLADE_HOOKUP_OBJECT_NO_REF (ctmappingeditdlg, dialog_action_area12, "dialog_action_area12"); + GLADE_HOOKUP_OBJECT (ctmappingeditdlg, cancelbutton8, "cancelbutton8"); + GLADE_HOOKUP_OBJECT (ctmappingeditdlg, okbutton8, "okbutton8"); + + return ctmappingeditdlg; +} + diff --git a/plugins/gtkui/interface.h b/plugins/gtkui/interface.h index 91891301..faaadcab 100644 --- a/plugins/gtkui/interface.h +++ b/plugins/gtkui/interface.h @@ -17,3 +17,4 @@ GtkWidget* create_sortbydlg (void); GtkWidget* create_select_dsp_plugin (void); GtkWidget* create_tagwritersettings (void); GtkWidget* create_ctmappingdlg (void); +GtkWidget* create_ctmappingeditdlg (void); diff --git a/plugins/gtkui/prefwin.c b/plugins/gtkui/prefwin.c index a6b72040..e5efc8d3 100644 --- a/plugins/gtkui/prefwin.c +++ b/plugins/gtkui/prefwin.c @@ -1088,16 +1088,3 @@ on_useragent_changed (GtkEditable *editable, deadbeef->sendmessage (DB_EV_CONFIGCHANGED, 0, 0, 0); } -void -on_edit_content_type_mapping_clicked (GtkButton *button, - gpointer user_data) -{ - GtkWidget *dlg = create_ctmappingdlg (); - - const char mapstr[2048]; - deadbeef->conf_get_str ("network.ctmapping", DDB_DEFAULT_CTMAPPING, mapstr, sizeof (mapstr)); - - int response = gtk_dialog_run (GTK_DIALOG (dlg)); - gtk_widget_destroy (dlg); -} - diff --git a/po/POTFILES.in b/po/POTFILES.in index 568c48f0..9b120c38 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -31,3 +31,4 @@ plugins/shellexecui/shellexecui.c plugins/shellexecui/support.c plugins/shellexecui/shellexec.glade plugins/gtkui/actionhandlers.c +plugins/gtkui/ctmapping.c -- cgit v1.2.3