From: jstebbins <jstebbins.hb@gmail.com>
Date: Tue, 29 Jun 2010 00:15:59 +0000 (+0000)
Subject: LinGui: improvements to maxWidth/maxHeight preset gui
X-Git-Tag: 0.9.5~314
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e71a5fc9de03802003f9c683b84367fee14e43a5;p=handbrake

LinGui: improvements to maxWidth/maxHeight preset gui
Add checkbox for each of max width/height entries in the presets save dialog.
When not checked, the value is not stored to the preset.
If neither is checked, UsesPictureSettings=2 is assumed.
If either is checked, UsesPictureSettings=1 is assumed.


git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3420 b64f7644-9d1e-0410-96f1-a4d463321fa5
---

diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui
index d1019dea7..118afa4b2 100644
--- a/gtk/src/ghb.ui
+++ b/gtk/src/ghb.ui
@@ -4666,6 +4666,147 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property>
       <action-widget response="-5">tweak_ok</action-widget>
     </action-widgets>
   </object>
+  <object class="GtkDialog" id="preset_new_folder_dialog">
+    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+    <property name="border_width">5</property>
+    <property name="modal">True</property>
+    <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
+    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <property name="has_separator">False</property>
+    <signal handler="gtk_widget_hide_on_delete" name="delete_event"/>
+    <child internal-child="vbox">
+      <object class="GtkVBox" id="dialog-vbox2">
+        <property name="orientation">vertical</property>
+        <property name="visible">True</property>
+        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+        <property name="spacing">2</property>
+        <child>
+          <object class="GtkVBox" id="vbox26">
+            <property name="orientation">vertical</property>
+            <property name="visible">True</property>
+            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+            <child>
+              <object class="GtkHBox" id="hbox31">
+                <property name="visible">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <child>
+                  <object class="GtkLabel" id="label30">
+                    <property name="visible">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="label" translatable="yes">Folder Name:</property>
+                    <property name="xalign">0</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="FolderName">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="max_length">40</property>
+                    <property name="activates_default">True</property>
+                    <property name="width_chars">30</property>
+                    <property name="truncate_multiline">True</property>
+                  </object>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+				<property name="position">0</property>
+                <property name="padding">10</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkFrame" id="frame17">
+                <property name="visible">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="label_xalign">0</property>
+                <property name="shadow_type">GTK_SHADOW_ETCHED_OUT</property>
+                <child>
+                  <object class="GtkAlignment" id="alignment32">
+                    <property name="visible">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="top_padding">6</property>
+                    <property name="bottom_padding">4</property>
+                    <property name="left_padding">12</property>
+                    <property name="right_padding">4</property>
+                    <child>
+                      <object class="GtkTextView" id="FolderDescription">
+                        <property name="height_request">60</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                        <property name="wrap_mode">GTK_WRAP_WORD</property>
+                        <property name="accepts_tab">False</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+                <child type="label">
+                  <object class="GtkLabel" id="label21">
+                    <property name="visible">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="label" translatable="yes">&lt;b&gt;Description&lt;/b&gt;</property>
+                    <property name="use_markup">True</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="padding">10</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="dialog-action_area2">
+            <property name="visible">True</property>
+            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+            <property name="layout_style">GTK_BUTTONBOX_END</property>
+            <child>
+              <object class="GtkButton" id="preset_folder_cancel">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="label" translatable="yes">gtk-cancel</property>
+                <property name="use_stock">True</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkButton" id="preset_folder_ok">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="label" translatable="yes">gtk-ok</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">GTK_PACK_END</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="0">preset_folder_cancel</action-widget>
+      <action-widget response="-5">preset_folder_ok</action-widget>
+    </action-widgets>
+  </object>
   <object class="GtkDialog" id="preset_save_dialog">
     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
     <property name="border_width">5</property>
@@ -4722,86 +4863,112 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property>
               </packing>
             </child>
 			<child>
-			  <object class="GtkVBox" id="PicturePresetBox">
-				<property name="orientation">vertical</property>
+			  <object class="GtkTable" id="PicturePresetBox">
 				<property name="visible">True</property>
 				<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-
