static AtkObject * gtk_combo_box_accessible_ref_child (AtkObject *obj, gint i) { GtkWidget *widget; AtkObject *child; GtkComboBoxAccessible *box; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); if (widget == NULL) return NULL; if (i == 0) { child = gtk_combo_box_get_popup_accessible (GTK_COMBO_BOX (widget)); box = GTK_COMBO_BOX_ACCESSIBLE (obj); if (box->popup_set == FALSE) { atk_object_set_parent (child, obj); box->popup_set = TRUE; } } else if (i == 1 && gtk_combo_box_get_has_entry (GTK_COMBO_BOX (widget))) { child = gtk_widget_get_accessible (gtk_bin_get_child (GTK_BIN (widget))); } else { return NULL; } return g_object_ref (child); }
static void gtk_combo_box_accessible_initialize (AtkObject *obj, gpointer data) { GtkComboBox *combo_box; GtkComboBoxAccessible *accessible; AtkObject *popup; ATK_OBJECT_CLASS (_gtk_combo_box_accessible_parent_class)->initialize (obj, data); combo_box = GTK_COMBO_BOX (data); accessible = GTK_COMBO_BOX_ACCESSIBLE (obj); g_signal_connect (combo_box, "changed", G_CALLBACK (changed_cb), NULL); accessible->old_selection = gtk_combo_box_get_active (combo_box); popup = gtk_combo_box_get_popup_accessible (combo_box); if (popup) { atk_object_set_parent (popup, obj); accessible->popup_set = TRUE; } if (gtk_combo_box_get_has_entry (combo_box)) atk_object_set_parent (gtk_widget_get_accessible (gtk_bin_get_child (GTK_BIN (combo_box))), obj); obj->role = ATK_ROLE_COMBO_BOX; }
static GObject * gtk_combo_box_text_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties) { GObject *object; const gint text_column = 0; object = G_OBJECT_CLASS (gtk_combo_box_text_parent_class)->constructor (type, n_construct_properties, construct_properties); gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (object), text_column); gtk_combo_box_set_id_column (GTK_COMBO_BOX (object), 1); if (!gtk_combo_box_get_has_entry (GTK_COMBO_BOX (object))) { GtkCellRenderer *cell; cell = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (object), cell, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (object), cell, "text", text_column, NULL); } return object; }
/** * gtk_combo_box_text_get_active_text: * @combo_box: A #GtkComboBoxText * * Returns the currently active string in @combo_box, or %NULL * if none is selected. If @combo_box contains an entry, this * function will return its contents (which will not necessarily * be an item from the list). * * Returns: (transfer full): a newly allocated string containing the * currently active text. Must be freed with g_free(). * * Since: 2.24 */ gchar * gtk_combo_box_text_get_active_text (GtkComboBoxText *combo_box) { GtkTreeIter iter; gchar *text = NULL; g_return_val_if_fail (GTK_IS_COMBO_BOX_TEXT (combo_box), NULL); if (gtk_combo_box_get_has_entry (GTK_COMBO_BOX (combo_box))) { GtkWidget *entry; entry = gtk_bin_get_child (GTK_BIN (combo_box)); text = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry))); } else if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo_box), &iter)) { GtkTreeModel *model; gint text_column; gint column_type; model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box)); g_return_val_if_fail (GTK_IS_LIST_STORE (model), NULL); text_column = gtk_combo_box_get_entry_text_column (GTK_COMBO_BOX (combo_box)); g_return_val_if_fail (text_column >= 0, NULL); column_type = gtk_tree_model_get_column_type (model, text_column); g_return_val_if_fail (column_type == G_TYPE_STRING, NULL); gtk_tree_model_get (model, &iter, text_column, &text, -1); } return text; }
GList * glade_gtk_combo_box_get_children (GladeWidgetAdaptor * adaptor, GtkComboBox * combo) { GList *list = NULL; list = glade_gtk_cell_layout_get_children (adaptor, G_OBJECT (combo)); if (gtk_combo_box_get_has_entry (combo)) list = g_list_append (list, gtk_bin_get_child (GTK_BIN (combo))); return list; }
static gint gtk_combo_box_accessible_get_n_children (AtkObject* obj) { gint n_children = 0; GtkWidget *widget; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); if (widget == NULL) return 0; n_children++; if (gtk_combo_box_get_has_entry (GTK_COMBO_BOX (widget))) n_children++; return n_children; }
/** * gtk_combo_box_text_insert: * @combo_box: A #GtkComboBoxText * @position: An index to insert @text * @id: (allow-none): a string ID for this value, or %NULL * @text: A string to display * * Inserts @text at @position in the list of strings stored in @combo_box. * If @id is non-%NULL then it is used as the ID of the row. See * #GtkComboBox:id-column. * * If @position is negative then @text is appended. * * Since: 3.0 */ void gtk_combo_box_text_insert (GtkComboBoxText *combo_box, gint position, const gchar *id, const gchar *text) { GtkListStore *store; GtkTreeIter iter; gint text_column; gint column_type; g_return_if_fail (GTK_IS_COMBO_BOX_TEXT (combo_box)); g_return_if_fail (text != NULL); store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box))); g_return_if_fail (GTK_IS_LIST_STORE (store)); text_column = gtk_combo_box_get_entry_text_column (GTK_COMBO_BOX (combo_box)); if (gtk_combo_box_get_has_entry (GTK_COMBO_BOX (combo_box))) g_return_if_fail (text_column >= 0); else if (text_column < 0) text_column = 0; column_type = gtk_tree_model_get_column_type (GTK_TREE_MODEL (store), text_column); g_return_if_fail (column_type == G_TYPE_STRING); if (position < 0) gtk_list_store_append (store, &iter); else gtk_list_store_insert (store, &iter, position); gtk_list_store_set (store, &iter, text_column, text, -1); if (id != NULL) { gint id_column; id_column = gtk_combo_box_get_id_column (GTK_COMBO_BOX (combo_box)); g_return_if_fail (id_column >= 0); column_type = gtk_tree_model_get_column_type (GTK_TREE_MODEL (store), id_column); g_return_if_fail (column_type == G_TYPE_STRING); gtk_list_store_set (store, &iter, id_column, id, -1); } }
static void gtk_combo_box_text_constructed (GObject *object) { const gint text_column = 0; G_OBJECT_CLASS (gtk_combo_box_text_parent_class)->constructed (object); gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (object), text_column); gtk_combo_box_set_id_column (GTK_COMBO_BOX (object), 1); if (!gtk_combo_box_get_has_entry (GTK_COMBO_BOX (object))) { GtkCellRenderer *cell; cell = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (object), cell, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (object), cell, "text", text_column, NULL); } }
void glade_gtk_combo_box_post_create (GladeWidgetAdaptor *adaptor, GObject *object, GladeCreateReason reason) { GladeWidget *widget; /* Chain Up */ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->post_create (adaptor, object, reason); widget = glade_widget_get_from_gobject (object); if (gtk_combo_box_get_has_entry (GTK_COMBO_BOX (object))) { glade_widget_property_set_sensitive (widget, "entry-text-column", TRUE, NULL); glade_widget_property_set_sensitive (widget, "has-frame", TRUE, NULL); } else { glade_widget_property_set_sensitive (widget, "entry-text-column", FALSE, NO_ENTRY_MSG); glade_widget_property_set_sensitive (widget, "has-frame", FALSE, NO_ENTRY_MSG); } }
/** * na_gtk_utils_set_editable: * @widget: the #GtkWdiget. * @editable: whether the @widget is editable or not. * * Try to set a visual indication of whether the @widget is editable or not. * * Having a GtkWidget should be enough, but we also deal with a GtkTreeViewColumn. * So the most-bottom common ancestor is just GObject (since GtkObject having been * deprecated in Gtk+-3.0) * * Note that using 'sensitivity' property is just a work-around because the * two things have distinct semantics: * - editable: whether we are allowed to modify the value (is not read-only) * - sensitive: whether the value is relevant (has a sense in this context) */ void na_gtk_utils_set_editable( GObject *widget, gboolean editable ) { GList *renderers, *irender; /* GtkComboBoxEntry is deprecated from Gtk+3 * see. http://git.gnome.org/browse/gtk+/commit/?id=9612c648176378bf237ad0e1a8c6c995b0ca7c61 * while 'has_entry' property exists since 2.24 */ #if GTK_CHECK_VERSION( 2,24,0 ) if( GTK_IS_COMBO_BOX( widget ) && gtk_combo_box_get_has_entry( GTK_COMBO_BOX( widget ))){ #else if( GTK_IS_COMBO_BOX_ENTRY( widget )){ #endif /* idem as GtkEntry */ gtk_editable_set_editable( GTK_EDITABLE( gtk_bin_get_child( GTK_BIN( widget ))), editable ); g_object_set( G_OBJECT( gtk_bin_get_child( GTK_BIN( widget ))), "can-focus", editable, NULL ); /* disable the listbox button itself */ gtk_combo_box_set_button_sensitivity( GTK_COMBO_BOX( widget ), editable ? GTK_SENSITIVITY_ON : GTK_SENSITIVITY_OFF ); } else if( GTK_IS_COMBO_BOX( widget )){ /* disable the listbox button itself */ gtk_combo_box_set_button_sensitivity( GTK_COMBO_BOX( widget ), editable ? GTK_SENSITIVITY_ON : GTK_SENSITIVITY_OFF ); } else if( GTK_IS_ENTRY( widget )){ gtk_editable_set_editable( GTK_EDITABLE( widget ), editable ); /* removing the frame leads to a disturbing modification of the * height of the control */ /*g_object_set( G_OBJECT( widget ), "has-frame", editable, NULL );*/ /* this prevents the caret to be displayed when we click in the entry */ g_object_set( G_OBJECT( widget ), "can-focus", editable, NULL ); } else if( GTK_IS_TEXT_VIEW( widget )){ g_object_set( G_OBJECT( widget ), "can-focus", editable, NULL ); gtk_text_view_set_editable( GTK_TEXT_VIEW( widget ), editable ); } else if( GTK_IS_TOGGLE_BUTTON( widget )){ /* transforms to a quasi standard GtkButton */ /*g_object_set( G_OBJECT( widget ), "draw-indicator", editable, NULL );*/ /* this at least prevent the keyboard focus to go to the button * (which is better than nothing) */ g_object_set( G_OBJECT( widget ), "can-focus", editable, NULL ); } else if( GTK_IS_TREE_VIEW_COLUMN( widget )){ renderers = gtk_cell_layout_get_cells( GTK_CELL_LAYOUT( GTK_TREE_VIEW_COLUMN( widget ))); for( irender = renderers ; irender ; irender = irender->next ){ if( GTK_IS_CELL_RENDERER_TEXT( irender->data )){ g_object_set( G_OBJECT( irender->data ), "editable", editable, "editable-set", TRUE, NULL ); } } g_list_free( renderers ); } else if( GTK_IS_BUTTON( widget )){ gtk_widget_set_sensitive( GTK_WIDGET( widget ), editable ); } } /** * na_gtk_utils_radio_set_initial_state: * @button: the #GtkRadioButton button which is initially active. * @handler: the corresponding "toggled" handler. * @user_data: the user data associated to the handler. * @editable: whether this radio button group is editable. * @sensitive: whether this radio button group is sensitive. * * This function should be called for the button which is initially active * inside of a radio button group when the radio group may happen to not be * editable. * This function should be called only once for the radio button group. * * It does the following operations: * - set the button as active * - set other buttons of the radio button group as icactive * - set all buttons of radio button group as @editable * * The initially active @button, along with its @handler, are recorded * as properties of the radio button group (actually as properties of each * radio button of the group), so that they can later be used to reset the * initial state. */ void na_gtk_utils_radio_set_initial_state( GtkRadioButton *button, GCallback handler, void *user_data, gboolean editable, gboolean sensitive ) { GSList *group, *ig; GtkRadioButton *other; group = gtk_radio_button_get_group( button ); for( ig = group ; ig ; ig = ig->next ){ other = GTK_RADIO_BUTTON( ig->data ); g_object_set_data( G_OBJECT( other ), NA_TOGGLE_DATA_BUTTON, button ); g_object_set_data( G_OBJECT( other ), NA_TOGGLE_DATA_HANDLER, handler ); g_object_set_data( G_OBJECT( other ), NA_TOGGLE_DATA_USER_DATA, user_data ); g_object_set_data( G_OBJECT( other ), NA_TOGGLE_DATA_EDITABLE, GUINT_TO_POINTER( editable )); na_gtk_utils_set_editable( G_OBJECT( other ), editable ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( other ), FALSE ); gtk_widget_set_sensitive( GTK_WIDGET( other ), sensitive ); } gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), TRUE ); }
/** * repository_ipod_init: * * Ask for the iPod model and mountpoint and then create the directory * structure on the iPod. * * @itdb: itdb from where to extract the mountpoint. After * initialisation the model number is set. */ gboolean repository_ipod_init(iTunesDB *itdb) { IpodInit *ii; gint response; gboolean result = FALSE; gchar *mountpoint, *new_mount, *name, *model; GError *error = NULL; gchar buf[PATH_MAX]; GtkComboBox *cb; const IpodInfo *info; GtkTreeIter iter; g_return_val_if_fail (itdb, FALSE); /* Create window */ ii = g_new0 (IpodInit, 1); ii->itdb = itdb; ii->builder = init_repository_builder(); ii->window = gtkpod_builder_xml_get_widget(ii->builder, "ipod_init_dialog"); g_return_val_if_fail (ii->window, FALSE); /* Set mountpoint */ mountpoint = get_itdb_prefs_string(itdb, KEY_MOUNTPOINT); if (mountpoint) { gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(GET_WIDGET (ii->builder, IID_MOUNTPOINT_CHOOSER)), mountpoint); } /* Setup model number combo */ cb = GTK_COMBO_BOX (GET_WIDGET (ii->builder, IID_MODEL_COMBO)); repository_init_model_number_combo(cb); /* If available set current model number, otherwise indicate that none is available */ info = itdb_device_get_ipod_info(itdb->device); if (info && (info->ipod_generation != ITDB_IPOD_GENERATION_UNKNOWN)) { g_snprintf(buf, PATH_MAX, "x%s", info->model_number); } else { model = get_itdb_prefs_string(itdb, KEY_IPOD_MODEL); if (model && (strlen(g_strstrip (model)) != 0)) { g_snprintf(buf, PATH_MAX, "%s", model); g_free(model); } else { g_snprintf(buf, PATH_MAX, "%s", gettext (SELECT_OR_ENTER_YOUR_MODEL)); } } /* Try and set buf as the active selection in the combo box */ _model_combo_set_active_iter(cb, buf); gtk_window_set_transient_for(GTK_WINDOW (ii->window), GTK_WINDOW (gtkpod_app)); response = gtk_dialog_run(GTK_DIALOG (ii->window)); switch (response) { case GTK_RESPONSE_OK: new_mount = g_strdup(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(GET_WIDGET (ii->builder, IID_MOUNTPOINT_CHOOSER)))); if (!new_mount || (strlen(new_mount) == 0)) { gtkpod_statusbar_message("No mount point has been selected"); return FALSE; } if (!gtk_combo_box_get_has_entry(cb)) { gtkpod_statusbar_message("No model has been selected"); return FALSE; } /* remove trailing '/' in case it's present. */ if (mountpoint && (strlen(mountpoint) > 0)) { if (G_IS_DIR_SEPARATOR(mountpoint[strlen(mountpoint) - 1])) { mountpoint[strlen(mountpoint) - 1] = 0; } } if (new_mount && (strlen(new_mount) > 0)) { if (G_IS_DIR_SEPARATOR(new_mount[strlen(new_mount) - 1])) { new_mount[strlen(new_mount) - 1] = 0; } } if (!(mountpoint && new_mount && (strcmp(mountpoint, new_mount) == 0))) { /* mountpoint has changed */ g_free(mountpoint); mountpoint = new_mount; new_mount = NULL; set_itdb_prefs_string(itdb, KEY_MOUNTPOINT, mountpoint); call_script("gtkpod.load", mountpoint, NULL); itdb_set_mountpoint(itdb, mountpoint); } else { g_free(new_mount); new_mount = NULL; } g_return_val_if_fail(gtk_combo_box_get_active_iter(cb, &iter), FALSE); gtk_tree_model_get(gtk_combo_box_get_model(cb), &iter, COL_STRING, &model, -1); g_return_val_if_fail(model, FALSE); if ((strcmp(model, gettext(SELECT_OR_ENTER_YOUR_MODEL)) == 0) || (strlen(model) == 0)) { /* User didn't choose a model */ g_free(model); model = NULL; } /* Set model in the prefs system */ set_itdb_prefs_string(itdb, KEY_IPOD_MODEL, model); name = get_itdb_prefs_string(itdb, "name"); result = itdb_init_ipod(mountpoint, model, name, &error); /* Set the model in the sysinfo of the itdb */ itdb_device_set_sysinfo(itdb->device, "ModelNumStr", model); if (!result) { if (error) { gtkpod_warning(_("Error initialising iPod: %s\n"), error->message); g_error_free(error); error = NULL; } else { gtkpod_warning(_("Error initialising iPod, unknown error\n")); } } else { /* Should write the extended info file */ result = gp_create_extended_info(itdb); } g_free(name); g_free(model); break; default: /* canceled -- do nothing */ break; } gtk_widget_destroy(ii->window); g_free(mountpoint); g_free(ii); return result; }
void ghb_update_widget(GtkWidget *widget, const GValue *value) { GType type; gchar *str; gint ival; gdouble dval; g_debug("ghb_update_widget"); type = G_VALUE_TYPE(value); if (type == ghb_array_get_type() || type == ghb_dict_get_type()) return; if (value == NULL) return; str = ghb_value_string(value); ival = ghb_value_int(value); dval = ghb_value_double(value); type = G_OBJECT_TYPE(widget); if (type == GTK_TYPE_ENTRY) { g_debug("entry"); gtk_entry_set_text((GtkEntry*)widget, str); } else if (type == GTK_TYPE_RADIO_BUTTON) { g_debug("radio button"); if (ival) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), !!ival); } else if (type == GTK_TYPE_CHECK_BUTTON) { g_debug("check button"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), ival); } else if (type == GTK_TYPE_TOGGLE_TOOL_BUTTON) { g_debug("toggle button"); gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(widget), ival); } else if (type == GTK_TYPE_TOGGLE_BUTTON) { g_debug("toggle button"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), ival); } else if (type == GTK_TYPE_CHECK_MENU_ITEM) { g_debug("check menu item"); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), ival); } else if (type == GTK_TYPE_COMBO_BOX) { GtkTreeModel *store; GtkTreeIter iter; gchar *shortOpt; gdouble ivalue; gboolean foundit = FALSE; g_debug("combo (%s)", str); store = gtk_combo_box_get_model(GTK_COMBO_BOX(widget)); if (gtk_tree_model_get_iter_first (store, &iter)) { do { gtk_tree_model_get(store, &iter, 2, &shortOpt, -1); if (strcasecmp(shortOpt, str) == 0) { gtk_combo_box_set_active_iter ( GTK_COMBO_BOX(widget), &iter); g_free(shortOpt); foundit = TRUE; break; } g_free(shortOpt); } while (gtk_tree_model_iter_next (store, &iter)); } if (!foundit && gtk_tree_model_get_iter_first (store, &iter)) { do { gtk_tree_model_get(store, &iter, 3, &ivalue, -1); if ((gint)ivalue == ival || ivalue == dval) { gtk_combo_box_set_active_iter ( GTK_COMBO_BOX(widget), &iter); foundit = TRUE; break; } } while (gtk_tree_model_iter_next (store, &iter)); } if (!foundit) { if (gtk_combo_box_get_has_entry(GTK_COMBO_BOX(widget))) { GtkEntry *entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(widget))); if (entry) { gtk_entry_set_text (entry, str); } else { gtk_combo_box_set_active (GTK_COMBO_BOX(widget), 0); } } else { gtk_combo_box_set_active (GTK_COMBO_BOX(widget), 0); } } } else if (type == GTK_TYPE_SPIN_BUTTON) { g_debug("spin (%s)", str); gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), dval); } else if (type == GTK_TYPE_SCALE) { g_debug("hscale"); gtk_range_set_value(GTK_RANGE(widget), dval); } else if (type == GTK_TYPE_SCALE_BUTTON) { g_debug("scale_button"); gtk_scale_button_set_value(GTK_SCALE_BUTTON(widget), dval); } else if (type == GTK_TYPE_TEXT_VIEW) { g_debug("textview (%s)", str); GtkTextBuffer *buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(widget)); gtk_text_buffer_set_text (buffer, str, -1); } else if (type == GTK_TYPE_LABEL) { gtk_label_set_markup (GTK_LABEL(widget), str); } else if (type == GTK_TYPE_FILE_CHOOSER_BUTTON) { GtkFileChooserAction act; act = gtk_file_chooser_get_action(GTK_FILE_CHOOSER(widget)); if (str[0] == 0) { // Do nothing ; } else if (act == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER || act == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER) { gtk_file_chooser_set_filename (GTK_FILE_CHOOSER(widget), str); } else if (act == GTK_FILE_CHOOSER_ACTION_SAVE) { gtk_file_chooser_set_filename (GTK_FILE_CHOOSER(widget), str); } else { if (g_file_test(str, G_FILE_TEST_IS_DIR)) { gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(widget), str); } else if (g_file_test(str, G_FILE_TEST_EXISTS)) { gtk_file_chooser_set_filename (GTK_FILE_CHOOSER(widget), str); } else { gchar *dirname; dirname = g_path_get_dirname(str); gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(widget), dirname); g_free(dirname); } } } else { g_debug("Attempt to set unknown widget type"); } g_free(str); }
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; }