]> granicus.if.org Git - handbrake/commitdiff
LinGui: fix some preset loading issues
authorjstebbins <jstebbins.hb@gmail.com>
Tue, 25 Feb 2014 00:41:24 +0000 (00:41 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Tue, 25 Feb 2014 00:41:24 +0000 (00:41 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6081 b64f7644-9d1e-0410-96f1-a4d463321fa5

gtk/src/callbacks.c
gtk/src/ghb.ui
gtk/src/internal_defaults.xml
gtk/src/presets.c

index 81522d5ada63b1dbc50466a97c327879f0f74d06..fd1988ea956edf0121fb6f5d75c6e7c458835968 100644 (file)
@@ -1822,10 +1822,10 @@ set_title_settings(signal_user_data_t *ud, GValue *settings)
             ghb_settings_set_string(settings, "MetaLongDescription",
                     title->metadata->long_description);
         }
+        update_chapter_list_settings(settings);
+        ghb_set_pref_audio_settings(settings);
         ghb_set_pref_subtitle_settings(ud, title, settings);
     }
-    update_chapter_list_settings(settings);
-    ghb_set_pref_audio_settings(settings);
 
     set_destination_settings(ud, settings);
     ghb_settings_set_value(settings, "dest_dir",
@@ -1853,7 +1853,7 @@ static void
 load_all_titles(signal_user_data_t *ud, int titleindex)
 {
     gint ii, count;
-    GValue *preset, *preset_path;
+    GValue *preset, *preset_path = NULL;
     GValue *settings_array;
     const hb_title_t *title;
 
@@ -1866,7 +1866,14 @@ load_all_titles(signal_user_data_t *ud, int titleindex)
     settings_array = ghb_array_value_new(count);
 
     preset = ghb_get_current_preset(ud);
-    preset_path = ghb_get_current_preset_path(ud);
+    if (preset != NULL)
+    {
+        preset_path = ghb_get_current_preset_path(ud);
+    }
+    else
+    {
+        preset = ud->settings;
+    }
     for (ii = 0; ii < count; ii++)
     {
         int index;
index 61d5f46fbc843a6f75fde7fb972e3abfb369cfde..b1aff07ae9e87c196fc20fa03adb005d45decfa2 100644 (file)
@@ -6924,7 +6924,7 @@ on the Video tab instead.</property>
                     <property name="tooltip_text" translatable="yes">Enable maximum width limit.</property>
                     <property name="xalign">0</property>
                     <property name="draw_indicator">True</property>
-                    <signal name="toggled" handler="setting_widget_changed_cb" swapped="no"/>
+                    <signal name="toggled" handler="preset_widget_changed_cb" swapped="no"/>
                   </object>
                   <packing>
                     <property name="top_attach">1</property>
@@ -6946,7 +6946,7 @@ Setting this to 0 means there is no maximum width.</property>
                     <property name="secondary_icon_activatable">False</property>
                     <property name="adjustment">adjustment32</property>
                     <property name="snap_to_ticks">True</property>
-                    <signal name="value-changed" handler="setting_widget_changed_cb" swapped="no"/>
+                    <signal name="value-changed" handler="preset_widget_changed_cb" swapped="no"/>
                   </object>
                   <packing>
                     <property name="top_attach">1</property>
@@ -6965,7 +6965,7 @@ Setting this to 0 means there is no maximum width.</property>
                     <property name="tooltip_text" translatable="yes">Enable maximum height limit.</property>
                     <property name="xalign">0</property>
                     <property name="draw_indicator">True</property>
-                    <signal name="toggled" handler="setting_widget_changed_cb" swapped="no"/>
+                    <signal name="toggled" handler="preset_widget_changed_cb" swapped="no"/>
                   </object>
                   <packing>
                     <property name="top_attach">2</property>
@@ -6986,7 +6986,7 @@ Setting this to 0 means there is no maximum height.</property>
                     <property name="primary_icon_activatable">False</property>
                     <property name="secondary_icon_activatable">False</property>
                     <property name="adjustment">adjustment33</property>
-                    <signal name="value-changed" handler="setting_widget_changed_cb" swapped="no"/>
+                    <signal name="value-changed" handler="preset_widget_changed_cb" swapped="no"/>
                   </object>
                   <packing>
                     <property name="top_attach">2</property>
index 2e87927d01e7262e9b8cdd47b0c540b9ae098884..9a998bbb8a7a06efd6af50ed3fa14bd04257d141 100644 (file)
@@ -68,6 +68,8 @@
             <string>Regular</string>
             <string>Normal</string>
         </array>
+        <key>preset_modified</key>
+        <false />
         <key>preset_reload</key>
         <false />
         <key>preset_selection</key>
index fe3172f5e2281295bfdd6e3460003023201e0000..e1f517ec5d3d8278f85a51b47837cbcef7a19924 100644 (file)
@@ -965,8 +965,6 @@ ghb_preset_to_settings(GValue *settings, GValue *preset)
     ghb_settings_set_value(settings, "scale_width",
         ghb_settings_get_value(settings, "PictureWidth"));
 
-    ghb_settings_set_boolean(settings, "preset_modified", FALSE);
-
     gboolean uses_max;
     gint uses_pic;
     gint vqtype;
@@ -3466,6 +3464,32 @@ preset_import_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
     gtk_widget_destroy(dialog);
 }
 
+GValue*
+get_selected_path(signal_user_data_t *ud)
+{
+    GtkTreeView *treeview;
+    GtkTreeSelection *selection;
+    GtkTreeModel *store;
+    GtkTreeIter iter;
+
+    treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "presets_list"));
+    selection = gtk_tree_view_get_selection(treeview);
+    if (gtk_tree_selection_get_selected(selection, &store, &iter))
+    {
+        GtkTreePath *treepath;
+        gint *indices, len;
+        GValue *path;
+
+        treepath = gtk_tree_model_get_path(store, &iter);
+        indices = gtk_tree_path_get_indices(treepath);
+        len = gtk_tree_path_get_depth(treepath);
+
+        path = preset_path_from_indices(presetsPlist, indices, len);
+        return path;
+    }
+    return NULL;
+}
+
 G_MODULE_EXPORT void
 preset_export_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
 {
@@ -3478,13 +3502,16 @@ preset_export_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
     gchar *filename;
 
     g_debug("preset_export_clicked_cb ()");
-    preset = ghb_settings_get_value (ud->settings, "preset_selection");
+    preset = get_selected_path(ud);
     if (preset == NULL)
         return;
 
     count = ghb_array_len(preset);
     if (count <= 0)
+    {
+        ghb_value_free(preset);
         return;
+    }
 
     name = g_value_get_string(ghb_array_get_nth(preset, count-1));
 
@@ -3507,7 +3534,10 @@ preset_export_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
 
     indices = ghb_preset_indices_from_path(presetsPlist, preset, &len);
     if (indices == NULL)
+    {
+        ghb_value_free(preset);
         return;
+    }
 
     response = gtk_dialog_run(GTK_DIALOG(dialog));
     gtk_widget_hide(dialog);
@@ -3550,6 +3580,7 @@ preset_export_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
     }
     gtk_widget_destroy(dialog);
     g_free(indices);
