G_MODULE_EXPORT void fullscreen_clicked_cb(GtkWidget *toggle, signal_user_data_t *ud) { gboolean active; GtkWindow *window; g_debug("fullscreen_clicked_cb()"); ghb_widget_to_setting (ud->prefs, toggle); ghb_check_dependency(ud, toggle, NULL); const gchar *name = ghb_get_setting_key(toggle); ghb_pref_save(ud->prefs, name); window = GTK_WINDOW(GHB_WIDGET (ud->builder, "preview_window")); active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle)); if (active) { gtk_window_set_resizable(window, TRUE); gtk_button_set_label(GTK_BUTTON(toggle), _("Windowed")); // Changing resizable property doesn't take effect immediately // need to delay fullscreen till after this callback returns // to mainloop g_idle_add((GSourceFunc)go_full, ud); } else { gtk_window_unfullscreen(window); gtk_window_set_resizable(window, FALSE); gtk_button_set_label(GTK_BUTTON(toggle), _("Fullscreen")); ghb_set_preview_image(ud); } }
G_MODULE_EXPORT void preview_duration_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { g_debug("preview_duration_changed_cb ()"); ghb_live_reset(ud); ghb_widget_to_setting (ud->prefs, widget); ghb_check_dependency(ud, widget, NULL); const gchar *name = ghb_get_setting_key(widget); ghb_pref_save(ud->prefs, name); }
// If you should ever need to change the font for the running application.. // Ugly but effective. void change_font(GtkWidget *widget, gpointer data) { PangoFontDescription *font_desc; gchar *font = (gchar*)data; const gchar *name; font_desc = pango_font_description_from_string(font); if (font_desc == NULL) exit(1); gtk_widget_modify_font(widget, font_desc); name = ghb_get_setting_key(widget); g_debug("changing font for widget %s\n", name); if (GTK_IS_CONTAINER(widget)) { gtk_container_foreach((GtkContainer*)widget, change_font, data); } }
void ghb_widget_to_setting(GValue *settings, GtkWidget *widget) { const gchar *key = NULL; GValue *value; if (widget == NULL) return; g_debug("ghb_widget_to_setting"); // Find corresponding setting key = ghb_get_setting_key(widget); if (key == NULL) return; value = ghb_widget_value(widget); if (value != NULL) { ghb_settings_take_value(settings, key, value); } else { g_debug("No value found for %s\n", key); } }
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); } }
GValue* ghb_widget_value(GtkWidget *widget) { GValue *value = NULL; const gchar *name; GType type; if (widget == NULL) { g_debug("NULL widget\n"); return NULL; } type = G_OBJECT_TYPE(widget); name = ghb_get_setting_key(widget); g_debug("ghb_widget_value widget (%s)\n", name); if (type == GTK_TYPE_ENTRY) { const gchar *str = gtk_entry_get_text(GTK_ENTRY(widget)); value = ghb_string_value_new(str); } else if (type == GTK_TYPE_RADIO_BUTTON) { g_debug("\tradio_button"); gboolean bval; bval = gtk_toggle_button_get_inconsistent(GTK_TOGGLE_BUTTON(widget)); if (bval) { value = ghb_boolean_value_new(FALSE); } else { bval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); value = ghb_boolean_value_new(bval); } } else if (type == GTK_TYPE_CHECK_BUTTON) { g_debug("\tcheck_button"); gboolean bval; bval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); value = ghb_boolean_value_new(bval); } else if (type == GTK_TYPE_TOGGLE_TOOL_BUTTON) { g_debug("\ttoggle_tool_button"); gboolean bval; bval = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(widget)); value = ghb_boolean_value_new(bval); } else if (type == GTK_TYPE_TOGGLE_BUTTON) { g_debug("\ttoggle_button"); gboolean bval; bval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); value = ghb_boolean_value_new(bval); } else if (type == GTK_TYPE_CHECK_MENU_ITEM) { g_debug("\tcheck_menu_item"); gboolean bval; bval = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); value = ghb_boolean_value_new(bval); } else if (type == GTK_TYPE_COMBO_BOX) { g_debug("\tcombo_box"); GtkTreeModel *store; GtkTreeIter iter; gchar *shortOpt; store = gtk_combo_box_get_model(GTK_COMBO_BOX(widget)); if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget), &iter)) { gtk_tree_model_get(store, &iter, 2, &shortOpt, -1); value = ghb_string_value_new(shortOpt); g_free(shortOpt); } else if (gtk_combo_box_get_has_entry(GTK_COMBO_BOX(widget))) { const gchar *str; str = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(widget)))); if (str == NULL) str = ""; value = ghb_string_value_new(str); } else { value = ghb_string_value_new(""); } } else if (type == GTK_TYPE_SPIN_BUTTON) { gint ival; ival = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); value = ghb_int64_value_new(ival); } else if (type == GTK_TYPE_SCALE) { gdouble dval; gint digits; digits = gtk_scale_get_digits(GTK_SCALE(widget)); dval = gtk_range_get_value(GTK_RANGE(widget)); if (digits) { value = ghb_double_value_new(dval); } else { value = ghb_int_value_new(dval); } } else if (type == GTK_TYPE_SCALE_BUTTON) { gdouble dval; dval = gtk_scale_button_get_value(GTK_SCALE_BUTTON(widget)); value = ghb_double_value_new(dval); } else if (type == GTK_TYPE_TEXT_VIEW) { GtkTextBuffer *buffer; GtkTextIter start, end; gchar *str; buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget)); gtk_text_buffer_get_bounds(buffer, &start, &end); str = gtk_text_buffer_get_text(buffer, &start, &end, FALSE); value = ghb_string_value_new(str); g_free(str); } else if (type == GTK_TYPE_LABEL) { const gchar *str; str = gtk_label_get_text (GTK_LABEL(widget)); value = ghb_string_value_new(str); } else if (type == GTK_TYPE_FILE_CHOOSER_BUTTON) { gchar *str = NULL; str = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(widget)); if (str == NULL) { str = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(widget)); } value = ghb_string_value_new(str); if (str != NULL) g_free(str); } else { g_debug("Attempt to set unknown widget type: %s\n", name); g_free(value); value = NULL; } return value; }