OSDN Git Service

LinGui: add pref option to scale down high def previews
authorjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 18 Oct 2008 23:48:53 +0000 (23:48 +0000)
committerjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 18 Oct 2008 23:48:53 +0000 (23:48 +0000)
when this option is enabled, if the preview dims are above a threshold
then the size is scaled down to no larger than 1280x720.
1080p previews are too big for my laptop :-P

git-svn-id: svn://localhost/HandBrake/trunk@1846 b64f7644-9d1e-0410-96f1-a4d463321fa5

gtk/src/ghb.ui
gtk/src/hb-backend.c
gtk/src/internal_defaults.xml
gtk/src/presets.c
gtk/src/resource_data.h
gtk/src/resources.plist

index ce1db67..ba66bcb 100644 (file)
@@ -3421,6 +3421,21 @@ auto-generated destination name.</property>
                           </packing>
                         </child>
                         <child>
+                          <object class="GtkCheckButton" id="reduce_hd_preview">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="tooltip_text"> Automatically reduce the size of High Definition previews.
+This is helpfull when working on laptops or similar
+non-hidef screens.  </property>
+                            <property name="label" translatable="yes">Scale down High Definition previews</property>
+                            <property name="draw_indicator">True</property>
+                            <signal name="toggled" handler="pref_changed_cb"/>
+                          </object>
+                          <packing>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
+                        <child>
                           <object class="GtkCheckButton" id="noscale">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
@@ -3434,7 +3449,7 @@ the required multiple.</property>
                             <signal name="toggled" handler="pref_changed_cb"/>
                           </object>
                           <packing>
-                            <property name="position">2</property>
+                            <property name="position">3</property>
                           </packing>
                         </child>
                         <child>
@@ -3453,7 +3468,7 @@ this setting.</property>
                             <signal name="toggled" handler="vcodec_changed_cb"/>
                           </object>
                           <packing>
-                            <property name="position">3</property>
+                            <property name="position">4</property>
                           </packing>
                         </child>
                         <child>
@@ -3464,7 +3479,7 @@ this setting.</property>
                             <signal name="toggled" handler="tweaks_changed_cb"/>
                           </object>
                           <packing>
-                            <property name="position">4</property>
+                            <property name="position">5</property>
                           </packing>
                         </child>
                         <child>
@@ -3475,7 +3490,7 @@ this setting.</property>
                             <signal name="toggled" handler="hbfd_feature_changed_cb"/>
                           </object>
                           <packing>
-                            <property name="position">5</property>
+                            <property name="position">6</property>
                           </packing>
                         </child>
                       </object>
index b690838..98c27dc 100644 (file)
@@ -3453,6 +3453,9 @@ ghb_pause_queue()
     }
 }
 