+    ghb_value_free(preset);
 }
 
 G_MODULE_EXPORT void
@@ -3565,8 +3596,7 @@ presets_new_folder_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
     gint count, *indices, len;
 
     g_debug("presets_new_folder_clicked_cb ()");
-    preset = ghb_settings_get_value(ud->settings, "preset_selection");
-
+    preset = get_selected_path(ud);
     count = ghb_array_len(preset);
     if (count > 0)
         name = g_value_get_string(ghb_array_get_nth(preset, count-1));
@@ -3615,6 +3645,7 @@ presets_new_folder_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
         ghb_value_free(dest);
     }
     g_free(indices);
+    ghb_value_free(preset);
 }
 
 G_MODULE_EXPORT void
@@ -3629,8 +3660,7 @@ presets_save_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
     gint count, *indices, len;
 
     g_debug("presets_save_clicked_cb ()");
-    preset = ghb_settings_get_value(ud->settings, "preset_selection");
-
+    preset = get_selected_path(ud);
     count = ghb_array_len(preset);
     if (count > 0)
         name = g_value_get_string(ghb_array_get_nth(preset, count-1));
@@ -3687,6 +3717,7 @@ presets_save_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
         settings_save(ud, dest);
         ghb_value_free(dest);
     }
+    ghb_value_free(preset);
 }
 
 G_MODULE_EXPORT void