+				<property name="n_rows">3</property>
+				<property name="n_columns">3</property>
 				<child>
 				  <object class="GtkLabel" id="UsingCurrentPicLabel">
 					<property name="visible">True</property>
 					<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-					<property name="label" translatable="yes">&lt;b&gt;Using Current Picture Settings&lt;/b&gt;</property>
+					<property name="label" translatable="yes">&lt;b&gt;Custom Picture Dimensions&lt;/b&gt;</property>
 					<property name="xalign">0</property>
 					<property name="use_markup">True</property>
 				  </object>
 				  <packing>
-					<property name="expand">False</property>
-					<property name="position">0</property>
+					<property name="top_attach">0</property>
+					<property name="bottom_attach">1</property>
+					<property name="left_attach">0</property>
+					<property name="right_attach">3</property>
 				  </packing>
 				</child>
 				<child>
-				  <object class="GtkHBox" id="hbox31">
+				  <object class="GtkLabel" id="fillerlabel1">
 					<property name="visible">True</property>
 					<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-					<property name="spacing">4</property>
-					<child>
-					  <object class="GtkLabel" id="label31">
-						<property name="visible">True</property>
-						<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-						<property name="label" translatable="yes">Max Width:</property>
-						<property name="xalign">0</property>
-					  </object>
-					  <packing>
-						<property name="expand">False</property>
-						<property name="position">0</property>
-					  </packing>
-					</child>
-					<child>
-					  <object class="GtkSpinButton" id="PictureWidth">
-						<property name="visible">True</property>
-						<property name="can_focus">True</property>
-						<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-						<property name="tooltip-text" translatable="yes">This is the maximum width that the video will be stored at.  Whenever a new source is loaded, this value will be applied if the source width is greater. Setting this to 0 means there is no maximum width.</property>
-						<property name="adjustment">adjustment32</property>
-						<property name="snap_to_ticks">True</property>
-						<signal name="value_changed" handler="setting_widget_changed_cb"/>
-					  </object>
-					  <packing>
-						<property name="expand">False</property>
-						<property name="position">1</property>
-					  </packing>
-					</child>
-					<child>
-					  <object class="GtkLabel" id="label75">
-						<property name="visible">True</property>
-						<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-						<property name="label" translatable="yes">Max Height:</property>
-						<property name="xalign">1</property>
-					  </object>
-					  <packing>
-						<property name="expand">False</property>
-						<property name="position">2</property>
-					  </packing>
-					</child>
-					<child>
-					  <object class="GtkSpinButton" id="PictureHeight">
-						<property name="visible">True</property>
-						<property name="can_focus">True</property>
-						<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-						<property name="tooltip-text" translatable="yes">This is the maximum height that the video will be stored at.  Whenever a new source is loaded, this value will be applied if the source height is greater. Setting this to 0 means there is no maximum height.</property>
-						<property name="adjustment">adjustment33</property>
-						<signal name="value_changed" handler="setting_widget_changed_cb"/>
-					  </object>
-					  <packing>
-						<property name="expand">False</property>
-						<property name="position">3</property>
-					  </packing>
-					</child>
+					<property name="label" translatable="yes"></property>
+					<property name="xalign">0</property>
+				  </object>
+				  <packing>
+					<property name="top_attach">1</property>
+					<property name="bottom_attach">2</property>
+					<property name="left_attach">2</property>
+					<property name="right_attach">3</property>
+                    <property name="x_options">GTK_EXPAND</property>
+				  </packing>
+				</child>
+				<child>
+				  <object class="GtkCheckButton" id="PictureWidthEnable">
+					<property name="label" translatable="yes">Maximum Width:</property>
+					<property name="visible">True</property>
+					<property name="can_focus">True</property>
+					<property name="receives_default">False</property>
+					<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+					<property name="tooltip-text" translatable="yes">Enable maximum width limit.</property>
+					<property name="draw_indicator">True</property>
+					<signal name="toggled" handler="setting_widget_changed_cb"/>
+				  </object>
+				  <packing>
+					<property name="top_attach">1</property>
+					<property name="bottom_attach">2</property>
+					<property name="left_attach">0</property>
+					<property name="right_attach">1</property>
+                    <property name="x_options">GTK_FILL</property>
+				  </packing>
+				</child>
+				<child>
+				  <object class="GtkSpinButton" id="PictureWidth">
+					<property name="visible">True</property>
+					<property name="can_focus">True</property>
+					<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+					<property name="tooltip-text" translatable="yes">This is the maximum width that the video will be stored at.  Whenever a new source is loaded, this value will be applied if the source width is greater. Setting this to 0 means there is no maximum width.</property>
+					<property name="adjustment">adjustment32</property>
+					<property name="snap_to_ticks">True</property>
+					<signal name="value_changed" handler="setting_widget_changed_cb"/>
+				  </object>
+				  <packing>
+					<property name="top_attach">1</property>
+					<property name="bottom_attach">2</property>
+					<property name="left_attach">1</property>
+					<property name="right_attach">2</property>
+                    <property name="x_options"></property>
+				  </packing>
+				</child>
+				<child>
+				  <object class="GtkCheckButton" id="PictureHeightEnable">
+					<property name="label" translatable="yes">Maximum Height:</property>
+					<property name="visible">True</property>
+					<property name="can_focus">True</property>
+					<property name="receives_default">False</property>
+					<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+					<property name="tooltip-text" translatable="yes">Enable maximum height limit.</property>
+					<property name="draw_indicator">True</property>
+					<signal name="toggled" handler="setting_widget_changed_cb"/>
+				  </object>
+				  <packing>
+					<property name="top_attach">2</property>
+					<property name="bottom_attach">3</property>
+					<property name="left_attach">0</property>
+					<property name="right_attach">1</property>
+                    <property name="x_options">GTK_FILL</property>
+				  </packing>
+				</child>
+				<child>
+				  <object class="GtkSpinButton" id="PictureHeight">
+					<property name="visible">True</property>
+					<property name="can_focus">True</property>
+					<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+					<property name="tooltip-text" translatable="yes">This is the maximum height that the video will be stored at.  Whenever a new source is loaded, this value will be applied if the source height is greater. Setting this to 0 means there is no maximum height.</property>
+					<property name="adjustment">adjustment33</property>
+					<signal name="value_changed" handler="setting_widget_changed_cb"/>
 				  </object>
 				  <packing>
