Class: Gtk::ComboBox

Inherits:
Widget
  • Object
show all
Extended by:
GLib::Deprecatable
Defined in:
lib/gtk3/combo-box.rb,
lib/gtk3/deprecated.rb

Direct Known Subclasses

ComboBoxText

Instance Method Summary collapse

Methods inherited from Widget

#accessible_role, #accessible_role=, #action_set_enabled, #activate, #activate_action, #activate_action_variant, #activate_default, #activate_signal, #activate_signal=, #activate_signal_from_name=, #add_binding, #add_binding_action, #add_binding_signal, #add_controller, #add_css_class, #add_events, #add_events_raw, #add_mnemonic_label, #add_shortcut, #add_tick_callback, #allocate, #allocated_baseline, #allocated_height, #allocated_width, #baseline, #bind_template_callback_full, #bind_template_child, #bind_template_child_full, #can_focus, #can_focus=, #can_focus?, #can_target, #can_target=, #can_target?, #child_focus, #child_visible, #child_visible=, #clipboard, #compute_bounds, #compute_expand, #compute_point, #compute_transform, #contains, #create_pango_context, #create_pango_layout, #css_classes, #css_classes=, #css_name, #css_name=, #cursor, #cursor=, #cursor_from_name=, default_direction, default_direction=, #direction, #direction=, #display, #dispose_template, #drag_check_threshold, #drag_dest_set, #drag_dest_set_raw, #drag_source_set, #drag_source_set_raw, #error_bell, #events, #events_raw, #first_child, #focus_child, #focus_child=, #focus_on_click, #focus_on_click=, #focus_on_click?, #focusable, #focusable=, #focusable?, #font_map, #font_map=, #font_options, #font_options=, #frame_clock, #get_allocation, #get_ancestor, #get_color, #get_preferred_size, #get_size, #get_size_request, #get_template_child, #grab_focus, #halign, #halign=, #has_css_class, #has_default, #has_default=, #has_default?, #has_focus, #has_focus=, #has_focus?, #has_tooltip, #has_tooltip=, #has_tooltip?, #has_visible_focus, have_template?, #height, #height_request, #height_request=, #hexpand, #hexpand=, #hexpand?, #hexpand_set, #hexpand_set=, #hexpand_set?, #hide, #in_destruction, #init_template, #insert_action_group, #insert_action_group_raw, #insert_after, #insert_before, #install_action, #install_property_action, #is_ancestor, #is_drawable, #is_focus, #is_sensitive, #is_visible, #keynav_failed, #last_child, #layout_manager, #layout_manager=, #layout_manager_type, #layout_manager_type=, #list_mnemonic_labels, #map, #mapped, #margin_bottom, #margin_bottom=, #margin_end, #margin_end=, #margin_start, #margin_start=, #margin_top, #margin_top=, #measure, #mnemonic_activate, #name, #name=, #native, #next_sibling, #observe_children, #observe_controllers, #opacity, #opacity=, #overflow, #overflow=, #pango_context, #parent, #parent=, #pick, #prev_sibling, #primary_clipboard, #query_action, #queue_allocate, #queue_draw, #queue_resize, #realize, #realized, #receives_default, #receives_default=, #receives_default?, #remove_controller, #remove_css_class, #remove_mnemonic_label, #remove_tick_callback, #render_icon_pixbuf, #render_icon_pixbuf_raw, #request_mode, #root, #root=, #scale_factor, #scale_factor=, #sensitive, #sensitive=, #sensitive?, #set_allocation, set_connect_func, set_connect_func_raw, #set_events, #set_events_raw, #set_size_request, #set_size_request_raw, #set_state_flags, #set_template, #set_template_raw, #settings, #should_layout, #show, #size_allocate, #snapshot_child, #state_flags, #style_context, #style_context_raw, #style_get_property, #style_get_property_raw, #template=, template_children, #template_from_resource=, #template_scope=, #tooltip_markup, #tooltip_markup=, #tooltip_text, #tooltip_text=, #translate_coordinates, #translate_coordinates_raw, #trigger_tooltip_query, #unmap, #unparent, #unrealize, #unset_state_flags, #valign, #valign=, #vexpand, #vexpand=, #vexpand?, #vexpand_set, #vexpand_set=, #vexpand_set?, #visible, #visible=, #visible?, #width, #width_request, #width_request=

