G_MODULE_EXPORT void x264_entry_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { g_debug("x264_entry_changed_cb ()"); if (video_option_tooltip == NULL) { GtkWidget *eo = GTK_WIDGET(GHB_WIDGET(ud->builder, "VideoOptionExtra")); video_option_tooltip = gtk_widget_get_tooltip_text(eo); } if (!ignore_options_update) { GtkWidget *textview; const gchar *options; textview = GTK_WIDGET(GHB_WIDGET(ud->builder, "x264Option")); ghb_widget_to_setting(ud->settings, textview); options = ghb_dict_get_string(ud->settings, "x264Option"); ignore_options_update = TRUE; ghb_x264_parse_options(ud, options); if (!gtk_widget_has_focus(textview)) { gchar *sopts; sopts = sanitize_x264opts(ud, options); ghb_update_x264Option(ud, sopts); ghb_x264_parse_options(ud, sopts); if (ghb_dict_get_bool(ud->settings, "x264UseAdvancedOptions")) { GtkWidget *eo; eo = GTK_WIDGET(GHB_WIDGET(ud->builder, "VideoOptionExtra")); char * tt; if (sopts) tt = g_strdup_printf(_("%s\n\nExpanded Options:\n\"%s\""), video_option_tooltip, sopts); else tt = g_strdup_printf(_("%s\n\nExpanded Options:\n\"\""), video_option_tooltip); gtk_widget_set_tooltip_text(eo, tt); g_free(tt); } g_free(sopts); } ignore_options_update = FALSE; } }
G_MODULE_EXPORT void x264_entry_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { g_debug("x264_entry_changed_cb ()"); static char *tt = NULL; if (tt == NULL) { GtkWidget *eo = GTK_WIDGET(GHB_WIDGET(ud->builder, "x264OptionExtra")); tt = gtk_widget_get_tooltip_text(eo); } if (!ignore_options_update) { GtkWidget *textview; gchar *options; textview = GTK_WIDGET(GHB_WIDGET(ud->builder, "x264Option")); ghb_widget_to_setting(ud->settings, textview); options = ghb_settings_get_string(ud->settings, "x264Option"); ignore_options_update = TRUE; ghb_x264_parse_options(ud, options); if (!gtk_widget_has_focus(textview)) { gchar *sopts; sopts = sanitize_x264opts(ud, options); ghb_ui_update(ud, "x264Option", ghb_string_value(sopts)); ghb_x264_parse_options(ud, sopts); GtkWidget *eo = GTK_WIDGET(GHB_WIDGET(ud->builder, "x264OptionExtra")); char * new_tt; if (sopts) new_tt = g_strdup_printf("%s\n\nExpanded Options:\n\"%s\"", tt, sopts); else new_tt = g_strdup_printf("%s\n\nExpanded Options:\n\"\"", tt); gtk_widget_set_tooltip_text(eo, new_tt); g_free(new_tt); g_free(options); options = sopts; } g_free(options); ignore_options_update = FALSE; } }
G_MODULE_EXPORT gboolean lavc_focus_out_cb(GtkWidget *widget, GdkEventFocus *event, signal_user_data_t *ud) { ghb_widget_to_setting(ud->settings, widget); #if 0 gchar *options, *sopts; **************************************************************** When there are lavc widget in the future, this will be populated **************************************************************** options = ghb_settings_get_string(ud->settings, "x264Option"); sopts = sanitize_x264opts(ud, options); ignore_options_update = TRUE; if (sopts != NULL && strcmp(sopts, options) != 0) { ghb_ui_update(ud, "x264Option", ghb_string_value(sopts)); ghb_x264_parse_options(ud, sopts); } g_free(options); g_free(sopts); ignore_options_update = FALSE; #endif return FALSE; }
G_MODULE_EXPORT gboolean x264_focus_out_cb(GtkWidget *widget, GdkEventFocus *event, signal_user_data_t *ud) { const gchar *options; gchar *sopts; ghb_widget_to_setting(ud->settings, widget); options = ghb_dict_get_string(ud->settings, "x264Option"); sopts = sanitize_x264opts(ud, options); ignore_options_update = TRUE; if (sopts != NULL && strcmp(sopts, options) != 0) { ghb_ui_update(ud, "x264Option", ghb_string_value(sopts)); ghb_x264_parse_options(ud, sopts); } g_free(sopts); ignore_options_update = FALSE; return FALSE; }
int main (int argc, char *argv[]) { signal_user_data_t *ud; GValue *preset; GError *error = NULL; GOptionContext *context; #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif if (!g_thread_supported()) g_thread_init(NULL); context = g_option_context_new ("- Transcode media formats"); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (TRUE)); #if defined(_ENABLE_GST) g_option_context_add_group (context, gst_init_get_option_group ()); #endif g_option_context_parse (context, &argc, &argv, &error); g_option_context_free(context); if (argc > 1 && dvd_device == NULL && argv[1][0] != '-') { dvd_device = argv[1]; } gtk_init (&argc, &argv); gtk_rc_parse_string(hud_rcstyle); g_type_class_unref(g_type_class_ref(GTK_TYPE_BUTTON)); g_object_set(gtk_settings_get_default(), "gtk-button-images", TRUE, NULL); #if !defined(_WIN32) notify_init("HandBrake"); #endif ghb_register_transforms(); ghb_resource_init(); ghb_load_icons(); #if !defined(_WIN32) dbus_g_thread_init(); #endif ghb_udev_init(); ghb_write_pid_file(); ud = g_malloc0(sizeof(signal_user_data_t)); ud->debug = ghb_debug; g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, debug_log_handler, ud); g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING, warn_log_handler, ud); //g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL, warn_log_handler, ud); ud->settings = ghb_settings_new(); ud->builder = create_builder_or_die (BUILDER_NAME); // Enable events that alert us to media change events watch_volumes (ud); //GtkWidget *widget = GHB_WIDGET(ud->builder, "PictureDetelecineCustom"); //gtk_entry_set_inner_border(widget, 2); // Since GtkBuilder no longer assigns object ids to widget names // Assign a few that are necessary for style overrides to work GtkWidget *widget; #if defined(_NO_UPDATE_CHECK) widget = GHB_WIDGET(ud->builder, "check_updates_box"); gtk_widget_hide(widget); #endif widget = GHB_WIDGET(ud->builder, "preview_hud"); gtk_widget_set_name(widget, "preview_hud"); widget = GHB_WIDGET(ud->builder, "preview_window"); gtk_widget_set_name(widget, "preview_window"); // Set up the "hud" control overlay for the preview window GtkWidget *draw, *hud, *blender, *align; align = GHB_WIDGET(ud->builder, "preview_window_alignment"); draw = GHB_WIDGET(ud->builder, "preview_image_align"); hud = GHB_WIDGET(ud->builder, "preview_hud"); // Set up compositing for hud blender = ghb_compositor_new(); gtk_container_add(GTK_CONTAINER(align), blender); ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), draw, 1, 1); ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), hud, 2, .85); gtk_widget_show(blender); // Redirect stderr to the activity window ghb_preview_init(ud); IoRedirect(ud); ghb_log( "%s - %s - %s", HB_PROJECT_TITLE, HB_PROJECT_BUILD_TITLE, HB_PROJECT_URL_WEBSITE ); ghb_init_dep_map(); // Need to connect x264_options textview buffer to the changed signal // since it can't be done automatically GtkTextView *textview; GtkTextBuffer *buffer; textview = GTK_TEXT_VIEW(GHB_WIDGET (ud->builder, "x264Option")); buffer = gtk_text_view_get_buffer (textview); g_signal_connect(buffer, "changed", (GCallback)x264_entry_changed_cb, ud); ghb_combo_init(ud); g_debug("ud %p\n", ud); g_debug("ud->builder %p\n", ud->builder); bind_audio_tree_model(ud); bind_subtitle_tree_model(ud); bind_presets_tree_model(ud); bind_queue_tree_model(ud); bind_chapter_tree_model(ud); // Connect up the signals to their callbacks // I wrote my own connector so that I could pass user data // to the callbacks. Builder's standard autoconnect doesn't all this. gtk_builder_connect_signals_full (ud->builder, MyConnect, ud); // Load all internal settings ghb_settings_init(ud); // Load the presets files ghb_presets_load(ud); ghb_prefs_load(ud); ghb_prefs_to_ui(ud); gint logLevel; logLevel = ghb_settings_get_int(ud->settings, "LoggingLevel"); ghb_backend_init(logLevel); if (ghb_settings_get_boolean(ud->settings, "hbfd")) { ghb_hbfd(ud, TRUE); } gchar *source = ghb_settings_get_string(ud->settings, "default_source"); ghb_dvd_set_current(source, ud); g_free(source); // Parsing x264 options "" initializes x264 widgets to proper defaults ghb_x264_parse_options(ud, ""); // Populate the presets tree view ghb_presets_list_init(ud, NULL, 0); // Get the first preset name if (arg_preset != NULL) { preset = ghb_parse_preset_path(arg_preset); if (preset) { ghb_select_preset(ud->builder, preset); ghb_value_free(preset); } } else { ghb_select_default_preset(ud->builder); } // Grey out widgets that are dependent on a disabled feature ghb_check_all_depencencies (ud); if (dvd_device != NULL) { // Source overridden from command line option ghb_settings_set_string(ud->settings, "scan_source", dvd_device); g_idle_add((GSourceFunc)ghb_idle_scan, ud); } // Reload and check status of the last saved queue g_idle_add((GSourceFunc)ghb_reload_queue, ud); // Start timer for monitoring libhb status, 500ms g_timeout_add (500, ghb_timer_cb, (gpointer)ud); // Add dvd devices to File menu ghb_volname_cache_init(); g_thread_create((GThreadFunc)ghb_cache_volnames, ud, FALSE, NULL); #if defined(_USE_APP_IND) GtkUIManager * uim = GTK_UI_MANAGER(GHB_OBJECT(ud->builder, "uimanager1")); GtkMenu *ai_menu = GTK_MENU(gtk_ui_manager_get_widget(uim, "/ui/tray_menu")); ud->ai = app_indicator_new("HandBrake", "hb-icon", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); app_indicator_set_menu( ud->ai, ai_menu ); app_indicator_set_label( ud->ai, "", "99.99%"); if (ghb_settings_get_boolean(ud->settings, "show_status")) { app_indicator_set_status( ud->ai, APP_INDICATOR_STATUS_ACTIVE ); } else { app_indicator_set_status( ud->ai, APP_INDICATOR_STATUS_PASSIVE ); } GtkStatusIcon *si; si = GTK_STATUS_ICON(GHB_OBJECT(ud->builder, "hb_status")); gtk_status_icon_set_visible(si, FALSE ); #else GtkStatusIcon *si; si = GTK_STATUS_ICON(GHB_OBJECT(ud->builder, "hb_status")); gtk_status_icon_set_visible(si, ghb_settings_get_boolean(ud->settings, "show_status")); #if GTK_CHECK_VERSION(2, 16, 0) gtk_status_icon_set_has_tooltip(si, TRUE); g_signal_connect(si, "query-tooltip", status_icon_query_tooltip_cb, ud); #else gtk_status_icon_set_tooltip(si, "HandBrake"); #endif #endif // Ugly hack to keep subtitle table from bouncing around as I change // which set of controls are visible GtkRequisition req; gint width, height; widget = GHB_WIDGET(ud->builder, "SrtCodeset"); gtk_widget_size_request( widget, &req ); height = req.height; widget = GHB_WIDGET(ud->builder, "srt_code_label"); gtk_widget_size_request( widget, &req ); height += req.height; widget = GHB_WIDGET(ud->builder, "subtitle_table"); gtk_widget_set_size_request(widget, -1, height); widget = GHB_WIDGET (ud->builder, "hb_window"); GdkGeometry geo = { -1, -1, 1024, 768, -1, -1, 10, 10, 0, 0, GDK_GRAVITY_NORTH_WEST }; GdkWindowHints geo_mask; geo_mask = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_BASE_SIZE; gtk_window_set_geometry_hints( GTK_WINDOW(widget), widget, &geo, geo_mask); width = ghb_settings_get_int(ud->settings, "window_width"); height = ghb_settings_get_int(ud->settings, "window_height"); gtk_window_resize(GTK_WINDOW(widget), width, height); gtk_widget_show(widget); /* * Filter objects in GtkBuilder xml * Unfortunately, GtkFilter is poorly supported by GtkBuilder, * so a lot of the setup must happen in code. SourceFilterAll SourceFilterVideo SourceFilterTS SourceFilterMPG SourceFilterEVO SourceFilterVOB SourceFilterMKV SourceFilterMP4 SourceFilterAVI SourceFilterMOV SourceFilterOGG SourceFilterFLV SourceFilterWMV */ // Add filters to source chooser GtkFileFilter *filter; GtkFileChooser *chooser; chooser = GTK_FILE_CHOOSER(GHB_WIDGET(ud->builder, "source_dialog")); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterAll")); gtk_file_filter_set_name(filter, "All"); gtk_file_filter_add_pattern(filter, "*"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterVideo")); gtk_file_filter_set_name(filter, "Video"); gtk_file_filter_add_mime_type(filter, "video/*"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterTS")); gtk_file_filter_set_name(filter, "TS"); gtk_file_filter_add_pattern(filter, "*.ts"); gtk_file_filter_add_pattern(filter, "*.TS"); gtk_file_filter_add_pattern(filter, "*.m2ts"); gtk_file_filter_add_pattern(filter, "*.M2TS"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterMPG")); gtk_file_filter_set_name(filter, "MPG"); gtk_file_filter_add_pattern(filter, "*.mpg"); gtk_file_filter_add_pattern(filter, "*.MPG"); gtk_file_filter_add_pattern(filter, "*.mepg"); gtk_file_filter_add_pattern(filter, "*.MEPG"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterEVO")); gtk_file_filter_set_name(filter, "EVO"); gtk_file_filter_add_pattern(filter, "*.evo"); gtk_file_filter_add_pattern(filter, "*.EVO"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterVOB")); gtk_file_filter_set_name(filter, "VOB"); gtk_file_filter_add_pattern(filter, "*.vob"); gtk_file_filter_add_pattern(filter, "*.VOB"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterMKV")); gtk_file_filter_set_name(filter, "MKV"); gtk_file_filter_add_pattern(filter, "*.mkv"); gtk_file_filter_add_pattern(filter, "*.MKV"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterMP4")); gtk_file_filter_set_name(filter, "MP4"); gtk_file_filter_add_pattern(filter, "*.mp4"); gtk_file_filter_add_pattern(filter, "*.MP4"); gtk_file_filter_add_pattern(filter, "*.m4v"); gtk_file_filter_add_pattern(filter, "*.M4V"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterMOV")); gtk_file_filter_set_name(filter, "MOV"); gtk_file_filter_add_pattern(filter, "*.mov"); gtk_file_filter_add_pattern(filter, "*.MOV"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterAVI")); gtk_file_filter_set_name(filter, "AVI"); gtk_file_filter_add_pattern(filter, "*.avi"); gtk_file_filter_add_pattern(filter, "*.AVI"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterOGG")); gtk_file_filter_set_name(filter, "OGG"); gtk_file_filter_add_pattern(filter, "*.ogg"); gtk_file_filter_add_pattern(filter, "*.OGG"); gtk_file_filter_add_pattern(filter, "*.ogv"); gtk_file_filter_add_pattern(filter, "*.OGV"); gtk_file_filter_add_pattern(filter, "*.ogm"); gtk_file_filter_add_pattern(filter, "*.OGM"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterFLV")); gtk_file_filter_set_name(filter, "FLV"); gtk_file_filter_add_pattern(filter, "*.flv"); gtk_file_filter_add_pattern(filter, "*.FLV"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterWMV")); gtk_file_filter_set_name(filter, "WMV"); gtk_file_filter_add_pattern(filter, "*.wmv"); gtk_file_filter_add_pattern(filter, "*.WMV"); gtk_file_chooser_add_filter(chooser, filter); // Gtk has a really stupid bug. If the file chooser is showing // hidden files AND there is no filter set, it will not select // the filename when gtk_file_chooser_set_filename is called. // So add a completely unnessary filter to prevent this behavior. filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterAll")); gtk_file_chooser_set_filter(chooser, filter); PangoFontDescription *font_desc; font_desc = pango_font_description_from_string ("monospace 10"); textview = GTK_TEXT_VIEW(GHB_WIDGET (ud->builder, "activity_view")); gtk_widget_modify_font(GTK_WIDGET(textview), font_desc); pango_font_description_free (font_desc); // Everything should be go-to-go. Lets rock! gtk_main (); gtk_status_icon_set_visible(si, FALSE); ghb_backend_close(); if (ud->queue) ghb_value_free(ud->queue); ghb_value_free(ud->settings); g_io_channel_unref(ud->activity_log); ghb_settings_close(); #if !defined(_WIN32) notify_uninit(); #endif g_free(ud); return 0; }
static void x264_opt_update(signal_user_data_t *ud, GtkWidget *widget) { gint jj; const gchar *name = ghb_get_setting_key(widget); gchar **opt_syns = NULL; const gchar *def_val = NULL; gint type; trans_table_t *trans; for (jj = 0; jj < X264_OPT_MAP_SIZE; jj++) { if (strcmp(name, x264_opt_map[jj].name) == 0) { // found the options that needs updating opt_syns = x264_opt_map[jj].opt_syns; def_val = x264_opt_map[jj].def_val; type = x264_opt_map[jj].type; trans = x264_opt_map[jj].translation; break; } } if (opt_syns != NULL) { GString *x264opts = g_string_new(""); const gchar *options; gchar **split = NULL; gint ii; gboolean foundit = FALSE; options = ghb_dict_get_string(ud->settings, "x264Option"); if (options) { split = g_strsplit(options, ":", -1); } for (ii = 0; split && split[ii] != NULL; ii++) { gint syn; gchar *val = NULL; gchar *pos = strchr(split[ii], '='); if (pos != NULL) { val = pos + 1; *pos = 0; } syn = find_syn_match(split[ii], opt_syns); if (syn >= 0) { // Updating this option gchar *val; foundit = TRUE; if (type == X264_OPT_DEBLOCK) val = get_deblock_val(ud); else if (type == X264_OPT_PSY) val = get_psy_val(ud); else { GhbValue *gval; gval = ghb_widget_value(widget); if (ghb_value_type(gval) == GHB_BOOL) { if (ghb_value_get_bool(gval)) val = g_strdup("1"); else val = g_strdup("0"); } else { val = ghb_widget_string(widget); } ghb_value_free(&gval); } if (type == X264_OPT_TRANS) { gchar *tmp; tmp = g_strdup(trans_ui_val(trans, val)); if (tmp) { g_free(val); val = tmp; } } if (strcmp(def_val, val) != 0) { g_string_append_printf(x264opts, "%s=%s:", opt_syns[syn], val); } g_free(val); } else if (val != NULL) g_string_append_printf(x264opts, "%s=%s:", split[ii], val); else g_string_append_printf(x264opts, "%s:", split[ii]); } if (split) g_strfreev(split); if (!foundit) { gchar *val; if (type == X264_OPT_DEBLOCK) val = get_deblock_val(ud); else if (type == X264_OPT_PSY) val = get_psy_val(ud); else { GhbValue *gval; gval = ghb_widget_value(widget); if (ghb_value_type(gval) == GHB_BOOL) { if (ghb_value_get_bool(gval)) val = g_strdup("1"); else val = g_strdup("0"); } else { val = ghb_widget_string(widget); } ghb_value_free(&gval); } if (type == X264_OPT_TRANS) { gchar *tmp; tmp = g_strdup(trans_ui_val(trans, val)); if (tmp) { g_free(val); val = tmp; } } if (strcmp(def_val, val) != 0) { g_string_append_printf(x264opts, "%s=%s:", opt_syns[0], val); } g_free(val); } // Update the options value // strip the trailing ":" gchar *result; gint len; result = g_string_free(x264opts, FALSE); len = strlen(result); if (len > 0) result[len - 1] = 0; gchar *sopts; sopts = sanitize_x264opts(ud, result); ghb_update_x264Option(ud, sopts); ghb_x264_parse_options(ud, sopts); g_free(sopts); g_free(result); } }
int main (int argc, char *argv[]) { signal_user_data_t *ud; GValue *preset; GError *error = NULL; GOptionContext *context; #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif if (!g_thread_supported()) g_thread_init(NULL); context = g_option_context_new ("- Rip and encode DVD or MPEG file"); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (TRUE)); #if !defined(_WIN32) g_option_context_add_group (context, gst_init_get_option_group ()); #endif g_option_context_parse (context, &argc, &argv, &error); g_option_context_free(context); if (argc > 1 && dvd_device == NULL && argv[1][0] != '-') { dvd_device = argv[1]; } gtk_set_locale (); gtk_init (&argc, &argv); gtk_rc_parse_string(hud_rcstyle); g_type_class_unref(g_type_class_ref(GTK_TYPE_BUTTON)); g_object_set(gtk_settings_get_default(), "gtk-button-images", TRUE, NULL); #if !defined(_WIN32) notify_init("HandBrake"); #endif ghb_register_transforms(); ghb_resource_init(); ghb_load_icons(); #if !defined(_WIN32) dbus_g_thread_init(); #endif ghb_udev_init(); ghb_write_pid_file(); ud = g_malloc0(sizeof(signal_user_data_t)); ud->debug = ghb_debug; g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, debug_log_handler, ud); g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING, warn_log_handler, ud); //g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL, warn_log_handler, ud); ud->settings = ghb_settings_new(); ud->builder = create_builder_or_die (BUILDER_NAME); // Enable events that alert us to media change events watch_volumes (ud); //GtkWidget *widget = GHB_WIDGET(ud->builder, "PictureDetelecineCustom"); //gtk_entry_set_inner_border(widget, 2); // Since GtkBuilder no longer assigns object ids to widget names // Assign a few that are necessary for style overrides to work GtkWidget *widget; #if defined(_NO_UPDATE_CHECK) widget = GHB_WIDGET(ud->builder, "check_updates_box"); gtk_widget_hide(widget); #endif widget = GHB_WIDGET(ud->builder, "preview_hud"); gtk_widget_set_name(widget, "preview_hud"); widget = GHB_WIDGET(ud->builder, "preview_window"); gtk_widget_set_name(widget, "preview_window"); // Set up the "hud" control overlay for the preview window GtkWidget *draw, *hud, *blender, *align; align = GHB_WIDGET(ud->builder, "preview_window_alignment"); draw = GHB_WIDGET(ud->builder, "preview_image_align"); hud = GHB_WIDGET(ud->builder, "preview_hud"); // Set up compositing for hud blender = ghb_compositor_new(); gtk_container_add(GTK_CONTAINER(align), blender); ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), draw, 1, 1); ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), hud, 2, .85); gtk_widget_show(blender); // Redirect stderr to the activity window ghb_preview_init(ud); IoRedirect(ud); ghb_log( "%s - %s - %s", HB_PROJECT_TITLE, HB_PROJECT_BUILD_TITLE, HB_PROJECT_URL_WEBSITE ); ghb_init_dep_map(); // Need to connect x264_options textview buffer to the changed signal // since it can't be done automatically GtkTextView *textview; GtkTextBuffer *buffer; textview = GTK_TEXT_VIEW(GHB_WIDGET (ud->builder, "x264Option")); buffer = gtk_text_view_get_buffer (textview); g_signal_connect(buffer, "changed", (GCallback)x264_entry_changed_cb, ud); ghb_combo_init(ud); g_debug("ud %p\n", ud); g_debug("ud->builder %p\n", ud->builder); bind_audio_tree_model(ud); bind_subtitle_tree_model(ud); bind_presets_tree_model(ud); bind_queue_tree_model(ud); bind_chapter_tree_model(ud); // Connect up the signals to their callbacks // I wrote my own connector so that I could pass user data // to the callbacks. Builder's standard autoconnect doesn't all this. gtk_builder_connect_signals_full (ud->builder, MyConnect, ud); // Load all internal settings ghb_settings_init(ud); // Load the presets files ghb_presets_load(ud); ghb_prefs_load(ud); ghb_prefs_to_ui(ud); gint logLevel; logLevel = ghb_settings_get_int(ud->settings, "LoggingLevel"); ghb_backend_init(logLevel); if (ghb_settings_get_boolean(ud->settings, "hbfd")) { ghb_hbfd(ud, TRUE); } gchar *source = ghb_settings_get_string(ud->settings, "default_source"); ghb_dvd_set_current(source, ud); g_free(source); // Parsing x264 options "" initializes x264 widgets to proper defaults ghb_x264_parse_options(ud, ""); // Populate the presets tree view ghb_presets_list_init(ud, NULL, 0); // Get the first preset name if (arg_preset != NULL) { preset = ghb_parse_preset_path(arg_preset); if (preset) { ghb_select_preset(ud->builder, preset); ghb_value_free(preset); } } else { ghb_select_default_preset(ud->builder); } // Grey out widgets that are dependent on a disabled feature ghb_check_all_depencencies (ud); if (dvd_device != NULL) { // Source overridden from command line option ghb_settings_set_string(ud->settings, "scan_source", dvd_device); g_idle_add((GSourceFunc)ghb_idle_scan, ud); } // Reload and check status of the last saved queue g_idle_add((GSourceFunc)ghb_reload_queue, ud); // Start timer for monitoring libhb status, 500ms g_timeout_add (500, ghb_timer_cb, (gpointer)ud); // Add dvd devices to File menu ghb_volname_cache_init(); g_thread_create((GThreadFunc)ghb_cache_volnames, ud, FALSE, NULL); GtkStatusIcon *si; si = GTK_STATUS_ICON(GHB_OBJECT(ud->builder, "hb_status")); gtk_status_icon_set_visible(si, ghb_settings_get_boolean(ud->settings, "show_status")); #if GTK_CHECK_VERSION(2, 16, 0) gtk_status_icon_set_has_tooltip(si, TRUE); g_signal_connect(si, "query-tooltip", status_icon_query_tooltip_cb, ud); #else gtk_status_icon_set_tooltip(si, "HandBrake"); #endif // Ugly hack to keep subtitle table from bouncing around as I change // which set of controls are visible GtkRequisition req; gint height; widget = GHB_WIDGET(ud->builder, "SrtCodeset"); gtk_widget_size_request( widget, &req ); height = req.height; widget = GHB_WIDGET(ud->builder, "srt_code_label"); gtk_widget_size_request( widget, &req ); height += req.height; widget = GHB_WIDGET(ud->builder, "subtitle_table"); gtk_widget_set_size_request(widget, -1, height); // Everything should be go-to-go. Lets rock! gtk_main (); gtk_status_icon_set_visible(si, FALSE); ghb_backend_close(); if (ud->queue) ghb_value_free(ud->queue); ghb_value_free(ud->settings); g_io_channel_unref(ud->activity_log); ghb_settings_close(); #if !defined(_WIN32) notify_uninit(); #endif g_free(ud); return 0; }
void ghb_x264_init(signal_user_data_t *ud) { ud->x264_priv = ghb_settings_new(); ghb_x264_parse_options(ud, ""); }