Commit 3aa2bf29 authored by Laura Lucas Alday's avatar Laura Lucas Alday

Photo and video resolution can be set separately. Fixes bug #582268

parent e8114fd8
......@@ -100,7 +100,7 @@
<child>
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="label" translatable="yes">Resolution</property>
<property name="label" translatable="yes">Photo resolution</property>
</object>
</child>
</object>
......@@ -108,6 +108,23 @@
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment10">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="xscale">0</property>
<property name="left_padding">10</property>
<child>
<object class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="label" translatable="yes">Video resolution</property>
</object>
</child>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
......@@ -129,15 +146,25 @@
</packing>
</child>
<child>
<object class="GtkComboBox" id="resolution_combo_box">
<object class="GtkComboBox" id="photo_resolution_combo_box">
<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>
<signal name="changed" handler="cheese_preferences_dialog_on_resolution_change"/>
<signal name="changed" handler="cheese_preferences_dialog_on_photo_resolution_change"/>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="video_resolution_combo_box">
<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>
<signal name="changed" handler="cheese_preferences_dialog_on_video_resolution_change"/>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
......
......@@ -32,22 +32,38 @@
<default>'identity'</default>
</key>
<key name='x-resolution' type='i'>
<summary>Width resolution</summary>
<key name='photo-x-resolution' type='i'>
<summary>Photo width resolution</summary>
<description>
The width resolution of the image captured from the camera
</description>
<default>0</default>
</key>
<key name='y-resolution' type='i'>
<summary>Height resolution</summary>
<key name='photo-y-resolution' type='i'>
<summary>Photo height resolution</summary>
<description>
The height resolution of the image captured from the camera
</description>
<default>0</default>
</key>
<key name='video-x-resolution' type='i'>
<summary>Video width resolution</summary>
<description>
The width resolution of the video captured from the camera
</description>
<default>0</default>
</key>
<key name='video-y-resolution' type='i'>
<summary>Video height resolution</summary>
<description>
The height resolution of the video captured from the camera
</description>
<default>0</default>
</key>
<key name='brightness' type='d'>
<summary>Picture brightness</summary>
<description>
......
......@@ -310,9 +310,9 @@ setup_camera (CheeseWidget *widget)
gdouble contrast;
gdouble saturation;
gdouble hue;
g_settings_get (priv->settings, "x-resolution", "i", &x_resolution);
g_settings_get (priv->settings, "y-resolution", "i", &y_resolution);
g_settings_get (priv->settings, "photo-x-resolution", "i", &x_resolution);
g_settings_get (priv->settings, "photo-y-resolution", "i", &y_resolution);
g_settings_get (priv->settings, "camera", "s", &webcam_device);
g_settings_get (priv->settings, "brightness", "d", &brightness);
g_settings_get (priv->settings, "contrast", "d", &contrast);
......
......@@ -109,7 +109,7 @@ internal class Cheese.EffectsManager : GLib.Object
string user_effects = GLib.Path.build_filename (Environment.get_user_data_dir (), "gnome-video-effects");
effects.add_all (load_effects_from_directory (user_effects));
effects.sort((CompareFunc) sort_value);
effects.sort ((CompareFunc) sort_value);
/* add identity effect as the first in the effect list */
if (effects.size > 0)
......
......@@ -29,7 +29,8 @@ public class Cheese.PreferencesDialog : GLib.Object
private Gtk.Dialog dialog;
private Gtk.ComboBox resolution_combo;
private Gtk.ComboBox photo_resolution_combo;
private Gtk.ComboBox video_resolution_combo;
private Gtk.ComboBox source_combo;
private Gtk.Adjustment brightness_adjustment;
......@@ -47,6 +48,8 @@ public class Cheese.PreferencesDialog : GLib.Object
private Gtk.CheckButton countdown_check;
private Gtk.CheckButton flash_check;
private MediaMode current_mode;
public PreferencesDialog (Cheese.Camera camera, GLib.Settings settings)
{
......@@ -82,7 +85,8 @@ public class Cheese.PreferencesDialog : GLib.Object
this.hue_scale.add_mark (0, Gtk.PositionType.BOTTOM, null);
this.saturation_scale.add_mark (1, Gtk.PositionType.BOTTOM, null);
this.resolution_combo = (Gtk.ComboBox) builder.get_object ("resolution_combo_box");
this.photo_resolution_combo = (Gtk.ComboBox) builder.get_object ("photo_resolution_combo_box");
this.video_resolution_combo = (Gtk.ComboBox) builder.get_object ("video_resolution_combo_box");
this.source_combo = (Gtk.ComboBox) builder.get_object ("camera_combo_box");
this.burst_repeat_spin = (Gtk.SpinButton) builder.get_object ("burst_repeat");
......@@ -106,8 +110,11 @@ public class Cheese.PreferencesDialog : GLib.Object
{
CellRendererText cell = new CellRendererText ();
resolution_combo.pack_start (cell, false);
resolution_combo.set_attributes (cell, "text", 0);
photo_resolution_combo.pack_start (cell, false);
photo_resolution_combo.set_attributes (cell, "text", 0);
video_resolution_combo.pack_start (cell, false);
video_resolution_combo.set_attributes (cell, "text", 0);
source_combo.pack_start (cell, false);
source_combo.set_attributes (cell, "text", 0);
......@@ -137,7 +144,7 @@ public class Cheese.PreferencesDialog : GLib.Object
}
}
settings.set_string("camera", camera.get_selected_device ().get_device_file ());
settings.set_string ("camera", camera.get_selected_device ().get_device_file ());
setup_resolutions_for_device (camera.get_selected_device ());
}
......@@ -147,7 +154,8 @@ public class Cheese.PreferencesDialog : GLib.Object
unowned Cheese.VideoFormat format;
ListStore resolution_model = new ListStore (2, typeof (string), typeof (Cheese.VideoFormat));
resolution_combo.model = resolution_model;
photo_resolution_combo.model = resolution_model;
video_resolution_combo.model = resolution_model;
for (int i = 0; i < formats.length (); i++)
{
......@@ -160,25 +168,42 @@ public class Cheese.PreferencesDialog : GLib.Object
if (camera.get_current_video_format ().width == format.width &&
camera.get_current_video_format ().height == format.height)
{
resolution_combo.set_active_iter (iter);
settings.set_int("x-resolution", format.width);
settings.set_int("y-resolution", format.height);
photo_resolution_combo.set_active_iter (iter);
settings.set_int ("photo-x-resolution", format.width);
settings.set_int ("photo-y-resolution", format.height);
}
if (settings.get_int ("video-x-resolution") == format.width &&
settings.get_int ("video-y-resolution") == format.height)
{
video_resolution_combo.set_active_iter (iter);
}
}
/* Video resolution combo shows photo resolution by
* default if previous user choice is not found in settings or not supported
* by current device. These values are saved to settings.
*/
if (video_resolution_combo.get_active () == -1)
{
video_resolution_combo.set_active (photo_resolution_combo.get_active ());
settings.set_int ("video-x-resolution", settings.get_int ("photo-x-resolution"));
settings.set_int ("video-y-resolution", settings.get_int ("photo-y-resolution"));
}
}
private void initialize_values_from_settings ()
{
brightness_adjustment.value = settings.get_double("brightness");
contrast_adjustment.value = settings.get_double("contrast");
hue_adjustment.value = settings.get_double("hue");
saturation_adjustment.value = settings.get_double("saturation");
brightness_adjustment.value = settings.get_double ("brightness");
contrast_adjustment.value = settings.get_double ("contrast");
hue_adjustment.value = settings.get_double ("hue");
saturation_adjustment.value = settings.get_double ("saturation");
burst_repeat_spin.value = settings.get_int("burst-repeat");
burst_delay_spin.value = settings.get_int("burst-delay") / 1000;
burst_repeat_spin.value = settings.get_int ("burst-repeat");
burst_delay_spin.value = settings.get_int ("burst-delay") / 1000;
countdown_check.active = settings.get_boolean("countdown");
flash_check.active = settings.get_boolean("flash");
countdown_check.active = settings.get_boolean ("countdown");
flash_check.active = settings.get_boolean ("flash");
}
[CCode (instance_pos = -1)]
......@@ -193,11 +218,11 @@ public class Cheese.PreferencesDialog : GLib.Object
camera.set_device_by_dev_file (dev.get_device_file ());
camera.switch_camera_device ();
setup_resolutions_for_device (camera.get_selected_device ());
settings.set_string("camera", dev.get_device_file ());
settings.set_string ("camera", dev.get_device_file ());
}
[CCode (instance_pos = -1)]
public void on_resolution_change (Gtk.ComboBox combo)
public void on_photo_resolution_change (Gtk.ComboBox combo)
{
TreeIter iter;
......@@ -205,10 +230,29 @@ public class Cheese.PreferencesDialog : GLib.Object
combo.get_active_iter (out iter);
combo.model.get (iter, 1, out format);
camera.set_video_format (format);
if (current_mode == MediaMode.PHOTO || current_mode == MediaMode.BURST)
camera.set_video_format (format);
settings.set_int("x-resolution", format.width);
settings.set_int("y-resolution", format.height);
settings.set_int ("photo-x-resolution", format.width);
settings.set_int ("photo-y-resolution", format.height);
}
[CCode (instance_pos = -1)]
public void on_video_resolution_change (Gtk.ComboBox combo)
{
TreeIter iter;
unowned Cheese.VideoFormat format;
combo.get_active_iter (out iter);
combo.model.get (iter, 1, out format);
if (current_mode == MediaMode.VIDEO)
camera.set_video_format (format);
settings.set_int ("video-x-resolution", format.width);
settings.set_int ("video-y-resolution", format.height);
}
[CCode (instance_pos = -1)]
......@@ -220,57 +264,63 @@ public class Cheese.PreferencesDialog : GLib.Object
[CCode (instance_pos = -1)]
public void on_countdown_toggle (Gtk.CheckButton checkbutton)
{
settings.set_boolean("countdown", checkbutton.active);
settings.set_boolean ("countdown", checkbutton.active);
}
[CCode (instance_pos = -1)]
public void on_flash_toggle (Gtk.CheckButton checkbutton)
{
settings.set_boolean("flash", checkbutton.active);
settings.set_boolean ("flash", checkbutton.active);
}
[CCode (instance_pos = -1)]
public void on_burst_repeat_change (Gtk.SpinButton spinbutton)
{
settings.set_int("burst-repeat", (int) spinbutton.value);
settings.set_int ("burst-repeat", (int) spinbutton.value);
}
[CCode (instance_pos = -1)]
public void on_burst_delay_change (Gtk.SpinButton spinbutton)
{
settings.set_int("burst-delay", (int) spinbutton.value * 1000);
settings.set_int ("burst-delay", (int) spinbutton.value * 1000);
}
[CCode (instance_pos = -1)]
public void on_brightness_change (Gtk.Adjustment adjustment)
{
this.camera.set_balance_property ("brightness", adjustment.value);
settings.set_double("brightness", adjustment.value);
settings.set_double ("brightness", adjustment.value);
}
[CCode (instance_pos = -1)]
public void on_contrast_change (Gtk.Adjustment adjustment)
{
this.camera.set_balance_property ("contrast", adjustment.value);
settings.set_double("contrast", adjustment.value);
settings.set_double ("contrast", adjustment.value);
}
[CCode (instance_pos = -1)]
public void on_hue_change (Gtk.Adjustment adjustment)
{
this.camera.set_balance_property ("hue", adjustment.value);
settings.set_double("hue", adjustment.value);
settings.set_double ("hue", adjustment.value);
}
[CCode (instance_pos = -1)]
public void on_saturation_change (Gtk.Adjustment adjustment)
{
this.camera.set_balance_property ("saturation", adjustment.value);
settings.set_double("saturation", adjustment.value);
settings.set_double ("saturation", adjustment.value);
}
public void show ()
{
this.dialog.show_all ();
}
public void set_current_mode (MediaMode mode)
{
this.current_mode = mode;
}
}
......@@ -117,6 +117,7 @@ public class Cheese.MainWindow : Gtk.Window
{
if (preferences_dialog == null)
preferences_dialog = new Cheese.PreferencesDialog (camera, settings);
preferences_dialog.set_current_mode (current_mode);
preferences_dialog.show ();
}
......@@ -224,7 +225,7 @@ public class Cheese.MainWindow : Gtk.Window
Gtk.MessageType.ERROR,
Gtk.ButtonsType.OK,
"Could not delete %s",
file.get_path());
file.get_path ());
error_dialog.run ();
error_dialog.destroy ();
......@@ -258,7 +259,7 @@ public class Cheese.MainWindow : Gtk.Window
Gtk.MessageType.ERROR,
Gtk.ButtonsType.OK,
"Could not move %s to trash",
file.get_path());
file.get_path ());
error_dialog.run ();
error_dialog.destroy ();
......@@ -377,7 +378,7 @@ public class Cheese.MainWindow : Gtk.Window
[CCode (instance_pos = -1)]
public void on_layout_wide_mode (ToggleAction action)
{
if(!is_command_line_startup)
if (!is_command_line_startup)
{
/* Don't save to settings when using -w mode from command-line, so
* command-line options change the mode for one run only. */
......@@ -389,7 +390,7 @@ public class Cheese.MainWindow : Gtk.Window
[CCode (instance_pos = -1)]
public void on_layout_fullscreen (ToggleAction action)
{
if(!is_command_line_startup)
if (!is_command_line_startup)
{
/* Don't save to settings when using -f mode from command-line, so
* command-line options change the mode for one run only. */
......@@ -420,9 +421,53 @@ public class Cheese.MainWindow : Gtk.Window
effects_toggle_action.sensitive = false;
}
private void set_resolution(MediaMode mode)
{
if (camera == null)
return;
unowned GLib.List<VideoFormat> formats = camera.get_video_formats ();
if (formats == null)
return;
unowned Cheese.VideoFormat format;
int width = 0;
int height = 0;
switch (mode)
{
case MediaMode.PHOTO:
case MediaMode.BURST:
width = settings.get_int ("photo-x-resolution");
height = settings.get_int ("photo-y-resolution");
break;
case MediaMode.VIDEO:
width = settings.get_int ("video-x-resolution");
height = settings.get_int ("video-y-resolution");
break;
}
for (int i = 0; i < formats.length (); i++)
{
format = formats<VideoFormat>.nth (i).data;
if (width == format.width && height == format.height)
{
camera.set_video_format (format);
break;
}
}
}
private void set_mode (MediaMode mode)
{
this.current_mode = mode;
set_resolution (current_mode);
if (preferences_dialog != null)
preferences_dialog.set_current_mode (current_mode);
switch (this.current_mode)
{
case MediaMode.PHOTO:
......@@ -482,9 +527,9 @@ public class Cheese.MainWindow : Gtk.Window
private void set_fullscreen_mode (bool fullscreen_mode)
{
/* After the first time the window has been shown using this.show_all(),
/* After the first time the window has been shown using this.show_all (),
* the value of leave_fullscreen_button_container.no_show_all should be set to false
* So that the next time leave_fullscreen_button_container.show_all() is called, the button is actually shown
* So that the next time leave_fullscreen_button_container.show_all () is called, the button is actually shown
* FIXME: If this code can be made cleaner/clearer, please do */
is_fullscreen = fullscreen_mode;
......@@ -612,9 +657,9 @@ public class Cheese.MainWindow : Gtk.Window
string file_name = fileutil.get_new_media_filename (this.current_mode);
if (current_mode == MediaMode.VIDEO)
thumb_view.start_monitoring_video_path(fileutil.get_video_path ());
thumb_view.start_monitoring_video_path (fileutil.get_video_path ());
else
thumb_view.start_monitoring_photo_path(fileutil.get_photo_path ());
thumb_view.start_monitoring_photo_path (fileutil.get_photo_path ());
if (settings.get_boolean ("flash"))
{
......@@ -911,7 +956,7 @@ public class Cheese.MainWindow : Gtk.Window
for (int i = 0; i <= effects_manager.effects.size / EFFECTS_PER_PAGE; i++)
{
Clutter.TableLayout table_layout = new TableLayout();
Clutter.TableLayout table_layout = new TableLayout ();
Clutter.Box grid = new Clutter.Box (table_layout);
effects_grids.add (grid);
grid.set_size (viewport.width, viewport.height);
......@@ -1180,8 +1225,8 @@ public class Cheese.MainWindow : Gtk.Window
camera = new Camera (video_preview,
device,
settings.get_int ("x-resolution"),
settings.get_int ("y-resolution"));
settings.get_int ("photo-x-resolution"),
settings.get_int ("photo-y-resolution"));
try {
camera.setup (device);
}
......@@ -1200,19 +1245,19 @@ public class Cheese.MainWindow : Gtk.Window
if (effect != null)
camera.set_effect (effect);
value = settings.get_double("brightness");
value = settings.get_double ("brightness");
if (value != 0.0)
camera.set_balance_property ("brightness", value);
value = settings.get_double("contrast");
value = settings.get_double ("contrast");
if (value != 1.0)
camera.set_balance_property ("contrast", value);
value = settings.get_double("hue");
value = settings.get_double ("hue");
if (value != 0.0)
camera.set_balance_property ("hue", value);
value = settings.get_double("saturation");
value = settings.get_double ("saturation");
if (value != 1.0)
camera.set_balance_property ("saturation", value);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment