summaryrefslogtreecommitdiffstats
path: root/gtk/src
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2009-07-11 17:34:29 +0000
committerjstebbins <[email protected]>2009-07-11 17:34:29 +0000
commit890091c4b70840627df66b7826f522fd8dc936b2 (patch)
treebda558a2abd898de03e4481c17006c944ca80db1 /gtk/src
parentadadf0a418c77c2d89470b7f0efbf661c3981296 (diff)
LinGui: more preset list improvements
- Make separate menu items for creating new folders and saving presets - Make custom preset and folder names editable git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2684 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk/src')
-rw-r--r--gtk/src/callbacks.c16
-rw-r--r--gtk/src/callbacks.h2
-rw-r--r--gtk/src/ghb.ui74
-rw-r--r--gtk/src/internal_defaults.xml4
-rw-r--r--gtk/src/main.c11
-rw-r--r--gtk/src/presets.c179
6 files changed, 167 insertions, 119 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c
index 5ca5a536e..54a5d0ca2 100644
--- a/gtk/src/callbacks.c
+++ b/gtk/src/callbacks.c
@@ -1886,6 +1886,22 @@ ghb_message_dialog(GtkMessageType type, const gchar *message, const gchar *no, c
return TRUE;
}
+void
+ghb_error_dialog(GtkMessageType type, const gchar *message, const gchar *cancel)
+{
+ GtkWidget *dialog;
+ GtkResponseType response;
+
+ // Toss up a warning dialog
+ dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
+ type, GTK_BUTTONS_NONE,
+ "%s", message);
+ gtk_dialog_add_buttons( GTK_DIALOG(dialog),
+ cancel, GTK_RESPONSE_CANCEL, NULL);
+ response = gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy (dialog);
+}
+
gboolean
ghb_cancel_encode(const gchar *extra_msg)
{
diff --git a/gtk/src/callbacks.h b/gtk/src/callbacks.h
index 6134bef91..c52bf553d 100644
--- a/gtk/src/callbacks.h
+++ b/gtk/src/callbacks.h
@@ -45,6 +45,8 @@ void ghb_hal_init(void);
gboolean ghb_message_dialog(
GtkMessageType type, const gchar *message,
const gchar *no, const gchar *yes);
+void ghb_error_dialog(
+ GtkMessageType type, const gchar *message, const gchar *cancel);
void ghb_init_dep_map(void);
gboolean ghb_cancel_encode(const gchar *extra_msg);
GValue* ghb_start_next_job(signal_user_data_t *ud, gboolean find_first);
diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui
index 5c8ad72dd..cff7f43e1 100644
--- a/gtk/src/ghb.ui
+++ b/gtk/src/ghb.ui
@@ -462,8 +462,19 @@
<object class="GtkMenu" id="presets_menu">
<child>
+ <object class="GtkImageMenuItem" id="presets_new_folder">
+ <property name="label" translatable="yes">New _Folder</property>
+ <property name="use-underline">True</property>
+ <property name="visible">True</property>
+ <property name="use_stock">True</property>
+ <property name="image">image11</property>
+ <signal name="activate" handler="presets_new_folder_clicked_cb"/>
+ </object>
+ </child>
+ <child>
<object class="GtkImageMenuItem" id="presets_save">
- <property name="label">gtk-save</property>
+ <property name="label">_Save Preset</property>
+ <property name="image">image12</property>
<property name="visible">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
@@ -484,7 +495,7 @@
<property name="label" translatable="yes">_Export</property>
<property name="use-underline">True</property>
<property name="visible">True</property>
- <property name="image">image1</property>
+ <property name="image">image13</property>
<property name="use_stock">False</property>
<signal name="activate" handler="preset_export_clicked_cb"/>
</object>
@@ -494,14 +505,15 @@
<property name="label" translatable="yes">_Import</property>
<property name="use-underline">True</property>
<property name="visible">True</property>
- <property name="image">image5</property>
+ <property name="image">image14</property>
<property name="use_stock">False</property>
<signal name="activate" handler="preset_import_clicked_cb"/>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="presets_restore">
- <property name="label">gtk-refresh</property>
+ <property name="label" translatable="yes">_Update Built-in Presets</property>
+ <property name="image">image15</property>
<property name="visible">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
@@ -4498,7 +4510,6 @@ no-dct-decimate=0:cabac=1</property>
<property name="activates_default">True</property>
<property name="width_chars">30</property>
<property name="truncate_multiline">True</property>
- <signal handler="preset_name_changed_cb" name="changed"/>
</object>
<packing>
<property name="position">1</property>
@@ -4549,43 +4560,6 @@ no-dct-decimate=0:cabac=1</property>
<property name="position">1</property>
</packing>
</child>
- <child>
- <object class="GtkHBox" id="hbox43">
- <property name="visible">True</property>
- <child>
- <object class="GtkRadioButton" id="preset_type_folder">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Folder</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="preset_type_changed_cb"/>
- </object>
- <packing>
- <property name="expand">False</property>
- </packing>
- </child>
- <child>
- <object class="GtkRadioButton" id="preset_type_normal">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Preset</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
- <property name="group">preset_type_folder</property>
- <signal name="toggled" handler="preset_type_changed_cb"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">2</property>
- </packing>
- </child>
</object>
<packing>
<property name="position">1</property>
@@ -6590,12 +6564,24 @@ libx264 authors:
<action-widget response="-3">source_ok</action-widget>
</action-widgets>
</object>
- <object class="GtkImage" id="image1">
+ <object class="GtkImage" id="image11">
+ <property name="visible">True</property>
+ <property name="stock">gtk-new</property>
+ </object>
+ <object class="GtkImage" id="image12">
+ <property name="visible">True</property>
+ <property name="stock">gtk-save</property>
+ </object>
+ <object class="GtkImage" id="image13">
<property name="visible">True</property>
<property name="stock">gtk-save-as</property>
</object>
- <object class="GtkImage" id="image5">
+ <object class="GtkImage" id="image14">
<property name="visible">True</property>
<property name="stock">gtk-open</property>
</object>
+ <object class="GtkImage" id="image15">
+ <property name="visible">True</property>
+ <property name="stock">gtk-refresh</property>
+ </object>
</interface>
diff --git a/gtk/src/internal_defaults.xml b/gtk/src/internal_defaults.xml
index 932a50302..f09df0da4 100644
--- a/gtk/src/internal_defaults.xml
+++ b/gtk/src/internal_defaults.xml
@@ -26,10 +26,6 @@
<array>
<string>Normal</string>
</array>
- <key>preset_type_folder</key>
- <false />
- <key>preset_type_normal</key>
- <true />
<key>PictureDisplayWidth</key>
<integer>720</integer>
<key>PictureDisplayHeight</key>
diff --git a/gtk/src/main.c b/gtk/src/main.c
index c089a7616..efc2fbc99 100644
--- a/gtk/src/main.c
+++ b/gtk/src/main.c
@@ -467,6 +467,7 @@ bind_subtitle_tree_model (signal_user_data_t *ud)
extern G_MODULE_EXPORT void presets_list_selection_changed_cb(void);
extern G_MODULE_EXPORT void presets_drag_cb(void);
extern G_MODULE_EXPORT void presets_drag_motion_cb(void);
+extern G_MODULE_EXPORT void preset_edited_cb(void);
extern void presets_row_expanded_cb(void);
// Create and bind the tree model to the tree view for the preset list
@@ -487,13 +488,17 @@ bind_presets_tree_model (signal_user_data_t *ud)
g_debug("bind_presets_tree_model ()\n");
treeview = GTK_TREE_VIEW(GHB_WIDGET (ud->builder, "presets_list"));
selection = gtk_tree_view_get_selection (treeview);
- treestore = gtk_tree_store_new(5, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT,
- G_TYPE_STRING, G_TYPE_STRING);
+ treestore = gtk_tree_store_new(6, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(treestore));
cell = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes(_("Preset Name"), cell,
- "text", 0, "weight", 1, "style", 2, "foreground", 3, NULL);
+ "text", 0, "weight", 1, "style", 2,
+ "foreground", 3, "editable", 5, NULL);
+
+ g_signal_connect(cell, "edited", preset_edited_cb, ud);
+
gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
gtk_tree_view_column_set_expand (column, TRUE);
gtk_tree_view_set_tooltip_column (treeview, 4);
diff --git a/gtk/src/presets.c b/gtk/src/presets.c
index b536c8aba..5bd8786dd 100644
--- a/gtk/src/presets.c
+++ b/gtk/src/presets.c
@@ -1565,6 +1565,7 @@ ghb_presets_list_init(
2, def ? 2 : 0,
3, color,
4, description,
+ 5, type == PRESETS_BUILTIN ? 0 : 1,
-1);
if (def && piter)
{
@@ -1608,7 +1609,8 @@ static void
presets_list_update_item(
signal_user_data_t *ud,
gint *indices,
- gint len)
+ gint len,
+ gboolean recurse)
{
GtkTreeView *treeview;
GtkTreeStore *store;
@@ -1642,8 +1644,9 @@ presets_list_update_item(
2, def ? 2 : 0,
3, color,
4, description,
+ 5, type == PRESETS_BUILTIN ? 0 : 1,
-1);
- if (folder)
+ if (recurse && folder)
{
ghb_presets_list_init(ud, indices, len);
}
@@ -1706,6 +1709,7 @@ presets_list_insert(
2, def ? 2 : 0,
3, color,
4, description,
+ 5, type == PRESETS_BUILTIN ? 0 : 1,
-1);
if (folder)
{
@@ -2954,7 +2958,7 @@ settings_save(signal_user_data_t *ud, const GValue *path)
ghb_dict_insert(dict, g_strdup("Default"),
ghb_boolean_value_new(FALSE));
}
- presets_list_update_item(ud, indices, len);
+ presets_list_update_item(ud, indices, len, FALSE);
}
else
{
@@ -3000,7 +3004,9 @@ folder_save(signal_user_data_t *ud, const GValue *path)
ghb_dict_insert(dict, g_strdup("PresetDescription"),
ghb_value_dup(preset_dict_get_value(
ud->settings, "PresetDescription")));
+ presets_list_update_item(ud, indices, len, FALSE);
g_free(indices);
+ store_presets();
return;
}
else
@@ -3125,36 +3131,6 @@ update_subtitle_presets(signal_user_data_t *ud)
ghb_settings_take_value(ud->settings, "SubtitleList", slist);
}
-void
-enforce_preset_type(signal_user_data_t *ud, const GValue *path)
-{
- gint *indices, len;
- GtkWidget *normal, *folder;
- gboolean fold;
-
- normal = GHB_WIDGET(ud->builder, "preset_type_normal");
- folder = GHB_WIDGET(ud->builder, "preset_type_folder");
- indices = ghb_preset_indices_from_path(presetsPlist, path, &len);
- if (indices)
- {
- fold = ghb_presets_get_folder(presetsPlist, indices, len);
- if (fold)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(folder),
- TRUE);
- else
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(normal),
- TRUE);
- gtk_widget_set_sensitive(folder, fold);
- gtk_widget_set_sensitive(normal, !fold);
- g_free(indices);
- }
- else
- {
- gtk_widget_set_sensitive(folder, TRUE);
- gtk_widget_set_sensitive(normal, TRUE);
- }
-}
-
G_MODULE_EXPORT void
presets_menu_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
{
@@ -3362,14 +3338,15 @@ preset_export_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
}
G_MODULE_EXPORT void
-presets_save_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
+presets_new_folder_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
{
GtkWidget *dialog;
GtkEntry *entry;
GtkTextView *desc;
GtkResponseType response;
- GValue *preset;
+ GValue *preset, *dict;
const gchar *name = "";
+ const gchar *description = "";
gint count, *indices, len;
g_debug("presets_save_clicked_cb ()");
@@ -3380,12 +3357,20 @@ presets_save_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
name = g_value_get_string(ghb_array_get_nth(preset, count-1));
else
count = 1;
- // Clear the description
+
+ indices = ghb_preset_indices_from_path(presetsPlist, preset, &len);
+ dict = presets_get_dict(presetsPlist, indices, len);
+ if (dict != NULL)
+ {
+ description = g_value_get_string(
+ ghb_dict_lookup(dict, "PresetDescription"));
+ ghb_ui_update(ud, "PresetDescription", ghb_string_value(description));
+ }
+
desc = GTK_TEXT_VIEW(GHB_WIDGET(ud->builder, "PresetDescription"));
dialog = GHB_WIDGET(ud->builder, "preset_save_dialog");
entry = GTK_ENTRY(GHB_WIDGET(ud->builder, "PresetName"));
gtk_entry_set_text(entry, name);
- enforce_preset_type(ud, preset);
response = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_hide(dialog);
if (response == GTK_RESPONSE_OK)
@@ -3394,13 +3379,61 @@ presets_save_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
const gchar *name = gtk_entry_get_text(entry);
GValue *dest;
- if (ghb_settings_get_boolean(ud->settings, "preset_type_folder"))
+ if (count > MAX_NESTED_PRESET-1)
+ count = MAX_NESTED_PRESET-1;
+
+ dest = ghb_array_value_new(MAX_NESTED_PRESET);
+ if (indices != NULL)
{
- if (count > MAX_NESTED_PRESET-1)
+ gint ptype;
+
+ ptype = ghb_presets_get_type(presetsPlist, indices, len);
+ if (ptype == PRESETS_CUSTOM)
{
- count = MAX_NESTED_PRESET-1;
+ ghb_array_copy(dest, preset, count-1);
}
}
+ ghb_array_append(dest, ghb_string_value_new(name));
+ ghb_widget_to_setting(ud->settings, GTK_WIDGET(desc));
+ folder_save(ud, dest);
+ ghb_value_free(dest);
+ }
+ if (indices != NULL)
+ g_free(indices);
+}
+
+G_MODULE_EXPORT void
+presets_save_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
+{
+ GtkWidget *dialog;
+ GtkEntry *entry;
+ GtkTextView *desc;
+ GtkResponseType response;
+ GValue *preset;
+ const gchar *name = "";
+ gint count, *indices, len;
+
+ g_debug("presets_save_clicked_cb ()");
+ preset = ghb_settings_get_value (ud->settings, "preset_selection");
+
+ count = ghb_array_len(preset);
+ if (count > 0)
+ name = g_value_get_string(ghb_array_get_nth(preset, count-1));
+ else
+ count = 1;
+
+ desc = GTK_TEXT_VIEW(GHB_WIDGET(ud->builder, "PresetDescription"));
+ dialog = GHB_WIDGET(ud->builder, "preset_save_dialog");
+ entry = GTK_ENTRY(GHB_WIDGET(ud->builder, "PresetName"));
+ gtk_entry_set_text(entry, name);
+ response = gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_hide(dialog);
+ if (response == GTK_RESPONSE_OK)
+ {
+ // save the preset
+ const gchar *name = gtk_entry_get_text(entry);
+ GValue *dest;
+
dest = ghb_array_value_new(MAX_NESTED_PRESET);
indices = ghb_preset_indices_from_path(presetsPlist, preset, &len);
if (indices)
@@ -3412,21 +3445,16 @@ presets_save_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
{
ghb_array_copy(dest, preset, count-1);
}
+ g_free(indices);
}
ghb_array_append(dest, ghb_string_value_new(name));
ghb_widget_to_setting(ud->settings, GTK_WIDGET(desc));
- if (ghb_settings_get_boolean(ud->settings, "preset_type_folder"))
- {
- folder_save(ud, dest);
- }
- else
- {
- // Construct the audio settings presets from the current audio list
- update_audio_presets(ud);
- update_subtitle_presets(ud);
- settings_save(ud, dest);
- }
+
+ // Construct the audio settings presets from the current audio list
+ update_audio_presets(ud);
+ update_subtitle_presets(ud);
+ settings_save(ud, dest);
ghb_value_free(dest);
}
}
@@ -3438,22 +3466,6 @@ preset_type_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
}
G_MODULE_EXPORT void
-preset_name_changed_cb(GtkWidget *entry, signal_user_data_t *ud)
-{
- gchar *name;
- GValue *preset, *dest;
- gint count;
-
- preset = ghb_settings_get_value (ud->settings, "preset_selection");
- name = ghb_widget_string(entry);
- dest = ghb_value_dup(preset);
- count = ghb_array_len(dest);
- ghb_array_replace(dest, count-1, ghb_string_value_new(name));
- enforce_preset_type(ud, dest);
- ghb_value_free(dest);
-}
-
-G_MODULE_EXPORT void
presets_restore_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
{
GValue *preset;
@@ -3772,7 +3784,7 @@ presets_drag_cb(
dstpath = gtk_tree_model_get_path (dstmodel, &iter);
dst_indices = gtk_tree_path_get_indices(dstpath);
dst_len = gtk_tree_path_get_depth(dstpath);
- presets_list_update_item(ud, dst_indices, dst_len);
+ presets_list_update_item(ud, dst_indices, dst_len, TRUE);
gtk_tree_path_free(dstpath);
store_presets();
@@ -4017,3 +4029,34 @@ presets_default_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
}
}
+G_MODULE_EXPORT void
+preset_edited_cb(
+ GtkCellRendererText *cell,
+ gchar *path,
+ gchar *text,
+ signal_user_data_t *ud)
+{
+ GtkTreePath *treepath;
+ GtkTreeStore *store;
+ GtkTreeView *treeview;
+ GtkTreeIter iter;
+ gint *indices, len;
+ GValue *dict;
+
+ g_debug("preset_edited_cb ()");
+ g_debug("path (%s)", path);
+ g_debug("text (%s)", text);
+ treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "presets_list"));
+ store = GTK_TREE_STORE(gtk_tree_view_get_model(treeview));
+ treepath = gtk_tree_path_new_from_string (path);
+ indices = gtk_tree_path_get_indices(treepath);
+ len = gtk_tree_path_get_depth(treepath);
+ gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, treepath);
+ gtk_tree_store_set(store, &iter, 0, text, -1);
+
+ dict = presets_get_dict(presetsPlist, indices, len);
+ ghb_dict_insert(dict, g_strdup("PresetName"), ghb_string_value_new(text));
+ store_presets();
+ gtk_tree_path_free (treepath);
+}
+