diff options
author | jstebbins <[email protected]> | 2009-04-17 17:29:38 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2009-04-17 17:29:38 +0000 |
commit | 6f64e12f82fd851dc630bd5d55a6954efac20e5b (patch) | |
tree | dba2e79c0b695650b99c2dc29dbedfb9b10180db /gtk | |
parent | 55ab7a83c83f973169e0ff4377e4588d6d40007e (diff) |
LinGui:
- add volume label to dvd source shortcuts in the file menu
- move loose crop option from preferences to picture settings
- add label to show cropped dimensions to picture settings
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2337 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/src/callbacks.c | 299 | ||||
-rw-r--r-- | gtk/src/ghb.ui | 186 | ||||
-rw-r--r-- | gtk/src/hb-backend.c | 128 | ||||
-rw-r--r-- | gtk/src/internal_defaults.xml | 8 | ||||
-rw-r--r-- | gtk/src/main.c | 3 |
5 files changed, 333 insertions, 291 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index bad0db24e..e2b8c3c40 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -275,7 +275,7 @@ on_quit1_activate(GtkMenuItem *quit, signal_user_data_t *ud) gint state = ghb_get_queue_state(); g_debug("on_quit1_activate ()"); if (state & GHB_STATE_WORKING) - { + { if (ghb_cancel_encode("Closing HandBrake will terminate encoding.\n")) { ghb_hb_cleanup(FALSE); @@ -290,59 +290,6 @@ on_quit1_activate(GtkMenuItem *quit, signal_user_data_t *ud) gtk_main_quit(); } -static void -set_destination(signal_user_data_t *ud) -{ - g_debug("set_destination"); - if (ghb_settings_get_boolean(ud->settings, "use_source_name")) - { - GString *str = g_string_new(""); - gchar *vol_name, *filename, *extension; - gchar *new_name; - gint title; - - filename = ghb_settings_get_string(ud->settings, "dest_file"); - extension = ghb_settings_get_string(ud->settings, "FileFormat"); - vol_name = ghb_settings_get_string(ud->settings, "volume_label"); - g_string_append_printf(str, "%s", vol_name); - title = ghb_settings_combo_int(ud->settings, "title"); - if (title >= 0) - { - if (ghb_settings_get_boolean( - ud->settings, "title_no_in_destination")) - { - - title = ghb_settings_combo_int(ud->settings, "title"); - g_string_append_printf(str, " - %d", title+1); - } - if (ghb_settings_get_boolean( - ud->settings, "chapters_in_destination")) - { - gint start, end; - - if (!ghb_settings_get_boolean( - ud->settings, "title_no_in_destination")) - { - g_string_append_printf(str, " -"); - } - start = ghb_settings_get_int(ud->settings, "start_chapter"); - end = ghb_settings_get_int(ud->settings, "end_chapter"); - if (start == end) - g_string_append_printf(str, " Ch %d", start); - else - g_string_append_printf(str, " Ch %d-%d", start, end); - } - } - g_string_append_printf(str, ".%s", extension); - new_name = g_string_free(str, FALSE); - ghb_ui_update(ud, "dest_file", ghb_string_value(new_name)); - g_free(filename); - g_free(extension); - g_free(vol_name); - g_free(new_name); - } -} - gboolean uppers_and_unders(const gchar *str) { @@ -399,6 +346,125 @@ camel_convert(gchar *str) } } +#if defined(_WIN32) +static gchar* +get_dvd_device_name(gchar *device) +{ + return g_strdup(device); +} +#else +static gchar* +get_dvd_device_name(GDrive *gd) +{ + return g_drive_get_identifier(gd, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE); +} +#endif + +#if defined(_WIN32) +static gchar* +get_dvd_volume_name(const gchar *drive) +{ + gchar *result; + gchar vname[51], fsname[51]; + if (GetVolumeInformation(drive, vname, 50, NULL, NULL, NULL, fsname, 51)) + { + result = g_strdup_printf("%s (%s)", vname, drive); + } + else + { + result = g_strdup_printf("%s", drive); + } + return result; +} +#else +static gchar* +get_dvd_volume_name(GDrive *gd) +{ + gchar *label; + gchar *result; + gchar *drive; + + drive = g_drive_get_identifier(gd, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE); + if (g_drive_has_media (gd)) + { + label = ghb_dvd_volname (drive); + if (label != NULL) + { + if (uppers_and_unders(label)) + { + camel_convert(label); + } + result = g_strdup_printf("%s - %s", drive, label); + g_free(label); + } + else + { + result = g_strdup_printf("%s", drive); + } + } + else + { + result = g_strdup_printf("%s", drive); + } + g_free(drive); + return result; +} +#endif + + +static void +set_destination(signal_user_data_t *ud) +{ + g_debug("set_destination"); + if (ghb_settings_get_boolean(ud->settings, "use_source_name")) + { + GString *str = g_string_new(""); + gchar *vol_name, *filename, *extension; + gchar *new_name; + gint title; + + filename = ghb_settings_get_string(ud->settings, "dest_file"); + extension = ghb_settings_get_string(ud->settings, "FileFormat"); + vol_name = ghb_settings_get_string(ud->settings, "volume_label"); + g_string_append_printf(str, "%s", vol_name); + title = ghb_settings_combo_int(ud->settings, "title"); + if (title >= 0) + { + if (ghb_settings_get_boolean( + ud->settings, "title_no_in_destination")) + { + + title = ghb_settings_combo_int(ud->settings, "title"); + g_string_append_printf(str, " - %d", title+1); + } + if (ghb_settings_get_boolean( + ud->settings, "chapters_in_destination")) + { + gint start, end; + + if (!ghb_settings_get_boolean( + ud->settings, "title_no_in_destination")) + { + g_string_append_printf(str, " -"); + } + start = ghb_settings_get_int(ud->settings, "start_chapter"); + end = ghb_settings_get_int(ud->settings, "end_chapter"); + if (start == end) + g_string_append_printf(str, " Ch %d", start); + else + g_string_append_printf(str, " Ch %d-%d", start, end); + } + } + g_string_append_printf(str, ".%s", extension); + new_name = g_string_free(str, FALSE); + ghb_ui_update(ud, "dest_file", ghb_string_value(new_name)); + g_free(filename); + g_free(extension); + g_free(vol_name); + g_free(new_name); + } +} + static gchar* get_file_label(const gchar *filename) { @@ -422,26 +488,6 @@ get_file_label(const gchar *filename) } static gchar* -get_drive_name(const gchar *drive) -{ - gchar *result; -#if defined(_WIN32) - gchar vname[51], fsname[51]; - if (GetVolumeInformation(drive, vname, 50, NULL, NULL, NULL, fsname, 51)) - { - result = g_strdup_printf("%s (%s)", vname, drive); - } - else - { - result = g_strdup_printf("%s", drive); - } -#else - result = g_strdup_printf("%s", drive); -#endif - return result; -} - -static gchar* resolve_drive_name(gchar *filename) { #if defined(_WIN32) @@ -663,9 +709,10 @@ source_dialog_extra_widgets( gtk_combo_box_append_text (combo, "Not Selected"); while (link != NULL) { - gchar *name = (gchar*)link->data; + gchar *name = get_dvd_volume_name(link->data); gtk_combo_box_append_text(combo, name); g_free(name); + g_object_unref(link->data); link = link->next; } g_list_free(drives); @@ -1172,7 +1219,7 @@ show_title_info(signal_user_data_t *ud, ghb_title_info_t *tinfo) widget = GHB_WIDGET (ud->builder, "start_chapter"); gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), 1); gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, tinfo->num_chapters); - ud->dont_clear_presets = TRUE; + ud->dont_clear_presets = FALSE; } static gboolean update_preview = FALSE; @@ -1410,6 +1457,8 @@ crop_changed_cb(GtkWidget *widget, signal_user_data_t *ud) widget = GHB_WIDGET (ud->builder, "crop_dimensions"); text = g_strdup_printf ("%d x %d", width, height); gtk_label_set_text (GTK_LABEL(widget), text); + widget = GHB_WIDGET (ud->builder, "crop_dimensions2"); + gtk_label_set_text (GTK_LABEL(widget), text); g_free(text); } gchar *text; @@ -2560,13 +2609,6 @@ chapter_edited_cb( gtk_tree_path_free (treepath); } -G_MODULE_EXPORT void -chapter_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_t *ud) -{ - g_debug("chapter_list_selection_changed_cb ()"); - //chapter_selection_changed = TRUE; -} - void debug_log_handler(const gchar *domain, GLogLevelFlags flags, const gchar *msg, gpointer data) { @@ -2686,28 +2728,33 @@ ghb_file_menu_add_dvd(signal_user_data_t *ud) { GList *link, *drives; static GtkActionGroup *agroup = NULL; + static gint merge_id; link = drives = dvd_device_list(); if (drives != NULL) { GtkUIManager *ui = GTK_UI_MANAGER( gtk_builder_get_object(ud->builder, "uimanager1")); - guint merge_id = gtk_ui_manager_new_merge_id(ui); + if (agroup == NULL) { agroup = gtk_action_group_new("dvdgroup"); - // Add separator gtk_ui_manager_insert_action_group(ui, agroup, 0); - gtk_ui_manager_add_ui(ui, merge_id, - "ui/menubar1/menuitem1/quit1", "dvdsep", NULL, - GTK_UI_MANAGER_SEPARATOR, TRUE); } + else + gtk_ui_manager_remove_ui(ui, merge_id); + + merge_id = gtk_ui_manager_new_merge_id(ui); + // Add separator + gtk_ui_manager_add_ui(ui, merge_id, + "ui/menubar1/menuitem1/quit1", "dvdsep", NULL, + GTK_UI_MANAGER_SEPARATOR, TRUE); while (link != NULL) { GtkAction *action; - gchar *drive = (gchar*)link->data; - gchar *name = get_drive_name(drive); + gchar *drive = get_dvd_device_name(link->data); + gchar *name = get_dvd_volume_name(link->data); action = gtk_action_group_get_action(agroup, drive); if (action != NULL) @@ -2723,13 +2770,13 @@ ghb_file_menu_add_dvd(signal_user_data_t *ud) // Add to ui manager gtk_ui_manager_add_ui(ui, merge_id, "ui/menubar1/menuitem1/dvdsep", drive, drive, - //"ui/menubar1/menuitem1/quit1", drive, drive, GTK_UI_MANAGER_AUTO, TRUE); // Connect signal to action (menu item) g_signal_connect(action, "activate", (GCallback)dvd_source_activate_cb, ud); g_free(name); g_free(drive); + g_object_unref(link->data); link = link->next; } g_list_free(drives); @@ -2779,11 +2826,10 @@ dvd_device_list() gd = (GDrive*)link->data; if (ghb_is_cd(gd)) { - gchar *device; - device = g_drive_get_identifier(gd, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE); - dvd_devices = g_list_append(dvd_devices, (gpointer)device); + dvd_devices = g_list_append(dvd_devices, gd); } - g_object_unref (gd); + else + g_object_unref (gd); link = link->next; } g_list_free(drives); @@ -2823,6 +2869,8 @@ handle_media_change(const gchar *device, gboolean insert, signal_user_data_t *ud static gint ins_count = 0; static gint rem_count = 0; + // The media change event in windows bounces around a bit + // so I debounce it here // DVD insertion detected. Scan it. dtype = GetDriveType(device); if (dtype != DRIVE_CDROM) @@ -2841,9 +2889,7 @@ handle_media_change(const gchar *device, gboolean insert, signal_user_data_t *ud progress = GTK_PROGRESS_BAR(GHB_WIDGET (ud->builder, "progressbar")); gtk_progress_bar_set_text (progress, "Scanning ..."); gtk_progress_bar_set_fraction (progress, 0); - update_source_label(ud, device); - ghb_hb_cleanup(TRUE); - prune_logs(ud); + update_source_label(ud, device); gint preview_count; preview_count = ghb_settings_get_int(ud->settings, "preview_count"); ghb_backend_scan(device, 0, preview_count); @@ -2926,43 +2972,34 @@ wm_drive_changed(MSG *msg, signal_user_data_t *ud) G_MODULE_EXPORT void drive_changed_cb(GVolumeMonitor *gvm, GDrive *gd, signal_user_data_t *ud) { + g_debug("drive_changed_cb()"); + ghb_file_menu_add_dvd(ud); + gchar *device; - gint state = ghb_get_scan_state(); - static gboolean first_time = TRUE; - if (state != GHB_STATE_IDLE) return; - if (ud->current_dvd_device == NULL) return; - // A drive change event happens when the program initially starts - // and I don't want to automatically scan at that time. - if (first_time) + device = g_drive_get_identifier(gd, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE); + if (ud->current_dvd_device == NULL || + strcmp(device, ud->current_dvd_device) != 0) { - first_time = FALSE; return; } - device = g_drive_get_identifier(gd, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE); - - // DVD insertion detected. Scan it. - if (strcmp(device, ud->current_dvd_device) == 0) + if (g_drive_has_media(gd)) { - if (g_drive_has_media (gd)) - { - GtkProgressBar *progress; - progress = GTK_PROGRESS_BAR(GHB_WIDGET (ud->builder, "progressbar")); - gtk_progress_bar_set_text (progress, "Scanning ..."); - gtk_progress_bar_set_fraction (progress, 0); - update_source_label(ud, device); - prune_logs(ud); - gint preview_count; - preview_count = ghb_settings_get_int(ud->settings, "preview_count"); - ghb_backend_scan(device, 0, preview_count); - } - else - { - prune_logs(ud); - ghb_backend_scan("/dev/null", 0, 1); - } + GtkProgressBar *progress; + progress = GTK_PROGRESS_BAR(GHB_WIDGET (ud->builder, "progressbar")); + gtk_progress_bar_set_text (progress, "Scanning ..."); + gtk_progress_bar_set_fraction (progress, 0); + update_source_label(ud, device); + gint preview_count; + preview_count = ghb_settings_get_int(ud->settings, "preview_count"); + ghb_backend_scan(device, 0, preview_count); + } + else + { + ghb_hb_cleanup(TRUE); + prune_logs(ud); + ghb_backend_scan("/dev/null", 0, 1); } - g_free(device); } #endif @@ -3464,13 +3501,13 @@ ghb_check_update(signal_user_data_t *ud) g_debug("ghb_check_update"); if (hb_get_build(NULL) % 100) { - query = + query = "GET /appcast_unstable.xml HTTP/1.0\r\nHost: handbrake.fr\r\n\r\n"; } else { stable_update_lock = TRUE; - query = "GET /appcast.xml HTTP/1.0\r\nHost: handbrake.fr\r\n\r\n"; + query = "GET /appcast.xml HTTP/1.0\r\nHost: handbrake.fr\r\n\r\n"; } ioc = ghb_net_open(ud, "handbrake.fr", 80); if (ioc == NULL) @@ -3493,7 +3530,7 @@ check_stable_update(signal_user_data_t *ud) g_debug("check_stable_update"); stable_update_lock = TRUE; - query = "GET /appcast.xml HTTP/1.0\r\nHost: handbrake.fr\r\n\r\n"; + query = "GET /appcast.xml HTTP/1.0\r\nHost: handbrake.fr\r\n\r\n"; ioc = ghb_net_open(ud, "handbrake.fr", 80); if (ioc == NULL) return NULL; diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui index 1a50256fa..0ae7f93c7 100644 --- a/gtk/src/ghb.ui +++ b/gtk/src/ghb.ui @@ -3420,24 +3420,6 @@ non-hidef screens. </property> </packing> </child> <child> - <object class="GtkCheckButton" id="noscale"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="tooltip_text">When picture settings require that the image -dimensions be rounded to some multiple number -of pixels. This setting will crop a few extra pixels -instead of doing exact cropping and scaling to -the required multiple.</property> - <property name="label" translatable="yes">Loose cropping</property> - <property name="draw_indicator">True</property> - <signal name="toggled" handler="pref_changed_cb"/> - </object> - <packing> - <property name="expand">False</property> - <property name="position">4</property> - </packing> - </child> - <child> <object class="GtkAlignment" id="alignment50"> <property name="visible">True</property> <property name="left_padding">4</property> @@ -3480,7 +3462,7 @@ increases scan duration.</property> </object> <packing> <property name="expand">False</property> - <property name="position">5</property> + <property name="position">4</property> </packing> </child> @@ -3520,7 +3502,7 @@ in the Video settings tab.</property> </object> <packing> <property name="expand">False</property> - <property name="position">6</property> + <property name="position">5</property> </packing> </child> <child> @@ -3537,7 +3519,7 @@ location as the movie.</property> </object> <packing> <property name="expand">False</property> - <property name="position">7</property> + <property name="position">6</property> </packing> </child> @@ -3575,7 +3557,7 @@ location as the movie.</property> </object> <packing> <property name="expand">False</property> - <property name="position">8</property> + <property name="position">7</property> </packing> </child> @@ -3588,7 +3570,7 @@ location as the movie.</property> </object> <packing> <property name="expand">False</property> - <property name="position">9</property> + <property name="position">8</property> </packing> </child> <child> @@ -3600,7 +3582,7 @@ location as the movie.</property> </object> <packing> <property name="expand">False</property> - <property name="position">10</property> + <property name="position">9</property> </packing> </child> </object> @@ -4152,6 +4134,15 @@ location as the movie.</property> <property name="label_xalign">0</property> <property name="shadow_type">none</property> <child> + <object class="GtkAlignment" id="alignment46"> + <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">2</property> + <property name="left_padding">12</property> + <property name="right_padding">2</property> + + <child> <object class="GtkVBox" id="vbox6"> <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> @@ -4160,33 +4151,7 @@ location as the movie.</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="n_rows">5</property> - <property name="n_columns">5</property> - <child> - <object class="GtkLabel" id="label20"> - <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">Left</property> - <property name="width_chars">4</property> - </object> - <packing> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options"></property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label41"> - <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="yalign">1</property> - <property name="label" translatable="yes">Top</property> - </object> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="x_options"></property> - </packing> - </child> + <property name="n_columns">6</property> <child> <object class="GtkSpinButton" id="PictureLeftCrop"> <property name="visible">True</property> @@ -4196,25 +4161,10 @@ location as the movie.</property> <signal name="value_changed" handler="crop_changed_cb"/> </object> <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options"></property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label24"> - <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="yalign">0</property> - <property name="label" translatable="yes">Bottom</property> - </object> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">4</property> - <property name="bottom_attach">5</property> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> <property name="x_options"></property> </packing> </child> @@ -4227,10 +4177,10 @@ location as the movie.</property> <signal name="value_changed" handler="crop_changed_cb"/> </object> <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <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="top_attach">0</property> + <property name="bottom_attach">1</property> <property name="x_options"></property> </packing> </child> @@ -4243,10 +4193,10 @@ location as the movie.</property> <signal name="value_changed" handler="crop_changed_cb"/> </object> <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> <property name="x_options"></property> </packing> </child> @@ -4259,43 +4209,50 @@ location as the movie.</property> <signal name="value_changed" handler="crop_changed_cb"/> </object> <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> <property name="x_options"></property> </packing> </child> <child> - <object class="GtkLabel" id="label25"> + <object class="GtkCheckButton" id="PictureAutoCrop"> + <property name="label" translatable="yes">Auto Crop</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="label" translatable="yes">Right</property> - <property name="width_chars">4</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="scale_changed_cb"/> </object> <packing> - <property name="left_attach">4</property> - <property name="right_attach">5</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options"></property> + <property name="y_options"></property> + <property name="left_attach">0</property> + <property name="right_attach">2</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> </packing> </child> <child> - <object class="GtkCheckButton" id="PictureAutoCrop"> - <property name="label" translatable="yes">Auto Crop</property> + <object class="GtkCheckButton" id="PictureLooseCrop"> <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">When picture settings require that the image +dimensions be rounded to some multiple number +of pixels. This setting will crop a few extra pixels +instead of doing exact cropping and scaling to +the required multiple.</property> + <property name="label" translatable="yes">Loose crop</property> <property name="draw_indicator">True</property> <signal name="toggled" handler="scale_changed_cb"/> </object> <packing> + <property name="y_options"></property> <property name="left_attach">0</property> <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> </packing> </child> <child> @@ -4343,15 +4300,46 @@ location as the movie.</property> <child> <placeholder/> </child> - <child> - <placeholder/> - </child> </object> <packing> <property name="expand">False</property> <property name="position">0</property> </packing> </child> + <child> + <object class="GtkHBox" id="hbox78"> + <property name="visible">True</property> + <property name="spacing">4</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="label97"> + <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="xalign">0</property> + <property name="label" translatable="yes">Crop Dimensions:</property> + </object> + <packing> + <property name="expand">False</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="crop_dimensions2"> + <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">--</property> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> </child> <child type="label"> diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index 8ff42aac4..ce4225a99 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -2580,23 +2580,33 @@ picture_settings_deps(signal_user_data_t *ud) gboolean autoscale, keep_aspect, enable_keep_aspect; gboolean enable_scale_width, enable_scale_height; gboolean enable_disp_width, enable_disp_height; - gint pic_par, disp_width, disp_height, scale_width, scale_height; + gint pic_par; + GtkWidget *widget; pic_par = ghb_settings_combo_int(ud->settings, "PicturePAR"); + if (pic_par == 1) + { + ghb_ui_update(ud, "autoscale", ghb_boolean_value(TRUE)); + ghb_ui_update(ud, "PictureAlignment", ghb_int_value(2)); + ghb_ui_update(ud, "PictureLooseCrop", ghb_boolean_value(TRUE)); + } + enable_keep_aspect = (pic_par != 1 && pic_par != 2); + if (!enable_keep_aspect) + { + ghb_ui_update(ud, "PictureKeepRatio", ghb_boolean_value(TRUE)); + } keep_aspect = ghb_settings_get_boolean(ud->settings, "PictureKeepRatio"); autoscale = ghb_settings_get_boolean(ud->settings, "autoscale"); - disp_width = ghb_settings_get_int(ud->settings, "PictureDisplayWidth"); - disp_height = ghb_settings_get_int(ud->settings, "PictureDisplayHeight"); - scale_width = ghb_settings_get_int(ud->settings, "scale_width"); - scale_height = ghb_settings_get_int(ud->settings, "scale_height"); enable_scale_width = !autoscale && (pic_par != 1); enable_scale_height = !autoscale && (pic_par != 1); enable_disp_width = (pic_par == 3) && !keep_aspect; enable_disp_height = FALSE; - enable_keep_aspect = (pic_par != 1 && pic_par != 2); - GtkWidget *widget; + widget = GHB_WIDGET(ud->builder, "PictureAlignment"); + gtk_widget_set_sensitive(widget, pic_par != 1); + widget = GHB_WIDGET(ud->builder, "PictureLooseCrop"); + gtk_widget_set_sensitive(widget, pic_par != 1); widget = GHB_WIDGET(ud->builder, "scale_width"); gtk_widget_set_sensitive(widget, enable_scale_width); widget = GHB_WIDGET(ud->builder, "scale_height"); @@ -2609,14 +2619,6 @@ picture_settings_deps(signal_user_data_t *ud) gtk_widget_set_sensitive(widget, enable_keep_aspect); widget = GHB_WIDGET(ud->builder, "autoscale"); gtk_widget_set_sensitive(widget, pic_par != 1); - if (!enable_keep_aspect) - { - ghb_ui_update(ud, "PictureKeepRatio", ghb_boolean_value(TRUE)); - } - if (pic_par == 1) - { - ghb_ui_update(ud, "autoscale", ghb_boolean_value(TRUE)); - } } void @@ -2638,9 +2640,9 @@ ghb_set_scale(signal_user_data_t *ud, gint mode) gint mod; gint max_width = 0; gint max_height = 0; + static gboolean busy = FALSE; g_debug("ghb_set_scale ()\n"); - if (h_scan == NULL) return; list = hb_get_titles( h_scan ); if( !hb_list_count( list ) ) @@ -2655,6 +2657,11 @@ ghb_set_scale(signal_user_data_t *ud, gint mode) if (title == NULL) return; job = title->job; if (job == NULL) return; + + picture_settings_deps(ud); + if (busy) return; + busy = TRUE; + // First configure widgets mod = ghb_settings_combo_int(ud->settings, "PictureAlignment"); @@ -2664,7 +2671,7 @@ ghb_set_scale(signal_user_data_t *ud, gint mode) autoscale = ghb_settings_get_boolean(ud->settings, "autoscale"); // "Noscale" is a flag that says we prefer to crop extra to satisfy // alignment constraints rather than scaling to satisfy them. - noscale = ghb_settings_get_boolean(ud->settings, "noscale"); + noscale = ghb_settings_get_boolean(ud->settings, "PictureLooseCrop"); // Align dimensions to either 16 or 2 pixels // The scaler crashes if the dimensions are not divisible by 2 // x264 also will not accept dims that are not multiple of 2 @@ -2679,39 +2686,36 @@ ghb_set_scale(signal_user_data_t *ud, gint mode) gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), step, 16); widget = GHB_WIDGET (ud->builder, "scale_height"); gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), step, 16); + if (noscale) + { + widget = GHB_WIDGET (ud->builder, "PictureTopCrop"); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), step, 16); + widget = GHB_WIDGET (ud->builder, "PictureBottomCrop"); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), step, 16); + widget = GHB_WIDGET (ud->builder, "PictureLeftCrop"); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), step, 16); + widget = GHB_WIDGET (ud->builder, "PictureRightCrop"); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), step, 16); + } + else + { + widget = GHB_WIDGET (ud->builder, "PictureTopCrop"); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), 1, 16); + widget = GHB_WIDGET (ud->builder, "PictureBottomCrop"); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), 1, 16); + widget = GHB_WIDGET (ud->builder, "PictureLeftCrop"); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), 1, 16); + widget = GHB_WIDGET (ud->builder, "PictureRightCrop"); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), 1, 16); + } ghb_title_info_t tinfo; - if (autocrop && ghb_get_title_info (&tinfo, titleindex)) + ghb_get_title_info (&tinfo, titleindex); + if (autocrop) { crop[0] = tinfo.crop[0]; crop[1] = tinfo.crop[1]; crop[2] = tinfo.crop[2]; crop[3] = tinfo.crop[3]; - if (noscale) - { - gint need1, need2; - - // Adjust the cropping to accomplish the desired width and height - crop_width = tinfo.width - crop[2] - crop[3]; - crop_height = tinfo.height - crop[0] - crop[1]; - width = MOD_DOWN(crop_width, mod); - height = MOD_DOWN(crop_height, mod); - - need1 = (crop_height - height) / 2; - need2 = crop_height - height - need1; - crop[0] += need1; - crop[1] += need2; - need1 = (crop_width - width) / 2; - need2 = crop_width - width - need1; - crop[2] += need1; - crop[3] += need2; - } - if (mod == 1) - { - crop[0] = MOD_UP(crop[0], 2); - crop[1] = MOD_UP(crop[1], 2); - crop[2] = MOD_UP(crop[2], 2); - crop[3] = MOD_UP(crop[3], 2); - } ghb_ui_update(ud, "PictureTopCrop", ghb_int64_value(crop[0])); ghb_ui_update(ud, "PictureBottomCrop", ghb_int64_value(crop[1])); ghb_ui_update(ud, "PictureLeftCrop", ghb_int64_value(crop[2])); @@ -2723,17 +2727,29 @@ ghb_set_scale(signal_user_data_t *ud, gint mode) crop[1] = ghb_settings_get_int(ud->settings, "PictureBottomCrop"); crop[2] = ghb_settings_get_int(ud->settings, "PictureLeftCrop"); crop[3] = ghb_settings_get_int(ud->settings, "PictureRightCrop"); - if (mod == 1) - { - crop[0] = MOD_UP(crop[0], 2); - crop[1] = MOD_UP(crop[1], 2); - crop[2] = MOD_UP(crop[2], 2); - crop[3] = MOD_UP(crop[3], 2); - ghb_ui_update(ud, "PictureTopCrop", ghb_int64_value(crop[0])); - ghb_ui_update(ud, "PictureBottomCrop", ghb_int64_value(crop[1])); - ghb_ui_update(ud, "PictureLeftCrop", ghb_int64_value(crop[2])); - ghb_ui_update(ud, "PictureRightCrop", ghb_int64_value(crop[3])); - } + } + if (noscale) + { + gint need1, need2; + + // Adjust the cropping to accomplish the desired width and height + crop_width = tinfo.width - crop[2] - crop[3]; + crop_height = tinfo.height - crop[0] - crop[1]; + width = MOD_DOWN(crop_width, mod); + height = MOD_DOWN(crop_height, mod); + + need1 = (crop_height - height) / 2; + need2 = crop_height - height - need1; + crop[0] += need1; + crop[1] += need2; + need1 = (crop_width - width) / 2; + need2 = crop_width - width - need1; + crop[2] += need1; + crop[3] += need2; + ghb_ui_update(ud, "PictureTopCrop", ghb_int64_value(crop[0])); + ghb_ui_update(ud, "PictureBottomCrop", ghb_int64_value(crop[1])); + ghb_ui_update(ud, "PictureLeftCrop", ghb_int64_value(crop[2])); + ghb_ui_update(ud, "PictureRightCrop", ghb_int64_value(crop[3])); } hb_reduce(&aspect_n, &aspect_d, title->width * title->pixel_aspect_width, @@ -2905,7 +2921,7 @@ ghb_set_scale(signal_user_data_t *ud, gint mode) ghb_ui_update(ud, "par_height", ghb_int64_value(par_height)); ghb_ui_update(ud, "PictureDisplayWidth", ghb_int64_value(disp_width)); ghb_ui_update(ud, "PictureDisplayHeight", ghb_int64_value(height)); - picture_settings_deps(ud); + busy = FALSE; } static void diff --git a/gtk/src/internal_defaults.xml b/gtk/src/internal_defaults.xml index 3c2beaf92..4a082fc7c 100644 --- a/gtk/src/internal_defaults.xml +++ b/gtk/src/internal_defaults.xml @@ -28,6 +28,10 @@ <false /> <key>preset_type_normal</key> <true /> + <key>PictureDisplayWidth</key> + <integer>720</integer> + <key>PictureDisplayHeight</key> + <integer>480</integer> <key>scale_height</key> <integer>0</integer> <key>scale_width</key> @@ -116,8 +120,6 @@ <false /> <key>reduce_hd_preview</key> <true /> - <key>noscale</key> - <false /> <key>preview_count</key> <integer>10</integer> <key>preview_fullscreen</key> @@ -172,6 +174,8 @@ <string>mp4</string> <key>Folder</key> <false /> + <key>PictureLooseCrop</key> + <false /> <key>PictureAlignment</key> <integer>16</integer> <key>PictureDeblock</key> diff --git a/gtk/src/main.c b/gtk/src/main.c index e67b3db13..d4a1e87cb 100644 --- a/gtk/src/main.c +++ b/gtk/src/main.c @@ -201,7 +201,6 @@ change_font(GtkWidget *widget, gpointer data) //gtk_container_foreach((GtkContainer*)window, change_font, "sans 20"); #endif -extern G_MODULE_EXPORT void chapter_list_selection_changed_cb(void); extern G_MODULE_EXPORT void chapter_edited_cb(void); extern G_MODULE_EXPORT void chapter_keypress_cb(void); @@ -239,7 +238,6 @@ bind_chapter_tree_model (signal_user_data_t *ud) g_signal_connect(cell, "key-press-event", chapter_keypress_cb, ud); g_signal_connect(cell, "edited", chapter_edited_cb, ud); - g_signal_connect(selection, "changed", chapter_list_selection_changed_cb, ud); g_debug("Done\n"); } @@ -485,7 +483,6 @@ static GOptionEntry entries[] = }; G_MODULE_EXPORT void drive_changed_cb(GVolumeMonitor *gvm, GDrive *gd, signal_user_data_t *ud); -//void drive_disconnected_cb(GnomeVFSVolumeMonitor *gvm, GnomeVFSDrive *gd, signal_user_data_t *ud); #if defined(_WIN32) G_MODULE_EXPORT GdkFilterReturn |