2003-09-26 21:57:06 +00:00
|
|
|
|
/* gtkcombobox.c
|
|
|
|
|
* Copyright (C) 2002, 2003 Kristian Rietveld <kris@gtk.org>
|
|
|
|
|
*
|
2003-10-24 18:36:55 +00:00
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
2003-09-26 21:57:06 +00:00
|
|
|
|
*
|
2003-10-24 18:36:55 +00:00
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
2003-09-26 21:57:06 +00:00
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2003-10-24 18:36:55 +00:00
|
|
|
|
* Library General Public License for more details.
|
2003-09-26 21:57:06 +00:00
|
|
|
|
*
|
2003-10-24 18:36:55 +00:00
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2003-09-26 21:57:06 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
|
#include "config.h"
|
2012-03-03 18:41:55 +00:00
|
|
|
|
|
2018-02-08 23:42:38 +00:00
|
|
|
|
#include "gtkcomboboxprivate.h"
|
2012-03-03 18:41:55 +00:00
|
|
|
|
|
2018-02-08 23:42:38 +00:00
|
|
|
|
#include "gtkbox.h"
|
|
|
|
|
#include "gtkcellareabox.h"
|
2003-10-23 18:25:53 +00:00
|
|
|
|
#include "gtkcelllayout.h"
|
2004-02-29 00:08:04 +00:00
|
|
|
|
#include "gtkcellrenderertext.h"
|
2003-10-23 18:25:53 +00:00
|
|
|
|
#include "gtkcellview.h"
|
2018-08-12 19:15:37 +00:00
|
|
|
|
#include "gtkeventcontrollerkey.h"
|
2018-02-08 23:42:38 +00:00
|
|
|
|
#include "gtkeventcontrollerscroll.h"
|
2003-10-23 18:25:53 +00:00
|
|
|
|
#include "gtkframe.h"
|
2020-01-28 14:03:42 +00:00
|
|
|
|
#include "gtkbuiltiniconprivate.h"
|
2018-02-08 23:42:38 +00:00
|
|
|
|
#include "gtkintl.h"
|
2004-02-29 00:08:04 +00:00
|
|
|
|
#include "gtkliststore.h"
|
|
|
|
|
#include "gtkmain.h"
|
2018-02-08 23:42:38 +00:00
|
|
|
|
#include "gtkmarshalers.h"
|
|
|
|
|
#include "gtkprivate.h"
|
2018-08-12 19:15:37 +00:00
|
|
|
|
#include "gtkshortcutcontroller.h"
|
2003-10-23 18:25:53 +00:00
|
|
|
|
#include "gtktogglebutton.h"
|
2019-12-26 05:06:48 +00:00
|
|
|
|
#include "gtktreepopoverprivate.h"
|
2011-01-04 19:51:19 +00:00
|
|
|
|
#include "gtktypebuiltins.h"
|
2018-08-12 19:15:37 +00:00
|
|
|
|
#include "gtkwidgetprivate.h"
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2018-02-08 23:42:38 +00:00
|
|
|
|
#include <gobject/gvaluecollector.h>
|
2003-10-23 18:25:53 +00:00
|
|
|
|
#include <string.h>
|
2003-09-26 21:57:06 +00:00
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
2010-10-04 00:05:45 +00:00
|
|
|
|
/**
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* GtkComboBox:
|
2010-10-04 00:05:45 +00:00
|
|
|
|
*
|
2021-02-18 18:17:56 +00:00
|
|
|
|
* A `GtkComboBox` is a widget that allows the user to choose from a list of
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* valid choices.
|
2010-10-04 00:05:45 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* ![An example GtkComboBox](combo-box.png)
|
|
|
|
|
*
|
|
|
|
|
* The `GtkComboBox` displays the selected choice; when activated, the
|
|
|
|
|
* `GtkComboBox` displays a popup which allows the user to make a new choice.
|
|
|
|
|
*
|
|
|
|
|
* The `GtkComboBox` uses the model-view pattern; the list of valid choices
|
2010-10-04 00:05:45 +00:00
|
|
|
|
* is specified in the form of a tree model, and the display of the choices
|
|
|
|
|
* can be adapted to the data in the model by using cell renderers, as you
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* would in a tree view. This is possible since `GtkComboBox` implements the
|
|
|
|
|
* [interface@Gtk.CellLayout] interface. The tree model holding the valid
|
|
|
|
|
* choices is not restricted to a flat list, it can be a real tree, and the
|
|
|
|
|
* popup will reflect the tree structure.
|
|
|
|
|
*
|
|
|
|
|
* To allow the user to enter values not in the model, the
|
|
|
|
|
* [property@Gtk.ComboBox:has-entry] property allows the `GtkComboBox` to
|
|
|
|
|
* contain a [class@Gtk.Entry]. This entry can be accessed by calling
|
|
|
|
|
* [method@Gtk.ComboBox.get_child] on the combo box.
|
|
|
|
|
*
|
|
|
|
|
* For a simple list of textual choices, the model-view API of `GtkComboBox`
|
|
|
|
|
* can be a bit overwhelming. In this case, [class@Gtk.ComboBoxText] offers
|
|
|
|
|
* a simple alternative. Both `GtkComboBox` and `GtkComboBoxText` can contain
|
2010-12-13 20:45:07 +00:00
|
|
|
|
* an entry.
|
2015-11-02 18:15:05 +00:00
|
|
|
|
*
|
2021-02-18 18:17:56 +00:00
|
|
|
|
* ## CSS nodes
|
2015-11-02 18:15:05 +00:00
|
|
|
|
*
|
2015-11-03 19:19:08 +00:00
|
|
|
|
* |[<!-- language="plain" -->
|
|
|
|
|
* combobox
|
2016-03-01 18:14:30 +00:00
|
|
|
|
* ├── box.linked
|
|
|
|
|
* │ ╰── button.combo
|
2016-03-02 20:20:47 +00:00
|
|
|
|
* │ ╰── box
|
|
|
|
|
* │ ├── cellview
|
|
|
|
|
* │ ╰── arrow
|
2016-01-15 22:47:08 +00:00
|
|
|
|
* ╰── window.popup
|
2015-11-03 19:19:08 +00:00
|
|
|
|
* ]|
|
|
|
|
|
*
|
2016-03-01 18:14:30 +00:00
|
|
|
|
* A normal combobox contains a box with the .linked class, a button
|
|
|
|
|
* with the .combo class and inside those buttons, there are a cellview and
|
|
|
|
|
* an arrow.
|
|
|
|
|
*
|
|
|
|
|
* |[<!-- language="plain" -->
|
|
|
|
|
* combobox
|
|
|
|
|
* ├── box.linked
|
|
|
|
|
* │ ├── entry.combo
|
|
|
|
|
* │ ╰── button.combo
|
2016-03-02 20:20:47 +00:00
|
|
|
|
* │ ╰── box
|
|
|
|
|
* │ ╰── arrow
|
2016-03-01 18:14:30 +00:00
|
|
|
|
* ╰── window.popup
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* A `GtkComboBox` with an entry has a single CSS node with name combobox.
|
|
|
|
|
* It contains a box with the .linked class. That box contains an entry and
|
|
|
|
|
* a button, both with the .combo class added. The button also contains another
|
|
|
|
|
* node with name arrow.
|
2020-10-13 21:53:39 +00:00
|
|
|
|
*
|
|
|
|
|
* # Accessibility
|
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* `GtkComboBox` uses the #GTK_ACCESSIBLE_ROLE_COMBO_BOX role.
|
2010-10-04 00:05:45 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2018-06-10 10:25:44 +00:00
|
|
|
|
typedef struct
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
2020-05-03 17:12:21 +00:00
|
|
|
|
GtkWidget *child;
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
|
|
|
|
|
GtkCellArea *area;
|
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int active; /* Only temporary */
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkTreeRowReference *active_row;
|
|
|
|
|
|
|
|
|
|
GtkWidget *cell_view;
|
|
|
|
|
|
2016-03-01 17:29:22 +00:00
|
|
|
|
GtkWidget *box;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkWidget *button;
|
|
|
|
|
GtkWidget *arrow;
|
|
|
|
|
|
|
|
|
|
GtkWidget *popup_widget;
|
|
|
|
|
|
|
|
|
|
guint popup_idle_id;
|
|
|
|
|
guint scroll_timer;
|
|
|
|
|
guint resize_idle_id;
|
|
|
|
|
|
|
|
|
|
/* For "has-entry" specific behavior we track
|
2011-01-21 04:38:50 +00:00
|
|
|
|
* an automated cell renderer and text column
|
|
|
|
|
*/
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int text_column;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkCellRenderer *text_renderer;
|
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int id_column;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
guint popup_in_progress : 1;
|
|
|
|
|
guint popup_shown : 1;
|
|
|
|
|
guint has_frame : 1;
|
|
|
|
|
guint is_cell_renderer : 1;
|
|
|
|
|
guint editing_canceled : 1;
|
|
|
|
|
guint auto_scroll : 1;
|
|
|
|
|
guint button_sensitivity : 2;
|
|
|
|
|
guint has_entry : 1;
|
|
|
|
|
guint popup_fixed_width : 1;
|
|
|
|
|
|
|
|
|
|
GtkTreeViewRowSeparatorFunc row_separator_func;
|
|
|
|
|
gpointer row_separator_data;
|
|
|
|
|
GDestroyNotify row_separator_destroy;
|
2018-06-10 10:25:44 +00:00
|
|
|
|
} GtkComboBoxPrivate;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
2017-01-19 22:28:41 +00:00
|
|
|
|
/* There are 2 modes to this widget, which can be characterized as follows:
|
2016-12-01 12:36:30 +00:00
|
|
|
|
*
|
2017-01-19 22:28:41 +00:00
|
|
|
|
* 1) no child added:
|
2004-02-24 23:12:57 +00:00
|
|
|
|
*
|
|
|
|
|
* cell_view -> GtkCellView, regular child
|
|
|
|
|
* button -> GtkToggleButton set_parent to combo
|
|
|
|
|
* arrow -> GtkArrow set_parent to button
|
|
|
|
|
* popup_widget -> GtkMenu
|
|
|
|
|
*
|
2017-01-19 22:28:41 +00:00
|
|
|
|
* 2) child added:
|
2016-12-01 12:36:30 +00:00
|
|
|
|
*
|
|
|
|
|
* cell_view -> NULL
|
2004-02-24 23:12:57 +00:00
|
|
|
|
* button -> GtkToggleButton set_parent to combo
|
|
|
|
|
* arrow -> GtkArrow, child of button
|
|
|
|
|
* popup_widget -> GtkMenu
|
|
|
|
|
*/
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
enum {
|
|
|
|
|
CHANGED,
|
|
|
|
|
MOVE_ACTIVE,
|
|
|
|
|
POPUP,
|
|
|
|
|
POPDOWN,
|
2011-10-06 09:14:38 +00:00
|
|
|
|
FORMAT_ENTRY_TEXT,
|
2010-12-06 12:30:00 +00:00
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_MODEL,
|
|
|
|
|
PROP_ACTIVE,
|
|
|
|
|
PROP_HAS_FRAME,
|
|
|
|
|
PROP_POPUP_SHOWN,
|
|
|
|
|
PROP_BUTTON_SENSITIVITY,
|
|
|
|
|
PROP_EDITING_CANCELED,
|
|
|
|
|
PROP_HAS_ENTRY,
|
|
|
|
|
PROP_ENTRY_TEXT_COLUMN,
|
|
|
|
|
PROP_POPUP_FIXED_WIDTH,
|
|
|
|
|
PROP_ID_COLUMN,
|
2020-05-03 16:04:23 +00:00
|
|
|
|
PROP_ACTIVE_ID,
|
|
|
|
|
PROP_CHILD
|
2010-12-06 12:30:00 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static guint combo_box_signals[LAST_SIGNAL] = {0,};
|
|
|
|
|
|
|
|
|
|
/* common */
|
|
|
|
|
|
|
|
|
|
static void gtk_combo_box_cell_layout_init (GtkCellLayoutIface *iface);
|
|
|
|
|
static void gtk_combo_box_cell_editable_init (GtkCellEditableIface *iface);
|
2014-06-26 22:22:42 +00:00
|
|
|
|
static void gtk_combo_box_constructed (GObject *object);
|
2007-05-02 22:19:45 +00:00
|
|
|
|
static void gtk_combo_box_dispose (GObject *object);
|
2017-01-20 03:30:36 +00:00
|
|
|
|
static void gtk_combo_box_unmap (GtkWidget *widget);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
|
static void gtk_combo_box_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *spec);
|
|
|
|
|
static void gtk_combo_box_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *spec);
|
|
|
|
|
|
2019-10-15 13:34:16 +00:00
|
|
|
|
static gboolean gtk_combo_box_grab_focus (GtkWidget *widget);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void gtk_combo_box_button_toggled (GtkWidget *widget,
|
|
|
|
|
gpointer data);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
|
|
static void gtk_combo_box_menu_show (GtkWidget *menu,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
static void gtk_combo_box_menu_hide (GtkWidget *menu,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
Fixes #124373, Murray Cumming.
Mon Nov 17 00:11:21 2003 Kristian Rietveld <kris@gtk.org>
Fixes #124373, Murray Cumming.
* gtk/gtkcombobox.[ch] (gtk_combo_box_class_init): the model property
is no longer construct only,
(gtk_combo_box_unset_model), (gtk_combo_box_set_model_internal),
(gtk_combo_box_menu_fill): new functions,
(gtk_combo_box_menu_setup), (gtk_combo_box_menu_destroy),
(gtk_combo_box_menu_row_*), (gtk_combo_box_list_setup),
(gtk_combo_box_list_destroy): updated,
(gtk_combo_box_new), (gtk_combo_box_new_with_model): new/changed
functions,
(gtk_combo_box_set_model): is now public, updated,
(gtk_combo_box_get_model): small update.
* gtk/gtkcomboboxentry.[ch] (gtk_combo_box_entry_class_init): the
text_column property is no longer construct only,
(gtk_combo_box_entry_set_text_column): now public,
(gtk_combo_box_entry_new), (gtk_combo_box_entry_new_with_model):
new/changed functions.
* tests/testcombo.c: updated.
2003-11-16 23:20:15 +00:00
|
|
|
|
static void gtk_combo_box_unset_model (GtkComboBox *combo_box);
|
|
|
|
|
|
2004-03-03 22:30:36 +00:00
|
|
|
|
static void gtk_combo_box_set_active_internal (GtkComboBox *combo_box,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreePath *path);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void gtk_combo_box_real_move_active (GtkComboBox *combo_box,
|
|
|
|
|
GtkScrollType scroll);
|
|
|
|
|
static void gtk_combo_box_real_popup (GtkComboBox *combo_box);
|
|
|
|
|
static gboolean gtk_combo_box_real_popdown (GtkComboBox *combo_box);
|
2004-07-16 20:27:40 +00:00
|
|
|
|
|
2018-07-18 13:34:39 +00:00
|
|
|
|
static gboolean gtk_combo_box_scroll_controller_scroll (GtkEventControllerScroll *scroll,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double dx,
|
|
|
|
|
double dy,
|
2017-09-15 11:52:55 +00:00
|
|
|
|
GtkComboBox *combo_box);
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
/* listening to the model */
|
|
|
|
|
static void gtk_combo_box_model_row_inserted (GtkTreeModel *model,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer user_data);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void gtk_combo_box_model_row_deleted (GtkTreeModel *model,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
gpointer user_data);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void gtk_combo_box_model_rows_reordered (GtkTreeModel *model,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int *new_order,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gpointer user_data);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void gtk_combo_box_model_row_changed (GtkTreeModel *model,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
static void gtk_combo_box_menu_activate (GtkWidget *menu,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *path,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkComboBox *combo_box);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void gtk_combo_box_update_sensitivity (GtkComboBox *combo_box);
|
2018-06-26 11:35:26 +00:00
|
|
|
|
static gboolean gtk_combo_box_menu_key (GtkEventControllerKey *key,
|
|
|
|
|
guint keyval,
|
|
|
|
|
guint keycode,
|
|
|
|
|
GdkModifierType modifiers,
|
|
|
|
|
GtkComboBox *combo_box);
|
2017-02-16 21:33:25 +00:00
|
|
|
|
static void gtk_combo_box_menu_popup (GtkComboBox *combo_box);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
/* cell layout */
|
2011-01-31 22:34:37 +00:00
|
|
|
|
static GtkCellArea *gtk_combo_box_cell_layout_get_area (GtkCellLayout *cell_layout);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2004-02-05 20:35:57 +00:00
|
|
|
|
static gboolean gtk_combo_box_mnemonic_activate (GtkWidget *widget,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gboolean group_cycling);
|
2003-10-01 20:51:54 +00:00
|
|
|
|
|
2005-11-10 21:17:19 +00:00
|
|
|
|
static void gtk_combo_box_child_show (GtkWidget *widget,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkComboBox *combo_box);
|
2005-11-10 21:17:19 +00:00
|
|
|
|
static void gtk_combo_box_child_hide (GtkWidget *widget,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkComboBox *combo_box);
|
2005-11-10 21:17:19 +00:00
|
|
|
|
|
2010-10-14 01:52:27 +00:00
|
|
|
|
/* GtkComboBox:has-entry callbacks */
|
|
|
|
|
static void gtk_combo_box_entry_contents_changed (GtkEntry *entry,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gpointer user_data);
|
2010-10-14 01:52:27 +00:00
|
|
|
|
static void gtk_combo_box_entry_active_changed (GtkComboBox *combo_box,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gpointer user_data);
|
2020-07-24 18:40:36 +00:00
|
|
|
|
static char *gtk_combo_box_format_entry_text (GtkComboBox *combo_box,
|
|
|
|
|
const char *path);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
/* GtkBuildable method implementation */
|
|
|
|
|
static GtkBuildableIface *parent_buildable_iface;
|
|
|
|
|
|
2019-08-29 13:21:20 +00:00
|
|
|
|
static void gtk_combo_box_buildable_init (GtkBuildableIface *iface);
|
|
|
|
|
static void gtk_combo_box_buildable_add_child (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *type);
|
2019-08-29 13:21:20 +00:00
|
|
|
|
static gboolean gtk_combo_box_buildable_custom_tag_start (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *tagname,
|
2019-08-29 13:21:20 +00:00
|
|
|
|
GtkBuildableParser *parser,
|
|
|
|
|
gpointer *data);
|
|
|
|
|
static void gtk_combo_box_buildable_custom_tag_end (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *tagname,
|
2019-08-29 13:21:20 +00:00
|
|
|
|
gpointer data);
|
|
|
|
|
static GObject *gtk_combo_box_buildable_get_internal_child (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *childname);
|
2019-08-29 13:21:20 +00:00
|
|
|
|
|
2010-10-14 01:52:27 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
/* GtkCellEditable method implementations */
|
2010-08-18 23:39:59 +00:00
|
|
|
|
static void gtk_combo_box_start_editing (GtkCellEditable *cell_editable,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GdkEvent *event);
|
|
|
|
|
|
2020-05-03 17:12:21 +00:00
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkComboBox, gtk_combo_box, GTK_TYPE_WIDGET,
|
2013-06-27 19:02:52 +00:00
|
|
|
|
G_ADD_PRIVATE (GtkComboBox)
|
2011-01-04 15:14:25 +00:00
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_LAYOUT,
|
|
|
|
|
gtk_combo_box_cell_layout_init)
|
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_EDITABLE,
|
|
|
|
|
gtk_combo_box_cell_editable_init)
|
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
|
|
|
|
|
gtk_combo_box_buildable_init))
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2004-02-24 00:07:15 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
/* common */
|
2015-12-22 02:43:19 +00:00
|
|
|
|
static void
|
2017-05-05 07:39:15 +00:00
|
|
|
|
gtk_combo_box_measure (GtkWidget *widget,
|
2015-12-22 02:43:19 +00:00
|
|
|
|
GtkOrientation orientation,
|
|
|
|
|
int size,
|
|
|
|
|
int *minimum,
|
|
|
|
|
int *natural,
|
|
|
|
|
int *minimum_baseline,
|
2017-05-05 07:39:15 +00:00
|
|
|
|
int *natural_baseline)
|
2015-12-22 02:43:19 +00:00
|
|
|
|
{
|
2016-03-01 18:14:30 +00:00
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2015-12-22 02:43:19 +00:00
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
gtk_widget_measure (priv->box,
|
|
|
|
|
orientation,
|
|
|
|
|
size,
|
|
|
|
|
minimum, natural,
|
|
|
|
|
minimum_baseline, natural_baseline);
|
2015-12-22 02:43:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-08-16 04:53:03 +00:00
|
|
|
|
gtk_combo_box_size_allocate (GtkWidget *widget,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
int baseline)
|
2015-12-22 02:43:19 +00:00
|
|
|
|
{
|
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int menu_width;
|
2015-12-22 02:43:19 +00:00
|
|
|
|
|
2018-08-16 04:53:03 +00:00
|
|
|
|
gtk_widget_size_allocate (priv->box,
|
|
|
|
|
&(GtkAllocation) {
|
|
|
|
|
0, 0,
|
|
|
|
|
width, height
|
|
|
|
|
}, baseline);
|
2015-12-22 02:43:19 +00:00
|
|
|
|
|
2019-12-26 05:06:48 +00:00
|
|
|
|
gtk_widget_set_size_request (priv->popup_widget, -1, -1);
|
2015-12-22 02:43:19 +00:00
|
|
|
|
|
2019-12-26 05:06:48 +00:00
|
|
|
|
if (priv->popup_fixed_width)
|
|
|
|
|
gtk_widget_measure (priv->popup_widget, GTK_ORIENTATION_HORIZONTAL, -1,
|
|
|
|
|
&menu_width, NULL, NULL, NULL);
|
|
|
|
|
else
|
|
|
|
|
gtk_widget_measure (priv->popup_widget, GTK_ORIENTATION_HORIZONTAL, -1,
|
|
|
|
|
NULL, &menu_width, NULL, NULL);
|
2015-12-22 02:43:19 +00:00
|
|
|
|
|
2019-12-26 05:06:48 +00:00
|
|
|
|
gtk_widget_set_size_request (priv->popup_widget,
|
|
|
|
|
MAX (width, menu_width), -1);
|
2016-11-11 20:50:07 +00:00
|
|
|
|
|
2020-12-04 08:20:50 +00:00
|
|
|
|
gtk_popover_present (GTK_POPOVER (priv->popup_widget));
|
2015-12-22 02:43:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-01 17:19:44 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_compute_expand (GtkWidget *widget,
|
|
|
|
|
gboolean *hexpand,
|
|
|
|
|
gboolean *vexpand)
|
|
|
|
|
{
|
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2020-05-03 17:12:21 +00:00
|
|
|
|
GtkWidget *child = priv->child;
|
2016-03-01 17:19:44 +00:00
|
|
|
|
|
|
|
|
|
if (child && child != priv->cell_view)
|
|
|
|
|
{
|
|
|
|
|
*hexpand = gtk_widget_compute_expand (child, GTK_ORIENTATION_HORIZONTAL);
|
|
|
|
|
*vexpand = gtk_widget_compute_expand (child, GTK_ORIENTATION_VERTICAL);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*hexpand = FALSE;
|
|
|
|
|
*vexpand = FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_class_init (GtkComboBoxClass *klass)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class;
|
|
|
|
|
GtkWidgetClass *widget_class;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
widget_class = (GtkWidgetClass *)klass;
|
|
|
|
|
widget_class->mnemonic_activate = gtk_combo_box_mnemonic_activate;
|
|
|
|
|
widget_class->grab_focus = gtk_combo_box_grab_focus;
|
2020-04-08 11:43:28 +00:00
|
|
|
|
widget_class->focus = gtk_widget_focus_child;
|
2017-05-05 07:39:15 +00:00
|
|
|
|
widget_class->measure = gtk_combo_box_measure;
|
2020-05-03 17:12:21 +00:00
|
|
|
|
widget_class->size_allocate = gtk_combo_box_size_allocate;
|
2017-01-20 03:30:36 +00:00
|
|
|
|
widget_class->unmap = gtk_combo_box_unmap;
|
2016-03-01 17:19:44 +00:00
|
|
|
|
widget_class->compute_expand = gtk_combo_box_compute_expand;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
object_class = (GObjectClass *)klass;
|
2014-06-26 22:22:42 +00:00
|
|
|
|
object_class->constructed = gtk_combo_box_constructed;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
object_class->dispose = gtk_combo_box_dispose;
|
|
|
|
|
object_class->set_property = gtk_combo_box_set_property;
|
|
|
|
|
object_class->get_property = gtk_combo_box_get_property;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2011-10-06 09:14:38 +00:00
|
|
|
|
klass->format_entry_text = gtk_combo_box_format_entry_text;
|
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
/* signals */
|
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox::changed:
|
2004-11-12 22:57:09 +00:00
|
|
|
|
* @widget: the object which received the signal
|
2016-12-01 12:36:30 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* Emitted when the active item is changed.
|
|
|
|
|
*
|
|
|
|
|
* The can be due to the user selecting a different item from the list,
|
|
|
|
|
* or due to a call to [method@Gtk.ComboBox.set_active_iter]. It will
|
|
|
|
|
* also be emitted while typing into the entry of a combo box with an entry.
|
2004-11-12 22:57:09 +00:00
|
|
|
|
*/
|
2003-09-26 21:57:06 +00:00
|
|
|
|
combo_box_signals[CHANGED] =
|
2005-09-01 05:11:46 +00:00
|
|
|
|
g_signal_new (I_("changed"),
|
2003-09-26 21:57:06 +00:00
|
|
|
|
G_OBJECT_CLASS_TYPE (klass),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (GtkComboBoxClass, changed),
|
|
|
|
|
NULL, NULL,
|
2019-05-29 20:05:19 +00:00
|
|
|
|
NULL,
|
2003-09-26 21:57:06 +00:00
|
|
|
|
G_TYPE_NONE, 0);
|
2021-02-21 22:20:23 +00:00
|
|
|
|
|
2007-08-08 19:59:42 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox::move-active:
|
|
|
|
|
* @widget: the object that received the signal
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @scroll_type: a `GtkScrollType`
|
2007-08-08 19:59:42 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* Emitted to move the active selection.
|
|
|
|
|
*
|
|
|
|
|
* This is an [keybinding signal](class.SignalAction.html).
|
2007-08-08 19:59:42 +00:00
|
|
|
|
*/
|
2006-10-12 13:04:44 +00:00
|
|
|
|
combo_box_signals[MOVE_ACTIVE] =
|
2008-07-21 09:48:20 +00:00
|
|
|
|
g_signal_new_class_handler (I_("move-active"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (klass),
|
|
|
|
|
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
|
|
|
|
G_CALLBACK (gtk_combo_box_real_move_active),
|
|
|
|
|
NULL, NULL,
|
2019-05-31 03:56:50 +00:00
|
|
|
|
NULL,
|
2008-07-21 09:48:20 +00:00
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
|
GTK_TYPE_SCROLL_TYPE);
|
2006-10-12 13:04:44 +00:00
|
|
|
|
|
2007-08-08 19:59:42 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox::popup:
|
|
|
|
|
* @widget: the object that received the signal
|
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* Emitted to popup the combo box list.
|
|
|
|
|
*
|
|
|
|
|
* This is an [keybinding signal](class.SignalAction.html).
|
2007-08-08 19:59:42 +00:00
|
|
|
|
*
|
|
|
|
|
* The default binding for this signal is Alt+Down.
|
|
|
|
|
*/
|
2006-10-12 13:04:44 +00:00
|
|
|
|
combo_box_signals[POPUP] =
|
2008-07-21 09:48:20 +00:00
|
|
|
|
g_signal_new_class_handler (I_("popup"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (klass),
|
|
|
|
|
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
|
|
|
|
G_CALLBACK (gtk_combo_box_real_popup),
|
|
|
|
|
NULL, NULL,
|
2019-05-29 20:05:19 +00:00
|
|
|
|
NULL,
|
2008-07-21 09:48:20 +00:00
|
|
|
|
G_TYPE_NONE, 0);
|
2007-08-08 19:59:42 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox::popdown:
|
|
|
|
|
* @button: the object which received the signal
|
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* Emitted to popdown the combo box list.
|
|
|
|
|
*
|
|
|
|
|
* This is an [keybinding signal](class.SignalAction.html).
|
2007-08-08 19:59:42 +00:00
|
|
|
|
*
|
|
|
|
|
* The default bindings for this signal are Alt+Up and Escape.
|
|
|
|
|
*/
|
2007-05-18 11:33:13 +00:00
|
|
|
|
combo_box_signals[POPDOWN] =
|
2008-07-21 09:48:20 +00:00
|
|
|
|
g_signal_new_class_handler (I_("popdown"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (klass),
|
|
|
|
|
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
|
|
|
|
G_CALLBACK (gtk_combo_box_real_popdown),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
_gtk_marshal_BOOLEAN__VOID,
|
|
|
|
|
G_TYPE_BOOLEAN, 0);
|
2007-05-18 11:33:13 +00:00
|
|
|
|
|
2011-10-06 09:14:38 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox::format-entry-text:
|
|
|
|
|
* @combo: the object which received the signal
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @path: the [struct@Gtk.TreePath] string from the combo box's current model
|
|
|
|
|
* to format text for
|
2011-10-06 09:14:38 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* Emitted to allow changing how the text in a combo box's entry is displayed.
|
2011-10-06 09:14:38 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* See [property@Gtk.ComboBox:has-entry].
|
2011-10-06 09:14:38 +00:00
|
|
|
|
*
|
|
|
|
|
* Connect a signal handler which returns an allocated string representing
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @path. That string will then be used to set the text in the combo box's
|
|
|
|
|
* entry. The default signal handler uses the text from the
|
|
|
|
|
* [property@Gtk.ComboBox:entry-text-column] model column.
|
2011-10-06 09:14:38 +00:00
|
|
|
|
*
|
|
|
|
|
* Here's an example signal handler which fetches data from the model and
|
|
|
|
|
* displays it in the entry.
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* ```c
|
2020-07-24 18:40:36 +00:00
|
|
|
|
* static char *
|
2011-10-06 09:14:38 +00:00
|
|
|
|
* format_entry_text_callback (GtkComboBox *combo,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
* const char *path,
|
2011-10-06 09:14:38 +00:00
|
|
|
|
* gpointer user_data)
|
|
|
|
|
* {
|
|
|
|
|
* GtkTreeIter iter;
|
|
|
|
|
* GtkTreeModel model;
|
2020-07-24 20:32:16 +00:00
|
|
|
|
* double value;
|
2016-12-01 12:36:30 +00:00
|
|
|
|
*
|
2011-10-06 09:14:38 +00:00
|
|
|
|
* model = gtk_combo_box_get_model (combo);
|
|
|
|
|
*
|
|
|
|
|
* gtk_tree_model_get_iter_from_string (model, &iter, path);
|
2016-12-01 12:36:30 +00:00
|
|
|
|
* gtk_tree_model_get (model, &iter,
|
2011-10-06 09:14:38 +00:00
|
|
|
|
* THE_DOUBLE_VALUE_COLUMN, &value,
|
|
|
|
|
* -1);
|
|
|
|
|
*
|
2014-02-09 22:24:06 +00:00
|
|
|
|
* return g_strdup_printf ("%g", value);
|
2011-10-06 09:14:38 +00:00
|
|
|
|
* }
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* ```
|
2011-10-06 09:14:38 +00:00
|
|
|
|
*
|
2016-12-01 12:36:30 +00:00
|
|
|
|
* Returns: (transfer full): a newly allocated string representing @path
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* for the current `GtkComboBox` model.
|
2011-10-06 09:14:38 +00:00
|
|
|
|
*/
|
|
|
|
|
combo_box_signals[FORMAT_ENTRY_TEXT] =
|
|
|
|
|
g_signal_new (I_("format-entry-text"),
|
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (GtkComboBoxClass, format_entry_text),
|
|
|
|
|
_gtk_single_string_accumulator, NULL,
|
|
|
|
|
_gtk_marshal_STRING__STRING,
|
|
|
|
|
G_TYPE_STRING, 1, G_TYPE_STRING);
|
|
|
|
|
|
2006-10-12 13:04:44 +00:00
|
|
|
|
/* key bindings */
|
2018-08-05 02:30:15 +00:00
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
2020-04-05 13:39:03 +00:00
|
|
|
|
GDK_KEY_Down, GDK_ALT_MASK,
|
2018-08-05 02:30:15 +00:00
|
|
|
|
"popup",
|
|
|
|
|
NULL);
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
2020-04-05 13:39:03 +00:00
|
|
|
|
GDK_KEY_KP_Down, GDK_ALT_MASK,
|
2018-08-05 02:30:15 +00:00
|
|
|
|
"popup",
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
2020-04-05 13:39:03 +00:00
|
|
|
|
GDK_KEY_Up, GDK_ALT_MASK,
|
2018-08-05 02:30:15 +00:00
|
|
|
|
"popdown",
|
|
|
|
|
NULL);
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
2020-04-05 13:39:03 +00:00
|
|
|
|
GDK_KEY_KP_Up, GDK_ALT_MASK,
|
2018-08-05 02:30:15 +00:00
|
|
|
|
"popdown",
|
|
|
|
|
NULL);
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_Escape, 0,
|
|
|
|
|
"popdown",
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_Up, 0,
|
|
|
|
|
"move-active",
|
|
|
|
|
"(i)", GTK_SCROLL_STEP_UP);
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_KP_Up, 0,
|
|
|
|
|
"move-active",
|
|
|
|
|
"(i)", GTK_SCROLL_STEP_UP);
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_Page_Up, 0,
|
|
|
|
|
"move-active",
|
|
|
|
|
"(i)", GTK_SCROLL_PAGE_UP);
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_KP_Page_Up, 0,
|
|
|
|
|
"move-active",
|
|
|
|
|
"(i)", GTK_SCROLL_PAGE_UP);
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_Home, 0,
|
|
|
|
|
"move-active",
|
|
|
|
|
"(i)", GTK_SCROLL_START);
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_KP_Home, 0,
|
|
|
|
|
"move-active",
|
|
|
|
|
"(i)", GTK_SCROLL_START);
|
|
|
|
|
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_Down, 0,
|
|
|
|
|
"move-active",
|
|
|
|
|
"(i)", GTK_SCROLL_STEP_DOWN);
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_KP_Down, 0,
|
|
|
|
|
"move-active",
|
|
|
|
|
"(i)", GTK_SCROLL_STEP_DOWN);
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_Page_Down, 0,
|
|
|
|
|
"move-active",
|
|
|
|
|
"(i)", GTK_SCROLL_PAGE_DOWN);
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_KP_Page_Down, 0,
|
|
|
|
|
"move-active",
|
|
|
|
|
"(i)", GTK_SCROLL_PAGE_DOWN);
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_End, 0,
|
|
|
|
|
"move-active",
|
|
|
|
|
"(i)", GTK_SCROLL_END);
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_KP_End, 0,
|
|
|
|
|
"move-active",
|
|
|
|
|
"(i)", GTK_SCROLL_END);
|
2006-10-12 13:04:44 +00:00
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
|
/* properties */
|
2009-10-21 16:40:19 +00:00
|
|
|
|
g_object_class_override_property (object_class,
|
|
|
|
|
PROP_EDITING_CANCELED,
|
|
|
|
|
"editing-canceled");
|
|
|
|
|
|
2004-11-12 22:57:09 +00:00
|
|
|
|
/**
|
2021-02-25 17:22:44 +00:00
|
|
|
|
* GtkComboBox:model: (attributes org.gtk.Property.get=gtk_combo_box_get_model org.gtk.Property.set=gtk_combo_box_set_model)
|
2004-11-12 22:57:09 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* The model from which the combo box takes its values.
|
2004-11-12 22:57:09 +00:00
|
|
|
|
*/
|
2003-09-26 21:57:06 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_MODEL,
|
|
|
|
|
g_param_spec_object ("model",
|
2004-01-16 23:10:05 +00:00
|
|
|
|
P_("ComboBox model"),
|
|
|
|
|
P_("The model for the combo box"),
|
2003-09-26 21:57:06 +00:00
|
|
|
|
GTK_TYPE_TREE_MODEL,
|
2014-06-07 15:47:53 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
|
|
|
2004-11-12 22:57:09 +00:00
|
|
|
|
/**
|
2021-02-25 17:22:44 +00:00
|
|
|
|
* GtkComboBox:active: (attributes org.gtk.Property.get=gtk_combo_box_get_active org.gtk.Property.set=gtk_combo_box_set_active)
|
2004-11-12 22:57:09 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* 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
|
|
|
|
|
* [struct@Gtk.TreePath] of the active item.
|
2004-11-12 22:57:09 +00:00
|
|
|
|
*/
|
2003-09-26 21:57:06 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_ACTIVE,
|
|
|
|
|
g_param_spec_int ("active",
|
2004-01-16 23:10:05 +00:00
|
|
|
|
P_("Active item"),
|
|
|
|
|
P_("The item which is currently active"),
|
2004-06-04 00:57:03 +00:00
|
|
|
|
-1,
|
2003-09-26 21:57:06 +00:00
|
|
|
|
G_MAXINT,
|
2004-06-04 00:57:03 +00:00
|
|
|
|
-1,
|
2014-06-07 15:47:53 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2004-07-16 20:27:40 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox:has-frame:
|
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* The `has-frame` property controls whether a frame is drawn around the entry.
|
2004-07-16 20:27:40 +00:00
|
|
|
|
*/
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_HAS_FRAME,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
g_param_spec_boolean ("has-frame",
|
|
|
|
|
P_("Has Frame"),
|
|
|
|
|
P_("Whether the combo box draws a frame around the child"),
|
|
|
|
|
TRUE,
|
2014-06-07 15:47:53 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2006-03-09 20:20:30 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox:popup-shown:
|
|
|
|
|
*
|
2011-01-04 15:14:25 +00:00
|
|
|
|
* Whether the combo boxes dropdown is popped up.
|
2021-02-21 22:20:23 +00:00
|
|
|
|
*
|
2006-03-09 20:20:30 +00:00
|
|
|
|
* Note that this property is mainly useful, because
|
|
|
|
|
* it allows you to connect to notify::popup-shown.
|
|
|
|
|
*/
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_POPUP_SHOWN,
|
|
|
|
|
g_param_spec_boolean ("popup-shown",
|
|
|
|
|
P_("Popup shown"),
|
2016-10-03 16:20:03 +00:00
|
|
|
|
P_("Whether the combo’s dropdown is shown"),
|
2006-03-09 20:20:30 +00:00
|
|
|
|
FALSE,
|
|
|
|
|
GTK_PARAM_READABLE));
|
2007-05-18 11:33:13 +00:00
|
|
|
|
|
2008-08-04 23:40:36 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 17:22:44 +00:00
|
|
|
|
* GtkComboBox:button-sensitivity: (attributes org.gtk.Property.get=gtk_combo_box_get_button_sensitivity org.gtk.Property.set=gtk_combo_box_set_button_sensitivity)
|
2008-08-04 23:40:36 +00:00
|
|
|
|
*
|
|
|
|
|
* Whether the dropdown button is sensitive when
|
|
|
|
|
* the model is empty.
|
|
|
|
|
*/
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_BUTTON_SENSITIVITY,
|
|
|
|
|
g_param_spec_enum ("button-sensitivity",
|
|
|
|
|
P_("Button Sensitivity"),
|
|
|
|
|
P_("Whether the dropdown button is sensitive when the model is empty"),
|
|
|
|
|
GTK_TYPE_SENSITIVITY_TYPE,
|
|
|
|
|
GTK_SENSITIVITY_AUTO,
|
2014-06-07 15:47:53 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
2008-08-04 23:40:36 +00:00
|
|
|
|
|
2010-10-14 01:52:27 +00:00
|
|
|
|
/**
|
2021-02-25 17:22:44 +00:00
|
|
|
|
* GtkComboBox:has-entry: (attributes org.gtk.Property.get=gtk_combo_box_get_has_entry)
|
2010-10-14 01:52:27 +00:00
|
|
|
|
*
|
|
|
|
|
* Whether the combo box has an entry.
|
|
|
|
|
*/
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_HAS_ENTRY,
|
|
|
|
|
g_param_spec_boolean ("has-entry",
|
2011-01-04 15:14:25 +00:00
|
|
|
|
P_("Has Entry"),
|
|
|
|
|
P_("Whether combo box has an entry"),
|
|
|
|
|
FALSE,
|
2014-06-07 15:47:53 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
|
2010-10-14 01:52:27 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 17:22:44 +00:00
|
|
|
|
* GtkComboBox:entry-text-column: (attributes org.gtk.Property.get=gtk_combo_box_get_entry_text_column org.gtk.Property.set=gtk_combo_box_set_entry_text_column)
|
2010-10-14 01:52:27 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* The model column to associate with strings from the entry.
|
|
|
|
|
*
|
|
|
|
|
* This is property only relevant if the combo was created with
|
|
|
|
|
* [property@Gtk.ComboBox:has-entry] is %TRUE.
|
2010-10-14 01:52:27 +00:00
|
|
|
|
*/
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_ENTRY_TEXT_COLUMN,
|
|
|
|
|
g_param_spec_int ("entry-text-column",
|
2011-01-04 15:14:25 +00:00
|
|
|
|
P_("Entry Text Column"),
|
2016-10-03 16:20:03 +00:00
|
|
|
|
P_("The column in the combo box’s model to associate "
|
2011-01-04 15:14:25 +00:00
|
|
|
|
"with strings from the entry if the combo was "
|
|
|
|
|
"created with #GtkComboBox:has-entry = %TRUE"),
|
|
|
|
|
-1, G_MAXINT, -1,
|
2014-06-07 15:47:53 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
2010-10-14 01:52:27 +00:00
|
|
|
|
|
2010-11-30 05:07:08 +00:00
|
|
|
|
/**
|
2021-02-25 17:22:44 +00:00
|
|
|
|
* GtkComboBox:id-column: (attributes org.gtk.Property.get=gtk_combo_box_get_id_column org.gtk.Property.set=gtk_combo_box_set_id_column)
|
2010-11-30 05:07:08 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* The model column that provides string IDs for the values
|
|
|
|
|
* in the model, if != -1.
|
2010-11-30 05:07:08 +00:00
|
|
|
|
*/
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_ID_COLUMN,
|
|
|
|
|
g_param_spec_int ("id-column",
|
|
|
|
|
P_("ID Column"),
|
2016-10-03 16:20:03 +00:00
|
|
|
|
P_("The column in the combo box’s model that provides "
|
2010-11-30 05:07:08 +00:00
|
|
|
|
"string IDs for the values in the model"),
|
|
|
|
|
-1, G_MAXINT, -1,
|
2014-06-07 15:47:53 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
2010-11-30 05:07:08 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 17:22:44 +00:00
|
|
|
|
* GtkComboBox:active-id: (attributes org.gtk.Property.get=gtk_combo_box_get_active_id org.gtk.Property.set=gtk_combo_box_set_active_id)
|
2010-11-30 05:07:08 +00:00
|
|
|
|
*
|
|
|
|
|
* The value of the ID column of the active row.
|
|
|
|
|
*/
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_ACTIVE_ID,
|
|
|
|
|
g_param_spec_string ("active-id",
|
|
|
|
|
P_("Active id"),
|
|
|
|
|
P_("The value of the id column "
|
|
|
|
|
"for the active row"),
|
2014-06-07 15:47:53 +00:00
|
|
|
|
NULL,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
2010-11-30 05:07:08 +00:00
|
|
|
|
|
2010-10-16 09:01:33 +00:00
|
|
|
|
/**
|
2021-02-25 17:22:44 +00:00
|
|
|
|
* GtkComboBox:popup-fixed-width: (attributes org.gtk.Property.get=gtk_combo_box_get_popup_fixed_width org.gtk.Property.set=gtk_combo_box_set_popup_fixed_width)
|
2010-10-16 09:01:33 +00:00
|
|
|
|
*
|
|
|
|
|
* Whether the popup's width should be a fixed width matching the
|
|
|
|
|
* allocated width of the combo box.
|
|
|
|
|
*/
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_POPUP_FIXED_WIDTH,
|
|
|
|
|
g_param_spec_boolean ("popup-fixed-width",
|
2011-01-04 15:14:25 +00:00
|
|
|
|
P_("Popup Fixed Width"),
|
2016-10-03 16:20:03 +00:00
|
|
|
|
P_("Whether the popup’s width should be a "
|
2011-01-04 15:14:25 +00:00
|
|
|
|
"fixed width matching the allocated width "
|
|
|
|
|
"of the combo box"),
|
|
|
|
|
TRUE,
|
2014-06-07 15:47:53 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
2010-10-16 09:01:33 +00:00
|
|
|
|
|
2021-02-21 22:20:23 +00:00
|
|
|
|
/**
|
2021-02-25 17:22:44 +00:00
|
|
|
|
* GtkComboBox:child: (attributes org.gtk.Property.get=gtk_combo_box_get_child org.gtk.Property.set=gtk_combo_box_set_child)
|
2021-02-21 22:20:23 +00:00
|
|
|
|
*
|
|
|
|
|
* The child widget.
|
|
|
|
|
*/
|
2020-05-03 16:04:23 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_CHILD,
|
|
|
|
|
g_param_spec_object ("child",
|
|
|
|
|
P_("Child"),
|
|
|
|
|
P_("The child_widget"),
|
|
|
|
|
GTK_TYPE_WIDGET,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
|
|
|
|
|
2015-07-25 22:06:46 +00:00
|
|
|
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/ui/gtkcombobox.ui");
|
2016-03-01 17:29:22 +00:00
|
|
|
|
gtk_widget_class_bind_template_child_internal_private (widget_class, GtkComboBox, box);
|
2015-07-25 22:06:46 +00:00
|
|
|
|
gtk_widget_class_bind_template_child_internal_private (widget_class, GtkComboBox, button);
|
|
|
|
|
gtk_widget_class_bind_template_child_internal_private (widget_class, GtkComboBox, arrow);
|
2017-01-21 20:23:27 +00:00
|
|
|
|
gtk_widget_class_bind_template_child_internal_private (widget_class, GtkComboBox, area);
|
|
|
|
|
gtk_widget_class_bind_template_child_internal_private (widget_class, GtkComboBox, popup_widget);
|
2015-07-25 22:06:46 +00:00
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, gtk_combo_box_button_toggled);
|
2017-01-21 20:23:27 +00:00
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, gtk_combo_box_menu_activate);
|
2018-06-26 11:35:26 +00:00
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, gtk_combo_box_menu_key);
|
2017-01-21 20:23:27 +00:00
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, gtk_combo_box_menu_show);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, gtk_combo_box_menu_hide);
|
2015-07-25 22:06:46 +00:00
|
|
|
|
|
2017-11-18 03:49:57 +00:00
|
|
|
|
gtk_widget_class_set_css_name (widget_class, I_("combobox"));
|
2020-10-13 21:53:39 +00:00
|
|
|
|
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_COMBO_BOX);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_buildable_init (GtkBuildableIface *iface)
|
|
|
|
|
{
|
|
|
|
|
parent_buildable_iface = g_type_interface_peek_parent (iface);
|
2015-07-25 22:06:46 +00:00
|
|
|
|
iface->add_child = gtk_combo_box_buildable_add_child;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
iface->custom_tag_start = gtk_combo_box_buildable_custom_tag_start;
|
|
|
|
|
iface->custom_tag_end = gtk_combo_box_buildable_custom_tag_end;
|
|
|
|
|
iface->get_internal_child = gtk_combo_box_buildable_get_internal_child;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_cell_layout_init (GtkCellLayoutIface *iface)
|
|
|
|
|
{
|
|
|
|
|
iface->get_area = gtk_combo_box_cell_layout_get_area;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_cell_editable_init (GtkCellEditableIface *iface)
|
|
|
|
|
{
|
|
|
|
|
iface->start_editing = gtk_combo_box_start_editing;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-21 20:23:27 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_combo_box_row_separator_func (GtkTreeModel *model,
|
|
|
|
|
GtkTreeIter *iter,
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBox *combo_box)
|
2017-01-21 20:23:27 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2017-01-21 20:23:27 +00:00
|
|
|
|
|
|
|
|
|
if (priv->row_separator_func)
|
|
|
|
|
return priv->row_separator_func (model, iter, priv->row_separator_data);
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_init (GtkComboBox *combo_box)
|
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2018-03-10 17:29:57 +00:00
|
|
|
|
GtkEventController *controller;
|
2020-03-28 19:37:29 +00:00
|
|
|
|
GtkEventController **controllers;
|
|
|
|
|
guint n_controllers, i;
|
2010-06-02 03:13:35 +00:00
|
|
|
|
|
2008-12-13 08:11:54 +00:00
|
|
|
|
priv->active = -1;
|
2007-12-28 06:56:48 +00:00
|
|
|
|
priv->active_row = NULL;
|
2004-07-16 20:27:40 +00:00
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
|
priv->popup_shown = FALSE;
|
|
|
|
|
priv->has_frame = TRUE;
|
|
|
|
|
priv->is_cell_renderer = FALSE;
|
|
|
|
|
priv->editing_canceled = FALSE;
|
|
|
|
|
priv->auto_scroll = FALSE;
|
2008-08-04 23:40:36 +00:00
|
|
|
|
priv->button_sensitivity = GTK_SENSITIVITY_AUTO;
|
2010-10-14 01:52:27 +00:00
|
|
|
|
priv->has_entry = FALSE;
|
2010-10-16 09:01:33 +00:00
|
|
|
|
priv->popup_fixed_width = TRUE;
|
2010-10-14 01:52:27 +00:00
|
|
|
|
|
|
|
|
|
priv->text_column = -1;
|
|
|
|
|
priv->text_renderer = NULL;
|
2010-11-30 05:07:08 +00:00
|
|
|
|
priv->id_column = -1;
|
2015-07-25 21:19:40 +00:00
|
|
|
|
|
2020-01-28 14:03:42 +00:00
|
|
|
|
g_type_ensure (GTK_TYPE_BUILTIN_ICON);
|
2019-12-26 05:06:48 +00:00
|
|
|
|
g_type_ensure (GTK_TYPE_TREE_POPOVER);
|
2015-07-25 22:06:46 +00:00
|
|
|
|
gtk_widget_init_template (GTK_WIDGET (combo_box));
|
2015-07-25 21:19:40 +00:00
|
|
|
|
|
2020-02-06 16:32:26 +00:00
|
|
|
|
gtk_widget_remove_css_class (priv->button, "toggle");
|
|
|
|
|
gtk_widget_add_css_class (priv->button, "combo");
|
2015-12-22 02:43:19 +00:00
|
|
|
|
|
2019-12-26 05:06:48 +00:00
|
|
|
|
gtk_tree_popover_set_row_separator_func (GTK_TREE_POPOVER (priv->popup_widget),
|
|
|
|
|
(GtkTreeViewRowSeparatorFunc)gtk_combo_box_row_separator_func,
|
|
|
|
|
combo_box, NULL);
|
2017-09-15 11:52:55 +00:00
|
|
|
|
|
2018-03-10 17:29:57 +00:00
|
|
|
|
controller = gtk_event_controller_scroll_new (GTK_EVENT_CONTROLLER_SCROLL_VERTICAL |
|
|
|
|
|
GTK_EVENT_CONTROLLER_SCROLL_DISCRETE);
|
|
|
|
|
g_signal_connect (controller, "scroll",
|
2017-09-15 11:52:55 +00:00
|
|
|
|
G_CALLBACK (gtk_combo_box_scroll_controller_scroll),
|
|
|
|
|
combo_box);
|
2018-03-10 17:29:57 +00:00
|
|
|
|
gtk_widget_add_controller (GTK_WIDGET (combo_box), controller);
|
2018-08-12 19:15:37 +00:00
|
|
|
|
|
2020-03-28 19:37:29 +00:00
|
|
|
|
controllers = gtk_widget_list_controllers (priv->popup_widget, GTK_PHASE_BUBBLE, &n_controllers);
|
|
|
|
|
for (i = 0; i < n_controllers; i ++)
|
2018-08-12 19:15:37 +00:00
|
|
|
|
{
|
2020-03-28 19:37:29 +00:00
|
|
|
|
controller = controllers[i];
|
|
|
|
|
|
|
|
|
|
if (GTK_IS_SHORTCUT_CONTROLLER (controller))
|
2018-08-12 19:15:37 +00:00
|
|
|
|
{
|
2020-03-28 19:37:29 +00:00
|
|
|
|
g_object_ref (controller);
|
|
|
|
|
gtk_widget_remove_controller (priv->popup_widget, controller);
|
|
|
|
|
gtk_widget_add_controller (priv->popup_widget, controller);
|
2018-08-12 19:15:37 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-03-28 19:37:29 +00:00
|
|
|
|
g_free (controllers);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (object);
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
switch (prop_id)
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
case PROP_MODEL:
|
|
|
|
|
gtk_combo_box_set_model (combo_box, g_value_get_object (value));
|
|
|
|
|
break;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
case PROP_ACTIVE:
|
|
|
|
|
gtk_combo_box_set_active (combo_box, g_value_get_int (value));
|
|
|
|
|
break;
|
2010-12-05 09:03:32 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
case PROP_HAS_FRAME:
|
2014-06-07 20:40:09 +00:00
|
|
|
|
if (priv->has_frame != g_value_get_boolean (value))
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
2014-06-07 20:40:09 +00:00
|
|
|
|
priv->has_frame = g_value_get_boolean (value);
|
|
|
|
|
if (priv->has_entry)
|
2020-05-03 17:12:21 +00:00
|
|
|
|
gtk_entry_set_has_frame (GTK_ENTRY (priv->child), priv->has_frame);
|
2014-06-07 20:40:09 +00:00
|
|
|
|
g_object_notify (object, "has-frame");
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2009-10-21 16:40:19 +00:00
|
|
|
|
case PROP_POPUP_SHOWN:
|
|
|
|
|
if (g_value_get_boolean (value))
|
|
|
|
|
gtk_combo_box_popup (combo_box);
|
|
|
|
|
else
|
|
|
|
|
gtk_combo_box_popdown (combo_box);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_BUTTON_SENSITIVITY:
|
|
|
|
|
gtk_combo_box_set_button_sensitivity (combo_box,
|
|
|
|
|
g_value_get_enum (value));
|
|
|
|
|
break;
|
|
|
|
|
|
2010-10-16 09:01:33 +00:00
|
|
|
|
case PROP_POPUP_FIXED_WIDTH:
|
|
|
|
|
gtk_combo_box_set_popup_fixed_width (combo_box,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
g_value_get_boolean (value));
|
2010-10-16 09:01:33 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2009-12-19 00:18:14 +00:00
|
|
|
|
case PROP_EDITING_CANCELED:
|
2014-06-07 20:40:09 +00:00
|
|
|
|
if (priv->editing_canceled != g_value_get_boolean (value))
|
|
|
|
|
{
|
|
|
|
|
priv->editing_canceled = g_value_get_boolean (value);
|
|
|
|
|
g_object_notify (object, "editing-canceled");
|
|
|
|
|
}
|
2009-12-19 00:18:14 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2010-10-14 01:52:27 +00:00
|
|
|
|
case PROP_HAS_ENTRY:
|
2011-01-31 22:34:37 +00:00
|
|
|
|
priv->has_entry = g_value_get_boolean (value);
|
2010-10-14 01:52:27 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_ENTRY_TEXT_COLUMN:
|
|
|
|
|
gtk_combo_box_set_entry_text_column (combo_box, g_value_get_int (value));
|
|
|
|
|
break;
|
|
|
|
|
|
2010-11-30 05:07:08 +00:00
|
|
|
|
case PROP_ID_COLUMN:
|
|
|
|
|
gtk_combo_box_set_id_column (combo_box, g_value_get_int (value));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_ACTIVE_ID:
|
|
|
|
|
gtk_combo_box_set_active_id (combo_box, g_value_get_string (value));
|
|
|
|
|
break;
|
|
|
|
|
|
2020-05-03 16:04:23 +00:00
|
|
|
|
case PROP_CHILD:
|
|
|
|
|
gtk_combo_box_set_child (combo_box, g_value_get_object (value));
|
|
|
|
|
break;
|
|
|
|
|
|
2009-10-21 16:40:19 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (object);
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_MODEL:
|
2015-12-22 02:32:14 +00:00
|
|
|
|
g_value_set_object (value, priv->model);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_ACTIVE:
|
|
|
|
|
g_value_set_int (value, gtk_combo_box_get_active (combo_box));
|
|
|
|
|
break;
|
|
|
|
|
|
2004-07-16 20:27:40 +00:00
|
|
|
|
case PROP_HAS_FRAME:
|
2015-12-22 02:32:14 +00:00
|
|
|
|
g_value_set_boolean (value, priv->has_frame);
|
2004-07-16 20:27:40 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2006-03-09 20:20:30 +00:00
|
|
|
|
case PROP_POPUP_SHOWN:
|
2015-12-22 02:32:14 +00:00
|
|
|
|
g_value_set_boolean (value, priv->popup_shown);
|
2006-03-09 20:20:30 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2008-08-04 23:40:36 +00:00
|
|
|
|
case PROP_BUTTON_SENSITIVITY:
|
2015-12-22 02:32:14 +00:00
|
|
|
|
g_value_set_enum (value, priv->button_sensitivity);
|
2008-08-04 23:40:36 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2010-10-16 09:01:33 +00:00
|
|
|
|
case PROP_POPUP_FIXED_WIDTH:
|
2015-12-22 02:32:14 +00:00
|
|
|
|
g_value_set_boolean (value, priv->popup_fixed_width);
|
2010-10-16 09:01:33 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2009-10-21 16:40:19 +00:00
|
|
|
|
case PROP_EDITING_CANCELED:
|
|
|
|
|
g_value_set_boolean (value, priv->editing_canceled);
|
|
|
|
|
break;
|
|
|
|
|
|
2010-10-14 01:52:27 +00:00
|
|
|
|
case PROP_HAS_ENTRY:
|
2011-01-04 15:14:25 +00:00
|
|
|
|
g_value_set_boolean (value, priv->has_entry);
|
|
|
|
|
break;
|
2010-10-14 01:52:27 +00:00
|
|
|
|
|
|
|
|
|
case PROP_ENTRY_TEXT_COLUMN:
|
2011-01-04 15:14:25 +00:00
|
|
|
|
g_value_set_int (value, priv->text_column);
|
|
|
|
|
break;
|
2010-10-15 20:15:16 +00:00
|
|
|
|
|
2010-11-30 05:07:08 +00:00
|
|
|
|
case PROP_ID_COLUMN:
|
|
|
|
|
g_value_set_int (value, priv->id_column);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_ACTIVE_ID:
|
|
|
|
|
g_value_set_string (value, gtk_combo_box_get_active_id (combo_box));
|
|
|
|
|
break;
|
|
|
|
|
|
2020-05-03 16:04:23 +00:00
|
|
|
|
case PROP_CHILD:
|
|
|
|
|
g_value_set_object (value, gtk_combo_box_get_child (combo_box));
|
|
|
|
|
break;
|
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_button_toggled (GtkWidget *widget,
|
|
|
|
|
gpointer data)
|
2003-09-26 21:57:06 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (data);
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2010-12-17 15:30:15 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
|
2004-03-13 00:36:27 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
if (!priv->popup_in_progress)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_combo_box_popup (combo_box);
|
2004-03-13 00:36:27 +00:00
|
|
|
|
}
|
2010-12-06 12:30:00 +00:00
|
|
|
|
else
|
2017-01-19 22:28:41 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_combo_box_popdown (combo_box);
|
|
|
|
|
}
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2015-07-28 16:57:48 +00:00
|
|
|
|
static void
|
2016-03-01 16:39:47 +00:00
|
|
|
|
gtk_combo_box_create_child (GtkComboBox *combo_box)
|
2015-07-28 16:57:48 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2016-03-01 16:39:47 +00:00
|
|
|
|
|
|
|
|
|
if (priv->has_entry)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *entry;
|
|
|
|
|
|
|
|
|
|
entry = gtk_entry_new ();
|
2020-05-03 17:12:21 +00:00
|
|
|
|
gtk_combo_box_set_child (combo_box, entry);
|
2015-07-28 16:57:48 +00:00
|
|
|
|
|
2020-02-06 16:32:26 +00:00
|
|
|
|
gtk_widget_add_css_class (GTK_WIDGET (entry), "combo");
|
2016-03-01 16:39:47 +00:00
|
|
|
|
|
|
|
|
|
g_signal_connect (combo_box, "changed",
|
|
|
|
|
G_CALLBACK (gtk_combo_box_entry_active_changed), NULL);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-05-03 17:12:21 +00:00
|
|
|
|
priv->cell_view = gtk_cell_view_new_with_context (priv->area, NULL);
|
|
|
|
|
gtk_widget_set_hexpand (priv->cell_view, TRUE);
|
2016-03-01 16:39:47 +00:00
|
|
|
|
gtk_cell_view_set_fit_model (GTK_CELL_VIEW (priv->cell_view), TRUE);
|
|
|
|
|
gtk_cell_view_set_model (GTK_CELL_VIEW (priv->cell_view), priv->model);
|
2019-01-22 23:44:34 +00:00
|
|
|
|
gtk_box_insert_child_after (GTK_BOX (gtk_widget_get_parent (priv->arrow)), priv->cell_view, NULL);
|
2020-05-03 17:12:21 +00:00
|
|
|
|
priv->child = priv->cell_view;
|
2016-03-01 16:39:47 +00:00
|
|
|
|
}
|
2015-07-28 16:57:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void
|
2020-05-03 17:12:21 +00:00
|
|
|
|
gtk_combo_box_add (GtkComboBox *combo_box,
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkWidget *widget)
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2016-03-01 18:14:30 +00:00
|
|
|
|
if (priv->box == NULL)
|
|
|
|
|
{
|
2020-05-03 17:12:21 +00:00
|
|
|
|
gtk_widget_set_parent (widget, GTK_WIDGET (combo_box));
|
2016-03-01 18:14:30 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (priv->has_entry && !GTK_IS_ENTRY (widget))
|
|
|
|
|
{
|
|
|
|
|
g_warning ("Attempting to add a widget with type %s to a GtkComboBox that needs an entry "
|
2011-01-04 15:14:25 +00:00
|
|
|
|
"(need an instance of GtkEntry or of a subclass)",
|
2010-12-06 12:30:00 +00:00
|
|
|
|
G_OBJECT_TYPE_NAME (widget));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2010-10-14 01:52:27 +00:00
|
|
|
|
|
2020-05-03 17:12:21 +00:00
|
|
|
|
g_clear_pointer (&priv->cell_view, gtk_widget_unparent);
|
2016-10-02 15:37:22 +00:00
|
|
|
|
|
2017-04-21 16:59:59 +00:00
|
|
|
|
gtk_widget_set_hexpand (widget, TRUE);
|
2019-01-22 23:44:34 +00:00
|
|
|
|
gtk_box_insert_child_after (GTK_BOX (priv->box), widget, NULL);
|
2020-05-03 17:12:21 +00:00
|
|
|
|
|
|
|
|
|
priv->child = widget;
|
2010-11-27 03:38:17 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (priv->has_entry)
|
2010-10-14 01:52:27 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_signal_connect (widget, "changed",
|
2011-01-04 15:14:25 +00:00
|
|
|
|
G_CALLBACK (gtk_combo_box_entry_contents_changed),
|
|
|
|
|
combo_box);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
gtk_entry_set_has_frame (GTK_ENTRY (widget), priv->has_frame);
|
2010-10-14 01:52:27 +00:00
|
|
|
|
}
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
2010-10-14 01:52:27 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void
|
2020-05-03 17:12:21 +00:00
|
|
|
|
gtk_combo_box_remove (GtkComboBox *combo_box,
|
|
|
|
|
GtkWidget *widget)
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkTreePath *path;
|
2020-05-03 17:12:21 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (priv->has_entry)
|
|
|
|
|
{
|
2020-05-03 17:12:21 +00:00
|
|
|
|
if (widget && widget == priv->child)
|
|
|
|
|
g_signal_handlers_disconnect_by_func (widget,
|
|
|
|
|
gtk_combo_box_entry_contents_changed,
|
|
|
|
|
combo_box);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
2004-03-13 00:36:27 +00:00
|
|
|
|
|
2020-05-09 12:26:52 +00:00
|
|
|
|
gtk_box_remove (GTK_BOX (priv->box), widget);
|
2020-05-03 17:12:21 +00:00
|
|
|
|
|
|
|
|
|
priv->child = NULL;
|
2004-03-13 00:36:27 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (gtk_widget_in_destruction (GTK_WIDGET (combo_box)))
|
|
|
|
|
return;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2020-05-03 17:12:21 +00:00
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (combo_box));
|
2014-06-16 21:31:56 +00:00
|
|
|
|
|
2016-03-01 16:39:47 +00:00
|
|
|
|
gtk_combo_box_create_child (combo_box);
|
2004-03-13 00:36:27 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (gtk_tree_row_reference_valid (priv->active_row))
|
|
|
|
|
{
|
|
|
|
|
path = gtk_tree_row_reference_get_path (priv->active_row);
|
|
|
|
|
gtk_combo_box_set_active_internal (combo_box, path);
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
}
|
|
|
|
|
else
|
2017-01-19 22:28:41 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_combo_box_set_active_internal (combo_box, NULL);
|
|
|
|
|
}
|
2004-03-13 00:36:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_menu_show (GtkWidget *menu,
|
|
|
|
|
gpointer user_data)
|
2003-09-26 21:57:06 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_combo_box_child_show (menu, user_data);
|
|
|
|
|
|
|
|
|
|
priv->popup_in_progress = TRUE;
|
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button),
|
|
|
|
|
TRUE);
|
|
|
|
|
priv->popup_in_progress = FALSE;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_menu_hide (GtkWidget *menu,
|
|
|
|
|
gpointer user_data)
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_combo_box_child_hide (menu,user_data);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2019-12-26 05:06:48 +00:00
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button), FALSE);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static gboolean
|
2011-01-21 04:38:50 +00:00
|
|
|
|
cell_layout_is_sensitive (GtkCellLayout *layout)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
GList *cells, *list;
|
|
|
|
|
gboolean sensitive;
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2011-01-21 04:38:50 +00:00
|
|
|
|
cells = gtk_cell_layout_get_cells (layout);
|
2005-06-26 06:26:47 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
sensitive = FALSE;
|
|
|
|
|
for (list = cells; list; list = list->next)
|
|
|
|
|
{
|
|
|
|
|
g_object_get (list->data, "sensitive", &sensitive, NULL);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (sensitive)
|
2011-01-04 15:14:25 +00:00
|
|
|
|
break;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
|
|
|
|
g_list_free (cells);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
return sensitive;
|
|
|
|
|
}
|
2006-10-12 13:04:44 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
tree_column_row_is_sensitive (GtkComboBox *combo_box,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreeIter *iter)
|
2003-09-26 21:57:06 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (priv->row_separator_func)
|
2003-09-26 21:57:06 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (priv->row_separator_func (priv->model, iter,
|
|
|
|
|
priv->row_separator_data))
|
2011-01-04 15:14:25 +00:00
|
|
|
|
return FALSE;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
2007-03-08 02:36:46 +00:00
|
|
|
|
|
2017-01-21 15:11:40 +00:00
|
|
|
|
gtk_cell_area_apply_attributes (priv->area, priv->model, iter, FALSE, FALSE);
|
|
|
|
|
return cell_layout_is_sensitive (GTK_CELL_LAYOUT (priv->area));
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
Fixes #124373, Murray Cumming.
Mon Nov 17 00:11:21 2003 Kristian Rietveld <kris@gtk.org>
Fixes #124373, Murray Cumming.
* gtk/gtkcombobox.[ch] (gtk_combo_box_class_init): the model property
is no longer construct only,
(gtk_combo_box_unset_model), (gtk_combo_box_set_model_internal),
(gtk_combo_box_menu_fill): new functions,
(gtk_combo_box_menu_setup), (gtk_combo_box_menu_destroy),
(gtk_combo_box_menu_row_*), (gtk_combo_box_list_setup),
(gtk_combo_box_list_destroy): updated,
(gtk_combo_box_new), (gtk_combo_box_new_with_model): new/changed
functions,
(gtk_combo_box_set_model): is now public, updated,
(gtk_combo_box_get_model): small update.
* gtk/gtkcomboboxentry.[ch] (gtk_combo_box_entry_class_init): the
text_column property is no longer construct only,
(gtk_combo_box_entry_set_text_column): now public,
(gtk_combo_box_entry_new), (gtk_combo_box_entry_new_with_model):
new/changed functions.
* tests/testcombo.c: updated.
2003-11-16 23:20:15 +00:00
|
|
|
|
static void
|
2019-12-26 05:06:48 +00:00
|
|
|
|
gtk_combo_box_menu_popup (GtkComboBox *combo_box)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2019-12-26 05:06:48 +00:00
|
|
|
|
#if 0
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int active_item;
|
2017-01-19 03:12:32 +00:00
|
|
|
|
GtkWidget *active;
|
2019-01-24 03:52:36 +00:00
|
|
|
|
int width, min_width, nat_width;
|
2019-12-26 05:06:48 +00:00
|
|
|
|
#endif
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2019-12-26 05:06:48 +00:00
|
|
|
|
gtk_tree_popover_open_submenu (GTK_TREE_POPOVER (priv->popup_widget), "main");
|
|
|
|
|
gtk_popover_popup (GTK_POPOVER (priv->popup_widget));
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
2019-12-26 05:06:48 +00:00
|
|
|
|
#if 0
|
2010-12-06 12:30:00 +00:00
|
|
|
|
active_item = -1;
|
|
|
|
|
if (gtk_tree_row_reference_valid (priv->active_row))
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
2017-01-18 21:20:10 +00:00
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
path = gtk_tree_row_reference_get_path (priv->active_row);
|
|
|
|
|
active_item = gtk_tree_path_get_indices (path)[0];
|
|
|
|
|
gtk_tree_path_free (path);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
/* FIXME handle nested menus better */
|
2019-12-26 05:06:48 +00:00
|
|
|
|
//gtk_tree_popover_set_active (GTK_TREE_POPOVER (priv->popup_widget), active_item);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2019-01-24 03:52:36 +00:00
|
|
|
|
width = gtk_widget_get_width (GTK_WIDGET (combo_box));
|
|
|
|
|
gtk_widget_set_size_request (priv->popup_widget, -1, -1);
|
|
|
|
|
gtk_widget_measure (priv->popup_widget, GTK_ORIENTATION_HORIZONTAL, -1,
|
|
|
|
|
&min_width, &nat_width, NULL, NULL);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2019-01-24 03:52:36 +00:00
|
|
|
|
if (priv->popup_fixed_width)
|
|
|
|
|
width = MAX (width, min_width);
|
|
|
|
|
else
|
|
|
|
|
width = MAX (width, nat_width);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2019-01-24 03:52:36 +00:00
|
|
|
|
gtk_widget_set_size_request (priv->popup_widget, width, -1);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2016-07-12 18:08:36 +00:00
|
|
|
|
g_signal_handlers_disconnect_by_func (priv->popup_widget,
|
|
|
|
|
gtk_menu_update_scroll_offset,
|
|
|
|
|
NULL);
|
|
|
|
|
|
2019-01-24 03:52:36 +00:00
|
|
|
|
if (priv->cell_view == NULL)
|
2016-07-12 18:08:36 +00:00
|
|
|
|
{
|
|
|
|
|
g_object_set (priv->popup_widget,
|
|
|
|
|
"anchor-hints", (GDK_ANCHOR_FLIP_Y |
|
|
|
|
|
GDK_ANCHOR_SLIDE |
|
|
|
|
|
GDK_ANCHOR_RESIZE),
|
2017-08-14 10:12:09 +00:00
|
|
|
|
"rect-anchor-dx", 0,
|
2016-07-12 18:08:36 +00:00
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
gtk_menu_popup_at_widget (GTK_MENU (priv->popup_widget),
|
|
|
|
|
gtk_bin_get_child (GTK_BIN (combo_box)),
|
|
|
|
|
GDK_GRAVITY_SOUTH_WEST,
|
|
|
|
|
GDK_GRAVITY_NORTH_WEST,
|
2017-02-16 21:33:25 +00:00
|
|
|
|
NULL);
|
2016-07-12 18:08:36 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int rect_anchor_dy = -2;
|
2017-01-18 21:20:10 +00:00
|
|
|
|
GList *i;
|
|
|
|
|
GtkWidget *child;
|
2016-07-12 18:08:36 +00:00
|
|
|
|
|
2017-01-19 22:28:41 +00:00
|
|
|
|
/* FIXME handle nested menus better */
|
2017-01-19 03:26:09 +00:00
|
|
|
|
active = gtk_menu_get_active (GTK_MENU (priv->popup_widget));
|
|
|
|
|
|
2017-01-18 22:17:37 +00:00
|
|
|
|
if (!(active && gtk_widget_get_visible (active)))
|
2016-07-12 18:08:36 +00:00
|
|
|
|
{
|
2019-05-31 03:20:50 +00:00
|
|
|
|
GList *children;
|
|
|
|
|
children = gtk_menu_shell_get_items (GTK_MENU_SHELL (priv->popup_widget));
|
|
|
|
|
for (i = children; i && !active; i = i->next)
|
2016-07-12 18:08:36 +00:00
|
|
|
|
{
|
|
|
|
|
child = i->data;
|
|
|
|
|
|
|
|
|
|
if (child && gtk_widget_get_visible (child))
|
|
|
|
|
active = child;
|
|
|
|
|
}
|
2019-05-31 03:20:50 +00:00
|
|
|
|
g_list_free (children);
|
2016-07-12 18:08:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (active)
|
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int child_height;
|
2019-05-31 03:20:50 +00:00
|
|
|
|
GList *children;
|
|
|
|
|
children = gtk_menu_shell_get_items (GTK_MENU_SHELL (priv->popup_widget));
|
|
|
|
|
for (i = children; i && i->data != active; i = i->next)
|
2016-07-12 18:08:36 +00:00
|
|
|
|
{
|
|
|
|
|
child = i->data;
|
|
|
|
|
|
|
|
|
|
if (child && gtk_widget_get_visible (child))
|
|
|
|
|
{
|
2017-02-17 16:41:48 +00:00
|
|
|
|
gtk_widget_measure (child, GTK_ORIENTATION_VERTICAL, -1,
|
|
|
|
|
&child_height, NULL, NULL, NULL);
|
2016-07-12 18:08:36 +00:00
|
|
|
|
rect_anchor_dy -= child_height;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-05-31 03:20:50 +00:00
|
|
|
|
g_list_free (children);
|
2016-07-12 18:08:36 +00:00
|
|
|
|
|
2017-02-17 16:41:48 +00:00
|
|
|
|
gtk_widget_measure (active, GTK_ORIENTATION_VERTICAL, -1,
|
|
|
|
|
&child_height, NULL, NULL, NULL);
|
2016-07-12 18:08:36 +00:00
|
|
|
|
rect_anchor_dy -= child_height / 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_object_set (priv->popup_widget,
|
|
|
|
|
"anchor-hints", (GDK_ANCHOR_SLIDE |
|
|
|
|
|
GDK_ANCHOR_RESIZE),
|
|
|
|
|
"rect-anchor-dy", rect_anchor_dy,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
g_signal_connect (priv->popup_widget,
|
|
|
|
|
"popped-up",
|
|
|
|
|
G_CALLBACK (gtk_menu_update_scroll_offset),
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
gtk_menu_popup_at_widget (GTK_MENU (priv->popup_widget),
|
|
|
|
|
GTK_WIDGET (combo_box),
|
|
|
|
|
GDK_GRAVITY_WEST,
|
|
|
|
|
GDK_GRAVITY_NORTH_WEST,
|
2017-02-16 21:33:25 +00:00
|
|
|
|
NULL);
|
2016-07-12 18:08:36 +00:00
|
|
|
|
}
|
2019-12-26 05:06:48 +00:00
|
|
|
|
#endif
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-11 20:50:07 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_popup:
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @combo_box: a `GtkComboBox`
|
2016-11-11 20:50:07 +00:00
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
2017-01-20 03:30:36 +00:00
|
|
|
|
* Before calling this, @combo_box must be mapped, or nothing will happen.
|
2016-11-11 20:50:07 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_combo_box_popup (GtkComboBox *combo_box)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
|
|
|
|
|
2017-01-20 03:30:36 +00:00
|
|
|
|
if (gtk_widget_get_mapped (GTK_WIDGET (combo_box)))
|
|
|
|
|
g_signal_emit (combo_box, combo_box_signals[POPUP], 0);
|
2016-11-11 20:50:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_popup_for_device:
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @combo_box: a `GtkComboBox`
|
|
|
|
|
* @device: a `GdkDevice`
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
2016-11-11 20:50:07 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_combo_box_popup_for_device (GtkComboBox *combo_box,
|
|
|
|
|
GdkDevice *device)
|
|
|
|
|
{
|
2017-01-19 22:28:41 +00:00
|
|
|
|
/* As above, this currently does not do anything useful, and nothing with the
|
|
|
|
|
* passed-in device. But the bits that are not blatantly obsolete are kept. */
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2016-11-11 20:50:07 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
|
|
|
|
g_return_if_fail (GDK_IS_DEVICE (device));
|
|
|
|
|
|
|
|
|
|
if (!gtk_widget_get_realized (GTK_WIDGET (combo_box)))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (gtk_widget_get_mapped (priv->popup_widget))
|
|
|
|
|
return;
|
|
|
|
|
|
2017-02-16 21:33:25 +00:00
|
|
|
|
gtk_combo_box_menu_popup (combo_box);
|
2004-08-02 19:15:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_real_popup (GtkComboBox *combo_box)
|
2004-08-02 19:15:05 +00:00
|
|
|
|
{
|
2017-02-16 21:33:25 +00:00
|
|
|
|
gtk_combo_box_menu_popup (combo_box);
|
2004-08-02 19:15:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2010-11-24 09:14:36 +00:00
|
|
|
|
gtk_combo_box_real_popdown (GtkComboBox *combo_box)
|
2004-08-02 19:15:05 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
|
|
|
|
|
|
|
|
|
if (priv->popup_shown)
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_combo_box_popdown (combo_box);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2004-08-02 19:15:05 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2004-08-02 19:15:05 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_popdown:
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @combo_box: a `GtkComboBox`
|
2011-01-04 15:14:25 +00:00
|
|
|
|
*
|
2010-12-06 12:30:00 +00:00
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_combo_box_popdown (GtkComboBox *combo_box)
|
2004-08-02 19:15:05 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2004-08-02 19:15:05 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
2004-08-02 19:15:05 +00:00
|
|
|
|
|
2019-12-26 05:06:48 +00:00
|
|
|
|
gtk_popover_popdown (GTK_POPOVER (priv->popup_widget));
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
2004-08-02 19:15:05 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_unset_model (GtkComboBox *combo_box)
|
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (priv->model)
|
2003-09-26 21:57:06 +00:00
|
|
|
|
{
|
2017-09-01 19:17:11 +00:00
|
|
|
|
g_signal_handlers_disconnect_by_func (priv->model,
|
|
|
|
|
gtk_combo_box_model_row_inserted,
|
|
|
|
|
combo_box);
|
|
|
|
|
g_signal_handlers_disconnect_by_func (priv->model,
|
|
|
|
|
gtk_combo_box_model_row_deleted,
|
|
|
|
|
combo_box);
|
|
|
|
|
g_signal_handlers_disconnect_by_func (priv->model,
|
|
|
|
|
gtk_combo_box_model_rows_reordered,
|
|
|
|
|
combo_box);
|
|
|
|
|
g_signal_handlers_disconnect_by_func (priv->model,
|
|
|
|
|
gtk_combo_box_model_row_changed,
|
|
|
|
|
combo_box);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_object_unref (priv->model);
|
|
|
|
|
priv->model = NULL;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (priv->active_row)
|
|
|
|
|
{
|
|
|
|
|
gtk_tree_row_reference_free (priv->active_row);
|
|
|
|
|
priv->active_row = NULL;
|
|
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (priv->cell_view)
|
|
|
|
|
gtk_cell_view_set_model (GTK_CELL_VIEW (priv->cell_view), NULL);
|
|
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2011-01-04 15:14:25 +00:00
|
|
|
|
static void
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_combo_box_child_show (GtkWidget *widget,
|
|
|
|
|
GtkComboBox *combo_box)
|
2003-09-26 21:57:06 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
priv->popup_shown = TRUE;
|
|
|
|
|
g_object_notify (G_OBJECT (combo_box), "popup-shown");
|
|
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2011-01-04 15:14:25 +00:00
|
|
|
|
static void
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_combo_box_child_hide (GtkWidget *widget,
|
|
|
|
|
GtkComboBox *combo_box)
|
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
priv->popup_shown = FALSE;
|
|
|
|
|
g_object_notify (G_OBJECT (combo_box), "popup-shown");
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
typedef struct {
|
|
|
|
|
GtkComboBox *combo;
|
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
gboolean found;
|
|
|
|
|
gboolean set;
|
|
|
|
|
} SearchData;
|
2008-08-04 23:40:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
tree_next_func (GtkTreeModel *model,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
SearchData *search_data = (SearchData *)data;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2011-01-04 15:14:25 +00:00
|
|
|
|
if (search_data->found)
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (!tree_column_row_is_sensitive (search_data->combo, iter))
|
2011-01-04 15:14:25 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
search_data->set = TRUE;
|
|
|
|
|
search_data->iter = *iter;
|
2009-09-09 07:43:30 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
return TRUE;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (gtk_tree_path_compare (path, search_data->path) == 0)
|
|
|
|
|
search_data->found = TRUE;
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2008-08-04 23:40:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
tree_next (GtkComboBox *combo,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreeModel *model,
|
|
|
|
|
GtkTreeIter *iter,
|
2015-07-24 15:20:03 +00:00
|
|
|
|
GtkTreeIter *next)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
SearchData search_data;
|
2008-08-04 23:40:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
search_data.combo = combo;
|
|
|
|
|
search_data.path = gtk_tree_model_get_path (model, iter);
|
|
|
|
|
search_data.found = FALSE;
|
|
|
|
|
search_data.set = FALSE;
|
2004-03-02 18:56:10 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_tree_model_foreach (model, tree_next_func, &search_data);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
*next = search_data.iter;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_tree_path_free (search_data.path);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
return search_data.set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
tree_prev_func (GtkTreeModel *model,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
2004-03-02 18:56:10 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
SearchData *search_data = (SearchData *)data;
|
|
|
|
|
|
|
|
|
|
if (gtk_tree_path_compare (path, search_data->path) == 0)
|
2005-02-24 17:57:07 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
search_data->found = TRUE;
|
|
|
|
|
return TRUE;
|
2005-02-24 17:57:07 +00:00
|
|
|
|
}
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (!tree_column_row_is_sensitive (search_data->combo, iter))
|
|
|
|
|
return FALSE;
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
search_data->set = TRUE;
|
|
|
|
|
search_data->iter = *iter;
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
|
|
|
|
return FALSE;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
tree_prev (GtkComboBox *combo,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreeModel *model,
|
|
|
|
|
GtkTreeIter *iter,
|
2015-07-24 15:20:03 +00:00
|
|
|
|
GtkTreeIter *prev)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
SearchData search_data;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
search_data.combo = combo;
|
|
|
|
|
search_data.path = gtk_tree_model_get_path (model, iter);
|
|
|
|
|
search_data.found = FALSE;
|
|
|
|
|
search_data.set = FALSE;
|
|
|
|
|
|
|
|
|
|
gtk_tree_model_foreach (model, tree_prev_func, &search_data);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
*prev = search_data.iter;
|
2008-08-04 23:40:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_tree_path_free (search_data.path);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
return search_data.set;
|
|
|
|
|
}
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
tree_last_func (GtkTreeModel *model,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
SearchData *search_data = (SearchData *)data;
|
|
|
|
|
|
|
|
|
|
if (!tree_column_row_is_sensitive (search_data->combo, iter))
|
|
|
|
|
return FALSE;
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
search_data->set = TRUE;
|
|
|
|
|
search_data->iter = *iter;
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
|
|
|
|
return FALSE;
|
2004-03-02 18:56:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
static gboolean
|
2010-12-06 12:30:00 +00:00
|
|
|
|
tree_last (GtkComboBox *combo,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreeModel *model,
|
2015-07-24 15:20:03 +00:00
|
|
|
|
GtkTreeIter *last)
|
2004-03-02 18:56:10 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
SearchData search_data;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
search_data.combo = combo;
|
|
|
|
|
search_data.set = FALSE;
|
2004-03-02 18:56:10 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_tree_model_foreach (model, tree_last_func, &search_data);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
*last = search_data.iter;
|
2004-03-02 18:56:10 +00:00
|
|
|
|
|
2011-01-04 15:14:25 +00:00
|
|
|
|
return search_data.set;
|
2004-03-02 18:56:10 +00:00
|
|
|
|
}
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
tree_first_func (GtkTreeModel *model,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
SearchData *search_data = (SearchData *)data;
|
2004-08-02 19:15:05 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (!tree_column_row_is_sensitive (search_data->combo, iter))
|
|
|
|
|
return FALSE;
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
search_data->set = TRUE;
|
|
|
|
|
search_data->iter = *iter;
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
return TRUE;
|
2004-08-02 19:15:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
tree_first (GtkComboBox *combo,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreeModel *model,
|
2015-07-24 15:20:03 +00:00
|
|
|
|
GtkTreeIter *first)
|
2004-08-02 19:15:05 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
SearchData search_data;
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
search_data.combo = combo;
|
|
|
|
|
search_data.set = FALSE;
|
2007-12-28 06:56:48 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_tree_model_foreach (model, tree_first_func, &search_data);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
*first = search_data.iter;
|
|
|
|
|
|
2011-01-04 15:14:25 +00:00
|
|
|
|
return search_data.set;
|
2004-08-02 19:15:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-18 13:34:39 +00:00
|
|
|
|
static gboolean
|
2017-09-15 11:52:55 +00:00
|
|
|
|
gtk_combo_box_scroll_controller_scroll (GtkEventControllerScroll *scroll,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double dx,
|
|
|
|
|
double dy,
|
2017-09-15 11:52:55 +00:00
|
|
|
|
GtkComboBox *combo_box)
|
2004-08-02 19:15:05 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2017-05-09 06:22:41 +00:00
|
|
|
|
gboolean found = FALSE;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
GtkTreeIter new_iter;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2017-09-15 11:52:55 +00:00
|
|
|
|
if (!gtk_combo_box_get_active_iter (combo_box, &iter))
|
2018-07-18 13:34:39 +00:00
|
|
|
|
return GDK_EVENT_PROPAGATE;
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2017-09-15 11:52:55 +00:00
|
|
|
|
if (dy < 0)
|
|
|
|
|
found = tree_prev (combo_box, priv->model, &iter, &new_iter);
|
|
|
|
|
else if (dy > 0)
|
|
|
|
|
found = tree_next (combo_box, priv->model, &iter, &new_iter);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (found)
|
|
|
|
|
gtk_combo_box_set_active_iter (combo_box, &new_iter);
|
|
|
|
|
|
2018-07-18 13:34:39 +00:00
|
|
|
|
return found;
|
|
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
/* callbacks */
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_menu_activate (GtkWidget *menu,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *path,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkComboBox *combo_box)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
2018-06-10 10:25:44 +00:00
|
|
|
|
if (gtk_tree_model_get_iter_from_string (priv->model, &iter, path))
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_combo_box_set_active_iter (combo_box, &iter);
|
|
|
|
|
|
|
|
|
|
g_object_set (combo_box,
|
|
|
|
|
"editing-canceled", FALSE,
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
|
static void
|
2010-11-24 09:14:36 +00:00
|
|
|
|
gtk_combo_box_update_sensitivity (GtkComboBox *combo_box)
|
2003-09-26 21:57:06 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
gboolean sensitive = TRUE; /* fool code checkers */
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (!priv->button)
|
2010-11-24 09:14:36 +00:00
|
|
|
|
return;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
switch (priv->button_sensitivity)
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
|
|
|
|
case GTK_SENSITIVITY_ON:
|
|
|
|
|
sensitive = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
case GTK_SENSITIVITY_OFF:
|
|
|
|
|
sensitive = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
case GTK_SENSITIVITY_AUTO:
|
2015-12-22 02:32:14 +00:00
|
|
|
|
sensitive = priv->model &&
|
|
|
|
|
gtk_tree_model_get_iter_first (priv->model, &iter);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
gtk_widget_set_sensitive (priv->button, sensitive);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_model_row_inserted (GtkTreeModel *model,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer user_data)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
|
|
|
|
|
|
|
|
|
|
gtk_combo_box_update_sensitivity (combo_box);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_model_row_deleted (GtkTreeModel *model,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
gpointer user_data)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
if (!gtk_tree_row_reference_valid (priv->active_row))
|
|
|
|
|
{
|
|
|
|
|
if (priv->cell_view)
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gtk_cell_view_set_displayed_row (GTK_CELL_VIEW (priv->cell_view), NULL);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_signal_emit (combo_box, combo_box_signals[CHANGED], 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_combo_box_update_sensitivity (combo_box);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_model_rows_reordered (GtkTreeModel *model,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int *new_order,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gpointer user_data)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_tree_row_reference_reordered (G_OBJECT (user_data), path, iter, new_order);
|
|
|
|
|
}
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_model_row_changed (GtkTreeModel *model,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer user_data)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkTreePath *active_path;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
/* FIXME this belongs to GtkCellView */
|
|
|
|
|
if (gtk_tree_row_reference_valid (priv->active_row))
|
|
|
|
|
{
|
|
|
|
|
active_path = gtk_tree_row_reference_get_path (priv->active_row);
|
|
|
|
|
if (gtk_tree_path_compare (path, active_path) == 0 &&
|
2011-01-04 15:14:25 +00:00
|
|
|
|
priv->cell_view)
|
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (priv->cell_view));
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_tree_path_free (active_path);
|
|
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-04 23:35:31 +00:00
|
|
|
|
static gboolean
|
2018-06-26 11:35:26 +00:00
|
|
|
|
gtk_combo_box_menu_key (GtkEventControllerKey *key,
|
|
|
|
|
guint keyval,
|
|
|
|
|
guint keycode,
|
|
|
|
|
GdkModifierType modifiers,
|
|
|
|
|
GtkComboBox *combo_box)
|
2004-03-04 23:35:31 +00:00
|
|
|
|
{
|
2018-08-12 19:15:37 +00:00
|
|
|
|
gtk_event_controller_key_forward (key, GTK_WIDGET (combo_box));
|
2018-06-26 11:35:26 +00:00
|
|
|
|
|
|
|
|
|
return TRUE;
|
2004-03-04 23:35:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
|
/*
|
2010-12-06 12:30:00 +00:00
|
|
|
|
* GtkCellLayout implementation
|
2003-09-26 21:57:06 +00:00
|
|
|
|
*/
|
2011-01-31 22:34:37 +00:00
|
|
|
|
static GtkCellArea *
|
|
|
|
|
gtk_combo_box_cell_layout_get_area (GtkCellLayout *cell_layout)
|
2004-08-02 19:15:05 +00:00
|
|
|
|
{
|
2017-01-21 20:23:27 +00:00
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (cell_layout);
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
|
|
|
|
|
|
|
|
|
return priv->area;
|
2004-08-02 19:15:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
/*
|
|
|
|
|
* public API
|
|
|
|
|
*/
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_new:
|
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* Creates a new empty `GtkComboBox`.
|
2010-12-06 12:30:00 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* Returns: A new `GtkComboBox`
|
2010-12-06 12:30:00 +00:00
|
|
|
|
*/
|
|
|
|
|
GtkWidget *
|
|
|
|
|
gtk_combo_box_new (void)
|
|
|
|
|
{
|
|
|
|
|
return g_object_new (GTK_TYPE_COMBO_BOX, NULL);
|
|
|
|
|
}
|
2004-08-02 19:15:05 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_new_with_entry:
|
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* Creates a new empty `GtkComboBox` with an entry.
|
2010-12-06 12:30:00 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* Returns: A new `GtkComboBox`
|
2010-12-06 12:30:00 +00:00
|
|
|
|
*/
|
|
|
|
|
GtkWidget *
|
|
|
|
|
gtk_combo_box_new_with_entry (void)
|
|
|
|
|
{
|
|
|
|
|
return g_object_new (GTK_TYPE_COMBO_BOX, "has-entry", TRUE, NULL);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_new_with_model:
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @model: a `GtkTreeModel`
|
2010-12-06 12:30:00 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* Creates a new `GtkComboBox` with a model.
|
2010-12-06 12:30:00 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* Returns: A new `GtkComboBox`
|
2010-12-06 12:30:00 +00:00
|
|
|
|
*/
|
|
|
|
|
GtkWidget *
|
|
|
|
|
gtk_combo_box_new_with_model (GtkTreeModel *model)
|
2003-09-26 21:57:06 +00:00
|
|
|
|
{
|
2010-11-24 09:14:36 +00:00
|
|
|
|
GtkComboBox *combo_box;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_TREE_MODEL (model), NULL);
|
2004-11-06 20:16:40 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
combo_box = g_object_new (GTK_TYPE_COMBO_BOX, "model", model, NULL);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
return GTK_WIDGET (combo_box);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_new_with_model_and_entry:
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @model: A `GtkTreeModel`
|
2010-12-06 12:30:00 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* Creates a new empty `GtkComboBox` with an entry and a model.
|
2010-12-06 12:30:00 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* Returns: A new `GtkComboBox`
|
2010-12-06 12:30:00 +00:00
|
|
|
|
*/
|
|
|
|
|
GtkWidget *
|
|
|
|
|
gtk_combo_box_new_with_model_and_entry (GtkTreeModel *model)
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
return g_object_new (GTK_TYPE_COMBO_BOX,
|
|
|
|
|
"has-entry", TRUE,
|
|
|
|
|
"model", model,
|
|
|
|
|
NULL);
|
2004-08-02 19:15:05 +00:00
|
|
|
|
}
|
2004-05-10 14:07:35 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_get_active:
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @combo_box: A `GtkComboBox`
|
|
|
|
|
*
|
|
|
|
|
* Returns the index of the currently active item.
|
2010-12-06 12:30:00 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* If the model is a non-flat treemodel, and the active item is not
|
|
|
|
|
* an immediate child of the root of the tree, this function returns
|
|
|
|
|
* `gtk_tree_path_get_indices (path)[0]`, where `path` is the
|
|
|
|
|
* [struct@Gtk.TreePath] of the active item.
|
2010-12-06 12:30:00 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: An integer which is the index of the currently active item,
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* or -1 if there’s no active item.
|
2010-12-06 12:30:00 +00:00
|
|
|
|
*/
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_combo_box_get_active (GtkComboBox *combo_box)
|
2004-08-02 19:15:05 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int result;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), 0);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (gtk_tree_row_reference_valid (priv->active_row))
|
|
|
|
|
{
|
|
|
|
|
GtkTreePath *path;
|
2003-12-19 22:47:20 +00:00
|
|
|
|
|
2011-01-04 15:14:25 +00:00
|
|
|
|
path = gtk_tree_row_reference_get_path (priv->active_row);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
result = gtk_tree_path_get_indices (path)[0];
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
result = -1;
|
2003-12-19 22:47:20 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
return result;
|
2003-12-19 22:47:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-10-01 20:51:54 +00:00
|
|
|
|
/**
|
2021-02-25 17:22:44 +00:00
|
|
|
|
* gtk_combo_box_set_active: (attributes org.gtk.Method.set_property=active)
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @combo_box: a `GtkComboBox`
|
|
|
|
|
* @index_: An index in the model passed during construction,
|
|
|
|
|
* or -1 to have no active item
|
Fixes #124373, Murray Cumming.
Mon Nov 17 00:11:21 2003 Kristian Rietveld <kris@gtk.org>
Fixes #124373, Murray Cumming.
* gtk/gtkcombobox.[ch] (gtk_combo_box_class_init): the model property
is no longer construct only,
(gtk_combo_box_unset_model), (gtk_combo_box_set_model_internal),
(gtk_combo_box_menu_fill): new functions,
(gtk_combo_box_menu_setup), (gtk_combo_box_menu_destroy),
(gtk_combo_box_menu_row_*), (gtk_combo_box_list_setup),
(gtk_combo_box_list_destroy): updated,
(gtk_combo_box_new), (gtk_combo_box_new_with_model): new/changed
functions,
(gtk_combo_box_set_model): is now public, updated,
(gtk_combo_box_get_model): small update.
* gtk/gtkcomboboxentry.[ch] (gtk_combo_box_entry_class_init): the
text_column property is no longer construct only,
(gtk_combo_box_entry_set_text_column): now public,
(gtk_combo_box_entry_new), (gtk_combo_box_entry_new_with_model):
new/changed functions.
* tests/testcombo.c: updated.
2003-11-16 23:20:15 +00:00
|
|
|
|
*
|
2010-12-06 12:30:00 +00:00
|
|
|
|
* Sets the active item of @combo_box to be the item at @index.
|
Fixes #124373, Murray Cumming.
Mon Nov 17 00:11:21 2003 Kristian Rietveld <kris@gtk.org>
Fixes #124373, Murray Cumming.
* gtk/gtkcombobox.[ch] (gtk_combo_box_class_init): the model property
is no longer construct only,
(gtk_combo_box_unset_model), (gtk_combo_box_set_model_internal),
(gtk_combo_box_menu_fill): new functions,
(gtk_combo_box_menu_setup), (gtk_combo_box_menu_destroy),
(gtk_combo_box_menu_row_*), (gtk_combo_box_list_setup),
(gtk_combo_box_list_destroy): updated,
(gtk_combo_box_new), (gtk_combo_box_new_with_model): new/changed
functions,
(gtk_combo_box_set_model): is now public, updated,
(gtk_combo_box_get_model): small update.
* gtk/gtkcomboboxentry.[ch] (gtk_combo_box_entry_class_init): the
text_column property is no longer construct only,
(gtk_combo_box_entry_set_text_column): now public,
(gtk_combo_box_entry_new), (gtk_combo_box_entry_new_with_model):
new/changed functions.
* tests/testcombo.c: updated.
2003-11-16 23:20:15 +00:00
|
|
|
|
*/
|
2010-12-06 12:30:00 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_combo_box_set_active (GtkComboBox *combo_box,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int index_)
|
Fixes #124373, Murray Cumming.
Mon Nov 17 00:11:21 2003 Kristian Rietveld <kris@gtk.org>
Fixes #124373, Murray Cumming.
* gtk/gtkcombobox.[ch] (gtk_combo_box_class_init): the model property
is no longer construct only,
(gtk_combo_box_unset_model), (gtk_combo_box_set_model_internal),
(gtk_combo_box_menu_fill): new functions,
(gtk_combo_box_menu_setup), (gtk_combo_box_menu_destroy),
(gtk_combo_box_menu_row_*), (gtk_combo_box_list_setup),
(gtk_combo_box_list_destroy): updated,
(gtk_combo_box_new), (gtk_combo_box_new_with_model): new/changed
functions,
(gtk_combo_box_set_model): is now public, updated,
(gtk_combo_box_get_model): small update.
* gtk/gtkcomboboxentry.[ch] (gtk_combo_box_entry_class_init): the
text_column property is no longer construct only,
(gtk_combo_box_entry_set_text_column): now public,
(gtk_combo_box_entry_new), (gtk_combo_box_entry_new_with_model):
new/changed functions.
* tests/testcombo.c: updated.
2003-11-16 23:20:15 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkTreePath *path = NULL;
|
2015-12-22 02:32:14 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
|
|
|
|
g_return_if_fail (index_ >= -1);
|
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (priv->model == NULL)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
/* Save index, in case the model is set after the index */
|
2015-12-22 02:32:14 +00:00
|
|
|
|
priv->active = index_;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (index_ != -1)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (index_ != -1)
|
|
|
|
|
path = gtk_tree_path_new_from_indices (index_, -1);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_combo_box_set_active_internal (combo_box, path);
|
|
|
|
|
|
|
|
|
|
if (path)
|
|
|
|
|
gtk_tree_path_free (path);
|
Fixes #124373, Murray Cumming.
Mon Nov 17 00:11:21 2003 Kristian Rietveld <kris@gtk.org>
Fixes #124373, Murray Cumming.
* gtk/gtkcombobox.[ch] (gtk_combo_box_class_init): the model property
is no longer construct only,
(gtk_combo_box_unset_model), (gtk_combo_box_set_model_internal),
(gtk_combo_box_menu_fill): new functions,
(gtk_combo_box_menu_setup), (gtk_combo_box_menu_destroy),
(gtk_combo_box_menu_row_*), (gtk_combo_box_list_setup),
(gtk_combo_box_list_destroy): updated,
(gtk_combo_box_new), (gtk_combo_box_new_with_model): new/changed
functions,
(gtk_combo_box_set_model): is now public, updated,
(gtk_combo_box_get_model): small update.
* gtk/gtkcomboboxentry.[ch] (gtk_combo_box_entry_class_init): the
text_column property is no longer construct only,
(gtk_combo_box_entry_set_text_column): now public,
(gtk_combo_box_entry_new), (gtk_combo_box_entry_new_with_model):
new/changed functions.
* tests/testcombo.c: updated.
2003-11-16 23:20:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_set_active_internal (GtkComboBox *combo_box,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreePath *path)
|
2010-10-14 01:52:27 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkTreePath *active_path;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int path_cmp;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
/* Remember whether the initially active row is valid. */
|
|
|
|
|
gboolean is_valid_row_reference = gtk_tree_row_reference_valid (priv->active_row);
|
|
|
|
|
|
|
|
|
|
if (path && is_valid_row_reference)
|
|
|
|
|
{
|
|
|
|
|
active_path = gtk_tree_row_reference_get_path (priv->active_row);
|
|
|
|
|
path_cmp = gtk_tree_path_compare (path, active_path);
|
|
|
|
|
gtk_tree_path_free (active_path);
|
|
|
|
|
if (path_cmp == 0)
|
2011-01-04 15:14:25 +00:00
|
|
|
|
return;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (priv->active_row)
|
|
|
|
|
{
|
|
|
|
|
gtk_tree_row_reference_free (priv->active_row);
|
|
|
|
|
priv->active_row = NULL;
|
|
|
|
|
}
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (!path)
|
|
|
|
|
{
|
2019-12-26 05:06:48 +00:00
|
|
|
|
gtk_tree_popover_set_active (GTK_TREE_POPOVER (priv->popup_widget), -1);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
if (priv->cell_view)
|
|
|
|
|
gtk_cell_view_set_displayed_row (GTK_CELL_VIEW (priv->cell_view), NULL);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Do not emit a "changed" signal when an already invalid selection was
|
|
|
|
|
* now set to invalid.
|
|
|
|
|
*/
|
|
|
|
|
if (!is_valid_row_reference)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-01-04 15:14:25 +00:00
|
|
|
|
priv->active_row =
|
|
|
|
|
gtk_tree_row_reference_new (priv->model, path);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
2019-12-26 05:06:48 +00:00
|
|
|
|
gtk_tree_popover_set_active (GTK_TREE_POPOVER (priv->popup_widget),
|
|
|
|
|
gtk_tree_path_get_indices (path)[0]);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
if (priv->cell_view)
|
2019-12-26 05:06:48 +00:00
|
|
|
|
gtk_cell_view_set_displayed_row (GTK_CELL_VIEW (priv->cell_view), path);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_signal_emit (combo_box, combo_box_signals[CHANGED], 0);
|
|
|
|
|
g_object_notify (G_OBJECT (combo_box), "active");
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (priv->id_column >= 0)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_object_notify (G_OBJECT (combo_box), "active-id");
|
2010-10-14 01:52:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
Fixes #124373, Murray Cumming.
Mon Nov 17 00:11:21 2003 Kristian Rietveld <kris@gtk.org>
Fixes #124373, Murray Cumming.
* gtk/gtkcombobox.[ch] (gtk_combo_box_class_init): the model property
is no longer construct only,
(gtk_combo_box_unset_model), (gtk_combo_box_set_model_internal),
(gtk_combo_box_menu_fill): new functions,
(gtk_combo_box_menu_setup), (gtk_combo_box_menu_destroy),
(gtk_combo_box_menu_row_*), (gtk_combo_box_list_setup),
(gtk_combo_box_list_destroy): updated,
(gtk_combo_box_new), (gtk_combo_box_new_with_model): new/changed
functions,
(gtk_combo_box_set_model): is now public, updated,
(gtk_combo_box_get_model): small update.
* gtk/gtkcomboboxentry.[ch] (gtk_combo_box_entry_class_init): the
text_column property is no longer construct only,
(gtk_combo_box_entry_set_text_column): now public,
(gtk_combo_box_entry_new), (gtk_combo_box_entry_new_with_model):
new/changed functions.
* tests/testcombo.c: updated.
2003-11-16 23:20:15 +00:00
|
|
|
|
/**
|
2010-12-06 12:30:00 +00:00
|
|
|
|
* gtk_combo_box_get_active_iter:
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @combo_box: A `GtkComboBox`
|
|
|
|
|
* @iter: (out): A `GtkTreeIter`
|
2011-01-04 15:14:25 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* Sets @iter to point to the currently active item.
|
|
|
|
|
*
|
|
|
|
|
* If no item is active, @iter is left unchanged.
|
2011-01-04 15:14:25 +00:00
|
|
|
|
*
|
2017-08-24 11:46:47 +00:00
|
|
|
|
* Returns: %TRUE if @iter was set, %FALSE otherwise
|
2003-10-01 20:51:54 +00:00
|
|
|
|
*/
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gtk_combo_box_get_active_iter (GtkComboBox *combo_box,
|
|
|
|
|
GtkTreeIter *iter)
|
2003-10-01 20:51:54 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
gboolean result;
|
2003-10-01 20:51:54 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), FALSE);
|
2003-10-01 20:51:54 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (!gtk_tree_row_reference_valid (priv->active_row))
|
2010-12-06 12:30:00 +00:00
|
|
|
|
return FALSE;
|
2003-10-01 20:51:54 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
path = gtk_tree_row_reference_get_path (priv->active_row);
|
|
|
|
|
result = gtk_tree_model_get_iter (priv->model, iter, path);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_tree_path_free (path);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
return result;
|
2010-10-29 16:28:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-05-06 04:06:35 +00:00
|
|
|
|
/**
|
2010-12-06 12:30:00 +00:00
|
|
|
|
* gtk_combo_box_set_active_iter:
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @combo_box: A `GtkComboBox`
|
|
|
|
|
* @iter: (allow-none): The `GtkTreeIter`, or %NULL
|
|
|
|
|
*
|
|
|
|
|
* Sets the current active item to be the one referenced by @iter.
|
2011-01-04 15:14:25 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* If @iter is %NULL, the active item is unset.
|
2004-05-06 04:06:35 +00:00
|
|
|
|
*/
|
2010-12-06 12:30:00 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_combo_box_set_active_iter (GtkComboBox *combo_box,
|
|
|
|
|
GtkTreeIter *iter)
|
2004-05-06 04:06:35 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkTreePath *path = NULL;
|
2004-05-06 04:06:35 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
|
|
|
|
|
|
|
|
|
if (iter)
|
|
|
|
|
path = gtk_tree_model_get_path (gtk_combo_box_get_model (combo_box), iter);
|
|
|
|
|
|
|
|
|
|
gtk_combo_box_set_active_internal (combo_box, path);
|
|
|
|
|
gtk_tree_path_free (path);
|
2004-05-06 04:06:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-10-02 21:30:11 +00:00
|
|
|
|
/**
|
2021-02-25 17:22:44 +00:00
|
|
|
|
* gtk_combo_box_set_model: (attributes org.gtk.Method.set_property=model)
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @combo_box: A `GtkComboBox`
|
|
|
|
|
* @model: (allow-none): A `GtkTreeModel`
|
|
|
|
|
*
|
|
|
|
|
* Sets the model used by @combo_box to be @model.
|
2003-10-02 21:30:11 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* Will unset a previously set model (if applicable). If model is %NULL,
|
|
|
|
|
* then it will unset the model.
|
2010-12-06 12:30:00 +00:00
|
|
|
|
*
|
2011-01-04 15:14:25 +00:00
|
|
|
|
* Note that this function does not clear the cell renderers, you have to
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* call [method@Gtk.CellLayout.clear] yourself if you need to set up different
|
2010-12-06 12:30:00 +00:00
|
|
|
|
* cell renderers for the new model.
|
2003-10-02 21:30:11 +00:00
|
|
|
|
*/
|
2003-09-26 21:57:06 +00:00
|
|
|
|
void
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_combo_box_set_model (GtkComboBox *combo_box,
|
|
|
|
|
GtkTreeModel *model)
|
2003-09-26 21:57:06 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2015-12-22 02:32:14 +00:00
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_return_if_fail (model == NULL || GTK_IS_TREE_MODEL (model));
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2017-01-20 20:43:19 +00:00
|
|
|
|
if (model == priv->model)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
return;
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_combo_box_unset_model (combo_box);
|
2007-12-28 06:56:48 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (model == NULL)
|
|
|
|
|
goto out;
|
2004-03-08 18:39:44 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
priv->model = model;
|
|
|
|
|
g_object_ref (priv->model);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2017-09-01 10:52:12 +00:00
|
|
|
|
g_signal_connect (priv->model, "row-inserted",
|
|
|
|
|
G_CALLBACK (gtk_combo_box_model_row_inserted),
|
|
|
|
|
combo_box);
|
|
|
|
|
g_signal_connect (priv->model, "row-deleted",
|
|
|
|
|
G_CALLBACK (gtk_combo_box_model_row_deleted),
|
|
|
|
|
combo_box);
|
|
|
|
|
g_signal_connect (priv->model, "rows-reordered",
|
|
|
|
|
G_CALLBACK (gtk_combo_box_model_rows_reordered),
|
|
|
|
|
combo_box);
|
|
|
|
|
g_signal_connect (priv->model, "row-changed",
|
|
|
|
|
G_CALLBACK (gtk_combo_box_model_row_changed),
|
|
|
|
|
combo_box);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2019-12-26 05:06:48 +00:00
|
|
|
|
gtk_tree_popover_set_model (GTK_TREE_POPOVER (priv->popup_widget), priv->model);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (priv->cell_view)
|
|
|
|
|
gtk_cell_view_set_model (GTK_CELL_VIEW (priv->cell_view),
|
|
|
|
|
priv->model);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (priv->active != -1)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
/* If an index was set in advance, apply it now */
|
2015-12-22 02:32:14 +00:00
|
|
|
|
gtk_combo_box_set_active (combo_box, priv->active);
|
|
|
|
|
priv->active = -1;
|
2004-02-23 00:53:05 +00:00
|
|
|
|
}
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
gtk_combo_box_update_sensitivity (combo_box);
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (combo_box), "model");
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-05-06 04:06:35 +00:00
|
|
|
|
/**
|
2021-02-25 17:22:44 +00:00
|
|
|
|
* gtk_combo_box_get_model: (attributes org.gtk.Method.get_property=model)
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @combo_box: A `GtkComboBox`
|
2004-05-06 04:06:35 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* Returns the `GtkTreeModel` of @combo_box.
|
2004-05-06 04:06:35 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* Returns: (nullable) (transfer none): A `GtkTreeModel` which was passed
|
2010-12-06 12:30:00 +00:00
|
|
|
|
* during construction.
|
2004-05-06 04:06:35 +00:00
|
|
|
|
*/
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkTreeModel *
|
|
|
|
|
gtk_combo_box_get_model (GtkComboBox *combo_box)
|
2004-05-06 04:06:35 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL);
|
2004-05-06 04:06:35 +00:00
|
|
|
|
|
2018-06-10 10:25:44 +00:00
|
|
|
|
return priv->model;
|
2004-05-06 04:06:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_real_move_active (GtkComboBox *combo_box,
|
|
|
|
|
GtkScrollType scroll)
|
2003-09-26 21:57:06 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
GtkTreeIter new_iter;
|
|
|
|
|
gboolean active_iter;
|
|
|
|
|
gboolean found;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (!priv->model)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_widget_error_bell (GTK_WIDGET (combo_box));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
active_iter = gtk_combo_box_get_active_iter (combo_box, &iter);
|
|
|
|
|
|
|
|
|
|
switch (scroll)
|
|
|
|
|
{
|
|
|
|
|
case GTK_SCROLL_STEP_BACKWARD:
|
|
|
|
|
case GTK_SCROLL_STEP_UP:
|
|
|
|
|
case GTK_SCROLL_STEP_LEFT:
|
|
|
|
|
if (active_iter)
|
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
found = tree_prev (combo_box, priv->model,
|
2015-07-24 15:20:03 +00:00
|
|
|
|
&iter, &new_iter);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
break;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
2019-01-26 14:05:06 +00:00
|
|
|
|
G_GNUC_FALLTHROUGH;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
case GTK_SCROLL_PAGE_FORWARD:
|
|
|
|
|
case GTK_SCROLL_PAGE_DOWN:
|
|
|
|
|
case GTK_SCROLL_PAGE_RIGHT:
|
|
|
|
|
case GTK_SCROLL_END:
|
2015-12-22 02:32:14 +00:00
|
|
|
|
found = tree_last (combo_box, priv->model, &new_iter);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GTK_SCROLL_STEP_FORWARD:
|
|
|
|
|
case GTK_SCROLL_STEP_DOWN:
|
|
|
|
|
case GTK_SCROLL_STEP_RIGHT:
|
|
|
|
|
if (active_iter)
|
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
found = tree_next (combo_box, priv->model,
|
2015-07-24 15:20:03 +00:00
|
|
|
|
&iter, &new_iter);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2019-01-26 14:05:06 +00:00
|
|
|
|
G_GNUC_FALLTHROUGH;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
case GTK_SCROLL_PAGE_BACKWARD:
|
|
|
|
|
case GTK_SCROLL_PAGE_UP:
|
|
|
|
|
case GTK_SCROLL_PAGE_LEFT:
|
|
|
|
|
case GTK_SCROLL_START:
|
2015-12-22 02:32:14 +00:00
|
|
|
|
found = tree_first (combo_box, priv->model, &new_iter);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2017-10-06 19:19:42 +00:00
|
|
|
|
case GTK_SCROLL_NONE:
|
|
|
|
|
case GTK_SCROLL_JUMP:
|
2010-12-06 12:30:00 +00:00
|
|
|
|
default:
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (found && active_iter)
|
|
|
|
|
{
|
|
|
|
|
GtkTreePath *old_path;
|
|
|
|
|
GtkTreePath *new_path;
|
2007-12-28 06:56:48 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
old_path = gtk_tree_model_get_path (priv->model, &iter);
|
|
|
|
|
new_path = gtk_tree_model_get_path (priv->model, &new_iter);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (gtk_tree_path_compare (old_path, new_path) == 0)
|
|
|
|
|
found = FALSE;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_tree_path_free (old_path);
|
|
|
|
|
gtk_tree_path_free (new_path);
|
2004-02-23 00:53:05 +00:00
|
|
|
|
}
|
2004-05-06 04:06:35 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (found)
|
|
|
|
|
{
|
|
|
|
|
gtk_combo_box_set_active_iter (combo_box, &new_iter);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gtk_widget_error_bell (GTK_WIDGET (combo_box));
|
|
|
|
|
}
|
2004-05-06 04:06:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_combo_box_mnemonic_activate (GtkWidget *widget,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gboolean group_cycling)
|
2003-09-26 21:57:06 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2018-06-10 10:25:44 +00:00
|
|
|
|
if (priv->has_entry)
|
2004-02-23 00:53:05 +00:00
|
|
|
|
{
|
2020-05-03 17:12:21 +00:00
|
|
|
|
if (priv->child)
|
|
|
|
|
gtk_widget_grab_focus (priv->child);
|
2004-02-23 00:53:05 +00:00
|
|
|
|
}
|
2010-12-06 12:30:00 +00:00
|
|
|
|
else
|
2018-06-10 10:25:44 +00:00
|
|
|
|
gtk_widget_grab_focus (priv->button);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
return TRUE;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-15 13:34:16 +00:00
|
|
|
|
static gboolean
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_combo_box_grab_focus (GtkWidget *widget)
|
2003-09-26 21:57:06 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2007-12-28 06:56:48 +00:00
|
|
|
|
|
2018-06-10 10:25:44 +00:00
|
|
|
|
if (priv->has_entry)
|
2004-08-02 19:15:05 +00:00
|
|
|
|
{
|
2020-05-03 17:12:21 +00:00
|
|
|
|
if (priv->child)
|
|
|
|
|
return gtk_widget_grab_focus (priv->child);
|
2019-10-15 13:34:16 +00:00
|
|
|
|
else
|
|
|
|
|
return FALSE;
|
2004-08-02 19:15:05 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2019-10-15 13:34:16 +00:00
|
|
|
|
return gtk_widget_grab_focus (priv->button);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-01-20 03:30:36 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_unmap (GtkWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
gtk_combo_box_popdown (GTK_COMBO_BOX (widget));
|
|
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (gtk_combo_box_parent_class)->unmap (widget);
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-03 22:30:36 +00:00
|
|
|
|
static void
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_combo_box_entry_contents_changed (GtkEntry *entry,
|
|
|
|
|
gpointer user_data)
|
2004-03-03 22:30:36 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
/*
|
|
|
|
|
* Fixes regression reported in bug #574059. The old functionality relied on
|
|
|
|
|
* bug #572478. As a bugfix, we now emit the "changed" signal ourselves
|
|
|
|
|
* when the selection was already set to -1.
|
|
|
|
|
*/
|
|
|
|
|
if (gtk_combo_box_get_active(combo_box) == -1)
|
|
|
|
|
g_signal_emit_by_name (combo_box, "changed");
|
|
|
|
|
else
|
|
|
|
|
gtk_combo_box_set_active (combo_box, -1);
|
|
|
|
|
}
|
2009-02-22 17:21:37 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_entry_active_changed (GtkComboBox *combo_box,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2020-05-03 17:12:21 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
|
|
if (gtk_combo_box_get_active_iter (combo_box, &iter))
|
2004-08-02 19:15:05 +00:00
|
|
|
|
{
|
2020-05-03 17:12:21 +00:00
|
|
|
|
GtkEntry *entry = GTK_ENTRY (priv->child);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
if (entry)
|
2011-01-04 15:14:25 +00:00
|
|
|
|
{
|
2016-12-01 12:36:30 +00:00
|
|
|
|
GtkTreePath *path;
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *path_str;
|
|
|
|
|
char *text = NULL;
|
2011-10-06 09:14:38 +00:00
|
|
|
|
|
|
|
|
|
model = gtk_combo_box_get_model (combo_box);
|
2016-12-01 12:36:30 +00:00
|
|
|
|
path = gtk_tree_model_get_path (model, &iter);
|
|
|
|
|
path_str = gtk_tree_path_to_string (path);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
2011-01-04 15:14:25 +00:00
|
|
|
|
g_signal_handlers_block_by_func (entry,
|
|
|
|
|
gtk_combo_box_entry_contents_changed,
|
|
|
|
|
combo_box);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
|
2016-12-01 12:36:30 +00:00
|
|
|
|
g_signal_emit (combo_box, combo_box_signals[FORMAT_ENTRY_TEXT], 0,
|
|
|
|
|
path_str, &text);
|
2011-10-06 09:14:38 +00:00
|
|
|
|
|
2019-02-28 19:31:36 +00:00
|
|
|
|
gtk_editable_set_text (GTK_EDITABLE (entry), text);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
2011-01-04 15:14:25 +00:00
|
|
|
|
g_signal_handlers_unblock_by_func (entry,
|
|
|
|
|
gtk_combo_box_entry_contents_changed,
|
|
|
|
|
combo_box);
|
2011-10-06 09:14:38 +00:00
|
|
|
|
|
2016-12-01 12:36:30 +00:00
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
g_free (text);
|
|
|
|
|
g_free (path_str);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
}
|
2004-08-02 19:15:05 +00:00
|
|
|
|
}
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2020-07-24 18:40:36 +00:00
|
|
|
|
static char *
|
2011-10-06 09:14:38 +00:00
|
|
|
|
gtk_combo_box_format_entry_text (GtkComboBox *combo_box,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *path)
|
2011-10-06 09:14:38 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2011-10-06 09:14:38 +00:00
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
GtkTreeIter iter;
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *text = NULL;
|
2011-10-06 09:14:38 +00:00
|
|
|
|
|
|
|
|
|
if (priv->text_column >= 0)
|
|
|
|
|
{
|
|
|
|
|
model = gtk_combo_box_get_model (combo_box);
|
|
|
|
|
gtk_tree_model_get_iter_from_string (model, &iter, path);
|
|
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, &iter,
|
2016-12-01 12:58:29 +00:00
|
|
|
|
priv->text_column, &text,
|
|
|
|
|
-1);
|
2011-10-06 09:14:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-26 22:22:42 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_constructed (GObject *object)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
2014-06-26 22:22:42 +00:00
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (object);
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
2014-06-26 22:22:42 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_combo_box_parent_class)->constructed (object);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
2016-03-01 16:39:47 +00:00
|
|
|
|
gtk_combo_box_create_child (combo_box);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
if (priv->has_entry)
|
2003-09-26 21:57:06 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
priv->text_renderer = gtk_cell_renderer_text_new ();
|
|
|
|
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box),
|
2011-01-04 15:14:25 +00:00
|
|
|
|
priv->text_renderer, TRUE);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), -1);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void
|
2017-01-21 14:44:30 +00:00
|
|
|
|
gtk_combo_box_dispose (GObject* object)
|
2003-10-14 20:09:39 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (object);
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2005-02-24 17:57:07 +00:00
|
|
|
|
|
2020-05-05 20:47:10 +00:00
|
|
|
|
if (priv->popup_idle_id > 0)
|
|
|
|
|
{
|
|
|
|
|
g_source_remove (priv->popup_idle_id);
|
|
|
|
|
priv->popup_idle_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (priv->box)
|
|
|
|
|
{
|
|
|
|
|
/* destroy things (unparent will kill the latest ref from us)
|
|
|
|
|
* last unref on button will destroy the arrow
|
|
|
|
|
*/
|
|
|
|
|
gtk_widget_unparent (priv->box);
|
|
|
|
|
priv->box = NULL;
|
|
|
|
|
priv->button = NULL;
|
|
|
|
|
priv->arrow = NULL;
|
|
|
|
|
priv->child = NULL;
|
|
|
|
|
priv->cell_view = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (priv->row_separator_destroy)
|
|
|
|
|
priv->row_separator_destroy (priv->row_separator_data);
|
|
|
|
|
|
|
|
|
|
priv->row_separator_func = NULL;
|
|
|
|
|
priv->row_separator_data = NULL;
|
|
|
|
|
priv->row_separator_destroy = NULL;
|
|
|
|
|
|
2017-01-19 22:28:41 +00:00
|
|
|
|
if (priv->popup_widget)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
2017-01-21 20:23:27 +00:00
|
|
|
|
/* Stop menu destruction triggering toggle on a now-invalid button */
|
|
|
|
|
g_signal_handlers_disconnect_by_func (priv->popup_widget,
|
|
|
|
|
gtk_combo_box_menu_hide,
|
|
|
|
|
combo_box);
|
2019-12-26 05:06:48 +00:00
|
|
|
|
g_clear_pointer (&priv->popup_widget, gtk_widget_unparent);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
2003-10-14 20:09:39 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_combo_box_unset_model (combo_box);
|
2010-01-06 17:46:37 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_combo_box_parent_class)->dispose (object);
|
2003-10-14 20:09:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static gboolean
|
2018-06-26 13:44:13 +00:00
|
|
|
|
gtk_cell_editable_key_pressed (GtkEventControllerKey *key,
|
|
|
|
|
guint keyval,
|
|
|
|
|
guint keycode,
|
|
|
|
|
GdkModifierType modifiers,
|
|
|
|
|
GtkComboBox *combo_box)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
2017-08-25 14:44:59 +00:00
|
|
|
|
if (keyval == GDK_KEY_Escape)
|
2004-03-08 18:39:44 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_object_set (combo_box,
|
|
|
|
|
"editing-canceled", TRUE,
|
|
|
|
|
NULL);
|
|
|
|
|
gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (combo_box));
|
|
|
|
|
gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (combo_box));
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
return TRUE;
|
2004-03-08 18:39:44 +00:00
|
|
|
|
}
|
2017-08-25 14:44:59 +00:00
|
|
|
|
else if (keyval == GDK_KEY_Return ||
|
|
|
|
|
keyval == GDK_KEY_ISO_Enter ||
|
|
|
|
|
keyval == GDK_KEY_KP_Enter)
|
2004-03-08 18:39:44 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (combo_box));
|
|
|
|
|
gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (combo_box));
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
return TRUE;
|
2004-03-08 18:39:44 +00:00
|
|
|
|
}
|
Fixes #124373, Murray Cumming.
Mon Nov 17 00:11:21 2003 Kristian Rietveld <kris@gtk.org>
Fixes #124373, Murray Cumming.
* gtk/gtkcombobox.[ch] (gtk_combo_box_class_init): the model property
is no longer construct only,
(gtk_combo_box_unset_model), (gtk_combo_box_set_model_internal),
(gtk_combo_box_menu_fill): new functions,
(gtk_combo_box_menu_setup), (gtk_combo_box_menu_destroy),
(gtk_combo_box_menu_row_*), (gtk_combo_box_list_setup),
(gtk_combo_box_list_destroy): updated,
(gtk_combo_box_new), (gtk_combo_box_new_with_model): new/changed
functions,
(gtk_combo_box_set_model): is now public, updated,
(gtk_combo_box_get_model): small update.
* gtk/gtkcomboboxentry.[ch] (gtk_combo_box_entry_class_init): the
text_column property is no longer construct only,
(gtk_combo_box_entry_set_text_column): now public,
(gtk_combo_box_entry_new), (gtk_combo_box_entry_new_with_model):
new/changed functions.
* tests/testcombo.c: updated.
2003-11-16 23:20:15 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2008-01-16 05:25:35 +00:00
|
|
|
|
|
2006-10-12 13:04:44 +00:00
|
|
|
|
static void
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_combo_box_start_editing (GtkCellEditable *cell_editable,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GdkEvent *event)
|
2006-10-12 13:04:44 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (cell_editable);
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2018-06-26 13:44:13 +00:00
|
|
|
|
GtkEventController *controller;
|
2006-10-12 13:04:44 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
priv->is_cell_renderer = TRUE;
|
2006-10-12 13:04:44 +00:00
|
|
|
|
|
2018-06-26 13:44:13 +00:00
|
|
|
|
controller = gtk_event_controller_key_new ();
|
|
|
|
|
g_signal_connect_object (controller, "key-pressed",
|
|
|
|
|
G_CALLBACK (gtk_cell_editable_key_pressed),
|
|
|
|
|
cell_editable, 0);
|
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (priv->cell_view)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
2018-06-26 13:44:13 +00:00
|
|
|
|
gtk_widget_add_controller (priv->button, controller);
|
2015-12-22 02:32:14 +00:00
|
|
|
|
gtk_widget_grab_focus (priv->button);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2006-10-12 13:04:44 +00:00
|
|
|
|
{
|
2020-05-03 17:12:21 +00:00
|
|
|
|
gtk_widget_add_controller (priv->child, controller);
|
2006-10-12 13:04:44 +00:00
|
|
|
|
|
2020-05-03 17:12:21 +00:00
|
|
|
|
gtk_widget_grab_focus (priv->child);
|
2015-12-22 02:32:14 +00:00
|
|
|
|
gtk_widget_set_can_focus (priv->button, FALSE);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
2006-10-12 13:04:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
/**
|
2021-02-25 17:22:44 +00:00
|
|
|
|
* gtk_combo_box_set_popup_fixed_width: (attributes org.gtk.Method.set_property=popup-fixed-width)
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @combo_box: a `GtkComboBox`
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* @fixed: whether to use a fixed popup width
|
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* Specifies whether the popup’s width should be a fixed width.
|
|
|
|
|
*
|
|
|
|
|
* If @fixed is %TRUE, the popup's width is set to match the
|
|
|
|
|
* allocated width of the combo box.
|
|
|
|
|
*/
|
2010-11-24 09:14:36 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_combo_box_set_popup_fixed_width (GtkComboBox *combo_box,
|
|
|
|
|
gboolean fixed)
|
2004-02-05 23:45:21 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2015-12-22 02:32:14 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
2007-05-02 22:19:45 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (priv->popup_fixed_width != fixed)
|
2004-07-22 02:36:54 +00:00
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
priv->popup_fixed_width = fixed;
|
2007-05-02 22:19:45 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
g_object_notify (G_OBJECT (combo_box), "popup-fixed-width");
|
|
|
|
|
}
|
2007-05-02 22:19:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
/**
|
2021-02-25 17:22:44 +00:00
|
|
|
|
* gtk_combo_box_get_popup_fixed_width: (attributes org.gtk.Method.get_property=popup-fixed-width)
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @combo_box: a `GtkComboBox`
|
2010-11-24 09:14:36 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* Gets whether the popup uses a fixed width.
|
|
|
|
|
*
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* Returns: %TRUE if the popup uses a fixed width
|
2021-02-21 22:20:23 +00:00
|
|
|
|
*/
|
2010-11-24 09:14:36 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gtk_combo_box_get_popup_fixed_width (GtkComboBox *combo_box)
|
2007-05-02 22:19:45 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), FALSE);
|
2004-02-05 23:45:21 +00:00
|
|
|
|
|
2018-06-10 10:25:44 +00:00
|
|
|
|
return priv->popup_fixed_width;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
2004-03-08 18:39:44 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
/**
|
2011-01-18 05:37:11 +00:00
|
|
|
|
* gtk_combo_box_get_row_separator_func: (skip)
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @combo_box: a `GtkComboBox`
|
2011-01-04 15:14:25 +00:00
|
|
|
|
*
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* Returns the current row separator function.
|
2011-01-04 15:14:25 +00:00
|
|
|
|
*
|
2020-11-24 18:27:33 +00:00
|
|
|
|
* Returns: (nullable): the current row separator function.
|
2010-11-24 09:14:36 +00:00
|
|
|
|
*/
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreeViewRowSeparatorFunc
|
2010-11-24 09:14:36 +00:00
|
|
|
|
gtk_combo_box_get_row_separator_func (GtkComboBox *combo_box)
|
2004-07-16 20:27:40 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL);
|
2004-07-16 20:27:40 +00:00
|
|
|
|
|
2018-06-10 10:25:44 +00:00
|
|
|
|
return priv->row_separator_func;
|
2004-07-16 20:27:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_set_row_separator_func:
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @combo_box: a `GtkComboBox`
|
|
|
|
|
* @func: (nullable): a `GtkTreeViewRowSeparatorFunc`
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* @data: (allow-none): user data to pass to @func, or %NULL
|
|
|
|
|
* @destroy: (allow-none): destroy notifier for @data, or %NULL
|
2011-01-04 15:14:25 +00:00
|
|
|
|
*
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* Sets the row separator function, which is used to determine
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* whether a row should be drawn as a separator.
|
|
|
|
|
*
|
|
|
|
|
* If the row separator function is %NULL, no separators are drawn.
|
|
|
|
|
* This is the default value.
|
2010-11-24 09:14:36 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_combo_box_set_row_separator_func (GtkComboBox *combo_box,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreeViewRowSeparatorFunc func,
|
|
|
|
|
gpointer data,
|
|
|
|
|
GDestroyNotify destroy)
|
2004-07-16 20:27:40 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2015-12-22 02:32:14 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
2004-07-16 20:27:40 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (priv->row_separator_destroy)
|
|
|
|
|
priv->row_separator_destroy (priv->row_separator_data);
|
2004-08-30 13:16:39 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
priv->row_separator_func = func;
|
|
|
|
|
priv->row_separator_data = data;
|
|
|
|
|
priv->row_separator_destroy = destroy;
|
2004-07-16 20:27:40 +00:00
|
|
|
|
|
2019-12-26 05:06:48 +00:00
|
|
|
|
gtk_tree_popover_set_row_separator_func (GTK_TREE_POPOVER (priv->popup_widget),
|
|
|
|
|
(GtkTreeViewRowSeparatorFunc)gtk_combo_box_row_separator_func,
|
|
|
|
|
combo_box, NULL);
|
2005-07-22 03:38:14 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
gtk_widget_queue_draw (GTK_WIDGET (combo_box));
|
2004-07-16 20:27:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
/**
|
2021-02-25 17:22:44 +00:00
|
|
|
|
* gtk_combo_box_set_button_sensitivity: (attributes org.gtk.Method.set_property=button-sensitivity)
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @combo_box: a `GtkComboBox`
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* @sensitivity: specify the sensitivity of the dropdown button
|
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* Sets whether the dropdown button of the combo box should update
|
|
|
|
|
* its sensitivity depending on the model contents.
|
|
|
|
|
*/
|
2010-11-24 09:14:36 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_combo_box_set_button_sensitivity (GtkComboBox *combo_box,
|
|
|
|
|
GtkSensitivityType sensitivity)
|
2004-07-16 20:27:40 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2015-12-22 02:32:14 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
2004-07-16 20:27:40 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (priv->button_sensitivity != sensitivity)
|
2004-07-16 20:27:40 +00:00
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
priv->button_sensitivity = sensitivity;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
gtk_combo_box_update_sensitivity (combo_box);
|
2004-07-16 20:27:40 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
g_object_notify (G_OBJECT (combo_box), "button-sensitivity");
|
2004-07-16 20:27:40 +00:00
|
|
|
|
}
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
2004-07-16 20:27:40 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
/**
|
2021-02-25 17:22:44 +00:00
|
|
|
|
* gtk_combo_box_get_button_sensitivity: (attributes org.gtk.Method.get_property=button-sensitivity)
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @combo_box: a `GtkComboBox`
|
2010-11-24 09:14:36 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns whether the combo box sets the dropdown button
|
|
|
|
|
* sensitive or not when there are no items in the model.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %GTK_SENSITIVITY_ON if the dropdown button
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* is sensitive when the model is empty, %GTK_SENSITIVITY_OFF
|
|
|
|
|
* if the button is always insensitive or %GTK_SENSITIVITY_AUTO
|
|
|
|
|
* if it is only sensitive as long as the model has one item to
|
|
|
|
|
* be selected.
|
|
|
|
|
*/
|
2010-11-24 09:14:36 +00:00
|
|
|
|
GtkSensitivityType
|
|
|
|
|
gtk_combo_box_get_button_sensitivity (GtkComboBox *combo_box)
|
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), FALSE);
|
2007-12-25 04:04:21 +00:00
|
|
|
|
|
2018-06-10 10:25:44 +00:00
|
|
|
|
return priv->button_sensitivity;
|
2004-07-16 20:27:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 17:22:44 +00:00
|
|
|
|
* gtk_combo_box_get_has_entry: (attributes org.gtk.Method.get_property=has-entry)
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @combo_box: a `GtkComboBox`
|
2010-11-24 09:14:36 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns whether the combo box has an entry.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: whether there is an entry in @combo_box.
|
2021-02-21 22:20:23 +00:00
|
|
|
|
*/
|
2004-05-10 14:07:35 +00:00
|
|
|
|
gboolean
|
2010-11-24 09:14:36 +00:00
|
|
|
|
gtk_combo_box_get_has_entry (GtkComboBox *combo_box)
|
2004-05-10 14:07:35 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2004-05-10 14:07:35 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), FALSE);
|
|
|
|
|
|
2018-06-10 10:25:44 +00:00
|
|
|
|
return priv->has_entry;
|
2004-05-10 14:07:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-07-16 20:27:40 +00:00
|
|
|
|
/**
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* gtk_combo_box_set_entry_text_column:
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @combo_box: A `GtkComboBox`
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* @text_column: A column in @model to get the strings from for
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* the internal entry
|
|
|
|
|
*
|
|
|
|
|
* Sets the model column which @combo_box should use to get strings
|
|
|
|
|
* from to be @text_column.
|
2004-07-16 20:27:40 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* The column @text_column in the model of @combo_box must be of
|
|
|
|
|
* type %G_TYPE_STRING.
|
2010-11-24 09:14:36 +00:00
|
|
|
|
*
|
|
|
|
|
* This is only relevant if @combo_box has been created with
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* [property@Gtk.ComboBox:has-entry] as %TRUE.
|
2007-03-12 06:04:44 +00:00
|
|
|
|
*/
|
2004-05-10 14:07:35 +00:00
|
|
|
|
void
|
2010-11-24 09:14:36 +00:00
|
|
|
|
gtk_combo_box_set_entry_text_column (GtkComboBox *combo_box,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int text_column)
|
2004-05-10 14:07:35 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2004-05-10 14:07:35 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
2010-11-24 09:14:36 +00:00
|
|
|
|
g_return_if_fail (text_column >= 0);
|
2020-02-22 05:57:32 +00:00
|
|
|
|
g_return_if_fail (priv->model == NULL || text_column < gtk_tree_model_get_n_columns (priv->model));
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2014-06-07 20:40:09 +00:00
|
|
|
|
if (priv->text_column != text_column)
|
|
|
|
|
{
|
|
|
|
|
priv->text_column = text_column;
|
|
|
|
|
|
|
|
|
|
if (priv->text_renderer != NULL)
|
|
|
|
|
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box),
|
|
|
|
|
priv->text_renderer,
|
|
|
|
|
"text", text_column,
|
|
|
|
|
NULL);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2014-06-07 20:40:09 +00:00
|
|
|
|
g_object_notify (G_OBJECT (combo_box), "entry-text-column");
|
|
|
|
|
}
|
2004-05-10 14:07:35 +00:00
|
|
|
|
}
|
2004-07-07 15:15:35 +00:00
|
|
|
|
|
2005-11-21 16:01:56 +00:00
|
|
|
|
/**
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* gtk_combo_box_get_entry_text_column:
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @combo_box: A `GtkComboBox`
|
2005-11-21 16:01:56 +00:00
|
|
|
|
*
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* Returns the column which @combo_box is using to get the strings
|
|
|
|
|
* from to display in the internal entry.
|
2005-11-21 16:01:56 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: A column in the data source model of @combo_box.
|
2005-11-21 16:01:56 +00:00
|
|
|
|
*/
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int
|
2010-11-24 09:14:36 +00:00
|
|
|
|
gtk_combo_box_get_entry_text_column (GtkComboBox *combo_box)
|
2005-11-21 16:01:56 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), 0);
|
2005-11-21 16:01:56 +00:00
|
|
|
|
|
2018-06-10 10:25:44 +00:00
|
|
|
|
return priv->text_column;
|
2005-11-21 16:01:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-25 22:06:46 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_buildable_add_child (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *type)
|
2015-07-25 22:06:46 +00:00
|
|
|
|
{
|
2018-03-08 02:13:57 +00:00
|
|
|
|
if (GTK_IS_CELL_RENDERER (child))
|
|
|
|
|
_gtk_cell_layout_buildable_add_child (buildable, builder, child, type);
|
2020-05-03 17:12:21 +00:00
|
|
|
|
else if (GTK_IS_WIDGET (child))
|
|
|
|
|
gtk_combo_box_set_child (GTK_COMBO_BOX (buildable), GTK_WIDGET (child));
|
2018-03-08 02:13:57 +00:00
|
|
|
|
else
|
|
|
|
|
parent_buildable_iface->add_child (buildable, builder, child, type);
|
2015-07-25 22:06:46 +00:00
|
|
|
|
}
|
2010-10-16 09:01:33 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static gboolean
|
2019-08-29 13:21:20 +00:00
|
|
|
|
gtk_combo_box_buildable_custom_tag_start (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *tagname,
|
2019-08-29 13:21:20 +00:00
|
|
|
|
GtkBuildableParser *parser,
|
|
|
|
|
gpointer *data)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
if (parent_buildable_iface->custom_tag_start (buildable, builder, child,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
tagname, parser, data))
|
2010-12-06 12:30:00 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
return _gtk_cell_layout_buildable_custom_tag_start (buildable, builder, child,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
tagname, parser, data);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_buildable_custom_tag_end (GtkBuildable *buildable,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *tagname,
|
2018-10-07 22:34:43 +00:00
|
|
|
|
gpointer data)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
2010-12-13 10:24:51 +00:00
|
|
|
|
if (!_gtk_cell_layout_buildable_custom_tag_end (buildable, builder, child, tagname, data))
|
|
|
|
|
parent_buildable_iface->custom_tag_end (buildable, builder, child, tagname, data);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GObject *
|
|
|
|
|
gtk_combo_box_buildable_get_internal_child (GtkBuildable *buildable,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkBuilder *builder,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *childname)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (buildable);
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
2018-06-10 10:25:44 +00:00
|
|
|
|
if (priv->has_entry && strcmp (childname, "entry") == 0)
|
2020-05-03 17:12:21 +00:00
|
|
|
|
return G_OBJECT (priv->child);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
return parent_buildable_iface->get_internal_child (buildable, builder, childname);
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-30 05:07:08 +00:00
|
|
|
|
/**
|
2021-02-25 17:22:44 +00:00
|
|
|
|
* gtk_combo_box_set_id_column: (attributes org.gtk.Method.set_property=id-column)
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @combo_box: A `GtkComboBox`
|
2010-11-30 05:07:08 +00:00
|
|
|
|
* @id_column: A column in @model to get string IDs for values from
|
|
|
|
|
*
|
|
|
|
|
* Sets the model column which @combo_box should use to get string IDs
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* for values from.
|
|
|
|
|
*
|
|
|
|
|
* The column @id_column in the model of @combo_box must be of type
|
|
|
|
|
* %G_TYPE_STRING.
|
2010-11-30 05:07:08 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_combo_box_set_id_column (GtkComboBox *combo_box,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int id_column)
|
2010-11-30 05:07:08 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2010-11-30 05:07:08 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
|
|
|
|
|
|
|
|
|
if (id_column != priv->id_column)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (id_column >= 0);
|
2020-02-22 05:57:32 +00:00
|
|
|
|
g_return_if_fail (priv->model == NULL || id_column < gtk_tree_model_get_n_columns (priv->model));
|
2010-11-30 05:07:08 +00:00
|
|
|
|
|
|
|
|
|
priv->id_column = id_column;
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (combo_box), "id-column");
|
|
|
|
|
g_object_notify (G_OBJECT (combo_box), "active-id");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 17:22:44 +00:00
|
|
|
|
* gtk_combo_box_get_id_column: (attributes org.gtk.Method.get_property=id-column)
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @combo_box: A `GtkComboBox`
|
2010-11-30 05:07:08 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns the column which @combo_box is using to get string IDs
|
|
|
|
|
* for values from.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: A column in the data source model of @combo_box.
|
2010-11-30 05:07:08 +00:00
|
|
|
|
*/
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int
|
2010-11-30 05:07:08 +00:00
|
|
|
|
gtk_combo_box_get_id_column (GtkComboBox *combo_box)
|
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
|
|
|
|
|
2010-11-30 05:07:08 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), 0);
|
|
|
|
|
|
2018-06-10 10:25:44 +00:00
|
|
|
|
return priv->id_column;
|
2010-11-30 05:07:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 17:22:44 +00:00
|
|
|
|
* gtk_combo_box_get_active_id: (attributes org.gtk.Method.get_property=active-id)
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @combo_box: a `GtkComboBox`
|
2010-11-30 05:07:08 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* Returns the ID of the active row of @combo_box.
|
|
|
|
|
*
|
|
|
|
|
* This value is taken from the active row and the column specified
|
|
|
|
|
* by the [property@Gtk.ComboBox:id-column] property of @combo_box
|
|
|
|
|
* (see [method@Gtk.ComboBox.set_id_column]).
|
2010-11-30 05:07:08 +00:00
|
|
|
|
*
|
|
|
|
|
* The returned value is an interned string which means that you can
|
|
|
|
|
* compare the pointer by value to other interned strings and that you
|
|
|
|
|
* must not free it.
|
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* If the [property@Gtk.ComboBox:id-column] property of @combo_box is
|
|
|
|
|
* not set, or if no row is active, or if the active row has a %NULL
|
|
|
|
|
* ID value, then %NULL is returned.
|
2010-11-30 05:07:08 +00:00
|
|
|
|
*
|
2014-05-26 16:13:02 +00:00
|
|
|
|
* Returns: (nullable): the ID of the active row, or %NULL
|
2021-02-21 22:20:23 +00:00
|
|
|
|
*/
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *
|
2010-11-30 05:07:08 +00:00
|
|
|
|
gtk_combo_box_get_active_id (GtkComboBox *combo_box)
|
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2010-11-30 05:07:08 +00:00
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
GtkTreeIter iter;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int column;
|
2010-11-30 05:07:08 +00:00
|
|
|
|
|
2011-06-01 04:05:06 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL);
|
2010-11-30 05:07:08 +00:00
|
|
|
|
|
2018-06-10 10:25:44 +00:00
|
|
|
|
column = priv->id_column;
|
2010-11-30 05:07:08 +00:00
|
|
|
|
|
|
|
|
|
if (column < 0)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
model = gtk_combo_box_get_model (combo_box);
|
|
|
|
|
g_return_val_if_fail (gtk_tree_model_get_column_type (model, column) ==
|
|
|
|
|
G_TYPE_STRING, NULL);
|
|
|
|
|
|
|
|
|
|
if (gtk_combo_box_get_active_iter (combo_box, &iter))
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *interned;
|
|
|
|
|
char *id;
|
2010-11-30 05:07:08 +00:00
|
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, &iter, column, &id, -1);
|
|
|
|
|
interned = g_intern_string (id);
|
|
|
|
|
g_free (id);
|
|
|
|
|
|
|
|
|
|
return interned;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 17:22:44 +00:00
|
|
|
|
* gtk_combo_box_set_active_id: (attributes org.gtk.Method.set_property=active-id)
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @combo_box: a `GtkComboBox`
|
2011-04-26 11:59:53 +00:00
|
|
|
|
* @active_id: (allow-none): the ID of the row to select, or %NULL
|
2010-11-30 05:07:08 +00:00
|
|
|
|
*
|
2011-04-26 11:59:53 +00:00
|
|
|
|
* Changes the active row of @combo_box to the one that has an ID equal to
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @active_id.
|
|
|
|
|
*
|
|
|
|
|
* If @active_id is %NULL, the active row is unset. Rows having
|
2011-04-26 11:59:53 +00:00
|
|
|
|
* a %NULL ID string cannot be made active by this function.
|
2010-11-30 05:07:08 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* If the [property@Gtk.ComboBox:id-column] property of @combo_box is
|
|
|
|
|
* unset or if no row has the given ID then the function does nothing
|
|
|
|
|
* and returns %FALSE.
|
2011-04-26 11:59:53 +00:00
|
|
|
|
*
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* Returns: %TRUE if a row with a matching ID was found. If a %NULL
|
|
|
|
|
* @active_id was given to unset the active row, the function
|
|
|
|
|
* always returns %TRUE.
|
|
|
|
|
*/
|
2011-04-26 11:59:53 +00:00
|
|
|
|
gboolean
|
2010-11-30 05:07:08 +00:00
|
|
|
|
gtk_combo_box_set_active_id (GtkComboBox *combo_box,
|
2021-02-21 22:20:23 +00:00
|
|
|
|
const char *active_id)
|
2010-11-30 05:07:08 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
2010-11-30 05:07:08 +00:00
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
GtkTreeIter iter;
|
2011-04-26 11:59:53 +00:00
|
|
|
|
gboolean match = FALSE;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int column;
|
2010-11-30 05:07:08 +00:00
|
|
|
|
|
2011-04-26 11:59:53 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), FALSE);
|
|
|
|
|
|
|
|
|
|
if (active_id == NULL)
|
|
|
|
|
{
|
|
|
|
|
gtk_combo_box_set_active (combo_box, -1);
|
|
|
|
|
return TRUE; /* active row was successfully unset */
|
|
|
|
|
}
|
2010-11-30 05:07:08 +00:00
|
|
|
|
|
2018-06-10 10:25:44 +00:00
|
|
|
|
column = priv->id_column;
|
2010-11-30 05:07:08 +00:00
|
|
|
|
|
|
|
|
|
if (column < 0)
|
2011-04-26 11:59:53 +00:00
|
|
|
|
return FALSE;
|
2010-11-30 05:07:08 +00:00
|
|
|
|
|
|
|
|
|
model = gtk_combo_box_get_model (combo_box);
|
2011-04-26 11:59:53 +00:00
|
|
|
|
g_return_val_if_fail (gtk_tree_model_get_column_type (model, column) ==
|
|
|
|
|
G_TYPE_STRING, FALSE);
|
2010-11-30 05:07:08 +00:00
|
|
|
|
|
|
|
|
|
if (gtk_tree_model_get_iter_first (model, &iter))
|
|
|
|
|
do {
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *id;
|
2010-11-30 05:07:08 +00:00
|
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, &iter, column, &id, -1);
|
2011-04-26 11:59:53 +00:00
|
|
|
|
if (id != NULL)
|
|
|
|
|
match = strcmp (id, active_id) == 0;
|
2010-11-30 05:07:08 +00:00
|
|
|
|
g_free (id);
|
|
|
|
|
|
|
|
|
|
if (match)
|
|
|
|
|
{
|
|
|
|
|
gtk_combo_box_set_active_iter (combo_box, &iter);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} while (gtk_tree_model_iter_next (model, &iter));
|
2011-04-26 11:59:53 +00:00
|
|
|
|
|
2014-06-07 20:40:09 +00:00
|
|
|
|
g_object_notify (G_OBJECT (combo_box), "active-id");
|
|
|
|
|
|
|
|
|
|
return match;
|
2010-11-30 05:07:08 +00:00
|
|
|
|
}
|
2014-06-10 12:47:27 +00:00
|
|
|
|
|
|
|
|
|
GtkWidget *
|
2018-06-10 10:25:44 +00:00
|
|
|
|
gtk_combo_box_get_popup (GtkComboBox *combo_box)
|
2014-06-10 12:47:27 +00:00
|
|
|
|
{
|
2018-06-10 10:25:44 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
|
|
|
|
|
|
|
|
|
return priv->popup_widget;
|
2014-06-10 12:47:27 +00:00
|
|
|
|
}
|
2020-05-03 16:04:23 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 17:22:44 +00:00
|
|
|
|
* gtk_combo_box_set_child: (attributes org.gtk.Method.set_property=child)
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @combo_box: a `GtkComboBox`
|
2020-05-03 16:04:23 +00:00
|
|
|
|
* @child: (allow-none): the child widget
|
|
|
|
|
*
|
|
|
|
|
* Sets the child widget of @combo_box.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_combo_box_set_child (GtkComboBox *combo_box,
|
|
|
|
|
GtkWidget *child)
|
|
|
|
|
{
|
2020-05-03 17:12:21 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
|
|
|
|
|
2020-05-03 16:04:23 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
|
|
|
|
g_return_if_fail (child == NULL || GTK_IS_WIDGET (child));
|
|
|
|
|
|
2020-05-03 17:12:21 +00:00
|
|
|
|
if (priv->child)
|
|
|
|
|
gtk_combo_box_remove (combo_box, priv->child);
|
|
|
|
|
|
2020-05-03 16:04:23 +00:00
|
|
|
|
if (child)
|
2020-05-03 17:12:21 +00:00
|
|
|
|
gtk_combo_box_add (combo_box, child);
|
|
|
|
|
|
2020-05-03 16:04:23 +00:00
|
|
|
|
g_object_notify (G_OBJECT (combo_box), "child");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 17:22:44 +00:00
|
|
|
|
* gtk_combo_box_get_child: (attributes org.gtk.Method.get_property=child)
|
2021-02-21 22:20:23 +00:00
|
|
|
|
* @combo_box: a `GtkComboBox`
|
2020-05-03 16:04:23 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets the child widget of @combo_box.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (nullable) (transfer none): the child widget of @combo_box
|
|
|
|
|
*/
|
|
|
|
|
GtkWidget *
|
|
|
|
|
gtk_combo_box_get_child (GtkComboBox *combo_box)
|
|
|
|
|
{
|
2020-05-03 17:12:21 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
|
|
|
|
|
2020-05-03 16:04:23 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL);
|
|
|
|
|
|
2020-05-03 17:12:21 +00:00
|
|
|
|
return priv->child;
|
2020-05-03 16:04:23 +00:00
|
|
|
|
}
|
|
|
|
|
|