-					<property name="expand">False</property>
-					<property name="position">1</property>
+					<property name="top_attach">2</property>
+					<property name="bottom_attach">3</property>
+					<property name="left_attach">1</property>
+					<property name="right_attach">2</property>
+                    <property name="x_options"></property>
 				  </packing>
 				</child>
 			  </object>
diff --git a/gtk/src/makedeps.py b/gtk/src/makedeps.py
index 594b22faf..751475031 100644
--- a/gtk/src/makedeps.py
+++ b/gtk/src/makedeps.py
@@ -40,7 +40,8 @@ dep_map = (
 	DepEntry("PictureDenoise", "PictureDenoiseCustom", "custom", False, True),
 	DepEntry("PictureDecomb", "PictureDecombCustom", "custom", False, True),
 	DepEntry("PictureDetelecine", "PictureDetelecineCustom", "custom", False, True),
-	DepEntry("autoscale", "PicturePresetBox", "FALSE", False, True),
+	DepEntry("PictureWidthEnable", "PictureWidth", "TRUE", False, False),
+	DepEntry("PictureHeightEnable", "PictureHeight", "TRUE", False, False),
 	DepEntry("PictureAutoCrop", "PictureTopCrop", "FALSE", False, False),
 	DepEntry("PictureAutoCrop", "PictureBottomCrop", "FALSE", False, False),
 	DepEntry("PictureAutoCrop", "PictureLeftCrop", "FALSE", False, False),
diff --git a/gtk/src/presets.c b/gtk/src/presets.c
index 40329de14..1946f0ba8 100644
--- a/gtk/src/presets.c
+++ b/gtk/src/presets.c
@@ -3157,6 +3157,20 @@ settings_save(signal_user_data_t *ud, const GValue *path)
 						ghb_boolean_value_new(FALSE));
 		presets_list_insert(ud, indices, len);
 	}