@@ -3733,7 +3764,6 @@ presets_remove_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
         path = gtk_tree_model_get_path(store, &iter);
         indices = gtk_tree_path_get_indices(path);
         len = gtk_tree_path_get_depth(path);
-        gtk_tree_path_free(path);
 
         folder = ghb_presets_get_folder(presetsPlist, indices, len);
         dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
@@ -3776,6 +3806,7 @@ presets_remove_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
                 gtk_tree_path_free(path);
             }
         }
+        gtk_tree_path_free(path);
         g_free(preset);
     }
 }
@@ -4149,20 +4180,17 @@ presets_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_
     {
         GtkTreePath *treepath;
         gint *indices, len;
-        GValue *path;
         gboolean folder;
 
         treepath = gtk_tree_model_get_path(store, &iter);
         indices = gtk_tree_path_get_indices(treepath);
         len = gtk_tree_path_get_depth(treepath);
 
-        path = preset_path_from_indices(presetsPlist, indices, len);
-        ghb_settings_take_value(ud->settings, "preset_selection", path);
-
         folder = ghb_presets_get_folder(presetsPlist, indices, len);
         if (!folder && !ghb_settings_get_boolean(ud->settings, "preset_reload"))
         {
             ghb_set_preset_settings_from_indices(ud, indices, len);
+            ghb_settings_set_boolean(ud->settings, "preset_modified", FALSE);
             ghb_set_current_title_settings(ud);
             ghb_load_settings(ud);
         }
@@ -4219,7 +4247,7 @@ presets_default_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
     gint *indices, len;
 
     g_debug("presets_default_clicked_cb ()");
-    preset = ghb_settings_get_value(ud->settings, "preset_selection");
+    preset = get_selected_path(ud);
     indices = ghb_preset_indices_from_path(presetsPlist, preset, &len);
     if (indices)
     {
@@ -4231,6 +4259,7 @@ presets_default_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
         }
         g_free(indices);
     }
+    ghb_value_free(preset);
 }
 
 G_MODULE_EXPORT void
@@ -4252,7 +4281,7 @@ preset_edited_cb(
     g_debug("path (%s)", path);
     g_debug("text (%s)", text);
 
-    preset = ghb_settings_get_value (ud->settings, "preset_selection");
+    preset = get_selected_path(ud);
     dest = ghb_array_value_new(MAX_NESTED_PRESET);
     count = ghb_array_len(preset);
     ghb_array_copy(dest, preset, count-1);
@@ -4263,6 +4292,7 @@ preset_edited_cb(
     {
         // Already exists
         g_free(indices);
+        ghb_value_free(preset);
         return;
     }
 
@@ -4278,5 +4308,12 @@ preset_edited_cb(
     ghb_dict_insert(dict, g_strdup("PresetName"), ghb_string_value_new(text));
     store_presets();
     gtk_tree_path_free (treepath);
+    ghb_value_free(preset);
+}
+
+G_MODULE_EXPORT void
+preset_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+    ghb_widget_to_setting(ud->settings, widget);
 }