Constructor Details

#initialize(options = {}) ⇒ Gtk::Widget

Creates a new empty GtkComboBox with an entry and a model.

See also [ctorGtk.ComboBox.new_with_entry].

Parameters:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/gtk3/combo-box.rb', line 20

def initialize(options={})
  entry = options[:entry]
  model = options[:model]
  area  = options[:area]

  if entry
    if model
      initialize_new_with_model_and_entry(model)
    elsif area
      initialize_new_with_area_and_entry(area)
    else
      initialize_new_with_entry
    end
  else
    if model
      initialize_new_with_model(model)
    elsif area
      initialize_new_with_area(area)
    else
      initialize_new
    end
  end
end

Instance Method Details

#activeInteger

The item which is currently active.

If the model is a non-flat treemodel, and the active item is not an immediate child of the root of the tree, this property has the value gtk_tree_path_get_indices (path)[0], where path is the [structGtk.TreePath] of the active item.

Returns:

  • (Integer)

    active

#active=(active) ⇒ Integer

The item which is currently active.

If the model is a non-flat treemodel, and the active item is not an immediate child of the root of the tree, this property has the value gtk_tree_path_get_indices (path)[0], where path is the [structGtk.TreePath] of the active item.

Parameters:

  • active (Integer)

Returns:

  • (Integer)

    active

  • (Integer)

    active

#active_idString

The value of the ID column of the active row.

Returns:

  • (String)

    active-id

#active_id=(active_id) ⇒ String

The value of the ID column of the active row.

Parameters:

  • active_id (String)

Returns:

  • (String)

    active-id

  • (String)

    active-id

#active_iterObject



45
46
47
48
49
50
51
52
53
# File 'lib/gtk3/combo-box.rb', line 45

def active_iter
  found, iter = active_iter_raw
  if found
    iter.model = model
    iter
  else
    nil
  end
end

#active_iter=(iter) ⇒ nil

Sets the current active item to be the one referenced by iter.

If iter is nil, the active item is unset.

Parameters:

Returns:

  • (nil)

#active_iter_rawObject



44
# File 'lib/gtk3/combo-box.rb', line 44

alias_method :active_iter_raw, :active_iter

#button_sensitivityGtk::SensitivityType

Whether the dropdown button is sensitive when the model is empty.

Returns:

#button_sensitivity=(button_sensitivity) ⇒ Gtk::SensitivityType

Whether the dropdown button is sensitive when the model is empty.

Parameters:

Returns:

#childGtk::Widget

The child widget.

Returns:

#child=(child) ⇒ Gtk::Widget

The child widget.

Parameters:

Returns:

#entry_text_columnInteger

The model column to associate with strings from the entry.

This is property only relevant if the combo was created with [propertyGtk.ComboBox:has-entry] is true.

Returns:

  • (Integer)

    entry-text-column

#entry_text_column=(entry_text_column) ⇒ Integer

The model column to associate with strings from the entry.

This is property only relevant if the combo was created with [propertyGtk.ComboBox:has-entry] is true.

Parameters:

  • entry_text_column (Integer)

Returns:

  • (Integer)

    entry-text-column

  • (Integer)

    entry-text-column

#get_active_iter(iter) ⇒ Boolean

Sets iter to point to the currently active item.

If no item is active, iter is left unchanged.

Parameters:

Returns:

  • (Boolean)

    true if iter was set, false otherwise

#has_entryBoolean