+	if (!ghb_settings_get_boolean( ud->settings, "PictureWidthEnable"))
+	{
+		ghb_dict_remove(dict, "PictureWidth");
+	}
+	if (!ghb_settings_get_boolean( ud->settings, "PictureHeightEnable"))
+	{
+		ghb_dict_remove(dict, "PictureHeight");
+	}
+	ghb_dict_insert(dict, g_strdup("autoscale"), 
+		ghb_boolean_value_new(
+			!ghb_settings_get_boolean( ud->settings, "PictureWidthEnable") &&
+			!ghb_settings_get_boolean( ud->settings, "PictureHeightEnable")
+		)
+	);
 	store_presets();
 	ud->dont_clear_presets = TRUE;
 	// Make the new preset the selected item
@@ -3541,7 +3555,7 @@ presets_new_folder_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
 	const gchar *description = "";
 	gint count, *indices, len;
 
-	g_debug("presets_save_clicked_cb ()");
+	g_debug("presets_new_folder_clicked_cb ()");
 	preset = ghb_settings_get_value (ud->settings, "preset_selection");
 
 	count = ghb_array_len(preset);
@@ -3556,12 +3570,12 @@ presets_new_folder_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
 	{
 		description = g_value_get_string(
 							ghb_dict_lookup(dict, "PresetDescription"));
-		ghb_ui_update(ud, "PresetDescription", ghb_string_value(description));
+		ghb_ui_update(ud, "FolderDescription", 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"));
+	desc = GTK_TEXT_VIEW(GHB_WIDGET(ud->builder, "FolderDescription"));
+	dialog = GHB_WIDGET(ud->builder, "preset_new_folder_dialog");
+	entry = GTK_ENTRY(GHB_WIDGET(ud->builder, "FolderName"));
 	gtk_entry_set_text(entry, name);
 	response = gtk_dialog_run(GTK_DIALOG(dialog));
 	gtk_widget_hide(dialog);
@@ -3586,7 +3600,8 @@ presets_new_folder_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
 			}
 		}
 		ghb_array_append(dest, ghb_string_value_new(name));
-		ghb_widget_to_setting(ud->settings, GTK_WIDGET(desc));
+		GValue *val = ghb_widget_value(GTK_WIDGET(desc));
+		ghb_settings_set_value(ud->settings, "PresetDescription", val);
 		folder_save(ud, dest);
 		ghb_value_free(dest);
 	}
@@ -3615,6 +3630,23 @@ presets_save_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
 		count = 1;
 
 	desc = GTK_TEXT_VIEW(GHB_WIDGET(ud->builder, "PresetDescription"));
+	int width = ghb_settings_get_int(ud->settings, "PictureWidth");
+	int height = ghb_settings_get_int(ud->settings, "PictureHeight");
+	gboolean autoscale = ghb_settings_get_boolean(ud->settings, "autoscale");
+	ghb_ui_update(ud, "PictureWidthEnable", 
+		ghb_boolean_value(width!=0&&!autoscale));
+	ghb_ui_update(ud, "PictureHeightEnable", 
+		ghb_boolean_value(height!=0&&!autoscale));
+	if (!width)
+	{
+		width = ghb_settings_get_int(ud->settings, "scale_width");
+		ghb_ui_update(ud, "PictureWidth", ghb_int_value(width));
+	}
+	if (!height)
+	{
+		height = ghb_settings_get_int(ud->settings, "scale_height");
+		ghb_ui_update(ud, "PictureHeight", ghb_int_value(height));
+	}
 	dialog = GHB_WIDGET(ud->builder, "preset_save_dialog");
 	entry = GTK_ENTRY(GHB_WIDGET(ud->builder, "PresetName"));
 	gtk_entry_set_text(entry, name);