+#define RED_HEIGHT     720.0
+#define RED_WIDTH      1280.0
+
 GdkPixbuf*
 ghb_get_preview_image(
        gint titleindex, 
@@ -3589,6 +3592,21 @@ ghb_get_preview_image(
                else
                        dstHeight = dstHeight * par_height / par_width;
        }
+       if (ghb_settings_get_boolean(settings, "reduce_hd_preview"))
+       {
+               gdouble factor = 1.0;
+
+               if (dstHeight > RED_HEIGHT)
+               {
+                       factor = RED_HEIGHT / (gdouble)dstHeight;
+               }
+               if (dstWidth * factor > RED_WIDTH)
+               {
+                       factor = RED_WIDTH / (gdouble)dstWidth;
+               }
+               dstHeight = dstHeight * factor + 0.5;
+               dstWidth = dstWidth * factor + 0.5;
+       }
        
        g_debug("scaled %d x %d\n", dstWidth, dstHeight);
        GdkPixbuf *scaled_preview;
index c445cdd..2820000 100644 (file)
@@ -98,6 +98,8 @@
                <false />
                <key>nocheckvquality</key>
                <false />
+               <key>reduce_hd_preview</key>
+               <true />
                <key>noscale</key>
                <false />
                <key>show_presets</key>
index bb5e2e7..cfea986 100644 (file)
@@ -1723,6 +1723,7 @@ export_subtitle_xlat2(GValue *lin_val)
        gchar *str;
        GValue *gval;
 
+       if (lin_val == NULL) return NULL;
        str = ghb_value_string(lin_val);
        if (strcmp(str, "none") == 0)
        {
@@ -1770,6 +1771,7 @@ import_subtitle_xlat2(GValue *mac_val)
        gchar *str;
        GValue *gval;
 
+       if (mac_val == NULL) return NULL;
        str = ghb_value_string(mac_val);
        if (strcmp(str, "None") == 0)
        {
@@ -1793,6 +1795,7 @@ export_audio_track_xlat2(GValue *lin_val)
        gchar *str;
        GValue *gval = NULL;
 
+       if (lin_val == NULL) return NULL;
        str = ghb_value_string(lin_val);
        if (strcmp(str, "none") == 0)
        {
@@ -1814,6 +1817,7 @@ import_audio_track_xlat2(GValue *mac_val)
        gchar *str;
        GValue *gval;
 
+       if (mac_val == NULL) return NULL;
        val = ghb_value_int(mac_val);
        if (val <= 0)
        {
@@ -2323,6 +2327,25 @@ ghb_presets_reload(signal_user_data_t *ud)
        store_presets();
 }
 
+static gboolean
+check_old_presets()
+{
+       gint count, ii;
+
+       count = ghb_array_len(presetsPlist);
+       for (ii = count-1; ii >= 0; ii--)
+       {
+               GValue *dict;
+               GValue *type;
+
+               dict = ghb_array_get_nth(presetsPlist, ii);
+               type = ghb_dict_lookup(dict, "Type");
+               if (type == NULL)
+                       return TRUE;
+       }
+       return FALSE;
+}
+
 void
 ghb_presets_load()
 {
@@ -2338,6 +2361,12 @@ ghb_presets_load()
                presetsPlist = ghb_value_dup(ghb_resource_get("standard-presets"));
                store_presets();
        }
+       else if (check_old_presets())
+       {
+               ghb_value_free(presetsPlist);
+               presetsPlist = ghb_value_dup(ghb_resource_get("standard-presets"));
+               store_presets();
+       }
        import_xlat_presets(presetsPlist);
 }
 
index a54b4ff..c6f06f6 100644 (file)
 "                        &lt;/child&gt;\n"
 "                        &lt;child&gt;\n"
 "                          &lt;object class=&quot;GtkCheckButton&quot; i"
+"d=&quot;reduce_hd_preview&quot;&gt;\n"
+"                            &lt;property name=&quot;visible&quot;&gt;Tr"
+"ue&lt;/property&gt;\n"
+"                            &lt;property name=&quot;can_focus&quot;&gt;"
+"True&lt;/property&gt;\n"
+"                            &lt;property name=&quot;tooltip_text&quot;&"
+"gt; Automatically reduce the size of High Definition previews.\n"
+"This is helpfull when working on laptops or similar\n"
+"non-hidef screens.  &lt;/property&gt;\n"
+"                            &lt;property name=&quot;label&quot; transla"
+"table=&quot;yes&quot;&gt;Scale down High Definition previews&lt;/proper"
+"ty&gt;\n"
+"                            &lt;property name=&quot;draw_indicator&quot"
+";&gt;True&lt;/property&gt;\n"
+"                            &lt;signal name=&quot;toggled&quot; handler"
+"=&quot;pref_changed_cb&quot;/&gt;\n"
+"                          &lt;/object&gt;\n"
+"                          &lt;packing&gt;\n"
+"                            &lt;property name=&quot;position&quot;&gt;2"
+"&lt;/property&gt;\n"
+"                          &lt;/packing&gt;\n"
+"                        &lt;/child&gt;\n"
+"                        &lt;child&gt;\n"
+"                          &lt;object class=&quot;GtkCheckButton&quot; i"
 "d=&quot;noscale&quot;&gt;\n"
 "                            &lt;property name=&quot;visible&quot;&gt;Tr"
 "ue&lt;/property&gt;\n"
 "=&quot;pref_changed_cb&quot;/&gt;\n"
 "                          &lt;/object&gt;\n"
 "                          &lt;packing&gt;\n"
-"                            &lt;property name=&quot;position&quot;&gt;2"
+"                            &lt;property name=&quot;position&quot;&gt;3"
 "&lt;/property&gt;\n"
 "                          &lt;/packing&gt;\n"
 "                        &lt;/child&gt;\n"
 "=&quot;vcodec_changed_cb&quot;/&gt;\n"
 "                          &lt;/object&gt;\n"
 "                          &lt;packing&gt;\n"
-"                            &lt;property name=&quot;position&quot;&gt;3"
+"                            &lt;property name=&quot;position&quot;&gt;4"
 "&lt;/property&gt;\n"
 "                          &lt;/packing&gt;\n"
 "                        &lt;/child&gt;\n"
 "=&quot;tweaks_changed_cb&quot;/&gt;\n"
 "                          &lt;/object&gt;\n"
 "                          &lt;packing&gt;\n"
-"                            &lt;property name=&quot;position&quot;&gt;4"
+"                            &lt;property name=&quot;position&quot;&gt;5"
 "&lt;/property&gt;\n"
 "                          &lt;/packing&gt;\n"
 "                        &lt;/child&gt;\n"
 "=&quot;hbfd_feature_changed_cb&quot;/&gt;\n"
 "                          &lt;/object&gt;\n"
 "                          &lt;packing&gt;\n"
-"                            &lt;property name=&quot;position&quot;&gt;5"
+"                            &lt;property name=&quot;position&quot;&gt;6"
 "&lt;/property&gt;\n"
 "                          &lt;/packing&gt;\n"
 "                        &lt;/child&gt;\n"
 "                      <false />\n"
 "                      <key>noscale</key>\n"
 "                      <false />\n"
+"                      <key>reduce_hd_preview</key>\n"
+"                      <true />\n"
 "                      <key>show_presets</key>\n"
 "                      <true />\n"
 "                      <key>use_source_name</key>\n"
index 0dc6536..dccb730 100644 (file)
@@ -3426,6 +3426,21 @@ auto-generated destination name.&lt;/property&gt;
                           &lt;/packing&gt;
                         &lt;/child&gt;
                         &lt;child&gt;
+                          &lt;object class=&quot;GtkCheckButton&quot; id=&quot;reduce_hd_preview&quot;&gt;
+                            &lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt;
+                            &lt;property name=&quot;can_focus&quot;&gt;True&lt;/property&gt;
+                            &lt;property name=&quot;tooltip_text&quot;&gt; Automatically reduce the size of High Definition previews.
+This is helpfull when working on laptops or similar
+non-hidef screens.  &lt;/property&gt;
+                            &lt;property name=&quot;label&quot; translatable=&quot;yes&quot;&gt;Scale down High Definition previews&lt;/property&gt;
+                            &lt;property name=&quot;draw_indicator&quot;&gt;True&lt;/property&gt;
+                            &lt;signal name=&quot;toggled&quot; handler=&quot;pref_changed_cb&quot;/&gt;
+                          &lt;/object&gt;
+                          &lt;packing&gt;
+                            &lt;property name=&quot;position&quot;&gt;2&lt;/property&gt;
+                          &lt;/packing&gt;
+                        &lt;/child&gt;
+                        &lt;child&gt;
                           &lt;object class=&quot;GtkCheckButton&quot; id=&quot;noscale&quot;&gt;
                             &lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt;
                             &lt;property name=&quot;can_focus&quot;&gt;True&lt;/property&gt;
@@ -3439,7 +3454,7 @@ the required multiple.&lt;/property&gt;
                             &lt;signal name=&quot;toggled&quot; handler=&quot;pref_changed_cb&quot;/&gt;
                           &lt;/object&gt;
                           &lt;packing&gt;
-                            &lt;property name=&quot;position&quot;&gt;2&lt;/property&gt;
+                            &lt;property name=&quot;position&quot;&gt;3&lt;/property&gt;
                           &lt;/packing&gt;
                         &lt;/child&gt;
                         &lt;child&gt;
@@ -3458,7 +3473,7 @@ this setting.&lt;/property&gt;
                             &lt;signal name=&quot;toggled&quot; handler=&quot;vcodec_changed_cb&quot;/&gt;
                           &lt;/object&gt;
                           &lt;packing&gt;
-                            &lt;property name=&quot;position&quot;&gt;3&lt;/property&gt;
+                            &lt;property name=&quot;position&quot;&gt;4&lt;/property&gt;
                           &lt;/packing&gt;
                         &lt;/child&gt;
                         &lt;child&gt;
@@ -3469,7 +3484,7 @@ this setting.&lt;/property&gt;
                             &lt;signal name=&quot;toggled&quot; handler=&quot;tweaks_changed_cb&quot;/&gt;
                           &lt;/object&gt;
                           &lt;packing&gt;
-                            &lt;property name=&quot;position&quot;&gt;4&lt;/property&gt;
+                            &lt;property name=&quot;position&quot;&gt;5&lt;/property&gt;
                           &lt;/packing&gt;
                         &lt;/child&gt;
                         &lt;child&gt;
@@ -3480,7 +3495,7 @@ this setting.&lt;/property&gt;
                             &lt;signal name=&quot;toggled&quot; handler=&quot;hbfd_feature_changed_cb&quot;/&gt;
                           &lt;/object&gt;
                           &lt;packing&gt;
-                            &lt;property name=&quot;position&quot;&gt;5&lt;/property&gt;
+                            &lt;property name=&quot;position&quot;&gt;6&lt;/property&gt;
                           &lt;/packing&gt;
                         &lt;/child&gt;
                       &lt;/object&gt;
@@ -4931,6 +4946,8 @@ R2RrUAAABBgBAQACAAAAQAAAABAAAAAQ////AP///wD///8A////AP///wD///8A////AP///wD///8A
                        <false />
                        <key>noscale</key>
                        <false />
+                       <key>reduce_hd_preview</key>
+                       <true />
                        <key>show_presets</key>
                        <true />
                        <key>use_source_name</key>