Returns whether the combo box has an entry.

Returns:

  • (Boolean)

    whether there is an entry in combo_box.

#has_entry=(has_entry) ⇒ Boolean

Whether the combo box has an entry.

Parameters:

  • has_entry (Boolean)

Returns:

  • (Boolean)

    has-entry

  • (Boolean)

    has-entry

#has_entry?Boolean

Whether the combo box has an entry.

Returns:

  • (Boolean)

    has-entry

#has_frame=(has_frame) ⇒ Boolean

The has-frame property controls whether a frame is drawn around the entry.

Parameters:

  • has_frame (Boolean)

Returns:

  • (Boolean)

    has-frame

  • (Boolean)

    has-frame

#has_frame?Boolean

The has-frame property controls whether a frame is drawn around the entry.

Returns:

  • (Boolean)

    has-frame

#id_columnInteger

The model column that provides string IDs for the values in the model, if != -1.

Returns:

  • (Integer)

    id-column

#id_column=(id_column) ⇒ Integer

The model column that provides string IDs for the values in the model, if != -1.

Parameters:

  • id_column (Integer)

Returns:

  • (Integer)

    id-column

  • (Integer)

    id-column

#initialize_rawGtk::Widget

Creates a new empty GtkComboBox with an entry and a model.

See also [ctorGtk.ComboBox.new_with_entry].

Parameters:

Returns:



# File 'lib/gtk3/combo-box.rb', line 19

#modelGtk::TreeModel

The model from which the combo box takes its values.

Returns:

#model=(model) ⇒ Gtk::TreeModel

The model from which the combo box takes its values.

Parameters:

Returns:

#popdownnil

Hides the menu or dropdown list of combo_box.

This function is mostly intended for use by accessibility technologies; applications should have little use for it.

Returns:

  • (nil)

Pops up the menu or dropdown list of combo_box.

This function is mostly intended for use by accessibility technologies; applications should have little use for it.

Before calling this, combo_box must be mapped, or nothing will happen.

Returns:

  • (nil)

Gets whether the popup uses a fixed width.

Returns:

  • (Boolean)

    true if the popup uses a fixed width

Whether the popup's width should be a fixed width matching the allocated width of the combo box.

Parameters:

  • popup_fixed_width (Boolean)

Returns:

  • (Boolean)

    popup-fixed-width

  • (Boolean)

    popup-fixed-width

Whether the popup's width should be a fixed width matching the allocated width of the combo box.

Returns:

  • (Boolean)

    popup-fixed-width

Pops up the menu of combo_box.

Note that currently this does not do anything with the device, as it was previously only used for list-mode combo boxes, and those were removed in GTK 4. However, it is retained in case similar functionality is added back later.

Parameters:

Returns:

  • (nil)

Whether the combo boxes dropdown is popped up.

Note that this property is mainly useful, because it allows you to connect to notify::popup-shown.

Parameters:

  • popup_shown (Boolean)

Returns:

  • (Boolean)

    popup-shown

  • (Boolean)

    popup-shown

Whether the combo boxes dropdown is popped up.

Note that this property is mainly useful, because it allows you to connect to notify::popup-shown.

Returns:

  • (Boolean)

    popup-shown

#row_separator_funcGtk::TreeViewRowSeparatorFunc

Returns the current row separator function.

Returns:

  • (Gtk::TreeViewRowSeparatorFunc)

    the current row separator function.

#set_row_separator_func(func, data, destroy) ⇒ nil

Sets the row separator function, which is used to determine whether a row should be drawn as a separator.

If the row separator function is nil, no separators are drawn. This is the default value.

Parameters:

  • func (Gtk::TreeViewRowSeparatorFunc)

    a GtkTreeViewRowSeparatorFunc

  • data (GObject)

    user data to pass to func

  • destroy (GLib::DestroyNotify)

    destroy notifier for data

Returns:

  • (nil)