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
|
|
|
|
|
2003-10-23 18:25:53 +00:00
|
|
|
|
#include "gtkcombobox.h"
|
2012-03-03 18:41:55 +00:00
|
|
|
|
|
|
|
|
|
#include "gtkadjustment.h"
|
2010-12-06 12:30:00 +00:00
|
|
|
|
#include "gtkcellareabox.h"
|
|
|
|
|
#include "gtktreemenu.h"
|
2004-02-29 00:08:04 +00:00
|
|
|
|
#include "gtkbindings.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"
|
2015-12-22 02:43:19 +00:00
|
|
|
|
#include "gtkcsscustomgadgetprivate.h"
|
2004-02-29 00:08:04 +00:00
|
|
|
|
#include "gtkeventbox.h"
|
2003-10-23 18:25:53 +00:00
|
|
|
|
#include "gtkframe.h"
|
2015-12-21 22:45:58 +00:00
|
|
|
|
#include "gtkiconprivate.h"
|
2011-08-28 05:54:55 +00:00
|
|
|
|
#include "gtkbox.h"
|
2004-02-29 00:08:04 +00:00
|
|
|
|
#include "gtkliststore.h"
|
|
|
|
|
#include "gtkmain.h"
|
2010-12-23 20:50:18 +00:00
|
|
|
|
#include "gtkmenuprivate.h"
|
2010-12-23 23:21:53 +00:00
|
|
|
|
#include "gtkmenushellprivate.h"
|
2004-07-26 04:50:07 +00:00
|
|
|
|
#include "gtkscrolledwindow.h"
|
2011-11-02 02:52:32 +00:00
|
|
|
|
#include "deprecated/gtktearoffmenuitem.h"
|
2003-10-23 18:25:53 +00:00
|
|
|
|
#include "gtktogglebutton.h"
|
2004-02-29 00:08:04 +00:00
|
|
|
|
#include "gtktreeselection.h"
|
2012-03-16 19:01:50 +00:00
|
|
|
|
#include "gtkwidgetpath.h"
|
2012-03-21 08:37:09 +00:00
|
|
|
|
#include "gtkwidgetprivate.h"
|
2003-10-23 18:25:53 +00:00
|
|
|
|
#include "gtkwindow.h"
|
2011-01-04 19:51:19 +00:00
|
|
|
|
#include "gtktypebuiltins.h"
|
2005-03-22 02:14:55 +00:00
|
|
|
|
#include "gtkprivate.h"
|
2014-06-10 12:47:27 +00:00
|
|
|
|
#include "gtkcomboboxprivate.h"
|
2003-09-26 21:57:06 +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>
|
|
|
|
|
|
|
|
|
|
#include "gtkmarshalers.h"
|
|
|
|
|
#include "gtkintl.h"
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
#include "gtkentryprivate.h"
|
2004-08-02 19:15:05 +00:00
|
|
|
|
#include "gtktreeprivate.h"
|
2011-06-29 21:31:09 +00:00
|
|
|
|
#include "a11y/gtkcomboboxaccessible.h"
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-10-04 00:05:45 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* SECTION:gtkcombobox
|
|
|
|
|
* @Short_description: A widget used to choose from a list of items
|
|
|
|
|
* @Title: GtkComboBox
|
2010-10-15 20:52:54 +00:00
|
|
|
|
* @See_also: #GtkComboBoxText, #GtkTreeModel, #GtkCellRenderer
|
2010-10-04 00:05:45 +00:00
|
|
|
|
*
|
|
|
|
|
* A GtkComboBox is a widget that allows the user to choose from a list of
|
|
|
|
|
* valid choices. The GtkComboBox displays the selected choice. When
|
|
|
|
|
* activated, the GtkComboBox displays a popup which allows the user to
|
|
|
|
|
* make a new choice. The style in which the selected value is displayed,
|
|
|
|
|
* and the style of the popup is determined by the current theme. It may
|
|
|
|
|
* be similar to a Windows-style combo box.
|
|
|
|
|
*
|
|
|
|
|
* The GtkComboBox uses the model-view pattern; the list of valid choices
|
|
|
|
|
* 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
|
|
|
|
|
* would in a tree view. This is possible since GtkComboBox implements the
|
|
|
|
|
* #GtkCellLayout 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.
|
|
|
|
|
*
|
2014-02-07 19:03:49 +00:00
|
|
|
|
* To allow the user to enter values not in the model, the “has-entry”
|
2010-12-13 20:45:07 +00:00
|
|
|
|
* property allows the GtkComboBox to contain a #GtkEntry. This entry
|
|
|
|
|
* can be accessed by calling gtk_bin_get_child() on the combo box.
|
|
|
|
|
*
|
2010-10-02 16:19:46 +00:00
|
|
|
|
* For a simple list of textual choices, the model-view API of GtkComboBox
|
|
|
|
|
* can be a bit overwhelming. In this case, #GtkComboBoxText offers a
|
2010-12-13 20:45:07 +00:00
|
|
|
|
* simple alternative. Both GtkComboBox and #GtkComboBoxText can contain
|
|
|
|
|
* an entry.
|
2015-11-02 18:15:05 +00:00
|
|
|
|
*
|
|
|
|
|
* # CSS nodes
|
|
|
|
|
*
|
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
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* A GtkComboBox with an entry has a single CSS node with name combobox. It
|
|
|
|
|
* contains a bx with the .linked class and that box contains an entry and a
|
|
|
|
|
* button, both with the .combo class added.
|
2015-12-21 22:45:58 +00:00
|
|
|
|
* The button also contains another node with name arrow.
|
2010-10-04 00:05:45 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
|
/* WELCOME, to THE house of evil code */
|
2010-12-06 12:30:00 +00:00
|
|
|
|
struct _GtkComboBoxPrivate
|
|
|
|
|
{
|
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
|
|
|
|
|
GtkCellArea *area;
|
|
|
|
|
|
|
|
|
|
gint col_column;
|
|
|
|
|
gint row_column;
|
|
|
|
|
|
|
|
|
|
gint wrap_width;
|
|
|
|
|
|
|
|
|
|
gint active; /* Only temporary */
|
|
|
|
|
GtkTreeRowReference *active_row;
|
|
|
|
|
|
|
|
|
|
GtkWidget *tree_view;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
GtkWidget *popup_window;
|
|
|
|
|
GtkWidget *scrolled_window;
|
|
|
|
|
|
2015-12-22 02:43:19 +00:00
|
|
|
|
GtkCssGadget *gadget;
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gulong inserted_id;
|
|
|
|
|
gulong deleted_id;
|
|
|
|
|
gulong reordered_id;
|
|
|
|
|
gulong changed_id;
|
|
|
|
|
guint popup_idle_id;
|
|
|
|
|
guint activate_button;
|
|
|
|
|
guint32 activate_time;
|
|
|
|
|
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
|
|
|
|
|
*/
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gint text_column;
|
|
|
|
|
GtkCellRenderer *text_renderer;
|
|
|
|
|
|
|
|
|
|
gint id_column;
|
|
|
|
|
|
|
|
|
|
guint popup_in_progress : 1;
|
|
|
|
|
guint popup_shown : 1;
|
|
|
|
|
guint add_tearoffs : 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;
|
|
|
|
|
|
|
|
|
|
GdkDevice *grab_pointer;
|
|
|
|
|
|
|
|
|
|
gchar *tearoff_title;
|
|
|
|
|
};
|
|
|
|
|
|
2004-02-24 23:12:57 +00:00
|
|
|
|
/* While debugging this evil code, I have learned that
|
|
|
|
|
* there are actually 4 modes to this widget, which can
|
|
|
|
|
* be characterized as follows
|
|
|
|
|
*
|
|
|
|
|
* 1) menu mode, no child added
|
|
|
|
|
*
|
|
|
|
|
* tree_view -> NULL
|
|
|
|
|
* cell_view -> GtkCellView, regular child
|
|
|
|
|
* button -> GtkToggleButton set_parent to combo
|
|
|
|
|
* arrow -> GtkArrow set_parent to button
|
|
|
|
|
* popup_widget -> GtkMenu
|
|
|
|
|
* popup_window -> NULL
|
2004-07-26 04:50:07 +00:00
|
|
|
|
* scrolled_window -> NULL
|
2004-02-24 23:12:57 +00:00
|
|
|
|
*
|
|
|
|
|
* 2) menu mode, child added
|
|
|
|
|
*
|
|
|
|
|
* tree_view -> NULL
|
|
|
|
|
* cell_view -> NULL
|
|
|
|
|
* button -> GtkToggleButton set_parent to combo
|
|
|
|
|
* arrow -> GtkArrow, child of button
|
|
|
|
|
* popup_widget -> GtkMenu
|
|
|
|
|
* popup_window -> NULL
|
2004-07-26 04:50:07 +00:00
|
|
|
|
* scrolled_window -> NULL
|
2004-02-24 23:12:57 +00:00
|
|
|
|
*
|
|
|
|
|
* 3) list mode, no child added
|
|
|
|
|
*
|
2007-06-13 23:15:42 +00:00
|
|
|
|
* tree_view -> GtkTreeView, child of scrolled_window
|
2004-02-24 23:12:57 +00:00
|
|
|
|
* cell_view -> GtkCellView, regular child
|
|
|
|
|
* button -> GtkToggleButton, set_parent to combo
|
|
|
|
|
* arrow -> GtkArrow, child of button
|
|
|
|
|
* popup_widget -> tree_view
|
|
|
|
|
* popup_window -> GtkWindow
|
2007-06-13 23:15:42 +00:00
|
|
|
|
* scrolled_window -> GtkScrolledWindow, child of popup_window
|
2004-02-24 23:12:57 +00:00
|
|
|
|
*
|
|
|
|
|
* 4) list mode, child added
|
|
|
|
|
*
|
2007-06-13 23:15:42 +00:00
|
|
|
|
* tree_view -> GtkTreeView, child of scrolled_window
|
2004-02-24 23:12:57 +00:00
|
|
|
|
* cell_view -> NULL
|
|
|
|
|
* button -> GtkToggleButton, set_parent to combo
|
|
|
|
|
* arrow -> GtkArrow, child of button
|
|
|
|
|
* popup_widget -> tree_view
|
|
|
|
|
* popup_window -> GtkWindow
|
2007-06-13 23:15:42 +00:00
|
|
|
|
* scrolled_window -> GtkScrolledWindow, child of popup_window
|
2004-02-24 23:12:57 +00:00
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
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_WRAP_WIDTH,
|
|
|
|
|
PROP_ROW_SPAN_COLUMN,
|
|
|
|
|
PROP_COLUMN_SPAN_COLUMN,
|
|
|
|
|
PROP_ACTIVE,
|
|
|
|
|
PROP_ADD_TEAROFFS,
|
|
|
|
|
PROP_TEAROFF_TITLE,
|
|
|
|
|
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,
|
|
|
|
|
PROP_ACTIVE_ID,
|
|
|
|
|
PROP_CELL_AREA
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static guint combo_box_signals[LAST_SIGNAL] = {0,};
|
|
|
|
|
|
|
|
|
|
#define SCROLL_TIME 100
|
|
|
|
|
|
|
|
|
|
/* 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);
|
2004-02-24 00:07:15 +00:00
|
|
|
|
static void gtk_combo_box_finalize (GObject *object);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void gtk_combo_box_destroy (GtkWidget *widget);
|
|
|
|
|
|
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);
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void gtk_combo_box_grab_focus (GtkWidget *widget);
|
|
|
|
|
static void gtk_combo_box_style_updated (GtkWidget *widget);
|
|
|
|
|
static void gtk_combo_box_button_toggled (GtkWidget *widget,
|
|
|
|
|
gpointer data);
|
|
|
|
|
static void gtk_combo_box_button_state_flags_changed (GtkWidget *widget,
|
|
|
|
|
GtkStateFlags previous,
|
|
|
|
|
gpointer data);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
static void gtk_combo_box_add (GtkContainer *container,
|
|
|
|
|
GtkWidget *widget);
|
2004-03-13 00:36:27 +00:00
|
|
|
|
static void gtk_combo_box_remove (GtkContainer *container,
|
|
|
|
|
GtkWidget *widget);
|
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);
|
|
|
|
|
|
|
|
|
|
static void gtk_combo_box_set_popup_widget (GtkComboBox *combo_box,
|
|
|
|
|
GtkWidget *popup);
|
|
|
|
|
|
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);
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void gtk_combo_box_forall (GtkContainer *container,
|
|
|
|
|
gboolean include_internals,
|
|
|
|
|
GtkCallback callback,
|
|
|
|
|
gpointer callback_data);
|
|
|
|
|
static gboolean gtk_combo_box_scroll_event (GtkWidget *widget,
|
|
|
|
|
GdkEventScroll *event);
|
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
|
|
|
|
|
2004-07-16 20:27:40 +00:00
|
|
|
|
static void gtk_combo_box_check_appearance (GtkComboBox *combo_box);
|
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
|
|
|
|
|
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,
|
|
|
|
|
gint *new_order,
|
|
|
|
|
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);
|
2004-08-02 19:15:05 +00:00
|
|
|
|
static void gtk_combo_box_model_row_expanded (GtkTreeModel *model,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data);
|
2004-03-02 18:56:10 +00:00
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
|
/* list */
|
2011-01-04 15:14:25 +00:00
|
|
|
|
static void gtk_combo_box_list_position (GtkComboBox *combo_box,
|
|
|
|
|
gint *x,
|
|
|
|
|
gint *y,
|
|
|
|
|
gint *width,
|
|
|
|
|
gint *height);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
static void gtk_combo_box_list_setup (GtkComboBox *combo_box);
|
|
|
|
|
static void gtk_combo_box_list_destroy (GtkComboBox *combo_box);
|
|
|
|
|
|
|
|
|
|
static gboolean gtk_combo_box_list_button_released (GtkWidget *widget,
|
|
|
|
|
GdkEventButton *event,
|
|
|
|
|
gpointer data);
|
|
|
|
|
static gboolean gtk_combo_box_list_key_press (GtkWidget *widget,
|
|
|
|
|
GdkEventKey *event,
|
|
|
|
|
gpointer data);
|
2004-07-26 04:50:07 +00:00
|
|
|
|
static gboolean gtk_combo_box_list_enter_notify (GtkWidget *widget,
|
|
|
|
|
GdkEventCrossing *event,
|
|
|
|
|
gpointer data);
|
|
|
|
|
static void gtk_combo_box_list_auto_scroll (GtkComboBox *combo,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gint x,
|
|
|
|
|
gint y);
|
2004-07-26 04:50:07 +00:00
|
|
|
|
static gboolean gtk_combo_box_list_scroll_timeout (GtkComboBox *combo);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
static gboolean gtk_combo_box_list_button_pressed (GtkWidget *widget,
|
|
|
|
|
GdkEventButton *event,
|
|
|
|
|
gpointer data);
|
|
|
|
|
|
2006-06-02 18:55:59 +00:00
|
|
|
|
static gboolean gtk_combo_box_list_select_func (GtkTreeSelection *selection,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreeModel *model,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
gboolean path_currently_selected,
|
|
|
|
|
gpointer data);
|
2006-06-02 18:55:59 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void gtk_combo_box_list_row_changed (GtkTreeModel *model,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data);
|
2004-08-02 19:15:05 +00:00
|
|
|
|
static void gtk_combo_box_list_popup_resize (GtkComboBox *combo_box);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
|
|
/* menu */
|
2015-07-18 03:10:39 +00:00
|
|
|
|
static void gtk_combo_box_menu_setup (GtkComboBox *combo_box);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
static void gtk_combo_box_update_title (GtkComboBox *combo_box);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void gtk_combo_box_menu_destroy (GtkComboBox *combo_box);
|
|
|
|
|
|
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
|
static gboolean gtk_combo_box_menu_button_press (GtkWidget *widget,
|
|
|
|
|
GdkEventButton *event,
|
|
|
|
|
gpointer user_data);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
static void gtk_combo_box_menu_activate (GtkWidget *menu,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
const gchar *path,
|
|
|
|
|
GtkComboBox *combo_box);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void gtk_combo_box_update_sensitivity (GtkComboBox *combo_box);
|
2004-03-04 23:35:31 +00:00
|
|
|
|
static gboolean gtk_combo_box_menu_key_press (GtkWidget *widget,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GdkEventKey *event,
|
|
|
|
|
gpointer data);
|
2004-08-02 19:15:05 +00:00
|
|
|
|
static void gtk_combo_box_menu_popup (GtkComboBox *combo_box,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
guint button,
|
|
|
|
|
guint32 activate_time);
|
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);
|
2011-10-06 09:14:38 +00:00
|
|
|
|
static gchar *gtk_combo_box_format_entry_text (GtkComboBox *combo_box,
|
|
|
|
|
const gchar *path);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
/* GtkBuildable method implementation */
|
|
|
|
|
static GtkBuildableIface *parent_buildable_iface;
|
|
|
|
|
|
Add GtkBuilder, fixes #172535
2007-06-15 Johan Dahlin <jdahlin@async.com.br>
* demos/gtk-demo/Makefile.am:
* demos/gtk-demo/builder.c: (quit_activate), (about_activate),
(do_builder):
* demos/gtk-demo/demo.ui:
* docs/reference/gtk/gtk-docs.sgml:
* docs/reference/gtk/gtk-sections.txt:
* docs/reference/gtk/gtk.types:
* docs/reference/gtk/tmpl/gtkbuildable.sgml:
* docs/reference/gtk/tmpl/gtkbuilder.sgml:
* gtk/Makefile.am:
* gtk/gtk.h:
* gtk/gtk.symbols:
* gtk/gtkaction.c: (gtk_action_buildable_init),
(gtk_action_buildable_set_name), (gtk_action_buildable_get_name):
* gtk/gtkactiongroup.c: (gtk_action_group_get_type),
(gtk_action_group_buildable_init),
(gtk_action_group_buildable_add),
(gtk_action_group_buildable_set_name),
(gtk_action_group_buildable_get_name):
* gtk/gtkbuildable.c: (gtk_buildable_get_type),
(gtk_buildable_set_name), (gtk_buildable_get_name),
(gtk_buildable_add), (gtk_buildable_set_property),
(gtk_buildable_parser_finished), (gtk_buildable_construct_child),
(gtk_buildable_custom_tag_start), (gtk_buildable_custom_tag_end),
(gtk_buildable_custom_finished),
(gtk_buildable_get_internal_child):
* gtk/gtkbuildable.h:
* gtk/gtkbuilder.c: (gtk_builder_class_init), (gtk_builder_init),
(gtk_builder_finalize), (gtk_builder_set_property),
(gtk_builder_get_property), (_gtk_builder_resolve_type_lazily),
(gtk_builder_real_get_type_from_name),
(gtk_builder_get_parameters), (gtk_builder_get_internal_child),
(_gtk_builder_construct), (_gtk_builder_add),
(apply_delayed_properties), (_gtk_builder_finish),
(gtk_builder_new), (gtk_builder_add_from_file),
(gtk_builder_add_from_string), (gtk_builder_get_object),
(object_add_to_list), (gtk_builder_get_objects),
(gtk_builder_set_translation_domain),
(gtk_builder_get_translation_domain),
(gtk_builder_connect_signals_default),
(gtk_builder_connect_signals), (gtk_builder_connect_signals_full),
(gtk_builder_value_from_string),
(gtk_builder_value_from_string_type),
(_gtk_builder_enum_from_string), (_gtk_builder_flags_from_string),
(gtk_builder_get_type_from_name), (gtk_builder_error_quark):
* gtk/gtkbuilder.h:
* gtk/gtkbuilderparser.c: (state_push), (state_peek), (state_pop),
(error_missing_attribute), (error_invalid_attribute),
(error_invalid_tag), (builder_construct), (parse_object),
(free_object_info), (_get_type_by_symbol), (parse_child),
(free_child_info), (parse_property), (free_property_info),
(parse_signal), (_free_signal_info), (parse_interface),
(create_subparser), (free_subparser), (subparser_start),
(subparser_end), (parse_custom), (start_element), (end_element),
(text), (_gtk_builder_parser_parse_buffer):
* gtk/gtkbuilderprivate.h:
* gtk/gtkcelllayout.c: (attributes_start_element),
(attributes_text_element),
(_gtk_cell_layout_buildable_custom_tag_start),
(_gtk_cell_layout_buildable_custom_tag_end),
(_gtk_cell_layout_buildable_add):
* gtk/gtkcelllayout.h:
* gtk/gtkcellview.c: (gtk_cell_view_buildable_init),
(gtk_cell_view_buildable_custom_tag_start),
(gtk_cell_view_buildable_custom_tag_end):
* gtk/gtkcolorseldialog.c:
(gtk_color_selection_dialog_buildable_interface_init),
(gtk_color_selection_dialog_buildable_get_internal_child):
* gtk/gtkcombobox.c: (gtk_combo_box_buildable_init),
(gtk_combo_box_buildable_custom_tag_start),
(gtk_combo_box_buildable_custom_tag_end):
* gtk/gtkcomboboxentry.c:
(gtk_combo_box_entry_buildable_interface_init),
(gtk_combo_box_entry_buildable_get_internal_child):
* gtk/gtkcontainer.c: (gtk_container_get_type),
(gtk_container_buildable_init), (gtk_container_buildable_add),
(gtk_container_buildable_set_child_property),
(attributes_start_element), (attributes_text_element),
(gtk_container_buildable_custom_tag_start),
(gtk_container_buildable_custom_tag_end):
* gtk/gtkdebug.h:
* gtk/gtkdialog.c: (gtk_dialog_buildable_interface_init),
(gtk_dialog_buildable_get_internal_child),
(attributes_start_element), (attributes_text_element),
(gtk_dialog_buildable_custom_tag_start),
(gtk_dialog_buildable_custom_finished):
* gtk/gtkentrycompletion.c: (gtk_entry_completion_buildable_init):
* gtk/gtkexpander.c: (gtk_expander_buildable_add),
(gtk_expander_buildable_init):
* gtk/gtkfontsel.c:
(gtk_font_selection_dialog_buildable_interface_init),
(gtk_font_selection_dialog_buildable_get_internal_child):
* gtk/gtkframe.c: (gtk_frame_buildable_init),
(gtk_frame_buildable_add):
* gtk/gtkiconview.c: (gtk_icon_view_buildable_init),
(gtk_icon_view_buildable_custom_tag_start),
(gtk_icon_view_buildable_custom_tag_end):
* gtk/gtkliststore.c: (gtk_list_store_buildable_init),
(list_store_start_element), (list_store_end_element),
(list_store_text), (gtk_list_store_buildable_custom_tag_start),
(gtk_list_store_buildable_custom_tag_end):
* gtk/gtkmain.c:
* gtk/gtknotebook.c: (gtk_notebook_buildable_init),
(gtk_notebook_buildable_add):
* gtk/gtksizegroup.c: (gtk_size_group_buildable_init),
(size_group_start_element),
(gtk_size_group_buildable_custom_tag_start),
(gtk_size_group_buildable_custom_finished):
* gtk/gtktreestore.c: (gtk_tree_store_buildable_init),
(tree_model_start_element),
(gtk_tree_store_buildable_custom_tag_start),
(gtk_tree_store_buildable_custom_finished):
* gtk/gtktreeview.c: (gtk_tree_view_buildable_init),
(gtk_tree_view_buildable_add):
* gtk/gtktreeviewcolumn.c: (gtk_tree_view_column_buildable_init):
* gtk/gtkuimanager.c: (gtk_ui_manager_buildable_init),
(gtk_ui_manager_buildable_add),
(gtk_ui_manager_buildable_construct_child),
(gtk_ui_manager_buildable_custom_tag_start),
(gtk_ui_manager_buildable_custom_tag_end):
* gtk/gtkwidget.c: (gtk_widget_get_type),
(gtk_widget_buildable_interface_init),
(gtk_widget_buildable_set_name), (gtk_widget_buildable_get_name),
(gtk_widget_buildable_set_property),
(gtk_widget_buildable_parser_finshed), (accel_group_start_element),
(gtk_widget_buildable_custom_tag_start),
(gtk_widget_buildable_custom_finshed):
* gtk/gtkwindow.c: (gtk_window_buildable_interface_init),
(gtk_window_buildable_set_property),
(gtk_window_buildable_parser_finished):
* tests/Makefile.am:
* tests/buildertest.c: (builder_new_from_string), (test_parser),
(signal_normal), (signal_after), (signal_object),
(signal_object_after), (signal_first), (signal_second),
(signal_extra), (signal_extra2), (test_connect_signals),
(test_uimanager_simple), (test_domain), (test_translation),
(test_sizegroup), (test_list_store), (test_tree_store),
(test_types), (test_spin_button), (test_notebook),
(test_construct_only_property), (test_children),
(test_child_properties), (test_treeview_column), (test_icon_view),
(test_combo_box), (test_combo_box_entry), (test_cell_view),
(test_dialog), (test_accelerators), (test_widget), (main):
Add GtkBuilder, fixes #172535
svn path=/trunk/; revision=18141
2007-06-15 17:53:46 +00:00
|
|
|
|
static void gtk_combo_box_buildable_init (GtkBuildableIface *iface);
|
2015-07-25 22:06:46 +00:00
|
|
|
|
static void gtk_combo_box_buildable_add_child (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
|
|
|
|
const gchar *type);
|
Add GtkBuilder, fixes #172535
2007-06-15 Johan Dahlin <jdahlin@async.com.br>
* demos/gtk-demo/Makefile.am:
* demos/gtk-demo/builder.c: (quit_activate), (about_activate),
(do_builder):
* demos/gtk-demo/demo.ui:
* docs/reference/gtk/gtk-docs.sgml:
* docs/reference/gtk/gtk-sections.txt:
* docs/reference/gtk/gtk.types:
* docs/reference/gtk/tmpl/gtkbuildable.sgml:
* docs/reference/gtk/tmpl/gtkbuilder.sgml:
* gtk/Makefile.am:
* gtk/gtk.h:
* gtk/gtk.symbols:
* gtk/gtkaction.c: (gtk_action_buildable_init),
(gtk_action_buildable_set_name), (gtk_action_buildable_get_name):
* gtk/gtkactiongroup.c: (gtk_action_group_get_type),
(gtk_action_group_buildable_init),
(gtk_action_group_buildable_add),
(gtk_action_group_buildable_set_name),
(gtk_action_group_buildable_get_name):
* gtk/gtkbuildable.c: (gtk_buildable_get_type),
(gtk_buildable_set_name), (gtk_buildable_get_name),
(gtk_buildable_add), (gtk_buildable_set_property),
(gtk_buildable_parser_finished), (gtk_buildable_construct_child),
(gtk_buildable_custom_tag_start), (gtk_buildable_custom_tag_end),
(gtk_buildable_custom_finished),
(gtk_buildable_get_internal_child):
* gtk/gtkbuildable.h:
* gtk/gtkbuilder.c: (gtk_builder_class_init), (gtk_builder_init),
(gtk_builder_finalize), (gtk_builder_set_property),
(gtk_builder_get_property), (_gtk_builder_resolve_type_lazily),
(gtk_builder_real_get_type_from_name),
(gtk_builder_get_parameters), (gtk_builder_get_internal_child),
(_gtk_builder_construct), (_gtk_builder_add),
(apply_delayed_properties), (_gtk_builder_finish),
(gtk_builder_new), (gtk_builder_add_from_file),
(gtk_builder_add_from_string), (gtk_builder_get_object),
(object_add_to_list), (gtk_builder_get_objects),
(gtk_builder_set_translation_domain),
(gtk_builder_get_translation_domain),
(gtk_builder_connect_signals_default),
(gtk_builder_connect_signals), (gtk_builder_connect_signals_full),
(gtk_builder_value_from_string),
(gtk_builder_value_from_string_type),
(_gtk_builder_enum_from_string), (_gtk_builder_flags_from_string),
(gtk_builder_get_type_from_name), (gtk_builder_error_quark):
* gtk/gtkbuilder.h:
* gtk/gtkbuilderparser.c: (state_push), (state_peek), (state_pop),
(error_missing_attribute), (error_invalid_attribute),
(error_invalid_tag), (builder_construct), (parse_object),
(free_object_info), (_get_type_by_symbol), (parse_child),
(free_child_info), (parse_property), (free_property_info),
(parse_signal), (_free_signal_info), (parse_interface),
(create_subparser), (free_subparser), (subparser_start),
(subparser_end), (parse_custom), (start_element), (end_element),
(text), (_gtk_builder_parser_parse_buffer):
* gtk/gtkbuilderprivate.h:
* gtk/gtkcelllayout.c: (attributes_start_element),
(attributes_text_element),
(_gtk_cell_layout_buildable_custom_tag_start),
(_gtk_cell_layout_buildable_custom_tag_end),
(_gtk_cell_layout_buildable_add):
* gtk/gtkcelllayout.h:
* gtk/gtkcellview.c: (gtk_cell_view_buildable_init),
(gtk_cell_view_buildable_custom_tag_start),
(gtk_cell_view_buildable_custom_tag_end):
* gtk/gtkcolorseldialog.c:
(gtk_color_selection_dialog_buildable_interface_init),
(gtk_color_selection_dialog_buildable_get_internal_child):
* gtk/gtkcombobox.c: (gtk_combo_box_buildable_init),
(gtk_combo_box_buildable_custom_tag_start),
(gtk_combo_box_buildable_custom_tag_end):
* gtk/gtkcomboboxentry.c:
(gtk_combo_box_entry_buildable_interface_init),
(gtk_combo_box_entry_buildable_get_internal_child):
* gtk/gtkcontainer.c: (gtk_container_get_type),
(gtk_container_buildable_init), (gtk_container_buildable_add),
(gtk_container_buildable_set_child_property),
(attributes_start_element), (attributes_text_element),
(gtk_container_buildable_custom_tag_start),
(gtk_container_buildable_custom_tag_end):
* gtk/gtkdebug.h:
* gtk/gtkdialog.c: (gtk_dialog_buildable_interface_init),
(gtk_dialog_buildable_get_internal_child),
(attributes_start_element), (attributes_text_element),
(gtk_dialog_buildable_custom_tag_start),
(gtk_dialog_buildable_custom_finished):
* gtk/gtkentrycompletion.c: (gtk_entry_completion_buildable_init):
* gtk/gtkexpander.c: (gtk_expander_buildable_add),
(gtk_expander_buildable_init):
* gtk/gtkfontsel.c:
(gtk_font_selection_dialog_buildable_interface_init),
(gtk_font_selection_dialog_buildable_get_internal_child):
* gtk/gtkframe.c: (gtk_frame_buildable_init),
(gtk_frame_buildable_add):
* gtk/gtkiconview.c: (gtk_icon_view_buildable_init),
(gtk_icon_view_buildable_custom_tag_start),
(gtk_icon_view_buildable_custom_tag_end):
* gtk/gtkliststore.c: (gtk_list_store_buildable_init),
(list_store_start_element), (list_store_end_element),
(list_store_text), (gtk_list_store_buildable_custom_tag_start),
(gtk_list_store_buildable_custom_tag_end):
* gtk/gtkmain.c:
* gtk/gtknotebook.c: (gtk_notebook_buildable_init),
(gtk_notebook_buildable_add):
* gtk/gtksizegroup.c: (gtk_size_group_buildable_init),
(size_group_start_element),
(gtk_size_group_buildable_custom_tag_start),
(gtk_size_group_buildable_custom_finished):
* gtk/gtktreestore.c: (gtk_tree_store_buildable_init),
(tree_model_start_element),
(gtk_tree_store_buildable_custom_tag_start),
(gtk_tree_store_buildable_custom_finished):
* gtk/gtktreeview.c: (gtk_tree_view_buildable_init),
(gtk_tree_view_buildable_add):
* gtk/gtktreeviewcolumn.c: (gtk_tree_view_column_buildable_init):
* gtk/gtkuimanager.c: (gtk_ui_manager_buildable_init),
(gtk_ui_manager_buildable_add),
(gtk_ui_manager_buildable_construct_child),
(gtk_ui_manager_buildable_custom_tag_start),
(gtk_ui_manager_buildable_custom_tag_end):
* gtk/gtkwidget.c: (gtk_widget_get_type),
(gtk_widget_buildable_interface_init),
(gtk_widget_buildable_set_name), (gtk_widget_buildable_get_name),
(gtk_widget_buildable_set_property),
(gtk_widget_buildable_parser_finshed), (accel_group_start_element),
(gtk_widget_buildable_custom_tag_start),
(gtk_widget_buildable_custom_finshed):
* gtk/gtkwindow.c: (gtk_window_buildable_interface_init),
(gtk_window_buildable_set_property),
(gtk_window_buildable_parser_finished):
* tests/Makefile.am:
* tests/buildertest.c: (builder_new_from_string), (test_parser),
(signal_normal), (signal_after), (signal_object),
(signal_object_after), (signal_first), (signal_second),
(signal_extra), (signal_extra2), (test_connect_signals),
(test_uimanager_simple), (test_domain), (test_translation),
(test_sizegroup), (test_list_store), (test_tree_store),
(test_types), (test_spin_button), (test_notebook),
(test_construct_only_property), (test_children),
(test_child_properties), (test_treeview_column), (test_icon_view),
(test_combo_box), (test_combo_box_entry), (test_cell_view),
(test_dialog), (test_accelerators), (test_widget), (main):
Add GtkBuilder, fixes #172535
svn path=/trunk/; revision=18141
2007-06-15 17:53:46 +00:00
|
|
|
|
static gboolean gtk_combo_box_buildable_custom_tag_start (GtkBuildable *buildable,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
|
|
|
|
const gchar *tagname,
|
|
|
|
|
GMarkupParser *parser,
|
|
|
|
|
gpointer *data);
|
Add GtkBuilder, fixes #172535
2007-06-15 Johan Dahlin <jdahlin@async.com.br>
* demos/gtk-demo/Makefile.am:
* demos/gtk-demo/builder.c: (quit_activate), (about_activate),
(do_builder):
* demos/gtk-demo/demo.ui:
* docs/reference/gtk/gtk-docs.sgml:
* docs/reference/gtk/gtk-sections.txt:
* docs/reference/gtk/gtk.types:
* docs/reference/gtk/tmpl/gtkbuildable.sgml:
* docs/reference/gtk/tmpl/gtkbuilder.sgml:
* gtk/Makefile.am:
* gtk/gtk.h:
* gtk/gtk.symbols:
* gtk/gtkaction.c: (gtk_action_buildable_init),
(gtk_action_buildable_set_name), (gtk_action_buildable_get_name):
* gtk/gtkactiongroup.c: (gtk_action_group_get_type),
(gtk_action_group_buildable_init),
(gtk_action_group_buildable_add),
(gtk_action_group_buildable_set_name),
(gtk_action_group_buildable_get_name):
* gtk/gtkbuildable.c: (gtk_buildable_get_type),
(gtk_buildable_set_name), (gtk_buildable_get_name),
(gtk_buildable_add), (gtk_buildable_set_property),
(gtk_buildable_parser_finished), (gtk_buildable_construct_child),
(gtk_buildable_custom_tag_start), (gtk_buildable_custom_tag_end),
(gtk_buildable_custom_finished),
(gtk_buildable_get_internal_child):
* gtk/gtkbuildable.h:
* gtk/gtkbuilder.c: (gtk_builder_class_init), (gtk_builder_init),
(gtk_builder_finalize), (gtk_builder_set_property),
(gtk_builder_get_property), (_gtk_builder_resolve_type_lazily),
(gtk_builder_real_get_type_from_name),
(gtk_builder_get_parameters), (gtk_builder_get_internal_child),
(_gtk_builder_construct), (_gtk_builder_add),
(apply_delayed_properties), (_gtk_builder_finish),
(gtk_builder_new), (gtk_builder_add_from_file),
(gtk_builder_add_from_string), (gtk_builder_get_object),
(object_add_to_list), (gtk_builder_get_objects),
(gtk_builder_set_translation_domain),
(gtk_builder_get_translation_domain),
(gtk_builder_connect_signals_default),
(gtk_builder_connect_signals), (gtk_builder_connect_signals_full),
(gtk_builder_value_from_string),
(gtk_builder_value_from_string_type),
(_gtk_builder_enum_from_string), (_gtk_builder_flags_from_string),
(gtk_builder_get_type_from_name), (gtk_builder_error_quark):
* gtk/gtkbuilder.h:
* gtk/gtkbuilderparser.c: (state_push), (state_peek), (state_pop),
(error_missing_attribute), (error_invalid_attribute),
(error_invalid_tag), (builder_construct), (parse_object),
(free_object_info), (_get_type_by_symbol), (parse_child),
(free_child_info), (parse_property), (free_property_info),
(parse_signal), (_free_signal_info), (parse_interface),
(create_subparser), (free_subparser), (subparser_start),
(subparser_end), (parse_custom), (start_element), (end_element),
(text), (_gtk_builder_parser_parse_buffer):
* gtk/gtkbuilderprivate.h:
* gtk/gtkcelllayout.c: (attributes_start_element),
(attributes_text_element),
(_gtk_cell_layout_buildable_custom_tag_start),
(_gtk_cell_layout_buildable_custom_tag_end),
(_gtk_cell_layout_buildable_add):
* gtk/gtkcelllayout.h:
* gtk/gtkcellview.c: (gtk_cell_view_buildable_init),
(gtk_cell_view_buildable_custom_tag_start),
(gtk_cell_view_buildable_custom_tag_end):
* gtk/gtkcolorseldialog.c:
(gtk_color_selection_dialog_buildable_interface_init),
(gtk_color_selection_dialog_buildable_get_internal_child):
* gtk/gtkcombobox.c: (gtk_combo_box_buildable_init),
(gtk_combo_box_buildable_custom_tag_start),
(gtk_combo_box_buildable_custom_tag_end):
* gtk/gtkcomboboxentry.c:
(gtk_combo_box_entry_buildable_interface_init),
(gtk_combo_box_entry_buildable_get_internal_child):
* gtk/gtkcontainer.c: (gtk_container_get_type),
(gtk_container_buildable_init), (gtk_container_buildable_add),
(gtk_container_buildable_set_child_property),
(attributes_start_element), (attributes_text_element),
(gtk_container_buildable_custom_tag_start),
(gtk_container_buildable_custom_tag_end):
* gtk/gtkdebug.h:
* gtk/gtkdialog.c: (gtk_dialog_buildable_interface_init),
(gtk_dialog_buildable_get_internal_child),
(attributes_start_element), (attributes_text_element),
(gtk_dialog_buildable_custom_tag_start),
(gtk_dialog_buildable_custom_finished):
* gtk/gtkentrycompletion.c: (gtk_entry_completion_buildable_init):
* gtk/gtkexpander.c: (gtk_expander_buildable_add),
(gtk_expander_buildable_init):
* gtk/gtkfontsel.c:
(gtk_font_selection_dialog_buildable_interface_init),
(gtk_font_selection_dialog_buildable_get_internal_child):
* gtk/gtkframe.c: (gtk_frame_buildable_init),
(gtk_frame_buildable_add):
* gtk/gtkiconview.c: (gtk_icon_view_buildable_init),
(gtk_icon_view_buildable_custom_tag_start),
(gtk_icon_view_buildable_custom_tag_end):
* gtk/gtkliststore.c: (gtk_list_store_buildable_init),
(list_store_start_element), (list_store_end_element),
(list_store_text), (gtk_list_store_buildable_custom_tag_start),
(gtk_list_store_buildable_custom_tag_end):
* gtk/gtkmain.c:
* gtk/gtknotebook.c: (gtk_notebook_buildable_init),
(gtk_notebook_buildable_add):
* gtk/gtksizegroup.c: (gtk_size_group_buildable_init),
(size_group_start_element),
(gtk_size_group_buildable_custom_tag_start),
(gtk_size_group_buildable_custom_finished):
* gtk/gtktreestore.c: (gtk_tree_store_buildable_init),
(tree_model_start_element),
(gtk_tree_store_buildable_custom_tag_start),
(gtk_tree_store_buildable_custom_finished):
* gtk/gtktreeview.c: (gtk_tree_view_buildable_init),
(gtk_tree_view_buildable_add):
* gtk/gtktreeviewcolumn.c: (gtk_tree_view_column_buildable_init):
* gtk/gtkuimanager.c: (gtk_ui_manager_buildable_init),
(gtk_ui_manager_buildable_add),
(gtk_ui_manager_buildable_construct_child),
(gtk_ui_manager_buildable_custom_tag_start),
(gtk_ui_manager_buildable_custom_tag_end):
* gtk/gtkwidget.c: (gtk_widget_get_type),
(gtk_widget_buildable_interface_init),
(gtk_widget_buildable_set_name), (gtk_widget_buildable_get_name),
(gtk_widget_buildable_set_property),
(gtk_widget_buildable_parser_finshed), (accel_group_start_element),
(gtk_widget_buildable_custom_tag_start),
(gtk_widget_buildable_custom_finshed):
* gtk/gtkwindow.c: (gtk_window_buildable_interface_init),
(gtk_window_buildable_set_property),
(gtk_window_buildable_parser_finished):
* tests/Makefile.am:
* tests/buildertest.c: (builder_new_from_string), (test_parser),
(signal_normal), (signal_after), (signal_object),
(signal_object_after), (signal_first), (signal_second),
(signal_extra), (signal_extra2), (test_connect_signals),
(test_uimanager_simple), (test_domain), (test_translation),
(test_sizegroup), (test_list_store), (test_tree_store),
(test_types), (test_spin_button), (test_notebook),
(test_construct_only_property), (test_children),
(test_child_properties), (test_treeview_column), (test_icon_view),
(test_combo_box), (test_combo_box_entry), (test_cell_view),
(test_dialog), (test_accelerators), (test_widget), (main):
Add GtkBuilder, fixes #172535
svn path=/trunk/; revision=18141
2007-06-15 17:53:46 +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,
|
|
|
|
|
const gchar *tagname,
|
|
|
|
|
gpointer *data);
|
2010-10-14 01:52:27 +00:00
|
|
|
|
static GObject *gtk_combo_box_buildable_get_internal_child (GtkBuildable *buildable,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
const gchar *childname);
|
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);
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkComboBox, gtk_combo_box, GTK_TYPE_BIN,
|
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
|
|
|
|
|
gtk_combo_box_measure (GtkCssGadget *gadget,
|
|
|
|
|
GtkOrientation orientation,
|
|
|
|
|
int size,
|
|
|
|
|
int *minimum,
|
|
|
|
|
int *natural,
|
|
|
|
|
int *minimum_baseline,
|
|
|
|
|
int *natural_baseline,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
|
2016-03-01 18:14:30 +00:00
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
|
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2015-12-22 02:43:19 +00:00
|
|
|
|
|
2016-03-01 18:14:30 +00:00
|
|
|
|
_gtk_widget_get_preferred_size_for_size (priv->box,
|
|
|
|
|
orientation,
|
|
|
|
|
size,
|
|
|
|
|
minimum, natural,
|
|
|
|
|
minimum_baseline, natural_baseline);
|
2015-12-22 02:43:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_allocate (GtkCssGadget *gadget,
|
|
|
|
|
const GtkAllocation *allocation,
|
|
|
|
|
int baseline,
|
|
|
|
|
GtkAllocation *out_clip,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
|
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
|
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
|
2016-03-01 18:14:30 +00:00
|
|
|
|
gtk_widget_size_allocate_with_baseline (priv->box, (GtkAllocation *) allocation, baseline);
|
|
|
|
|
gtk_widget_get_clip (priv->box, out_clip);
|
2015-12-22 02:43:19 +00:00
|
|
|
|
|
|
|
|
|
if (!priv->tree_view)
|
|
|
|
|
{
|
|
|
|
|
if (gtk_widget_get_visible (priv->popup_widget))
|
|
|
|
|
{
|
|
|
|
|
gint menu_width;
|
|
|
|
|
|
|
|
|
|
if (priv->wrap_width == 0)
|
|
|
|
|
{
|
|
|
|
|
gtk_widget_set_size_request (priv->popup_widget, -1, -1);
|
|
|
|
|
|
|
|
|
|
if (priv->popup_fixed_width)
|
|
|
|
|
gtk_widget_get_preferred_width (priv->popup_widget, &menu_width, NULL);
|
|
|
|
|
else
|
|
|
|
|
gtk_widget_get_preferred_width (priv->popup_widget, NULL, &menu_width);
|
|
|
|
|
|
|
|
|
|
gtk_widget_set_size_request (priv->popup_widget,
|
|
|
|
|
MAX (allocation->width, menu_width), -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* reposition the menu after giving it a new width */
|
|
|
|
|
gtk_menu_reposition (GTK_MENU (priv->popup_widget));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (gtk_widget_get_visible (priv->popup_window))
|
|
|
|
|
{
|
|
|
|
|
gint x, y, width, height;
|
|
|
|
|
gtk_combo_box_list_position (combo_box, &x, &y, &width, &height);
|
|
|
|
|
gtk_window_move (GTK_WINDOW (priv->popup_window), x, y);
|
|
|
|
|
gtk_widget_set_size_request (priv->popup_window, width, height);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gtk_combo_box_render (GtkCssGadget *gadget,
|
|
|
|
|
cairo_t *cr,
|
|
|
|
|
int x,
|
|
|
|
|
int y,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
|
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
|
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
|
|
|
|
|
gtk_container_propagate_draw (GTK_CONTAINER (widget),
|
2016-03-01 17:29:22 +00:00
|
|
|
|
priv->box, cr);
|
2015-12-22 02:43:19 +00:00
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_get_preferred_width (GtkWidget *widget,
|
|
|
|
|
gint *minimum_size,
|
|
|
|
|
gint *natural_size)
|
|
|
|
|
{
|
|
|
|
|
gint dummy;
|
|
|
|
|
|
|
|
|
|
/* https://bugzilla.gnome.org/show_bug.cgi?id=729496 */
|
|
|
|
|
if (natural_size == NULL)
|
|
|
|
|
natural_size = &dummy;
|
|
|
|
|
|
|
|
|
|
gtk_css_gadget_get_preferred_size (GTK_COMBO_BOX (widget)->priv->gadget,
|
|
|
|
|
GTK_ORIENTATION_HORIZONTAL,
|
|
|
|
|
-1,
|
|
|
|
|
minimum_size, natural_size,
|
|
|
|
|
NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_get_preferred_height (GtkWidget *widget,
|
|
|
|
|
gint *minimum_size,
|
|
|
|
|
gint *natural_size)
|
|
|
|
|
{
|
|
|
|
|
gint min_width;
|
|
|
|
|
|
|
|
|
|
/* Combo box is height-for-width only
|
|
|
|
|
* (so we always just reserve enough height for the minimum width) */
|
|
|
|
|
gtk_css_gadget_get_preferred_size (GTK_COMBO_BOX (widget)->priv->gadget,
|
|
|
|
|
GTK_ORIENTATION_HORIZONTAL,
|
|
|
|
|
-1,
|
|
|
|
|
&min_width, NULL,
|
|
|
|
|
NULL, NULL);
|
|
|
|
|
gtk_css_gadget_get_preferred_size (GTK_COMBO_BOX (widget)->priv->gadget,
|
|
|
|
|
GTK_ORIENTATION_VERTICAL,
|
|
|
|
|
min_width,
|
|
|
|
|
minimum_size, natural_size,
|
|
|
|
|
NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_get_preferred_width_for_height (GtkWidget *widget,
|
|
|
|
|
gint avail_size,
|
|
|
|
|
gint *minimum_size,
|
|
|
|
|
gint *natural_size)
|
|
|
|
|
{
|
|
|
|
|
/* Combo box is height-for-width only
|
|
|
|
|
* (so we assume we always reserved enough height for the minimum width) */
|
|
|
|
|
gtk_css_gadget_get_preferred_size (GTK_COMBO_BOX (widget)->priv->gadget,
|
|
|
|
|
GTK_ORIENTATION_HORIZONTAL,
|
|
|
|
|
avail_size,
|
|
|
|
|
minimum_size, natural_size,
|
|
|
|
|
NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_get_preferred_height_for_width (GtkWidget *widget,
|
|
|
|
|
gint avail_size,
|
|
|
|
|
gint *minimum_size,
|
|
|
|
|
gint *natural_size)
|
|
|
|
|
{
|
|
|
|
|
gtk_css_gadget_get_preferred_size (GTK_COMBO_BOX (widget)->priv->gadget,
|
|
|
|
|
GTK_ORIENTATION_VERTICAL,
|
|
|
|
|
avail_size,
|
|
|
|
|
minimum_size, natural_size,
|
|
|
|
|
NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_size_allocate (GtkWidget *widget,
|
|
|
|
|
GtkAllocation *allocation)
|
|
|
|
|
{
|
|
|
|
|
GtkAllocation clip;
|
|
|
|
|
|
|
|
|
|
gtk_widget_set_allocation (widget, allocation);
|
|
|
|
|
|
|
|
|
|
gtk_css_gadget_allocate (GTK_COMBO_BOX (widget)->priv->gadget,
|
|
|
|
|
allocation,
|
|
|
|
|
gtk_widget_get_allocated_baseline (widget),
|
|
|
|
|
&clip);
|
|
|
|
|
|
|
|
|
|
gtk_widget_set_clip (widget, &clip);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gtk_combo_box_draw (GtkWidget *widget,
|
|
|
|
|
cairo_t *cr)
|
|
|
|
|
{
|
|
|
|
|
gtk_css_gadget_draw (GTK_COMBO_BOX (widget)->priv->gadget, cr);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
GtkWidget *child;
|
|
|
|
|
|
|
|
|
|
child = gtk_bin_get_child (GTK_BIN (combo_box));
|
|
|
|
|
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;
|
|
|
|
|
GtkContainerClass *container_class;
|
|
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
|
GtkBindingSet *binding_set;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
container_class = (GtkContainerClass *)klass;
|
|
|
|
|
container_class->forall = gtk_combo_box_forall;
|
|
|
|
|
container_class->add = gtk_combo_box_add;
|
|
|
|
|
container_class->remove = gtk_combo_box_remove;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2012-02-01 00:02:36 +00:00
|
|
|
|
gtk_container_class_handle_border_width (container_class);
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
widget_class = (GtkWidgetClass *)klass;
|
|
|
|
|
widget_class->size_allocate = gtk_combo_box_size_allocate;
|
|
|
|
|
widget_class->draw = gtk_combo_box_draw;
|
|
|
|
|
widget_class->scroll_event = gtk_combo_box_scroll_event;
|
|
|
|
|
widget_class->mnemonic_activate = gtk_combo_box_mnemonic_activate;
|
|
|
|
|
widget_class->grab_focus = gtk_combo_box_grab_focus;
|
|
|
|
|
widget_class->style_updated = gtk_combo_box_style_updated;
|
|
|
|
|
widget_class->get_preferred_width = gtk_combo_box_get_preferred_width;
|
|
|
|
|
widget_class->get_preferred_height = gtk_combo_box_get_preferred_height;
|
|
|
|
|
widget_class->get_preferred_height_for_width = gtk_combo_box_get_preferred_height_for_width;
|
|
|
|
|
widget_class->get_preferred_width_for_height = gtk_combo_box_get_preferred_width_for_height;
|
|
|
|
|
widget_class->destroy = gtk_combo_box_destroy;
|
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->finalize = gtk_combo_box_finalize;
|
|
|
|
|
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
|
|
|
|
|
*
|
2006-02-10 18:53:35 +00:00
|
|
|
|
* The changed signal is emitted when the active
|
2004-11-12 22:57:09 +00:00
|
|
|
|
* item is changed. The can be due to the user selecting
|
2010-10-20 09:02:03 +00:00
|
|
|
|
* a different item from the list, or due to a
|
2004-11-12 22:57:09 +00:00
|
|
|
|
* call to gtk_combo_box_set_active_iter().
|
2010-10-20 09:02:03 +00:00
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
|
* Since: 2.4
|
|
|
|
|
*/
|
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,
|
|
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
|
G_TYPE_NONE, 0);
|
2007-08-08 19:59:42 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox::move-active:
|
|
|
|
|
* @widget: the object that received the signal
|
|
|
|
|
* @scroll_type: a #GtkScrollType
|
|
|
|
|
*
|
2011-01-04 15:14:25 +00:00
|
|
|
|
* The ::move-active signal is a
|
2014-02-07 20:37:02 +00:00
|
|
|
|
* [keybinding signal][GtkBindingSignal]
|
2007-08-08 19:59:42 +00:00
|
|
|
|
* which gets emitted to move the active selection.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.12
|
|
|
|
|
*/
|
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,
|
|
|
|
|
g_cclosure_marshal_VOID__ENUM,
|
|
|
|
|
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
|
|
|
|
|
*
|
2011-01-04 15:14:25 +00:00
|
|
|
|
* The ::popup signal is a
|
2014-02-07 20:37:02 +00:00
|
|
|
|
* [keybinding signal][GtkBindingSignal]
|
2007-08-08 19:59:42 +00:00
|
|
|
|
* which gets emitted to popup the combo box list.
|
|
|
|
|
*
|
|
|
|
|
* The default binding for this signal is Alt+Down.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.12
|
|
|
|
|
*/
|
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,
|
|
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
|
G_TYPE_NONE, 0);
|
2007-08-08 19:59:42 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox::popdown:
|
|
|
|
|
* @button: the object which received the signal
|
|
|
|
|
*
|
2011-01-04 15:14:25 +00:00
|
|
|
|
* The ::popdown signal is a
|
2014-02-07 20:37:02 +00:00
|
|
|
|
* [keybinding signal][GtkBindingSignal]
|
2007-08-08 19:59:42 +00:00
|
|
|
|
* which gets emitted to popdown the combo box list.
|
|
|
|
|
*
|
|
|
|
|
* The default bindings for this signal are Alt+Up and Escape.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.12
|
|
|
|
|
*/
|
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
|
|
|
|
|
* @path: the GtkTreePath string from the combo box's current model to format text for
|
|
|
|
|
*
|
|
|
|
|
* For combo boxes that are created with an entry (See GtkComboBox:has-entry).
|
|
|
|
|
*
|
|
|
|
|
* A signal which allows you to change how the text displayed in a combo box's
|
|
|
|
|
* entry is displayed.
|
|
|
|
|
*
|
|
|
|
|
* Connect a signal handler which returns an allocated string representing
|
|
|
|
|
* @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 GtkComboBox::entry-text-column
|
|
|
|
|
* model column.
|
|
|
|
|
*
|
|
|
|
|
* Here's an example signal handler which fetches data from the model and
|
|
|
|
|
* displays it in the entry.
|
2014-01-27 19:55:18 +00:00
|
|
|
|
* |[<!-- language="C" -->
|
2011-10-06 09:14:38 +00:00
|
|
|
|
* static gchar*
|
|
|
|
|
* format_entry_text_callback (GtkComboBox *combo,
|
|
|
|
|
* const gchar *path,
|
|
|
|
|
* gpointer user_data)
|
|
|
|
|
* {
|
|
|
|
|
* GtkTreeIter iter;
|
|
|
|
|
* GtkTreeModel model;
|
|
|
|
|
* gdouble value;
|
|
|
|
|
*
|
|
|
|
|
* model = gtk_combo_box_get_model (combo);
|
|
|
|
|
*
|
|
|
|
|
* gtk_tree_model_get_iter_from_string (model, &iter, path);
|
|
|
|
|
* gtk_tree_model_get (model, &iter,
|
|
|
|
|
* 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
|
|
|
|
* }
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: (transfer full): a newly allocated string representing @path
|
2011-10-06 09:14:38 +00:00
|
|
|
|
* for the current GtkComboBox model.
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.4
|
|
|
|
|
*/
|
|
|
|
|
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 */
|
|
|
|
|
binding_set = gtk_binding_set_by_class (widget_class);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Down, GDK_MOD1_MASK,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
"popup", 0);
|
2010-09-08 17:35:51 +00:00
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Down, GDK_MOD1_MASK,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
"popup", 0);
|
2007-05-18 11:33:13 +00:00
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Up, GDK_MOD1_MASK,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
"popdown", 0);
|
2010-09-08 17:35:51 +00:00
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Up, GDK_MOD1_MASK,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
"popdown", 0);
|
2010-09-08 17:35:51 +00:00
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
"popdown", 0);
|
2006-10-12 13:04:44 +00:00
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Up, 0,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
"move-active", 1,
|
|
|
|
|
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_UP);
|
2010-09-08 17:35:51 +00:00
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Up, 0,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
"move-active", 1,
|
|
|
|
|
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_UP);
|
2010-09-08 17:35:51 +00:00
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Page_Up, 0,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
"move-active", 1,
|
|
|
|
|
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_PAGE_UP);
|
2010-09-08 17:35:51 +00:00
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Page_Up, 0,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
"move-active", 1,
|
|
|
|
|
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_PAGE_UP);
|
2010-09-08 17:35:51 +00:00
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Home, 0,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
"move-active", 1,
|
|
|
|
|
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_START);
|
2010-09-08 17:35:51 +00:00
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Home, 0,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
"move-active", 1,
|
|
|
|
|
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_START);
|
2006-10-12 13:04:44 +00:00
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Down, 0,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
"move-active", 1,
|
|
|
|
|
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_DOWN);
|
2010-09-08 17:35:51 +00:00
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Down, 0,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
"move-active", 1,
|
|
|
|
|
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_DOWN);
|
2010-09-08 17:35:51 +00:00
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Page_Down, 0,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
"move-active", 1,
|
|
|
|
|
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_PAGE_DOWN);
|
2010-09-08 17:35:51 +00:00
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Page_Down, 0,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
"move-active", 1,
|
|
|
|
|
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_PAGE_DOWN);
|
2010-09-08 17:35:51 +00:00
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KEY_End, 0,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
"move-active", 1,
|
|
|
|
|
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_END);
|
2010-09-08 17:35:51 +00:00
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_End, 0,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
"move-active", 1,
|
|
|
|
|
GTK_TYPE_SCROLL_TYPE, 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
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox:model:
|
|
|
|
|
*
|
|
|
|
|
* The model from which the combo box takes the values shown
|
2011-01-04 15:14:25 +00:00
|
|
|
|
* in the list.
|
2004-11-12 22:57:09 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.4
|
|
|
|
|
*/
|
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
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox:wrap-width:
|
|
|
|
|
*
|
|
|
|
|
* If wrap-width is set to a positive value, the list will be
|
|
|
|
|
* displayed in multiple columns, the number of columns is
|
|
|
|
|
* determined by wrap-width.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.4
|
|
|
|
|
*/
|
2003-09-26 21:57:06 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_WRAP_WIDTH,
|
2005-03-09 06:15:13 +00:00
|
|
|
|
g_param_spec_int ("wrap-width",
|
2004-01-16 23:10:05 +00:00
|
|
|
|
P_("Wrap width"),
|
2005-09-09 16:21:15 +00:00
|
|
|
|
P_("Wrap width for laying out the items in a grid"),
|
2003-09-26 21:57:06 +00:00
|
|
|
|
0,
|
|
|
|
|
G_MAXINT,
|
|
|
|
|
0,
|
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
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox:row-span-column:
|
|
|
|
|
*
|
2011-01-04 15:14:25 +00:00
|
|
|
|
* If this is set to a non-negative value, it must be the index of a column
|
|
|
|
|
* of type %G_TYPE_INT in the model.
|
2004-11-12 22:57:09 +00:00
|
|
|
|
*
|
2011-01-04 15:14:25 +00:00
|
|
|
|
* The values of that column are used to determine how many rows a value in
|
|
|
|
|
* the list will span. Therefore, the values in the model column pointed to
|
2007-03-12 06:04:44 +00:00
|
|
|
|
* by this property must be greater than zero and not larger than wrap-width.
|
2004-11-12 22:57:09 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.4
|
|
|
|
|
*/
|
2003-09-26 21:57:06 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_ROW_SPAN_COLUMN,
|
2005-03-09 06:15:13 +00:00
|
|
|
|
g_param_spec_int ("row-span-column",
|
2004-01-16 23:10:05 +00:00
|
|
|
|
P_("Row span column"),
|
|
|
|
|
P_("TreeModel column containing the row span values"),
|
2004-07-07 15:15:35 +00:00
|
|
|
|
-1,
|
2003-09-26 21:57:06 +00:00
|
|
|
|
G_MAXINT,
|
2004-07-07 15:15:35 +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-11-12 22:57:09 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox:column-span-column:
|
|
|
|
|
*
|
2011-01-04 15:14:25 +00:00
|
|
|
|
* If this is set to a non-negative value, it must be the index of a column
|
|
|
|
|
* of type %G_TYPE_INT in the model.
|
2004-11-12 22:57:09 +00:00
|
|
|
|
*
|
2011-01-04 15:14:25 +00:00
|
|
|
|
* The values of that column are used to determine how many columns a value
|
|
|
|
|
* in the list will span.
|
2004-11-12 22:57:09 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.4
|
|
|
|
|
*/
|
2003-09-26 21:57:06 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_COLUMN_SPAN_COLUMN,
|
2005-03-09 06:15:13 +00:00
|
|
|
|
g_param_spec_int ("column-span-column",
|
2004-01-16 23:10:05 +00:00
|
|
|
|
P_("Column span column"),
|
|
|
|
|
P_("TreeModel column containing the column span values"),
|
2004-07-07 15:15:35 +00:00
|
|
|
|
-1,
|
2003-09-26 21:57:06 +00:00
|
|
|
|
G_MAXINT,
|
2004-07-07 15:15:35 +00:00
|
|
|
|
-1,
|
2014-06-07 15:47:53 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
2004-07-07 15:15:35 +00:00
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2004-11-12 22:57:09 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox:active:
|
|
|
|
|
*
|
|
|
|
|
* 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,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
* this property has the value
|
2014-02-04 23:21:13 +00:00
|
|
|
|
* `gtk_tree_path_get_indices (path)[0]`,
|
|
|
|
|
* where `path` is the #GtkTreePath of the active item.
|
2004-11-12 22:57:09 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.4
|
|
|
|
|
*/
|
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-05-10 14:07:35 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox:add-tearoffs:
|
|
|
|
|
*
|
2011-01-04 15:14:25 +00:00
|
|
|
|
* The add-tearoffs property controls whether generated menus
|
|
|
|
|
* have tearoff menu items.
|
2004-05-10 14:07:35 +00:00
|
|
|
|
*
|
|
|
|
|
* Note that this only affects menu style combo boxes.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.6
|
2013-07-18 02:52:53 +00:00
|
|
|
|
*
|
|
|
|
|
* Deprecated: 3.10
|
2004-05-10 14:07:35 +00:00
|
|
|
|
*/
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_ADD_TEAROFFS,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
g_param_spec_boolean ("add-tearoffs",
|
|
|
|
|
P_("Add tearoffs to menus"),
|
|
|
|
|
P_("Whether dropdowns should have a tearoff menu item"),
|
|
|
|
|
FALSE,
|
2014-06-07 15:47:53 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY|G_PARAM_DEPRECATED));
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2004-07-16 20:27:40 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox:has-frame:
|
|
|
|
|
*
|
2004-11-12 22:57:09 +00:00
|
|
|
|
* The has-frame property controls whether a frame
|
2004-07-16 20:27:40 +00:00
|
|
|
|
* is drawn around the entry.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.6
|
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
|
2005-11-21 16:01:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox:tearoff-title:
|
|
|
|
|
*
|
2011-01-04 15:14:25 +00:00
|
|
|
|
* A title that may be displayed by the window manager
|
2005-11-21 16:01:56 +00:00
|
|
|
|
* when the popup is torn-off.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
2013-07-18 02:52:53 +00:00
|
|
|
|
*
|
|
|
|
|
* Deprecated: 3.10
|
2005-11-21 16:01:56 +00:00
|
|
|
|
*/
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_TEAROFF_TITLE,
|
|
|
|
|
g_param_spec_string ("tearoff-title",
|
|
|
|
|
P_("Tearoff Title"),
|
|
|
|
|
P_("A title that may be displayed by the window manager when the popup is torn-off"),
|
2007-12-28 05:49:21 +00:00
|
|
|
|
NULL,
|
2014-06-07 15:47:53 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY|G_PARAM_DEPRECATED));
|
2005-11-21 16:01:56 +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.
|
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.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
|
|
|
|
*/
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_POPUP_SHOWN,
|
|
|
|
|
g_param_spec_boolean ("popup-shown",
|
|
|
|
|
P_("Popup shown"),
|
|
|
|
|
P_("Whether the combo's dropdown is shown"),
|
|
|
|
|
FALSE,
|
|
|
|
|
GTK_PARAM_READABLE));
|
2007-05-18 11:33:13 +00:00
|
|
|
|
|
2008-08-04 23:40:36 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox:button-sensitivity:
|
|
|
|
|
*
|
|
|
|
|
* Whether the dropdown button is sensitive when
|
|
|
|
|
* the model is empty.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.14
|
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox:has-entry:
|
|
|
|
|
*
|
|
|
|
|
* Whether the combo box has an entry.
|
|
|
|
|
*
|
2010-10-15 20:15:16 +00:00
|
|
|
|
* Since: 2.24
|
2010-10-14 01:52:27 +00:00
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox:entry-text-column:
|
|
|
|
|
*
|
|
|
|
|
* The column in the combo box's model to associate with strings from the entry
|
|
|
|
|
* if the combo was created with #GtkComboBox:has-entry = %TRUE.
|
|
|
|
|
*
|
2010-10-15 20:15:16 +00:00
|
|
|
|
* Since: 2.24
|
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"),
|
|
|
|
|
P_("The column in the combo box's model to associate "
|
|
|
|
|
"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
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox:id-column:
|
|
|
|
|
*
|
|
|
|
|
* The column in the combo box's model that provides string
|
|
|
|
|
* IDs for the values in the model, if != -1.
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_ID_COLUMN,
|
|
|
|
|
g_param_spec_int ("id-column",
|
|
|
|
|
P_("ID Column"),
|
|
|
|
|
P_("The column in the combo box's model that provides "
|
|
|
|
|
"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
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox:active-id:
|
|
|
|
|
*
|
|
|
|
|
* The value of the ID column of the active row.
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox:popup-fixed-width:
|
|
|
|
|
*
|
|
|
|
|
* Whether the popup's width should be a fixed width matching the
|
|
|
|
|
* allocated width of the combo box.
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
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"),
|
|
|
|
|
P_("Whether the popup's width should be a "
|
|
|
|
|
"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
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox:cell-area:
|
|
|
|
|
*
|
|
|
|
|
* The #GtkCellArea used to layout cell renderers for this combo box.
|
|
|
|
|
*
|
2011-02-24 07:05:41 +00:00
|
|
|
|
* If no area is specified when creating the combo box with gtk_combo_box_new_with_area()
|
|
|
|
|
* a horizontally oriented #GtkCellAreaBox will be used.
|
|
|
|
|
*
|
2010-12-06 12:30:00 +00:00
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_CELL_AREA,
|
|
|
|
|
g_param_spec_object ("cell-area",
|
2011-01-04 15:14:25 +00:00
|
|
|
|
P_("Cell Area"),
|
|
|
|
|
P_("The GtkCellArea used to layout cells"),
|
|
|
|
|
GTK_TYPE_CELL_AREA,
|
2014-06-07 15:47:53 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
|
gtk_widget_class_install_style_property (widget_class,
|
2004-03-02 20:42:14 +00:00
|
|
|
|
g_param_spec_boolean ("appears-as-list",
|
|
|
|
|
P_("Appears as list"),
|
2004-07-16 20:27:40 +00:00
|
|
|
|
P_("Whether dropdowns should look like lists rather than menus"),
|
2003-09-26 21:57:06 +00:00
|
|
|
|
FALSE,
|
2005-03-22 02:14:55 +00:00
|
|
|
|
GTK_PARAM_READABLE));
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2006-11-01 19:15:54 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox:arrow-size:
|
|
|
|
|
*
|
|
|
|
|
* Sets the minimum size of the arrow in the combo box. Note
|
|
|
|
|
* that the arrow size is coupled to the font size, so in case
|
|
|
|
|
* a larger font is used, the arrow will be larger than set
|
|
|
|
|
* by arrow size.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.12
|
2015-12-21 22:45:58 +00:00
|
|
|
|
*
|
|
|
|
|
* Deprecated: 3.20: use the standard min-width/min-height CSS properties on
|
|
|
|
|
* the arrow node; the value of this style property is ignored.
|
2006-11-01 19:15:54 +00:00
|
|
|
|
*/
|
|
|
|
|
gtk_widget_class_install_style_property (widget_class,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
g_param_spec_int ("arrow-size",
|
|
|
|
|
P_("Arrow Size"),
|
|
|
|
|
P_("The minimum size of the arrow in the combo box"),
|
|
|
|
|
0,
|
|
|
|
|
G_MAXINT,
|
|
|
|
|
15,
|
2015-12-21 22:45:58 +00:00
|
|
|
|
GTK_PARAM_READABLE|G_PARAM_DEPRECATED));
|
2006-11-01 19:15:54 +00:00
|
|
|
|
|
2011-02-28 21:37:52 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox:arrow-scaling:
|
|
|
|
|
*
|
|
|
|
|
* Sets the amount of space used up by the combobox arrow,
|
|
|
|
|
* proportional to the font size.
|
|
|
|
|
*
|
2015-12-21 22:45:58 +00:00
|
|
|
|
* Deprecated: 3.20: use the standard min-width/min-height CSS properties on
|
|
|
|
|
* the arrow node; the value of this style property is ignored.
|
2011-02-28 21:37:52 +00:00
|
|
|
|
*/
|
|
|
|
|
gtk_widget_class_install_style_property (widget_class,
|
|
|
|
|
g_param_spec_float ("arrow-scaling",
|
|
|
|
|
P_("Arrow Scaling"),
|
|
|
|
|
P_("The amount of space used by the arrow"),
|
|
|
|
|
0,
|
|
|
|
|
2.0,
|
|
|
|
|
1.0,
|
2015-12-21 22:45:58 +00:00
|
|
|
|
GTK_PARAM_READABLE|G_PARAM_DEPRECATED));
|
2011-02-28 21:37:52 +00:00
|
|
|
|
|
2007-03-08 02:36:46 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkComboBox:shadow-type:
|
|
|
|
|
*
|
|
|
|
|
* Which kind of shadow to draw around the combo box.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.12
|
2015-12-22 02:54:41 +00:00
|
|
|
|
*
|
|
|
|
|
* Deprecated: 3.20: use CSS styling to change the appearance of the combobox
|
|
|
|
|
* frame; the value of this style property is ignored.
|
2007-03-08 02:36:46 +00:00
|
|
|
|
*/
|
|
|
|
|
gtk_widget_class_install_style_property (widget_class,
|
|
|
|
|
g_param_spec_enum ("shadow-type",
|
|
|
|
|
P_("Shadow type"),
|
|
|
|
|
P_("Which kind of shadow to draw around the combo box"),
|
|
|
|
|
GTK_TYPE_SHADOW_TYPE,
|
|
|
|
|
GTK_SHADOW_NONE,
|
2015-12-22 02:54:41 +00:00
|
|
|
|
GTK_PARAM_READABLE|G_PARAM_DEPRECATED));
|
2007-03-08 02:36:46 +00:00
|
|
|
|
|
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);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, gtk_combo_box_button_toggled);
|
|
|
|
|
|
2011-06-29 21:31:09 +00:00
|
|
|
|
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_COMBO_BOX_ACCESSIBLE);
|
2015-11-02 18:15:05 +00:00
|
|
|
|
gtk_widget_class_set_css_name (widget_class, "combobox");
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_init (GtkComboBox *combo_box)
|
|
|
|
|
{
|
2010-06-02 03:13:35 +00:00
|
|
|
|
GtkComboBoxPrivate *priv;
|
2015-12-22 02:43:19 +00:00
|
|
|
|
GtkCssNode *widget_node;
|
2015-11-02 18:15:05 +00:00
|
|
|
|
GtkStyleContext *context;
|
2010-06-02 03:13:35 +00:00
|
|
|
|
|
2013-06-27 19:02:52 +00:00
|
|
|
|
combo_box->priv = gtk_combo_box_get_instance_private (combo_box);
|
2010-06-02 03:13:35 +00:00
|
|
|
|
priv = combo_box->priv;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
|
priv->wrap_width = 0;
|
2003-09-26 21:57:06 +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;
|
|
|
|
|
priv->col_column = -1;
|
|
|
|
|
priv->row_column = -1;
|
2004-07-16 20:27:40 +00:00
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
|
priv->popup_shown = FALSE;
|
|
|
|
|
priv->add_tearoffs = 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
|
|
|
|
|
2015-12-21 22:45:58 +00:00
|
|
|
|
g_type_ensure (GTK_TYPE_ICON);
|
2015-07-25 22:06:46 +00:00
|
|
|
|
gtk_widget_init_template (GTK_WIDGET (combo_box));
|
2015-07-25 21:19:40 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_add_events (priv->button, GDK_SCROLL_MASK);
|
2015-11-02 18:15:05 +00:00
|
|
|
|
|
|
|
|
|
context = gtk_widget_get_style_context (priv->button);
|
|
|
|
|
gtk_style_context_remove_class (context, "toggle");
|
|
|
|
|
gtk_style_context_add_class (context, "combo");
|
2015-12-22 02:43:19 +00:00
|
|
|
|
|
|
|
|
|
widget_node = gtk_widget_get_css_node (GTK_WIDGET (combo_box));
|
|
|
|
|
priv->gadget = gtk_css_custom_gadget_new_for_node (widget_node,
|
|
|
|
|
GTK_WIDGET (combo_box),
|
|
|
|
|
gtk_combo_box_measure,
|
|
|
|
|
gtk_combo_box_allocate,
|
|
|
|
|
gtk_combo_box_render,
|
|
|
|
|
NULL, NULL);
|
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);
|
2011-01-31 22:34:37 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkCellArea *area;
|
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_WRAP_WIDTH:
|
|
|
|
|
gtk_combo_box_set_wrap_width (combo_box, g_value_get_int (value));
|
|
|
|
|
break;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
case PROP_ROW_SPAN_COLUMN:
|
|
|
|
|
gtk_combo_box_set_row_span_column (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_COLUMN_SPAN_COLUMN:
|
|
|
|
|
gtk_combo_box_set_column_span_column (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_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_ADD_TEAROFFS:
|
2013-08-20 04:14:00 +00:00
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_combo_box_set_add_tearoffs (combo_box, g_value_get_boolean (value));
|
2013-08-20 04:14:00 +00:00
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
break;
|
2010-11-24 09:14:36 +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)
|
|
|
|
|
gtk_entry_set_has_frame (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (combo_box))),
|
|
|
|
|
priv->has_frame);
|
|
|
|
|
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_TEAROFF_TITLE:
|
2013-08-20 04:14:00 +00:00
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
2009-10-21 16:40:19 +00:00
|
|
|
|
gtk_combo_box_set_title (combo_box, g_value_get_string (value));
|
2013-08-20 04:14:00 +00:00
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS;
|
2009-10-21 16:40:19 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
case PROP_CELL_AREA:
|
|
|
|
|
/* Construct-only, can only be assigned once */
|
|
|
|
|
area = g_value_get_object (value);
|
|
|
|
|
if (area)
|
2011-01-31 22:34:37 +00:00
|
|
|
|
{
|
|
|
|
|
if (priv->area != NULL)
|
|
|
|
|
{
|
|
|
|
|
g_warning ("cell-area has already been set, ignoring construct property");
|
|
|
|
|
g_object_ref_sink (area);
|
|
|
|
|
g_object_unref (area);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
priv->area = g_object_ref_sink (area);
|
|
|
|
|
}
|
2010-11-24 09:14:36 +00:00
|
|
|
|
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);
|
2010-06-02 03:13:35 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
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_WRAP_WIDTH:
|
2015-12-22 02:32:14 +00:00
|
|
|
|
g_value_set_int (value, priv->wrap_width);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_ROW_SPAN_COLUMN:
|
2015-12-22 02:32:14 +00:00
|
|
|
|
g_value_set_int (value, priv->row_column);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_COLUMN_SPAN_COLUMN:
|
2015-12-22 02:32:14 +00:00
|
|
|
|
g_value_set_int (value, priv->col_column);
|
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-05-10 14:07:35 +00:00
|
|
|
|
case PROP_ADD_TEAROFFS:
|
2013-08-20 04:14:00 +00:00
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
2004-05-10 14:07:35 +00:00
|
|
|
|
g_value_set_boolean (value, gtk_combo_box_get_add_tearoffs (combo_box));
|
2013-08-20 04:14:00 +00:00
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS;
|
2004-05-10 14:07:35 +00:00
|
|
|
|
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;
|
|
|
|
|
|
2005-11-21 16:01:56 +00:00
|
|
|
|
case PROP_TEAROFF_TITLE:
|
2013-08-20 04:14:00 +00:00
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
2005-11-21 16:01:56 +00:00
|
|
|
|
g_value_set_string (value, gtk_combo_box_get_title (combo_box));
|
2013-08-20 04:14:00 +00:00
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS;
|
2005-11-21 16:01:56 +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;
|
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
case PROP_CELL_AREA:
|
2011-01-04 15:14:25 +00:00
|
|
|
|
g_value_set_object (value, priv->area);
|
|
|
|
|
break;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
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_state_flags_changed (GtkWidget *widget,
|
|
|
|
|
GtkStateFlags previous,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (data);
|
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
|
|
|
|
|
if (gtk_widget_get_realized (widget))
|
2004-12-24 03:44:17 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (!priv->tree_view && priv->cell_view)
|
|
|
|
|
gtk_widget_set_state_flags (priv->cell_view,
|
|
|
|
|
gtk_widget_get_state_flags (widget),
|
|
|
|
|
TRUE);
|
2004-12-24 03:44:17 +00:00
|
|
|
|
}
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
2004-02-27 20:41:14 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_check_appearance (GtkComboBox *combo_box)
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
gboolean appears_as_list;
|
|
|
|
|
|
|
|
|
|
/* if wrap_width > 0, then we are in grid-mode and forced to use
|
|
|
|
|
* unix style
|
2010-11-24 09:14:36 +00:00
|
|
|
|
*/
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (priv->wrap_width)
|
|
|
|
|
appears_as_list = FALSE;
|
|
|
|
|
else
|
|
|
|
|
gtk_widget_style_get (GTK_WIDGET (combo_box),
|
2011-01-04 15:14:25 +00:00
|
|
|
|
"appears-as-list", &appears_as_list,
|
|
|
|
|
NULL);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
if (appears_as_list)
|
|
|
|
|
{
|
|
|
|
|
/* Destroy all the menu mode widgets, if they exist. */
|
|
|
|
|
if (GTK_IS_MENU (priv->popup_widget))
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gtk_combo_box_menu_destroy (combo_box);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
/* Create the list mode widgets, if they don't already exist. */
|
|
|
|
|
if (!GTK_IS_TREE_VIEW (priv->tree_view))
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gtk_combo_box_list_setup (combo_box);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Destroy all the list mode widgets, if they exist. */
|
|
|
|
|
if (GTK_IS_TREE_VIEW (priv->tree_view))
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gtk_combo_box_list_destroy (combo_box);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
/* Create the menu mode widgets, if they don't already exist. */
|
|
|
|
|
if (!GTK_IS_MENU (priv->popup_widget))
|
2015-07-18 03:10:39 +00:00
|
|
|
|
gtk_combo_box_menu_setup (combo_box);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
2004-03-08 18:39:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_style_updated (GtkWidget *widget)
|
2004-03-08 18:39:44 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
|
2004-03-08 18:39:44 +00:00
|
|
|
|
|
2011-02-07 12:30:37 +00:00
|
|
|
|
GTK_WIDGET_CLASS (gtk_combo_box_parent_class)->style_updated (widget);
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_combo_box_check_appearance (combo_box);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
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);
|
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
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (!combo_box->priv->popup_in_progress)
|
|
|
|
|
gtk_combo_box_popup (combo_box);
|
2004-03-13 00:36:27 +00:00
|
|
|
|
}
|
2010-12-06 12:30:00 +00:00
|
|
|
|
else
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2016-03-01 16:39:47 +00:00
|
|
|
|
GtkWidget *child;
|
|
|
|
|
|
|
|
|
|
if (priv->has_entry)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *entry;
|
|
|
|
|
GtkStyleContext *context;
|
|
|
|
|
|
|
|
|
|
entry = gtk_entry_new ();
|
|
|
|
|
gtk_widget_show (entry);
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (combo_box), entry);
|
2015-07-28 16:57:48 +00:00
|
|
|
|
|
2016-03-01 16:39:47 +00:00
|
|
|
|
context = gtk_widget_get_style_context (GTK_WIDGET (entry));
|
|
|
|
|
gtk_style_context_add_class (context, "combo");
|
|
|
|
|
|
|
|
|
|
g_signal_connect (combo_box, "changed",
|
|
|
|
|
G_CALLBACK (gtk_combo_box_entry_active_changed), NULL);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
child = gtk_cell_view_new_with_context (priv->area, NULL);
|
|
|
|
|
priv->cell_view = child;
|
2016-03-01 17:19:44 +00:00
|
|
|
|
gtk_widget_set_hexpand (child, 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);
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (gtk_widget_get_parent (priv->arrow)),
|
|
|
|
|
priv->cell_view);
|
|
|
|
|
_gtk_bin_set_child (GTK_BIN (combo_box), priv->cell_view);
|
|
|
|
|
gtk_widget_show (priv->cell_view);
|
|
|
|
|
}
|
2015-07-28 16:57:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_add (GtkContainer *container,
|
|
|
|
|
GtkWidget *widget)
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (container);
|
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2016-03-01 18:14:30 +00:00
|
|
|
|
if (priv->box == NULL)
|
|
|
|
|
{
|
|
|
|
|
gtk_widget_set_parent (widget, GTK_WIDGET (container));
|
|
|
|
|
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
|
|
|
|
|
2015-07-28 23:12:09 +00:00
|
|
|
|
if (priv->cell_view)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
2015-07-28 23:12:09 +00:00
|
|
|
|
gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (priv->cell_view)),
|
|
|
|
|
priv->cell_view);
|
2014-06-16 21:31:56 +00:00
|
|
|
|
_gtk_bin_set_child (GTK_BIN (container), NULL);
|
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (container));
|
2015-07-29 20:25:52 +00:00
|
|
|
|
priv->cell_view = NULL;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2016-03-01 18:14:30 +00:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (priv->box), widget, TRUE, TRUE, 0);
|
2014-06-16 21:31:56 +00:00
|
|
|
|
_gtk_bin_set_child (GTK_BIN (container), 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
|
|
|
|
|
gtk_combo_box_remove (GtkContainer *container,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkWidget *widget)
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (container);
|
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
gboolean appears_as_list;
|
2006-08-14 20:12:10 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (priv->has_entry)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *child_widget;
|
2004-03-13 00:36:27 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
child_widget = gtk_bin_get_child (GTK_BIN (container));
|
|
|
|
|
if (widget && widget == child_widget)
|
2011-01-04 15:14:25 +00:00
|
|
|
|
{
|
|
|
|
|
g_signal_handlers_disconnect_by_func (widget,
|
|
|
|
|
gtk_combo_box_entry_contents_changed,
|
|
|
|
|
container);
|
|
|
|
|
}
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
2004-03-13 00:36:27 +00:00
|
|
|
|
|
2016-03-01 18:14:30 +00:00
|
|
|
|
gtk_container_remove (GTK_CONTAINER (priv->box), widget);
|
2014-06-16 21:31:56 +00:00
|
|
|
|
_gtk_bin_set_child (GTK_BIN (container), 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
|
|
|
|
|
2014-06-16 21:31:56 +00:00
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (container));
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (!priv->tree_view)
|
|
|
|
|
appears_as_list = FALSE;
|
|
|
|
|
else
|
|
|
|
|
appears_as_list = TRUE;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (appears_as_list)
|
|
|
|
|
gtk_combo_box_list_destroy (combo_box);
|
|
|
|
|
else if (GTK_IS_MENU (priv->popup_widget))
|
|
|
|
|
{
|
|
|
|
|
gtk_combo_box_menu_destroy (combo_box);
|
|
|
|
|
gtk_menu_detach (GTK_MENU (priv->popup_widget));
|
|
|
|
|
priv->popup_widget = NULL;
|
|
|
|
|
}
|
2004-03-13 00:36:27 +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 (appears_as_list)
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gtk_combo_box_list_setup (combo_box);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
else
|
2015-07-18 03:10:39 +00:00
|
|
|
|
gtk_combo_box_menu_setup (combo_box);
|
2010-11-24 09:14:36 +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
|
|
|
|
|
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);
|
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
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);
|
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
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button),
|
|
|
|
|
FALSE);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-02-08 00:42:59 +00:00
|
|
|
|
static void
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_combo_box_detacher (GtkWidget *widget,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkMenu *menu)
|
2004-02-08 00:42:59 +00:00
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2004-02-08 00:42:59 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_return_if_fail (priv->popup_widget == (GtkWidget *) menu);
|
2004-02-08 00:42:59 +00:00
|
|
|
|
|
2010-12-30 08:28:26 +00:00
|
|
|
|
g_signal_handlers_disconnect_by_func (menu->priv->toplevel,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gtk_combo_box_menu_show,
|
|
|
|
|
combo_box);
|
2010-12-30 08:28:26 +00:00
|
|
|
|
g_signal_handlers_disconnect_by_func (menu->priv->toplevel,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gtk_combo_box_menu_hide,
|
|
|
|
|
combo_box);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
priv->popup_widget = NULL;
|
2004-02-08 00:42:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
|
static void
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_combo_box_set_popup_widget (GtkComboBox *combo_box,
|
|
|
|
|
GtkWidget *popup)
|
2003-09-26 21:57:06 +00:00
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (GTK_IS_MENU (priv->popup_widget))
|
2003-09-26 21:57:06 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_menu_detach (GTK_MENU (priv->popup_widget));
|
|
|
|
|
priv->popup_widget = NULL;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
2010-12-06 12:30:00 +00:00
|
|
|
|
else if (priv->popup_widget)
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_container_remove (GTK_CONTAINER (priv->scrolled_window),
|
|
|
|
|
priv->popup_widget);
|
|
|
|
|
g_object_unref (priv->popup_widget);
|
|
|
|
|
priv->popup_widget = NULL;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
2010-11-30 23:55:14 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (GTK_IS_MENU (popup))
|
|
|
|
|
{
|
|
|
|
|
if (priv->popup_window)
|
|
|
|
|
{
|
|
|
|
|
gtk_widget_destroy (priv->popup_window);
|
|
|
|
|
priv->popup_window = NULL;
|
|
|
|
|
}
|
2009-06-08 15:05:51 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
priv->popup_widget = popup;
|
2010-08-11 21:14:32 +00:00
|
|
|
|
|
2011-01-04 15:14:25 +00:00
|
|
|
|
/*
|
2010-12-06 12:30:00 +00:00
|
|
|
|
* Note that we connect to show/hide on the toplevel, not the
|
|
|
|
|
* menu itself, since the menu is not shown/hidden when it is
|
|
|
|
|
* popped up while torn-off.
|
|
|
|
|
*/
|
2010-12-30 08:28:26 +00:00
|
|
|
|
g_signal_connect (GTK_MENU (popup)->priv->toplevel, "show",
|
2010-12-06 12:30:00 +00:00
|
|
|
|
G_CALLBACK (gtk_combo_box_menu_show), combo_box);
|
2010-12-30 08:28:26 +00:00
|
|
|
|
g_signal_connect (GTK_MENU (popup)->priv->toplevel, "hide",
|
2010-12-06 12:30:00 +00:00
|
|
|
|
G_CALLBACK (gtk_combo_box_menu_hide), combo_box);
|
2004-05-10 18:17:47 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_menu_attach_to_widget (GTK_MENU (popup),
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GTK_WIDGET (combo_box),
|
|
|
|
|
gtk_combo_box_detacher);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
2007-12-28 06:56:48 +00:00
|
|
|
|
else
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (!priv->popup_window)
|
|
|
|
|
{
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkWidget *toplevel;
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
priv->popup_window = gtk_window_new (GTK_WINDOW_POPUP);
|
|
|
|
|
gtk_widget_set_name (priv->popup_window, "gtk-combobox-popup-window");
|
2004-03-03 22:30:36 +00:00
|
|
|
|
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gtk_window_set_type_hint (GTK_WINDOW (priv->popup_window),
|
|
|
|
|
GDK_WINDOW_TYPE_HINT_COMBO);
|
|
|
|
|
|
|
|
|
|
g_signal_connect (GTK_WINDOW (priv->popup_window),"show",
|
|
|
|
|
G_CALLBACK (gtk_combo_box_child_show),
|
|
|
|
|
combo_box);
|
|
|
|
|
g_signal_connect (GTK_WINDOW (priv->popup_window),"hide",
|
|
|
|
|
G_CALLBACK (gtk_combo_box_child_hide),
|
|
|
|
|
combo_box);
|
|
|
|
|
|
|
|
|
|
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (combo_box));
|
|
|
|
|
if (GTK_IS_WINDOW (toplevel))
|
|
|
|
|
{
|
|
|
|
|
gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)),
|
|
|
|
|
GTK_WINDOW (priv->popup_window));
|
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (priv->popup_window),
|
|
|
|
|
GTK_WINDOW (toplevel));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_window_set_resizable (GTK_WINDOW (priv->popup_window), FALSE);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_window_set_screen (GTK_WINDOW (priv->popup_window),
|
|
|
|
|
gtk_widget_get_screen (GTK_WIDGET (combo_box)));
|
2004-03-03 22:30:36 +00:00
|
|
|
|
|
2011-01-04 15:14:25 +00:00
|
|
|
|
priv->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
|
|
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
|
|
|
|
|
GTK_POLICY_NEVER,
|
|
|
|
|
GTK_POLICY_NEVER);
|
|
|
|
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (priv->scrolled_window),
|
|
|
|
|
GTK_SHADOW_IN);
|
2004-03-03 22:30:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_widget_show (priv->scrolled_window);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (priv->popup_window),
|
|
|
|
|
priv->scrolled_window);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
2010-08-20 23:24:54 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_container_add (GTK_CONTAINER (priv->scrolled_window),
|
|
|
|
|
popup);
|
2004-03-03 22:30:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_widget_show (popup);
|
|
|
|
|
g_object_ref (popup);
|
|
|
|
|
priv->popup_widget = popup;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
2004-03-03 22:30:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gtk_combo_box_list_position (GtkComboBox *combo_box,
|
|
|
|
|
gint *x,
|
|
|
|
|
gint *y,
|
|
|
|
|
gint *width,
|
|
|
|
|
gint *height)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2015-12-22 02:43:19 +00:00
|
|
|
|
GtkAllocation content_allocation;
|
2016-04-11 03:01:10 +00:00
|
|
|
|
GdkDisplay *display;
|
|
|
|
|
GdkMonitor *monitor;
|
|
|
|
|
GdkRectangle area;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkRequisition popup_req;
|
|
|
|
|
GtkPolicyType hpolicy, vpolicy;
|
|
|
|
|
GdkWindow *window;
|
2004-05-27 03:31:17 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
/* under windows, the drop down list is as wide as the combo box itself.
|
|
|
|
|
see bug #340204 */
|
|
|
|
|
GtkWidget *widget = GTK_WIDGET (combo_box);
|
2004-07-07 15:15:35 +00:00
|
|
|
|
|
2015-12-22 02:43:19 +00:00
|
|
|
|
gtk_css_gadget_get_content_allocation (priv->gadget, &content_allocation, NULL);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2015-12-22 02:43:19 +00:00
|
|
|
|
*x = content_allocation.x;
|
|
|
|
|
*y = content_allocation.y;
|
|
|
|
|
*width = content_allocation.width;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2015-12-22 02:43:19 +00:00
|
|
|
|
window = gtk_widget_get_window (GTK_WIDGET (combo_box));
|
2015-12-22 01:50:42 +00:00
|
|
|
|
gdk_window_get_root_coords (window, *x, *y, x, y);
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
hpolicy = vpolicy = GTK_POLICY_NEVER;
|
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
|
2011-01-04 15:14:25 +00:00
|
|
|
|
hpolicy, vpolicy);
|
2010-10-16 09:01:33 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (priv->popup_fixed_width)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_widget_get_preferred_size (priv->scrolled_window, &popup_req, NULL);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (popup_req.width > *width)
|
2011-01-04 15:14:25 +00:00
|
|
|
|
{
|
|
|
|
|
hpolicy = GTK_POLICY_ALWAYS;
|
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
|
|
|
|
|
hpolicy, vpolicy);
|
|
|
|
|
}
|
2004-05-27 03:31:17 +00:00
|
|
|
|
}
|
2010-11-24 09:14:36 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2010-12-06 12:40:33 +00:00
|
|
|
|
/* XXX This code depends on treeviews properly reporting their natural width
|
|
|
|
|
* list-mode menus won't fill up to their natural width until then */
|
|
|
|
|
gtk_widget_get_preferred_size (priv->scrolled_window, NULL, &popup_req);
|
|
|
|
|
|
|
|
|
|
if (popup_req.width > *width)
|
2011-01-04 15:14:25 +00:00
|
|
|
|
{
|
|
|
|
|
hpolicy = GTK_POLICY_NEVER;
|
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
|
|
|
|
|
hpolicy, vpolicy);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2011-01-04 15:14:25 +00:00
|
|
|
|
*width = popup_req.width;
|
|
|
|
|
}
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
*height = popup_req.height;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2016-04-11 03:01:10 +00:00
|
|
|
|
display = gtk_widget_get_display (widget);
|
|
|
|
|
monitor = gdk_display_get_monitor_at_window (display, window);
|
|
|
|
|
gdk_monitor_get_workarea (monitor, &area);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2015-12-22 01:50:42 +00:00
|
|
|
|
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
|
2015-12-22 02:43:19 +00:00
|
|
|
|
*x = *x + content_allocation.width - *width;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2016-04-11 03:01:10 +00:00
|
|
|
|
if (*x < area.x)
|
|
|
|
|
*x = area.x;
|
|
|
|
|
else if (*x + *width > area.x + area.width)
|
|
|
|
|
*x = area.x + area.width - *width;
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2016-04-11 03:01:10 +00:00
|
|
|
|
if (*y + content_allocation.height + *height <= area.y + area.height)
|
2015-12-22 02:43:19 +00:00
|
|
|
|
*y += content_allocation.height;
|
2016-04-11 03:01:10 +00:00
|
|
|
|
else if (*y - *height >= area.y)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
*y -= *height;
|
2016-04-11 03:01:10 +00:00
|
|
|
|
else if (area.y + area.height - (*y + content_allocation.height) > *y - area.y)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
2015-12-22 02:43:19 +00:00
|
|
|
|
*y += content_allocation.height;
|
2016-04-11 03:01:10 +00:00
|
|
|
|
*height = area.y + area.height - *y;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
2011-01-04 15:14:25 +00:00
|
|
|
|
else
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
2016-04-11 03:01:10 +00:00
|
|
|
|
*height = *y - area.y;
|
|
|
|
|
*y = area.y;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
2005-06-26 06:26:47 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (popup_req.height > *height)
|
|
|
|
|
{
|
|
|
|
|
vpolicy = GTK_POLICY_ALWAYS;
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
|
2011-01-04 15:14:25 +00:00
|
|
|
|
hpolicy, vpolicy);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
2011-01-04 15:14:25 +00:00
|
|
|
|
}
|
2010-11-24 09:14:36 +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
|
|
|
|
|
2011-01-21 04:38:50 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
cell_is_sensitive (GtkCellRenderer *cell,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
gboolean *sensitive = data;
|
|
|
|
|
|
|
|
|
|
g_object_get (cell, "sensitive", sensitive, NULL);
|
|
|
|
|
|
|
|
|
|
return *sensitive;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
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
|
|
|
|
|
2011-01-21 04:38:50 +00:00
|
|
|
|
if (priv->area)
|
|
|
|
|
{
|
|
|
|
|
gboolean sensitive;
|
2008-09-03 12:38:32 +00:00
|
|
|
|
|
2011-01-21 04:38:50 +00:00
|
|
|
|
gtk_cell_area_apply_attributes (priv->area, priv->model, iter, FALSE, FALSE);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2011-01-21 04:38:50 +00:00
|
|
|
|
sensitive = FALSE;
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2011-01-21 04:38:50 +00:00
|
|
|
|
gtk_cell_area_foreach (priv->area, cell_is_sensitive, &sensitive);
|
|
|
|
|
|
|
|
|
|
return sensitive;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
2007-03-08 02:36:46 +00:00
|
|
|
|
|
2011-01-21 04:38:50 +00:00
|
|
|
|
return TRUE;
|
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
|
2010-12-06 12:30:00 +00:00
|
|
|
|
update_menu_sensitivity (GtkComboBox *combo_box,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkWidget *menu)
|
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
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GList *children, *child;
|
2015-12-06 10:30:58 +00:00
|
|
|
|
GtkWidget *item, *submenu;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkWidget *cell_view;
|
|
|
|
|
gboolean sensitive;
|
2007-12-28 06:56:48 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (!priv->model)
|
|
|
|
|
return;
|
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
|
|
|
|
children = gtk_container_get_children (GTK_CONTAINER (menu));
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
for (child = children; child; child = child->next)
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
item = GTK_WIDGET (child->data);
|
|
|
|
|
cell_view = gtk_bin_get_child (GTK_BIN (item));
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (!GTK_IS_CELL_VIEW (cell_view))
|
2011-01-04 15:14:25 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (item));
|
|
|
|
|
if (submenu != NULL)
|
2011-01-04 15:14:25 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_widget_set_sensitive (item, TRUE);
|
|
|
|
|
update_menu_sensitivity (combo_box, submenu);
|
|
|
|
|
}
|
2010-12-06 12:30:00 +00:00
|
|
|
|
else
|
2011-01-04 15:14:25 +00:00
|
|
|
|
{
|
2011-01-21 04:38:50 +00:00
|
|
|
|
sensitive = cell_layout_is_sensitive (GTK_CELL_LAYOUT (cell_view));
|
2015-12-06 10:30:58 +00:00
|
|
|
|
gtk_widget_set_sensitive (item, sensitive);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
}
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_list_free (children);
|
|
|
|
|
}
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2011-01-04 15:14:25 +00:00
|
|
|
|
static void
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_combo_box_menu_popup (GtkComboBox *combo_box,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
guint button,
|
|
|
|
|
guint32 activate_time)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
gint active_item;
|
|
|
|
|
gint width, min_width, nat_width;
|
2016-07-12 18:08:36 +00:00
|
|
|
|
GtkAllocation border_allocation;
|
|
|
|
|
GtkAllocation content_allocation;
|
|
|
|
|
gint rect_anchor_dy = -2;
|
|
|
|
|
gint child_height;
|
|
|
|
|
GtkWidget *active;
|
|
|
|
|
GtkWidget *child;
|
|
|
|
|
GList *i;
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
update_menu_sensitivity (combo_box, priv->popup_widget);
|
|
|
|
|
|
|
|
|
|
active_item = -1;
|
|
|
|
|
if (gtk_tree_row_reference_valid (priv->active_row))
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
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);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (priv->add_tearoffs)
|
2011-01-04 15:14:25 +00:00
|
|
|
|
active_item++;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
/* FIXME handle nested menus better */
|
|
|
|
|
gtk_menu_set_active (GTK_MENU (priv->popup_widget), active_item);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (priv->wrap_width == 0)
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
2015-12-22 02:43:19 +00:00
|
|
|
|
gtk_css_gadget_get_content_allocation (priv->gadget, &content_allocation, NULL);
|
|
|
|
|
width = content_allocation.width;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_widget_set_size_request (priv->popup_widget, -1, -1);
|
|
|
|
|
gtk_widget_get_preferred_width (priv->popup_widget, &min_width, &nat_width);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (priv->popup_fixed_width)
|
2011-01-04 15:14:25 +00:00
|
|
|
|
width = MAX (width, min_width);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
else
|
2011-01-04 15:14:25 +00:00
|
|
|
|
width = MAX (width, nat_width);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_widget_set_size_request (priv->popup_widget, width, -1);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
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);
|
|
|
|
|
|
|
|
|
|
g_object_set (priv->popup_widget, "menu-type-hint", GDK_WINDOW_TYPE_HINT_COMBO, NULL);
|
|
|
|
|
|
|
|
|
|
if (priv->wrap_width > 0 || priv->cell_view == NULL)
|
|
|
|
|
{
|
|
|
|
|
gtk_css_gadget_get_border_allocation (priv->gadget, &border_allocation, NULL);
|
|
|
|
|
gtk_css_gadget_get_content_allocation (priv->gadget, &content_allocation, NULL);
|
|
|
|
|
|
|
|
|
|
g_object_set (priv->popup_widget,
|
|
|
|
|
"anchor-hints", (GDK_ANCHOR_FLIP_Y |
|
|
|
|
|
GDK_ANCHOR_SLIDE |
|
|
|
|
|
GDK_ANCHOR_RESIZE),
|
|
|
|
|
"rect-anchor-dx", border_allocation.x - content_allocation.x,
|
|
|
|
|
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,
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* FIXME handle nested menus better */
|
|
|
|
|
active = gtk_menu_get_active (GTK_MENU (priv->popup_widget));
|
|
|
|
|
|
|
|
|
|
if (active)
|
|
|
|
|
gtk_menu_shell_select_item (GTK_MENU_SHELL (priv->popup_widget), active);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (i = GTK_MENU_SHELL (priv->popup_widget)->priv->children; i && !active; i = i->next)
|
|
|
|
|
{
|
|
|
|
|
child = i->data;
|
|
|
|
|
|
|
|
|
|
if (child && gtk_widget_get_visible (child))
|
|
|
|
|
active = child;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (active)
|
|
|
|
|
{
|
|
|
|
|
for (i = GTK_MENU_SHELL (priv->popup_widget)->priv->children; i && i->data != active; i = i->next)
|
|
|
|
|
{
|
|
|
|
|
child = i->data;
|
|
|
|
|
|
|
|
|
|
if (child && gtk_widget_get_visible (child))
|
|
|
|
|
{
|
|
|
|
|
gtk_widget_get_preferred_height (child, &child_height, NULL);
|
|
|
|
|
rect_anchor_dy -= child_height;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_widget_get_preferred_height (active, &child_height, NULL);
|
|
|
|
|
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,
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
popup_grab_on_window (GdkWindow *window,
|
2015-11-26 18:55:15 +00:00
|
|
|
|
GdkDevice *pointer)
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
2015-11-26 18:55:15 +00:00
|
|
|
|
GdkGrabStatus status;
|
|
|
|
|
GdkSeat *seat;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
2015-11-26 18:55:15 +00:00
|
|
|
|
seat = gdk_device_get_seat (pointer);
|
|
|
|
|
status = gdk_seat_grab (seat, window,
|
|
|
|
|
GDK_SEAT_CAPABILITY_ALL, TRUE,
|
|
|
|
|
NULL, NULL, NULL, NULL);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2015-11-26 18:55:15 +00:00
|
|
|
|
return status == GDK_GRAB_SUCCESS;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-03-06 12:16:12 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_combo_box_grab_broken_event (GtkWidget *widget,
|
|
|
|
|
GdkEventGrabBroken *event,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
|
|
|
|
|
|
|
|
|
|
if (event->grab_window == NULL)
|
|
|
|
|
gtk_combo_box_popdown (combo_box);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_popup:
|
|
|
|
|
* @combo_box: a #GtkComboBox
|
2011-01-04 15:14:25 +00:00
|
|
|
|
*
|
|
|
|
|
* Pops up the menu or dropdown list of @combo_box.
|
2010-12-06 12:30:00 +00:00
|
|
|
|
*
|
|
|
|
|
* This function is mostly intended for use by accessibility technologies;
|
|
|
|
|
* applications should have little use for it.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.4
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_combo_box_popup (GtkComboBox *combo_box)
|
2005-11-10 21:17:19 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
2006-03-09 20:20:30 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_signal_emit (combo_box, combo_box_signals[POPUP], 0);
|
|
|
|
|
}
|
2005-11-10 21:17:19 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_popup_for_device:
|
|
|
|
|
* @combo_box: a #GtkComboBox
|
|
|
|
|
* @device: a #GdkDevice
|
|
|
|
|
*
|
|
|
|
|
* Pops up the menu or dropdown list of @combo_box, the popup window
|
|
|
|
|
* will be grabbed so only @device and its associated pointer/keyboard
|
2014-02-09 22:24:06 +00:00
|
|
|
|
* are the only #GdkDevices able to send events to it.
|
2010-12-06 12:30:00 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
gtk_combo_box_popup_for_device (GtkComboBox *combo_box,
|
|
|
|
|
GdkDevice *device)
|
|
|
|
|
{
|
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
gint x, y, width, height;
|
|
|
|
|
GtkTreePath *path = NULL, *ppath;
|
|
|
|
|
GtkWidget *toplevel;
|
2015-11-26 18:55:15 +00:00
|
|
|
|
GdkDevice *pointer;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
|
|
|
|
g_return_if_fail (GDK_IS_DEVICE (device));
|
2010-11-24 00:31:53 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (!gtk_widget_get_realized (GTK_WIDGET (combo_box)))
|
|
|
|
|
return;
|
2010-11-24 00:31:53 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (gtk_widget_get_mapped (priv->popup_widget))
|
|
|
|
|
return;
|
2007-03-08 02:36:46 +00:00
|
|
|
|
|
2015-11-26 18:55:15 +00:00
|
|
|
|
if (priv->grab_pointer)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
return;
|
2007-02-16 16:00:19 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
|
2015-11-26 18:55:15 +00:00
|
|
|
|
pointer = gdk_device_get_associated_device (device);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
else
|
2015-11-26 18:55:15 +00:00
|
|
|
|
pointer = device;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (GTK_IS_MENU (priv->popup_widget))
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gtk_combo_box_menu_popup (combo_box,
|
2010-12-06 12:30:00 +00:00
|
|
|
|
priv->activate_button,
|
|
|
|
|
priv->activate_time);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (combo_box));
|
|
|
|
|
if (GTK_IS_WINDOW (toplevel))
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)),
|
|
|
|
|
GTK_WINDOW (priv->popup_window));
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_widget_show_all (priv->scrolled_window);
|
|
|
|
|
gtk_combo_box_list_position (combo_box, &x, &y, &width, &height);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_set_size_request (priv->popup_window, width, height);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_window_move (GTK_WINDOW (priv->popup_window), x, y);
|
2004-08-02 19:15:05 +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);
|
|
|
|
|
ppath = gtk_tree_path_copy (path);
|
|
|
|
|
if (gtk_tree_path_up (ppath))
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gtk_tree_view_expand_to_path (GTK_TREE_VIEW (priv->tree_view),
|
|
|
|
|
ppath);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_tree_path_free (ppath);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gtk_tree_view_set_hover_expand (GTK_TREE_VIEW (priv->tree_view),
|
|
|
|
|
TRUE);
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
/* popup */
|
|
|
|
|
gtk_widget_show (priv->popup_window);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (path)
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->tree_view),
|
2011-01-04 15:14:25 +00:00
|
|
|
|
path, NULL, FALSE);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_tree_path_free (path);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_grab_focus (priv->popup_window);
|
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button),
|
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
|
|
if (!gtk_widget_has_focus (priv->tree_view))
|
|
|
|
|
gtk_widget_grab_focus (priv->tree_view);
|
|
|
|
|
|
2015-11-26 18:55:15 +00:00
|
|
|
|
if (!popup_grab_on_window (gtk_widget_get_window (priv->popup_window), pointer))
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_widget_hide (priv->popup_window);
|
|
|
|
|
return;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
priv->grab_pointer = pointer;
|
2013-03-06 12:16:12 +00:00
|
|
|
|
|
|
|
|
|
g_signal_connect (priv->popup_window,
|
|
|
|
|
"grab-broken-event",
|
|
|
|
|
G_CALLBACK (gtk_combo_box_grab_broken_event),
|
|
|
|
|
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
|
|
|
|
{
|
2010-11-24 09:14:36 +00:00
|
|
|
|
GdkDevice *device;
|
2004-08-02 19:15:05 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
device = gtk_get_current_event_device ();
|
|
|
|
|
|
|
|
|
|
if (!device)
|
2004-08-02 19:15:05 +00:00
|
|
|
|
{
|
2010-11-24 09:14:36 +00:00
|
|
|
|
GdkDisplay *display;
|
2004-08-02 19:15:05 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
/* No device was set, pick the first master device */
|
2015-12-16 18:23:25 +00:00
|
|
|
|
display = gtk_widget_get_display (GTK_WIDGET (combo_box));
|
|
|
|
|
device = gdk_seat_get_pointer (gdk_display_get_default_seat (display));
|
2004-08-02 19:15:05 +00:00
|
|
|
|
}
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
|
|
|
|
gtk_combo_box_popup_for_device (combo_box, device);
|
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
|
|
|
|
{
|
2010-11-24 09:14:36 +00:00
|
|
|
|
if (combo_box->priv->popup_shown)
|
|
|
|
|
{
|
|
|
|
|
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:
|
|
|
|
|
* @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.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.4
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_combo_box_popdown (GtkComboBox *combo_box)
|
2004-08-02 19:15:05 +00:00
|
|
|
|
{
|
2010-11-24 09:14:36 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
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
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (GTK_IS_MENU (priv->popup_widget))
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_menu_popdown (GTK_MENU (priv->popup_widget));
|
|
|
|
|
return;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
2004-08-02 19:15:05 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (!gtk_widget_get_realized (GTK_WIDGET (combo_box)))
|
|
|
|
|
return;
|
2004-08-02 19:15:05 +00:00
|
|
|
|
|
2014-06-05 19:09:46 +00:00
|
|
|
|
if (!gtk_widget_is_drawable (priv->popup_window))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (priv->grab_pointer)
|
2015-11-26 18:55:15 +00:00
|
|
|
|
gdk_seat_ungrab (gdk_device_get_seat (priv->grab_pointer));
|
2013-03-06 12:16:12 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_widget_hide (priv->popup_window);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button),
|
2010-12-06 12:30:00 +00:00
|
|
|
|
FALSE);
|
2004-08-02 19:15:05 +00:00
|
|
|
|
|
2015-07-19 16:31:33 +00:00
|
|
|
|
if (priv->scroll_timer)
|
|
|
|
|
{
|
|
|
|
|
g_source_remove (priv->scroll_timer);
|
|
|
|
|
priv->scroll_timer = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
priv->grab_pointer = NULL;
|
|
|
|
|
}
|
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)
|
|
|
|
|
{
|
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
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
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_signal_handler_disconnect (priv->model,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
priv->inserted_id);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_signal_handler_disconnect (priv->model,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
priv->deleted_id);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_signal_handler_disconnect (priv->model,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
priv->reordered_id);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_signal_handler_disconnect (priv->model,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
priv->changed_id);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (priv->model)
|
2010-11-24 09:14:36 +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
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_forall (GtkContainer *container,
|
|
|
|
|
gboolean include_internals,
|
|
|
|
|
GtkCallback callback,
|
|
|
|
|
gpointer callback_data)
|
|
|
|
|
{
|
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (container);
|
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
GtkWidget *child;
|
2004-08-03 05:22:21 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (include_internals)
|
|
|
|
|
{
|
2016-03-01 17:29:22 +00:00
|
|
|
|
if (priv->box)
|
|
|
|
|
(* callback) (priv->box, callback_data);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
child = gtk_bin_get_child (GTK_BIN (container));
|
2015-07-28 23:12:09 +00:00
|
|
|
|
if (child && child != priv->cell_view)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
(* callback) (child, callback_data);
|
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
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
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)
|
|
|
|
|
{
|
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
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
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_combo_box_scroll_event (GtkWidget *widget,
|
|
|
|
|
GdkEventScroll *event)
|
2004-08-02 19:15:05 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
|
2015-12-22 02:32:14 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gboolean found;
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
GtkTreeIter new_iter;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (!gtk_combo_box_get_active_iter (combo_box, &iter))
|
|
|
|
|
return TRUE;
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (event->direction == GDK_SCROLL_UP)
|
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);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
else
|
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);
|
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);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2004-08-02 19:15:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
/*
|
|
|
|
|
* menu style
|
|
|
|
|
*/
|
2011-01-04 15:14:25 +00:00
|
|
|
|
static gboolean
|
2010-11-24 09:14:36 +00:00
|
|
|
|
gtk_combo_box_row_separator_func (GtkTreeModel *model,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
GtkComboBox *combo)
|
2004-08-02 19:15:05 +00:00
|
|
|
|
{
|
2010-11-24 09:14:36 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo->priv;
|
2004-08-02 19:15:05 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
if (priv->row_separator_func)
|
|
|
|
|
return priv->row_separator_func (model, iter, priv->row_separator_data);
|
2004-08-07 22:21:25 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2004-08-02 19:15:05 +00:00
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
|
static void
|
2015-07-18 03:10:39 +00:00
|
|
|
|
gtk_combo_box_menu_setup (GtkComboBox *combo_box)
|
2003-09-26 21:57:06 +00:00
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
GtkWidget *menu;
|
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-11-24 09:14:36 +00:00
|
|
|
|
g_signal_connect (priv->button, "button-press-event",
|
|
|
|
|
G_CALLBACK (gtk_combo_box_menu_button_press),
|
|
|
|
|
combo_box);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_signal_connect (priv->button, "state-flags-changed",
|
2011-01-04 15:14:25 +00:00
|
|
|
|
G_CALLBACK (gtk_combo_box_button_state_flags_changed),
|
|
|
|
|
combo_box);
|
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-11-24 09:14:36 +00:00
|
|
|
|
/* create our funky menu */
|
2010-12-15 08:17:45 +00:00
|
|
|
|
menu = _gtk_tree_menu_new_with_area (priv->area);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_widget_set_name (menu, "gtk-combobox-popup-menu");
|
|
|
|
|
|
2010-12-15 08:17:45 +00:00
|
|
|
|
_gtk_tree_menu_set_model (GTK_TREE_MENU (menu), priv->model);
|
2006-12-27 06:12:53 +00:00
|
|
|
|
|
2010-12-15 08:17:45 +00:00
|
|
|
|
_gtk_tree_menu_set_wrap_width (GTK_TREE_MENU (menu), priv->wrap_width);
|
|
|
|
|
_gtk_tree_menu_set_row_span_column (GTK_TREE_MENU (menu), priv->row_column);
|
|
|
|
|
_gtk_tree_menu_set_column_span_column (GTK_TREE_MENU (menu), priv->col_column);
|
2015-12-22 02:32:14 +00:00
|
|
|
|
_gtk_tree_menu_set_tearoff (GTK_TREE_MENU (menu), priv->add_tearoffs);
|
2006-12-27 06:12:53 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
g_signal_connect (menu, "menu-activate",
|
2011-01-04 15:14:25 +00:00
|
|
|
|
G_CALLBACK (gtk_combo_box_menu_activate), combo_box);
|
2006-12-27 06:12:53 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
/* Chain our row_separator_func through */
|
2010-12-15 08:17:45 +00:00
|
|
|
|
_gtk_tree_menu_set_row_separator_func (GTK_TREE_MENU (menu),
|
2011-01-04 15:14:25 +00:00
|
|
|
|
(GtkTreeViewRowSeparatorFunc)gtk_combo_box_row_separator_func,
|
|
|
|
|
combo_box, NULL);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
g_signal_connect (menu, "key-press-event",
|
2011-01-04 15:14:25 +00:00
|
|
|
|
G_CALLBACK (gtk_combo_box_menu_key_press), combo_box);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
gtk_combo_box_set_popup_widget (combo_box, menu);
|
2004-03-02 18:56:10 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
gtk_combo_box_update_title (combo_box);
|
2004-03-02 18:56:10 +00:00
|
|
|
|
}
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
|
static void
|
2010-11-24 09:14:36 +00:00
|
|
|
|
gtk_combo_box_menu_destroy (GtkComboBox *combo_box)
|
2003-09-26 21:57:06 +00:00
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
g_signal_handlers_disconnect_matched (priv->button,
|
|
|
|
|
G_SIGNAL_MATCH_DATA,
|
|
|
|
|
0, 0, NULL,
|
|
|
|
|
gtk_combo_box_menu_button_press, NULL);
|
|
|
|
|
g_signal_handlers_disconnect_matched (priv->button,
|
|
|
|
|
G_SIGNAL_MATCH_DATA,
|
|
|
|
|
0, 0, NULL,
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_combo_box_button_state_flags_changed, combo_box);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
g_signal_handlers_disconnect_matched (priv->popup_widget,
|
|
|
|
|
G_SIGNAL_MATCH_DATA,
|
|
|
|
|
0, 0, NULL,
|
|
|
|
|
gtk_combo_box_menu_activate, combo_box);
|
2004-08-07 22:21:25 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
/* changing the popup window will unref the menu and the children */
|
|
|
|
|
}
|
2004-12-13 04:22:07 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
/* callbacks */
|
|
|
|
|
static gboolean
|
|
|
|
|
gtk_combo_box_menu_button_press (GtkWidget *widget,
|
|
|
|
|
GdkEventButton *event,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
|
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2004-12-13 04:22:07 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
if (GTK_IS_MENU (priv->popup_widget) &&
|
2012-01-25 17:24:02 +00:00
|
|
|
|
event->type == GDK_BUTTON_PRESS && event->button == GDK_BUTTON_PRIMARY)
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
2015-10-23 16:39:01 +00:00
|
|
|
|
if (gtk_widget_get_focus_on_click (GTK_WIDGET (combo_box)) &&
|
2011-01-04 15:14:25 +00:00
|
|
|
|
!gtk_widget_has_focus (priv->button))
|
|
|
|
|
gtk_widget_grab_focus (priv->button);
|
2004-12-13 04:22:07 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
gtk_combo_box_menu_popup (combo_box, event->button, event->time);
|
2004-12-13 04:22:07 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
return TRUE;
|
2004-12-13 04:22:07 +00:00
|
|
|
|
}
|
2004-08-07 22:21:25 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
return FALSE;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_menu_activate (GtkWidget *menu,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
const gchar *path,
|
|
|
|
|
GtkComboBox *combo_box)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
|
|
if (gtk_tree_model_get_iter_from_string (combo_box->priv->model, &iter, path))
|
|
|
|
|
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
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
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);
|
|
|
|
|
|
|
|
|
|
if (combo_box->priv->tree_view)
|
|
|
|
|
gtk_combo_box_list_popup_resize (combo_box);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (priv->tree_view)
|
|
|
|
|
gtk_combo_box_list_popup_resize (combo_box);
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
gint *new_order,
|
|
|
|
|
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);
|
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
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);
|
|
|
|
|
}
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (priv->tree_view)
|
|
|
|
|
gtk_combo_box_list_row_changed (model, path, iter, user_data);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
list_popup_resize_idle (gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
|
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
gint x, y, width, height;
|
|
|
|
|
|
|
|
|
|
if (priv->tree_view && gtk_widget_get_mapped (priv->popup_window))
|
|
|
|
|
{
|
|
|
|
|
gtk_combo_box_list_position (combo_box, &x, &y, &width, &height);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
gtk_widget_set_size_request (priv->popup_window, width, height);
|
|
|
|
|
gtk_window_move (GTK_WINDOW (priv->popup_window), x, y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
priv->resize_idle_id = 0;
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_list_popup_resize (GtkComboBox *combo_box)
|
|
|
|
|
{
|
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
|
|
|
|
|
if (!priv->resize_idle_id)
|
2014-03-22 11:44:01 +00:00
|
|
|
|
{
|
|
|
|
|
priv->resize_idle_id =
|
|
|
|
|
gdk_threads_add_idle (list_popup_resize_idle, combo_box);
|
|
|
|
|
g_source_set_name_by_id (priv->resize_idle_id, "[gtk+] list_popup_resize_idle");
|
|
|
|
|
}
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_model_row_expanded (GtkTreeModel *model,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer user_data)
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
gtk_combo_box_list_popup_resize (combo_box);
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
/*
|
|
|
|
|
* list style
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_list_setup (GtkComboBox *combo_box)
|
|
|
|
|
{
|
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
GtkTreeSelection *sel;
|
|
|
|
|
|
|
|
|
|
g_signal_connect (priv->button, "button-press-event",
|
|
|
|
|
G_CALLBACK (gtk_combo_box_list_button_pressed), combo_box);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
|
priv->tree_view = gtk_tree_view_new ();
|
|
|
|
|
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view));
|
2004-05-11 13:44:09 +00:00
|
|
|
|
gtk_tree_selection_set_mode (sel, GTK_SELECTION_BROWSE);
|
2006-06-02 18:55:59 +00:00
|
|
|
|
gtk_tree_selection_set_select_function (sel,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gtk_combo_box_list_select_func,
|
|
|
|
|
NULL, NULL);
|
2007-12-28 06:56:48 +00:00
|
|
|
|
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->tree_view),
|
2003-09-26 21:57:06 +00:00
|
|
|
|
FALSE);
|
2007-12-28 06:56:48 +00:00
|
|
|
|
gtk_tree_view_set_hover_selection (GTK_TREE_VIEW (priv->tree_view),
|
2011-01-04 15:14:25 +00:00
|
|
|
|
TRUE);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (priv->tree_view),
|
|
|
|
|
(GtkTreeViewRowSeparatorFunc)gtk_combo_box_row_separator_func,
|
|
|
|
|
combo_box, NULL);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
|
if (priv->model)
|
|
|
|
|
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->tree_view), priv->model);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2011-01-21 04:38:50 +00:00
|
|
|
|
gtk_tree_view_append_column (GTK_TREE_VIEW (priv->tree_view),
|
|
|
|
|
gtk_tree_view_column_new_with_area (priv->area));
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
|
if (gtk_tree_row_reference_valid (priv->active_row))
|
2003-09-26 21:57:06 +00:00
|
|
|
|
{
|
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
|
path = gtk_tree_row_reference_get_path (priv->active_row);
|
|
|
|
|
gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->tree_view),
|
2011-01-04 15:14:25 +00:00
|
|
|
|
path, NULL, FALSE);
|
2004-08-02 19:15:05 +00:00
|
|
|
|
gtk_tree_path_free (path);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* set sample/popup widgets */
|
2007-12-28 06:56:48 +00:00
|
|
|
|
gtk_combo_box_set_popup_widget (combo_box, priv->tree_view);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2008-08-11 09:17:49 +00:00
|
|
|
|
g_signal_connect (priv->tree_view, "key-press-event",
|
2004-07-26 04:50:07 +00:00
|
|
|
|
G_CALLBACK (gtk_combo_box_list_key_press),
|
|
|
|
|
combo_box);
|
2008-08-11 09:17:49 +00:00
|
|
|
|
g_signal_connect (priv->tree_view, "enter-notify-event",
|
2004-07-26 04:50:07 +00:00
|
|
|
|
G_CALLBACK (gtk_combo_box_list_enter_notify),
|
|
|
|
|
combo_box);
|
2008-08-11 09:17:49 +00:00
|
|
|
|
g_signal_connect (priv->tree_view, "row-expanded",
|
2011-01-04 15:14:25 +00:00
|
|
|
|
G_CALLBACK (gtk_combo_box_model_row_expanded),
|
|
|
|
|
combo_box);
|
2008-08-11 09:17:49 +00:00
|
|
|
|
g_signal_connect (priv->tree_view, "row-collapsed",
|
2011-01-04 15:14:25 +00:00
|
|
|
|
G_CALLBACK (gtk_combo_box_model_row_expanded),
|
|
|
|
|
combo_box);
|
2008-08-11 09:17:49 +00:00
|
|
|
|
g_signal_connect (priv->popup_window, "button-press-event",
|
2004-07-26 04:50:07 +00:00
|
|
|
|
G_CALLBACK (gtk_combo_box_list_button_pressed),
|
|
|
|
|
combo_box);
|
2008-08-11 09:17:49 +00:00
|
|
|
|
g_signal_connect (priv->popup_window, "button-release-event",
|
2004-07-26 04:50:07 +00:00
|
|
|
|
G_CALLBACK (gtk_combo_box_list_button_released),
|
|
|
|
|
combo_box);
|
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
|
gtk_widget_show (priv->tree_view);
|
2009-09-09 07:43:30 +00:00
|
|
|
|
|
|
|
|
|
gtk_combo_box_update_sensitivity (combo_box);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_list_destroy (GtkComboBox *combo_box)
|
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
|
/* disconnect signals */
|
2007-12-28 06:56:48 +00:00
|
|
|
|
g_signal_handlers_disconnect_matched (priv->tree_view,
|
2003-09-26 21:57:06 +00:00
|
|
|
|
G_SIGNAL_MATCH_DATA,
|
|
|
|
|
0, 0, NULL, NULL, combo_box);
|
2007-12-28 06:56:48 +00:00
|
|
|
|
g_signal_handlers_disconnect_matched (priv->button,
|
2003-09-26 21:57:06 +00:00
|
|
|
|
G_SIGNAL_MATCH_DATA,
|
|
|
|
|
0, 0, NULL,
|
|
|
|
|
gtk_combo_box_list_button_pressed,
|
|
|
|
|
NULL);
|
2007-12-28 06:56:48 +00:00
|
|
|
|
g_signal_handlers_disconnect_matched (priv->popup_window,
|
2004-07-26 04:50:07 +00:00
|
|
|
|
G_SIGNAL_MATCH_DATA,
|
|
|
|
|
0, 0, NULL,
|
|
|
|
|
gtk_combo_box_list_button_pressed,
|
|
|
|
|
NULL);
|
2007-12-28 06:56:48 +00:00
|
|
|
|
g_signal_handlers_disconnect_matched (priv->popup_window,
|
2004-07-26 04:50:07 +00:00
|
|
|
|
G_SIGNAL_MATCH_DATA,
|
|
|
|
|
0, 0, NULL,
|
|
|
|
|
gtk_combo_box_list_button_released,
|
|
|
|
|
NULL);
|
2005-11-10 21:17:19 +00:00
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
|
g_signal_handlers_disconnect_matched (priv->popup_window,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
G_SIGNAL_MATCH_DATA,
|
|
|
|
|
0, 0, NULL,
|
|
|
|
|
gtk_combo_box_child_show,
|
|
|
|
|
NULL);
|
2005-11-10 21:17:19 +00:00
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
|
g_signal_handlers_disconnect_matched (priv->popup_window,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
G_SIGNAL_MATCH_DATA,
|
|
|
|
|
0, 0, NULL,
|
|
|
|
|
gtk_combo_box_child_hide,
|
|
|
|
|
NULL);
|
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
|
if (priv->cell_view)
|
2003-09-26 21:57:06 +00:00
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
|
g_object_set (priv->cell_view,
|
2005-03-26 05:49:15 +00:00
|
|
|
|
"background-set", FALSE,
|
2003-09-26 21:57:06 +00:00
|
|
|
|
NULL);
|
2004-04-14 20:26:26 +00:00
|
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
|
if (priv->scroll_timer)
|
2004-07-26 04:50:07 +00:00
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
|
g_source_remove (priv->scroll_timer);
|
|
|
|
|
priv->scroll_timer = 0;
|
2004-07-26 04:50:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
|
if (priv->resize_idle_id)
|
2005-07-22 03:38:14 +00:00
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
|
g_source_remove (priv->resize_idle_id);
|
|
|
|
|
priv->resize_idle_id = 0;
|
2005-07-22 03:38:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
|
gtk_widget_destroy (priv->tree_view);
|
2004-02-27 01:34:11 +00:00
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
|
priv->tree_view = NULL;
|
|
|
|
|
if (priv->popup_widget)
|
2007-02-01 11:42:38 +00:00
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
|
g_object_unref (priv->popup_widget);
|
|
|
|
|
priv->popup_widget = NULL;
|
2007-02-01 11:42:38 +00:00
|
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* callbacks */
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gtk_combo_box_list_button_pressed (GtkWidget *widget,
|
|
|
|
|
GdkEventButton *event,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (data);
|
2007-12-28 06:56:48 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
|
|
GtkWidget *ewidget = gtk_get_event_widget ((GdkEvent *)event);
|
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
|
if (ewidget == priv->popup_window)
|
2003-09-26 21:57:06 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
|
2015-12-22 18:52:42 +00:00
|
|
|
|
if (ewidget != priv->button ||
|
2007-12-28 06:56:48 +00:00
|
|
|
|
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->button)))
|
2003-09-26 21:57:06 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
2015-10-23 16:39:01 +00:00
|
|
|
|
if (gtk_widget_get_focus_on_click (GTK_WIDGET (combo_box)) &&
|
2010-03-01 03:21:41 +00:00
|
|
|
|
!gtk_widget_has_focus (priv->button))
|
2007-12-28 06:56:48 +00:00
|
|
|
|
gtk_widget_grab_focus (priv->button);
|
2004-08-16 05:43:50 +00:00
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
gtk_combo_box_popup_for_device (combo_box, event->device);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button), TRUE);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
|
priv->auto_scroll = FALSE;
|
2013-10-22 13:43:43 +00:00
|
|
|
|
if (priv->scroll_timer == 0) {
|
2011-01-04 15:14:25 +00:00
|
|
|
|
priv->scroll_timer = gdk_threads_add_timeout (SCROLL_TIME,
|
|
|
|
|
(GSourceFunc) gtk_combo_box_list_scroll_timeout,
|
|
|
|
|
combo_box);
|
2013-10-22 13:43:43 +00:00
|
|
|
|
g_source_set_name_by_id (priv->scroll_timer, "[gtk+] gtk_combo_box_list_scroll_timeout");
|
|
|
|
|
}
|
2004-07-26 04:50:07 +00:00
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
|
priv->popup_in_progress = TRUE;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gtk_combo_box_list_button_released (GtkWidget *widget,
|
|
|
|
|
GdkEventButton *event,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
gboolean ret;
|
|
|
|
|
GtkTreePath *path = NULL;
|
2004-08-02 19:15:05 +00:00
|
|
|
|
GtkTreeIter iter;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (data);
|
2007-12-28 06:56:48 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
|
|
gboolean popup_in_progress = FALSE;
|
|
|
|
|
|
|
|
|
|
GtkWidget *ewidget = gtk_get_event_widget ((GdkEvent *)event);
|
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
|
if (priv->popup_in_progress)
|
2003-09-26 21:57:06 +00:00
|
|
|
|
{
|
|
|
|
|
popup_in_progress = TRUE;
|
2007-12-28 06:56:48 +00:00
|
|
|
|
priv->popup_in_progress = FALSE;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gtk_tree_view_set_hover_expand (GTK_TREE_VIEW (priv->tree_view),
|
|
|
|
|
FALSE);
|
2007-12-28 06:56:48 +00:00
|
|
|
|
if (priv->scroll_timer)
|
2004-07-26 04:50:07 +00:00
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
|
g_source_remove (priv->scroll_timer);
|
|
|
|
|
priv->scroll_timer = 0;
|
2004-07-26 04:50:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
|
if (ewidget != priv->tree_view)
|
2003-09-26 21:57:06 +00:00
|
|
|
|
{
|
2015-12-22 18:52:42 +00:00
|
|
|
|
if (ewidget == priv->button &&
|
2003-09-26 21:57:06 +00:00
|
|
|
|
!popup_in_progress &&
|
2007-12-28 06:56:48 +00:00
|
|
|
|
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->button)))
|
2003-09-26 21:57:06 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_combo_box_popdown (combo_box);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* released outside treeview */
|
2015-12-22 18:52:42 +00:00
|
|
|
|
if (ewidget != priv->button)
|
2003-09-26 21:57:06 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_combo_box_popdown (combo_box);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* select something cool */
|
2007-12-28 06:56:48 +00:00
|
|
|
|
ret = gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (priv->tree_view),
|
2003-09-26 21:57:06 +00:00
|
|
|
|
event->x, event->y,
|
|
|
|
|
&path,
|
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
|
return TRUE; /* clicked outside window? */
|
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
|
gtk_tree_model_get_iter (priv->model, &iter, path);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
|
2006-03-15 19:00:59 +00:00
|
|
|
|
gtk_combo_box_popdown (combo_box);
|
|
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
|
if (tree_column_row_is_sensitive (combo_box, &iter))
|
|
|
|
|
gtk_combo_box_set_active_iter (combo_box, &iter);
|
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-04 23:35:31 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_combo_box_menu_key_press (GtkWidget *widget,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GdkEventKey *event,
|
|
|
|
|
gpointer data)
|
2004-03-04 23:35:31 +00:00
|
|
|
|
{
|
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (data);
|
|
|
|
|
|
2010-09-18 23:57:32 +00:00
|
|
|
|
if (!gtk_bindings_activate_event (G_OBJECT (widget), event))
|
2004-03-04 23:35:31 +00:00
|
|
|
|
{
|
2007-05-18 11:33:13 +00:00
|
|
|
|
/* The menu hasn't managed the
|
|
|
|
|
* event, forward it to the combobox
|
|
|
|
|
*/
|
2010-09-18 23:57:32 +00:00
|
|
|
|
gtk_bindings_activate_event (G_OBJECT (combo_box), event);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
2007-05-18 11:33:13 +00:00
|
|
|
|
|
|
|
|
|
return TRUE;
|
2004-03-04 23:35:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gtk_combo_box_list_key_press (GtkWidget *widget,
|
|
|
|
|
GdkEventKey *event,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (data);
|
2015-12-22 02:32:14 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2004-08-02 19:15:05 +00:00
|
|
|
|
GtkTreeIter iter;
|
2004-03-04 23:35:31 +00:00
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
if (event->keyval == GDK_KEY_Return || event->keyval == GDK_KEY_ISO_Enter || event->keyval == GDK_KEY_KP_Enter ||
|
2011-01-04 15:14:25 +00:00
|
|
|
|
event->keyval == GDK_KEY_space || event->keyval == GDK_KEY_KP_Space)
|
2004-03-04 23:35:31 +00:00
|
|
|
|
{
|
|
|
|
|
GtkTreeModel *model = NULL;
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2006-03-15 19:03:46 +00:00
|
|
|
|
gtk_combo_box_popdown (combo_box);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (priv->model)
|
2004-06-15 05:12:27 +00:00
|
|
|
|
{
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreeSelection *sel;
|
2006-03-15 19:00:59 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view));
|
2006-03-15 19:00:59 +00:00
|
|
|
|
|
2011-01-04 15:14:25 +00:00
|
|
|
|
if (gtk_tree_selection_get_selected (sel, &model, &iter))
|
|
|
|
|
gtk_combo_box_set_active_iter (combo_box, &iter);
|
2004-03-04 23:35:31 +00:00
|
|
|
|
}
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2004-03-13 20:33:45 +00:00
|
|
|
|
return TRUE;
|
2004-03-04 23:35:31 +00:00
|
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-09-18 23:57:32 +00:00
|
|
|
|
if (!gtk_bindings_activate_event (G_OBJECT (widget), event))
|
2007-05-18 11:33:13 +00:00
|
|
|
|
{
|
|
|
|
|
/* The list hasn't managed the
|
|
|
|
|
* event, forward it to the combobox
|
|
|
|
|
*/
|
2010-09-18 23:57:32 +00:00
|
|
|
|
gtk_bindings_activate_event (G_OBJECT (combo_box), event);
|
2007-05-18 11:33:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-07-26 04:50:07 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_list_auto_scroll (GtkComboBox *combo_box,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gint x,
|
|
|
|
|
gint y)
|
2004-07-26 04:50:07 +00:00
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2004-07-26 04:50:07 +00:00
|
|
|
|
GtkAdjustment *adj;
|
2010-08-11 21:14:32 +00:00
|
|
|
|
GtkAllocation allocation;
|
2004-07-26 04:50:07 +00:00
|
|
|
|
gdouble value;
|
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
gtk_widget_get_allocation (priv->tree_view, &allocation);
|
2010-08-11 21:14:32 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
adj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (priv->scrolled_window));
|
2011-01-05 21:29:13 +00:00
|
|
|
|
if (adj && gtk_adjustment_get_upper (adj) - gtk_adjustment_get_lower (adj) > gtk_adjustment_get_page_size (adj))
|
2004-07-26 04:50:07 +00:00
|
|
|
|
{
|
2010-08-11 21:14:32 +00:00
|
|
|
|
if (x <= allocation.x &&
|
2011-01-05 21:29:13 +00:00
|
|
|
|
gtk_adjustment_get_lower (adj) < gtk_adjustment_get_value (adj))
|
2011-01-04 15:14:25 +00:00
|
|
|
|
{
|
2011-01-05 21:29:13 +00:00
|
|
|
|
value = gtk_adjustment_get_value (adj) - (allocation.x - x + 1);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gtk_adjustment_set_value (adj, value);
|
|
|
|
|
}
|
2010-08-11 21:14:32 +00:00
|
|
|
|
else if (x >= allocation.x + allocation.width &&
|
2011-01-05 21:29:13 +00:00
|
|
|
|
gtk_adjustment_get_upper (adj) - gtk_adjustment_get_page_size (adj) > gtk_adjustment_get_value (adj))
|
2011-01-04 15:14:25 +00:00
|
|
|
|
{
|
2011-01-05 21:29:13 +00:00
|
|
|
|
value = gtk_adjustment_get_value (adj) + (x - allocation.x - allocation.width + 1);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gtk_adjustment_set_value (adj, MAX (value, 0.0));
|
|
|
|
|
}
|
2004-07-26 04:50:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->scrolled_window));
|
2011-01-05 21:29:13 +00:00
|
|
|
|
if (adj && gtk_adjustment_get_upper (adj) - gtk_adjustment_get_lower (adj) > gtk_adjustment_get_page_size (adj))
|
2004-07-26 04:50:07 +00:00
|
|
|
|
{
|
2010-08-11 21:14:32 +00:00
|
|
|
|
if (y <= allocation.y &&
|
2011-01-05 21:29:13 +00:00
|
|
|
|
gtk_adjustment_get_lower (adj) < gtk_adjustment_get_value (adj))
|
2011-01-04 15:14:25 +00:00
|
|
|
|
{
|
2011-01-05 21:29:13 +00:00
|
|
|
|
value = gtk_adjustment_get_value (adj) - (allocation.y - y + 1);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gtk_adjustment_set_value (adj, value);
|
|
|
|
|
}
|
2010-08-11 21:14:32 +00:00
|
|
|
|
else if (y >= allocation.height &&
|
2011-01-05 21:29:13 +00:00
|
|
|
|
gtk_adjustment_get_upper (adj) - gtk_adjustment_get_page_size (adj) > gtk_adjustment_get_value (adj))
|
2011-01-04 15:14:25 +00:00
|
|
|
|
{
|
2011-01-05 21:29:13 +00:00
|
|
|
|
value = gtk_adjustment_get_value (adj) + (y - allocation.height + 1);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gtk_adjustment_set_value (adj, MAX (value, 0.0));
|
|
|
|
|
}
|
2004-07-26 04:50:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gtk_combo_box_list_scroll_timeout (GtkComboBox *combo_box)
|
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2004-07-26 04:50:07 +00:00
|
|
|
|
gint x, y;
|
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
|
if (priv->auto_scroll)
|
2004-07-26 04:50:07 +00:00
|
|
|
|
{
|
2010-08-11 21:14:32 +00:00
|
|
|
|
gdk_window_get_device_position (gtk_widget_get_window (priv->tree_view),
|
2010-05-25 22:38:44 +00:00
|
|
|
|
priv->grab_pointer,
|
|
|
|
|
&x, &y, NULL);
|
2004-07-26 04:50:07 +00:00
|
|
|
|
gtk_combo_box_list_auto_scroll (combo_box, x, y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-04 15:14:25 +00:00
|
|
|
|
static gboolean
|
2004-07-26 04:50:07 +00:00
|
|
|
|
gtk_combo_box_list_enter_notify (GtkWidget *widget,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GdkEventCrossing *event,
|
|
|
|
|
gpointer data)
|
2004-07-26 04:50:07 +00:00
|
|
|
|
{
|
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (data);
|
|
|
|
|
|
|
|
|
|
combo_box->priv->auto_scroll = TRUE;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-02 18:55:59 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_combo_box_list_select_func (GtkTreeSelection *selection,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkTreeModel *model,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
gboolean path_currently_selected,
|
|
|
|
|
gpointer data)
|
2006-06-02 18:55:59 +00:00
|
|
|
|
{
|
2010-11-30 07:36:07 +00:00
|
|
|
|
GList *list, *columns;
|
2006-06-02 18:55:59 +00:00
|
|
|
|
gboolean sensitive = FALSE;
|
|
|
|
|
|
2010-12-19 01:27:41 +00:00
|
|
|
|
columns = gtk_tree_view_get_columns (gtk_tree_selection_get_tree_view (selection));
|
2010-11-30 07:36:07 +00:00
|
|
|
|
|
|
|
|
|
for (list = columns; list && !sensitive; list = list->next)
|
2006-06-02 18:55:59 +00:00
|
|
|
|
{
|
|
|
|
|
GList *cells, *cell;
|
|
|
|
|
gboolean cell_sensitive, cell_visible;
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN (list->data);
|
|
|
|
|
|
2010-11-19 06:47:27 +00:00
|
|
|
|
if (!gtk_tree_view_column_get_visible (column))
|
2011-01-04 15:14:25 +00:00
|
|
|
|
continue;
|
2006-06-02 18:55:59 +00:00
|
|
|
|
|
|
|
|
|
gtk_tree_model_get_iter (model, &iter, path);
|
|
|
|
|
gtk_tree_view_column_cell_set_cell_data (column, model, &iter,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
FALSE, FALSE);
|
2006-06-02 18:55:59 +00:00
|
|
|
|
|
2009-06-16 16:21:36 +00:00
|
|
|
|
cell = cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column));
|
2006-06-02 18:55:59 +00:00
|
|
|
|
while (cell)
|
|
|
|
|
{
|
2011-01-04 15:14:25 +00:00
|
|
|
|
g_object_get (cell->data,
|
|
|
|
|
"sensitive", &cell_sensitive,
|
|
|
|
|
"visible", &cell_visible,
|
|
|
|
|
NULL);
|
2006-06-02 18:55:59 +00:00
|
|
|
|
|
2011-01-04 15:14:25 +00:00
|
|
|
|
if (cell_visible && cell_sensitive)
|
2011-12-22 14:57:21 +00:00
|
|
|
|
{
|
|
|
|
|
sensitive = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2006-06-02 18:55:59 +00:00
|
|
|
|
|
2011-01-04 15:14:25 +00:00
|
|
|
|
cell = cell->next;
|
|
|
|
|
}
|
2006-06-02 18:55:59 +00:00
|
|
|
|
|
2011-12-22 14:57:21 +00:00
|
|
|
|
g_list_free (cells);
|
2006-06-02 18:55:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-11-30 07:36:07 +00:00
|
|
|
|
g_list_free (columns);
|
|
|
|
|
|
2006-06-02 18:55:59 +00:00
|
|
|
|
return sensitive;
|
|
|
|
|
}
|
2004-07-26 04:50:07 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_list_row_changed (GtkTreeModel *model,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
/* XXX Do nothing ? */
|
|
|
|
|
}
|
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
|
|
|
|
{
|
2011-01-31 22:34:37 +00:00
|
|
|
|
GtkComboBox *combo = GTK_COMBO_BOX (cell_layout);
|
|
|
|
|
GtkComboBoxPrivate *priv = combo->priv;
|
|
|
|
|
|
|
|
|
|
if (G_UNLIKELY (!priv->area))
|
|
|
|
|
{
|
|
|
|
|
priv->area = gtk_cell_area_box_new ();
|
|
|
|
|
g_object_ref_sink (priv->area);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
*
|
|
|
|
|
* Creates a new empty #GtkComboBox.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: A new #GtkComboBox.
|
2010-12-06 12:30:00 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.4
|
|
|
|
|
*/
|
|
|
|
|
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-13 10:34:26 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_new_with_area:
|
|
|
|
|
* @area: the #GtkCellArea to use to layout cell renderers
|
|
|
|
|
*
|
|
|
|
|
* Creates a new empty #GtkComboBox using @area to layout cells.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: A new #GtkComboBox.
|
2010-12-13 10:34:26 +00:00
|
|
|
|
*/
|
|
|
|
|
GtkWidget *
|
|
|
|
|
gtk_combo_box_new_with_area (GtkCellArea *area)
|
|
|
|
|
{
|
|
|
|
|
return g_object_new (GTK_TYPE_COMBO_BOX, "cell-area", area, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_new_with_area_and_entry:
|
|
|
|
|
* @area: the #GtkCellArea to use to layout cell renderers
|
|
|
|
|
*
|
|
|
|
|
* Creates a new empty #GtkComboBox with an entry.
|
|
|
|
|
*
|
|
|
|
|
* The new combo box will use @area to layout cells.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: A new #GtkComboBox.
|
2010-12-13 10:34:26 +00:00
|
|
|
|
*/
|
|
|
|
|
GtkWidget *
|
|
|
|
|
gtk_combo_box_new_with_area_and_entry (GtkCellArea *area)
|
|
|
|
|
{
|
2011-01-04 15:14:25 +00:00
|
|
|
|
return g_object_new (GTK_TYPE_COMBO_BOX,
|
|
|
|
|
"has-entry", TRUE,
|
|
|
|
|
"cell-area", area,
|
|
|
|
|
NULL);
|
2010-12-13 10:34:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_new_with_entry:
|
|
|
|
|
*
|
|
|
|
|
* Creates a new empty #GtkComboBox with an entry.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: A new #GtkComboBox.
|
2013-08-22 19:36:17 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.24
|
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:
|
|
|
|
|
* @model: A #GtkTreeModel.
|
|
|
|
|
*
|
|
|
|
|
* Creates a new #GtkComboBox with the model initialized to @model.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: A new #GtkComboBox.
|
2010-12-06 12:30:00 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.4
|
|
|
|
|
*/
|
|
|
|
|
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:
|
|
|
|
|
* @model: A #GtkTreeModel
|
|
|
|
|
*
|
|
|
|
|
* Creates a new empty #GtkComboBox with an entry
|
|
|
|
|
* and with the model initialized to @model.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: A new #GtkComboBox
|
2013-08-22 19:36:17 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.24
|
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_wrap_width:
|
|
|
|
|
* @combo_box: A #GtkComboBox
|
|
|
|
|
*
|
2011-01-04 15:14:25 +00:00
|
|
|
|
* Returns the wrap width which is used to determine the number of columns
|
|
|
|
|
* for the popup menu. If the wrap width is larger than 1, the combo box
|
2010-12-06 12:30:00 +00:00
|
|
|
|
* is in table mode.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the wrap width.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.6
|
|
|
|
|
*/
|
|
|
|
|
gint
|
|
|
|
|
gtk_combo_box_get_wrap_width (GtkComboBox *combo_box)
|
2007-09-07 11:02:04 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), -1);
|
2007-09-07 11:02:04 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
return combo_box->priv->wrap_width;
|
2007-09-07 11:02:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_set_wrap_width:
|
|
|
|
|
* @combo_box: A #GtkComboBox
|
|
|
|
|
* @width: Preferred number of columns
|
|
|
|
|
*
|
|
|
|
|
* Sets the wrap width of @combo_box to be @width. The wrap width is basically
|
|
|
|
|
* the preferred number of columns when you want the popup to be layed out
|
|
|
|
|
* in a table.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.4
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_combo_box_set_wrap_width (GtkComboBox *combo_box,
|
|
|
|
|
gint width)
|
2004-08-02 19:15:05 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkComboBoxPrivate *priv;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
|
|
|
|
g_return_if_fail (width >= 0);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
priv = combo_box->priv;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (width != priv->wrap_width)
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
priv->wrap_width = width;
|
2004-08-02 19:15:05 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_combo_box_check_appearance (combo_box);
|
2003-10-01 20:51:54 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (GTK_IS_TREE_MENU (priv->popup_widget))
|
2011-01-04 15:14:25 +00:00
|
|
|
|
_gtk_tree_menu_set_wrap_width (GTK_TREE_MENU (priv->popup_widget), priv->wrap_width);
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_object_notify (G_OBJECT (combo_box), "wrap-width");
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
2003-10-01 20:51:54 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_get_row_span_column:
|
|
|
|
|
* @combo_box: A #GtkComboBox
|
|
|
|
|
*
|
|
|
|
|
* Returns the column with row span information for @combo_box.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the row span column.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.6
|
|
|
|
|
*/
|
|
|
|
|
gint
|
|
|
|
|
gtk_combo_box_get_row_span_column (GtkComboBox *combo_box)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), -1);
|
|
|
|
|
|
|
|
|
|
return combo_box->priv->row_column;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_set_row_span_column:
|
|
|
|
|
* @combo_box: A #GtkComboBox.
|
|
|
|
|
* @row_span: A column in the model passed during construction.
|
|
|
|
|
*
|
|
|
|
|
* Sets the column with row span information for @combo_box to be @row_span.
|
|
|
|
|
* The row span column contains integers which indicate how many rows
|
|
|
|
|
* an item should span.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.4
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_combo_box_set_row_span_column (GtkComboBox *combo_box,
|
|
|
|
|
gint row_span)
|
|
|
|
|
{
|
|
|
|
|
GtkComboBoxPrivate *priv;
|
|
|
|
|
gint col;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
|
|
|
|
|
|
|
|
|
priv = combo_box->priv;
|
|
|
|
|
|
|
|
|
|
col = gtk_tree_model_get_n_columns (priv->model);
|
|
|
|
|
g_return_if_fail (row_span >= -1 && row_span < col);
|
|
|
|
|
|
|
|
|
|
if (row_span != priv->row_column)
|
2004-02-11 01:09:25 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
priv->row_column = row_span;
|
2004-02-11 01:09:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (GTK_IS_TREE_MENU (priv->popup_widget))
|
2011-01-04 15:14:25 +00:00
|
|
|
|
_gtk_tree_menu_set_row_span_column (GTK_TREE_MENU (priv->popup_widget), priv->row_column);
|
2004-02-11 01:09:25 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_object_notify (G_OBJECT (combo_box), "row-span-column");
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
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_column_span_column:
|
|
|
|
|
* @combo_box: A #GtkComboBox
|
|
|
|
|
*
|
|
|
|
|
* Returns the column with column span information for @combo_box.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the column span column.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.6
|
2010-11-24 09:14:36 +00:00
|
|
|
|
*/
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gint
|
|
|
|
|
gtk_combo_box_get_column_span_column (GtkComboBox *combo_box)
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), -1);
|
|
|
|
|
|
|
|
|
|
return combo_box->priv->col_column;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_set_column_span_column:
|
|
|
|
|
* @combo_box: A #GtkComboBox
|
|
|
|
|
* @column_span: A column in the model passed during construction
|
|
|
|
|
*
|
|
|
|
|
* Sets the column with column span information for @combo_box to be
|
|
|
|
|
* @column_span. The column span column contains integers which indicate
|
|
|
|
|
* how many columns an item should span.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.4
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_combo_box_set_column_span_column (GtkComboBox *combo_box,
|
|
|
|
|
gint column_span)
|
2003-09-26 21:57:06 +00:00
|
|
|
|
{
|
2010-11-24 09:14:36 +00:00
|
|
|
|
GtkComboBoxPrivate *priv;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gint col;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
2004-02-15 23:05:48 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
priv = combo_box->priv;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
col = gtk_tree_model_get_n_columns (priv->model);
|
|
|
|
|
g_return_if_fail (column_span >= -1 && column_span < col);
|
2003-10-01 20:51:54 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (column_span != priv->col_column)
|
|
|
|
|
{
|
|
|
|
|
priv->col_column = column_span;
|
2003-10-01 20:51:54 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (GTK_IS_TREE_MENU (priv->popup_widget))
|
2011-01-04 15:14:25 +00:00
|
|
|
|
_gtk_tree_menu_set_column_span_column (GTK_TREE_MENU (priv->popup_widget), priv->col_column);
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_object_notify (G_OBJECT (combo_box), "column-span-column");
|
|
|
|
|
}
|
2004-08-02 19:15:05 +00:00
|
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_get_active:
|
|
|
|
|
* @combo_box: A #GtkComboBox
|
|
|
|
|
*
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* Returns the index of the currently active item, or -1 if there’s no
|
2011-01-04 15:14:25 +00:00
|
|
|
|
* active item. 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
|
2014-02-04 23:21:13 +00:00
|
|
|
|
* `gtk_tree_path_get_indices (path)[0]`, where
|
|
|
|
|
* `path` is the #GtkTreePath 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
|
|
|
|
*
|
|
|
|
|
* Since: 2.4
|
|
|
|
|
*/
|
|
|
|
|
gint
|
|
|
|
|
gtk_combo_box_get_active (GtkComboBox *combo_box)
|
2004-08-02 19:15:05 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkComboBoxPrivate *priv;
|
|
|
|
|
gint 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
|
|
|
|
priv = combo_box->priv;
|
2003-10-01 20:51:54 +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
|
|
|
|
/**
|
2010-12-06 12:30:00 +00:00
|
|
|
|
* gtk_combo_box_set_active:
|
|
|
|
|
* @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
|
|
|
|
*
|
|
|
|
|
* Since: 2.4
|
|
|
|
|
*/
|
2010-12-06 12:30:00 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_combo_box_set_active (GtkComboBox *combo_box,
|
|
|
|
|
gint 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
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
GtkComboBoxPrivate *priv;
|
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
|
|
|
|
priv = combo_box->priv;
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
GtkTreePath *active_path;
|
|
|
|
|
gint path_cmp;
|
|
|
|
|
|
|
|
|
|
/* 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)
|
|
|
|
|
{
|
|
|
|
|
if (priv->tree_view)
|
|
|
|
|
gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view)));
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GtkMenu *menu = GTK_MENU (priv->popup_widget);
|
|
|
|
|
|
|
|
|
|
if (GTK_IS_MENU (menu))
|
|
|
|
|
gtk_menu_set_active (menu, -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
if (priv->tree_view)
|
2011-01-04 15:14:25 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->tree_view),
|
|
|
|
|
path, NULL, FALSE);
|
|
|
|
|
}
|
2010-12-06 12:30:00 +00:00
|
|
|
|
else if (GTK_IS_MENU (priv->popup_widget))
|
|
|
|
|
{
|
2011-01-04 15:14:25 +00:00
|
|
|
|
/* FIXME handle nested menus better */
|
|
|
|
|
gtk_menu_set_active (GTK_MENU (priv->popup_widget),
|
|
|
|
|
gtk_tree_path_get_indices (path)[0]);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (priv->cell_view)
|
2011-01-04 15:14:25 +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:
|
|
|
|
|
* @combo_box: A #GtkComboBox
|
|
|
|
|
* @iter: (out): The uninitialized #GtkTreeIter
|
2011-01-04 15:14:25 +00:00
|
|
|
|
*
|
2010-12-06 12:30:00 +00:00
|
|
|
|
* Sets @iter to point to the current active item, if it exists.
|
2011-01-04 15:14:25 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE, if @iter was set
|
2003-10-02 21:30:11 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.4
|
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
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
GtkComboBoxPrivate *priv;
|
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
|
|
|
|
priv = combo_box->priv;
|
|
|
|
|
|
|
|
|
|
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:
|
2007-03-12 06:04:44 +00:00
|
|
|
|
* @combo_box: A #GtkComboBox
|
2010-12-06 12:30:00 +00:00
|
|
|
|
* @iter: (allow-none): The #GtkTreeIter, or %NULL
|
2011-01-04 15:14:25 +00:00
|
|
|
|
*
|
2010-12-06 12:30:00 +00:00
|
|
|
|
* Sets the current active item to be the one referenced by @iter, or
|
|
|
|
|
* unsets the active item if @iter is %NULL.
|
2011-01-04 15:14:25 +00:00
|
|
|
|
*
|
2010-12-06 12:30:00 +00:00
|
|
|
|
* Since: 2.4
|
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
|
|
|
|
/**
|
2010-12-06 12:30:00 +00:00
|
|
|
|
* gtk_combo_box_set_model:
|
2007-03-12 06:04:44 +00:00
|
|
|
|
* @combo_box: A #GtkComboBox
|
2010-12-06 12:30:00 +00:00
|
|
|
|
* @model: (allow-none): A #GtkTreeModel
|
2003-10-02 21:30:11 +00:00
|
|
|
|
*
|
2010-12-06 12:30:00 +00:00
|
|
|
|
* Sets the model used by @combo_box to be @model. Will unset a previously set
|
|
|
|
|
* model (if applicable). If model is %NULL, then it will unset the model.
|
|
|
|
|
*
|
2011-01-04 15:14:25 +00:00
|
|
|
|
* Note that this function does not clear the cell renderers, you have to
|
|
|
|
|
* call gtk_cell_layout_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
|
|
|
|
*
|
|
|
|
|
* Since: 2.4
|
|
|
|
|
*/
|
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
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
GtkComboBoxPrivate *priv;
|
|
|
|
|
|
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
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
priv = combo_box->priv;
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (model == combo_box->priv->model)
|
|
|
|
|
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
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
priv->inserted_id =
|
|
|
|
|
g_signal_connect (priv->model, "row-inserted",
|
2011-01-04 15:14:25 +00:00
|
|
|
|
G_CALLBACK (gtk_combo_box_model_row_inserted),
|
|
|
|
|
combo_box);
|
2015-12-22 02:32:14 +00:00
|
|
|
|
priv->deleted_id =
|
|
|
|
|
g_signal_connect (priv->model, "row-deleted",
|
2011-01-04 15:14:25 +00:00
|
|
|
|
G_CALLBACK (gtk_combo_box_model_row_deleted),
|
|
|
|
|
combo_box);
|
2015-12-22 02:32:14 +00:00
|
|
|
|
priv->reordered_id =
|
|
|
|
|
g_signal_connect (priv->model, "rows-reordered",
|
2011-01-04 15:14:25 +00:00
|
|
|
|
G_CALLBACK (gtk_combo_box_model_rows_reordered),
|
|
|
|
|
combo_box);
|
2015-12-22 02:32:14 +00:00
|
|
|
|
priv->changed_id =
|
|
|
|
|
g_signal_connect (priv->model, "row-changed",
|
2011-01-04 15:14:25 +00:00
|
|
|
|
G_CALLBACK (gtk_combo_box_model_row_changed),
|
|
|
|
|
combo_box);
|
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (priv->tree_view)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
/* list mode */
|
2015-12-22 02:32:14 +00:00
|
|
|
|
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->tree_view),
|
|
|
|
|
priv->model);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_combo_box_list_popup_resize (combo_box);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (GTK_IS_TREE_MENU (priv->popup_widget))
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
/* menu mode */
|
2015-12-22 02:32:14 +00:00
|
|
|
|
_gtk_tree_menu_set_model (GTK_TREE_MENU (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
|
|
|
|
/**
|
2010-12-06 12:30:00 +00:00
|
|
|
|
* gtk_combo_box_get_model:
|
2007-03-12 06:04:44 +00:00
|
|
|
|
* @combo_box: A #GtkComboBox
|
2004-05-06 04:06:35 +00:00
|
|
|
|
*
|
2010-12-06 12:30:00 +00:00
|
|
|
|
* Returns the #GtkTreeModel which is acting as data source for @combo_box.
|
2004-05-06 04:06:35 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: (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
|
|
|
|
* Since: 2.4
|
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
|
|
|
|
{
|
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
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
return combo_box->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
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
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
|
|
|
|
}
|
|
|
|
|
/* else fall through */
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
/* else fall through */
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
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);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (combo_box->priv->has_entry)
|
2004-02-23 00:53:05 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkWidget* child;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
child = gtk_bin_get_child (GTK_BIN (combo_box));
|
|
|
|
|
if (child)
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gtk_widget_grab_focus (child);
|
2004-02-23 00:53:05 +00:00
|
|
|
|
}
|
2010-12-06 12:30:00 +00:00
|
|
|
|
else
|
|
|
|
|
gtk_widget_grab_focus (combo_box->priv->button);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void
|
|
|
|
|
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);
|
2007-12-28 06:56:48 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (combo_box->priv->has_entry)
|
2004-08-02 19:15:05 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkWidget *child;
|
2005-02-24 17:57:07 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
child = gtk_bin_get_child (GTK_BIN (combo_box));
|
|
|
|
|
if (child)
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gtk_widget_grab_focus (child);
|
2004-08-02 19:15:05 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_widget_grab_focus (combo_box->priv->button);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_destroy (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);
|
2015-07-25 21:19:40 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (priv->popup_idle_id > 0)
|
2008-12-13 08:11:54 +00:00
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
g_source_remove (priv->popup_idle_id);
|
|
|
|
|
priv->popup_idle_id = 0;
|
2008-12-13 08:11:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-01 17:29:22 +00:00
|
|
|
|
if (priv->box)
|
2015-07-25 21:19:40 +00:00
|
|
|
|
{
|
|
|
|
|
/* destroy things (unparent will kill the latest ref from us)
|
|
|
|
|
* last unref on button will destroy the arrow
|
|
|
|
|
*/
|
2016-03-01 17:29:22 +00:00
|
|
|
|
gtk_widget_unparent (priv->box);
|
|
|
|
|
priv->box = NULL;
|
2015-07-25 21:19:40 +00:00
|
|
|
|
priv->button = NULL;
|
|
|
|
|
priv->arrow = NULL;
|
2016-03-01 18:14:30 +00:00
|
|
|
|
priv->cell_view = NULL;
|
|
|
|
|
_gtk_bin_set_child (GTK_BIN (combo_box), NULL);
|
2015-07-25 21:19:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_combo_box_popdown (combo_box);
|
2004-08-09 02:45:18 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (priv->row_separator_destroy)
|
|
|
|
|
priv->row_separator_destroy (priv->row_separator_data);
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
priv->row_separator_func = NULL;
|
|
|
|
|
priv->row_separator_data = NULL;
|
|
|
|
|
priv->row_separator_destroy = NULL;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (gtk_combo_box_parent_class)->destroy (widget);
|
2015-12-22 02:32:14 +00:00
|
|
|
|
priv->cell_view = NULL;
|
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)
|
|
|
|
|
{
|
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
|
|
if (gtk_combo_box_get_active_iter (combo_box, &iter))
|
2004-08-02 19:15:05 +00:00
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkEntry *entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (combo_box)));
|
|
|
|
|
|
|
|
|
|
if (entry)
|
2011-01-04 15:14:25 +00:00
|
|
|
|
{
|
2011-10-06 09:14:38 +00:00
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
gchar *path_str;
|
|
|
|
|
gchar *text = NULL;
|
|
|
|
|
|
|
|
|
|
model = gtk_combo_box_get_model (combo_box);
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
2011-10-06 09:14:38 +00:00
|
|
|
|
g_signal_emit (combo_box, combo_box_signals[FORMAT_ENTRY_TEXT], 0,
|
|
|
|
|
path_str, &text);
|
|
|
|
|
|
|
|
|
|
gtk_entry_set_text (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
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2011-10-06 09:14:38 +00:00
|
|
|
|
static gchar *
|
|
|
|
|
gtk_combo_box_format_entry_text (GtkComboBox *combo_box,
|
|
|
|
|
const gchar *path)
|
|
|
|
|
{
|
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
gchar *text = NULL;
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
priv->text_column, &text,
|
|
|
|
|
-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
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
|
|
|
|
|
|
|
|
|
if (!priv->area)
|
2004-08-02 19:15:05 +00:00
|
|
|
|
{
|
2011-01-31 22:34:37 +00:00
|
|
|
|
priv->area = gtk_cell_area_box_new ();
|
|
|
|
|
g_object_ref_sink (priv->area);
|
2004-08-02 19:15:05 +00:00
|
|
|
|
}
|
2003-09-26 21:57:06 +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
|
|
|
|
|
|
|
|
|
gtk_combo_box_check_appearance (combo_box);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-14 20:09:39 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static void
|
|
|
|
|
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);
|
2015-12-22 02:32:14 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2005-02-24 17:57:07 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (GTK_IS_MENU (priv->popup_widget))
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_combo_box_menu_destroy (combo_box);
|
2015-12-22 02:32:14 +00:00
|
|
|
|
gtk_menu_detach (GTK_MENU (priv->popup_widget));
|
|
|
|
|
priv->popup_widget = NULL;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
2003-10-14 20:09:39 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (priv->area)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
g_object_unref (priv->area);
|
|
|
|
|
priv->area = NULL;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
2003-10-14 20:09:39 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (GTK_IS_TREE_VIEW (priv->tree_view))
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_combo_box_list_destroy (combo_box);
|
2003-10-14 20:09:39 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (priv->popup_window)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
gtk_widget_destroy (priv->popup_window);
|
|
|
|
|
priv->popup_window = NULL;
|
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 void
|
|
|
|
|
gtk_combo_box_finalize (GObject *object)
|
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
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (object);
|
2006-12-27 07:17:53 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_free (combo_box->priv->tearoff_title);
|
2015-12-22 02:43:19 +00:00
|
|
|
|
g_clear_object (&combo_box->priv->gadget);
|
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
|
|
|
|
G_OBJECT_CLASS (gtk_combo_box_parent_class)->finalize (object);
|
|
|
|
|
}
|
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 gboolean
|
|
|
|
|
gtk_cell_editable_key_press (GtkWidget *widget,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GdkEventKey *event,
|
|
|
|
|
gpointer data)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (data);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
if (event->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
|
|
|
|
}
|
2010-12-06 12:30:00 +00:00
|
|
|
|
else if (event->keyval == GDK_KEY_Return ||
|
|
|
|
|
event->keyval == GDK_KEY_ISO_Enter ||
|
|
|
|
|
event->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
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
popdown_idle (gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkComboBox *combo_box;
|
2008-12-13 08:11:54 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
combo_box = GTK_COMBO_BOX (data);
|
2011-01-04 15:14:25 +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));
|
|
|
|
|
|
|
|
|
|
g_object_unref (combo_box);
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
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
|
|
|
|
|
popdown_handler (GtkWidget *widget,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gpointer data)
|
2003-09-26 21:57:06 +00:00
|
|
|
|
{
|
2014-03-22 11:44:01 +00:00
|
|
|
|
guint id;
|
|
|
|
|
id = gdk_threads_add_idle (popdown_idle, g_object_ref (data));
|
|
|
|
|
g_source_set_name_by_id (id, "[gtk+] popdown_idle");
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
popup_idle (gpointer data)
|
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (data);
|
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (GTK_IS_MENU (priv->popup_widget) &&
|
|
|
|
|
priv->cell_view)
|
|
|
|
|
g_signal_connect_object (priv->popup_widget,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
"unmap", G_CALLBACK (popdown_handler),
|
|
|
|
|
combo_box, 0);
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
/* we unset this if a menu item is activated */
|
|
|
|
|
g_object_set (combo_box,
|
|
|
|
|
"editing-canceled", TRUE,
|
|
|
|
|
NULL);
|
|
|
|
|
gtk_combo_box_popup (combo_box);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
priv->popup_idle_id = 0;
|
|
|
|
|
priv->activate_button = 0;
|
|
|
|
|
priv->activate_time = 0;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
|
|
|
|
return FALSE;
|
2003-09-26 21:57:06 +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);
|
2015-12-22 02:32:14 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
GtkWidget *child;
|
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
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (priv->cell_view)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
g_signal_connect_object (priv->button, "key-press-event",
|
2011-01-04 15:14:25 +00:00
|
|
|
|
G_CALLBACK (gtk_cell_editable_key_press),
|
|
|
|
|
cell_editable, 0);
|
2006-10-12 13:04:44 +00:00
|
|
|
|
|
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
|
|
|
|
{
|
2010-12-06 12:30:00 +00:00
|
|
|
|
child = gtk_bin_get_child (GTK_BIN (combo_box));
|
2006-10-12 13:04:44 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
g_signal_connect_object (child, "key-press-event",
|
2011-01-04 15:14:25 +00:00
|
|
|
|
G_CALLBACK (gtk_cell_editable_key_press),
|
|
|
|
|
cell_editable, 0);
|
2006-10-12 13:04:44 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_widget_grab_focus (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
|
|
|
|
|
2011-01-04 15:14:25 +00:00
|
|
|
|
/* we do the immediate popup only for the optionmenu-like
|
|
|
|
|
* appearance
|
|
|
|
|
*/
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (priv->is_cell_renderer &&
|
|
|
|
|
priv->cell_view && !priv->tree_view)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
if (event && event->type == GDK_BUTTON_PRESS)
|
|
|
|
|
{
|
|
|
|
|
GdkEventButton *event_button = (GdkEventButton *)event;
|
2006-10-12 13:04:44 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
priv->activate_button = event_button->button;
|
|
|
|
|
priv->activate_time = event_button->time;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
}
|
2006-10-12 13:04:44 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
priv->popup_idle_id =
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gdk_threads_add_idle (popup_idle, combo_box);
|
2015-12-22 02:32:14 +00:00
|
|
|
|
g_source_set_name_by_id (priv->popup_idle_id, "[gtk+] popup_idle");
|
2006-10-12 13:04:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_get_add_tearoffs:
|
|
|
|
|
* @combo_box: a #GtkComboBox
|
2011-01-04 15:14:25 +00:00
|
|
|
|
*
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* Gets the current value of the :add-tearoffs property.
|
2011-01-04 15:14:25 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the current value of the :add-tearoffs property.
|
2013-07-18 02:52:53 +00:00
|
|
|
|
*
|
|
|
|
|
* Deprecated: 3.10
|
2010-11-24 09:14:36 +00:00
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_combo_box_get_add_tearoffs (GtkComboBox *combo_box)
|
2004-02-05 20:35:57 +00:00
|
|
|
|
{
|
2010-11-24 09:14:36 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), FALSE);
|
2004-02-05 22:46:22 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
return combo_box->priv->add_tearoffs;
|
2004-02-05 20:35:57 +00:00
|
|
|
|
}
|
2004-02-05 22:46:22 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_set_add_tearoffs:
|
2011-01-04 15:14:25 +00:00
|
|
|
|
* @combo_box: a #GtkComboBox
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* @add_tearoffs: %TRUE to add tearoff menu items
|
2011-01-04 15:14:25 +00:00
|
|
|
|
*
|
|
|
|
|
* Sets whether the popup menu should have a tearoff
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* menu item.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.6
|
2013-07-18 02:52:53 +00:00
|
|
|
|
*
|
|
|
|
|
* Deprecated: 3.10
|
2010-11-24 09:14:36 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_combo_box_set_add_tearoffs (GtkComboBox *combo_box,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gboolean add_tearoffs)
|
2005-04-06 04:01:19 +00:00
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
GtkComboBoxPrivate *priv;
|
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
2005-04-06 04:01:19 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
priv = combo_box->priv;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
add_tearoffs = add_tearoffs != FALSE;
|
2004-02-24 00:07:15 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (priv->add_tearoffs != add_tearoffs)
|
2004-07-16 20:27:40 +00:00
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
priv->add_tearoffs = add_tearoffs;
|
2010-12-06 12:30:00 +00:00
|
|
|
|
gtk_combo_box_check_appearance (combo_box);
|
2010-12-30 07:46:50 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (GTK_IS_TREE_MENU (priv->popup_widget))
|
|
|
|
|
_gtk_tree_menu_set_tearoff (GTK_TREE_MENU (priv->popup_widget),
|
|
|
|
|
priv->add_tearoffs);
|
2010-12-30 07:46:50 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
g_object_notify (G_OBJECT (combo_box), "add-tearoffs");
|
|
|
|
|
}
|
2004-02-24 00:07:15 +00:00
|
|
|
|
}
|
2004-02-05 23:45:21 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_get_title:
|
|
|
|
|
* @combo_box: a #GtkComboBox
|
|
|
|
|
*
|
|
|
|
|
* Gets the current title of the menu in tearoff mode. See
|
|
|
|
|
* gtk_combo_box_set_add_tearoffs().
|
|
|
|
|
*
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* Returns: the menu’s title in tearoff mode. This is an internal copy of the
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* string which must not be freed.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
2013-07-18 02:52:53 +00:00
|
|
|
|
*
|
|
|
|
|
* Deprecated: 3.10
|
2010-11-24 09:14:36 +00:00
|
|
|
|
*/
|
2011-06-06 18:13:44 +00:00
|
|
|
|
const gchar*
|
2010-11-24 09:14:36 +00:00
|
|
|
|
gtk_combo_box_get_title (GtkComboBox *combo_box)
|
2010-10-14 01:52:27 +00:00
|
|
|
|
{
|
2010-11-24 09:14:36 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
return combo_box->priv->tearoff_title;
|
2010-10-14 01:52:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-11-24 09:14:36 +00:00
|
|
|
|
gtk_combo_box_update_title (GtkComboBox *combo_box)
|
2010-10-14 01:52:27 +00:00
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
gtk_combo_box_check_appearance (combo_box);
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2016-01-31 03:50:54 +00:00
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
|
|
|
if (priv->popup_widget && GTK_IS_MENU (priv->popup_widget))
|
|
|
|
|
gtk_menu_set_title (GTK_MENU (priv->popup_widget), priv->tearoff_title);
|
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS
|
2010-10-14 01:52:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_set_title:
|
2011-01-04 15:14:25 +00:00
|
|
|
|
* @combo_box: a #GtkComboBox
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* @title: a title for the menu in tearoff mode
|
2011-01-04 15:14:25 +00:00
|
|
|
|
*
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* Sets the menu’s title in tearoff mode.
|
2010-11-24 09:14:36 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
2013-07-18 02:52:53 +00:00
|
|
|
|
*
|
|
|
|
|
* Deprecated: 3.10
|
2010-11-24 09:14:36 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_combo_box_set_title (GtkComboBox *combo_box,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
const gchar *title)
|
2010-10-14 01:52:27 +00:00
|
|
|
|
{
|
|
|
|
|
GtkComboBoxPrivate *priv;
|
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
2010-10-14 01:52:27 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
priv = combo_box->priv;
|
2010-10-14 01:52:27 +00:00
|
|
|
|
|
2011-01-04 15:14:25 +00:00
|
|
|
|
if (strcmp (title ? title : "",
|
|
|
|
|
priv->tearoff_title ? priv->tearoff_title : "") != 0)
|
2010-10-14 01:52:27 +00:00
|
|
|
|
{
|
2010-11-24 09:14:36 +00:00
|
|
|
|
g_free (priv->tearoff_title);
|
|
|
|
|
priv->tearoff_title = g_strdup (title);
|
2010-10-14 01:52:27 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
gtk_combo_box_update_title (combo_box);
|
2010-10-14 01:52:27 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
g_object_notify (G_OBJECT (combo_box), "tearoff-title");
|
2010-10-14 01:52:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_set_popup_fixed_width:
|
|
|
|
|
* @combo_box: a #GtkComboBox
|
|
|
|
|
* @fixed: whether to use a fixed popup width
|
|
|
|
|
*
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* Specifies whether the popup’s width should be a fixed width
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* matching the allocated width of the combo box.
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
gtk_combo_box_set_popup_fixed_width (GtkComboBox *combo_box,
|
|
|
|
|
gboolean fixed)
|
2004-02-05 23:45:21 +00:00
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
GtkComboBoxPrivate *priv;
|
|
|
|
|
|
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
|
|
|
|
priv = combo_box->priv;
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_get_popup_fixed_width:
|
|
|
|
|
* @combo_box: a #GtkComboBox
|
|
|
|
|
*
|
|
|
|
|
* Gets whether the popup uses a fixed width matching
|
|
|
|
|
* the allocated width of the combo box.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the popup uses a fixed width
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_combo_box_get_popup_fixed_width (GtkComboBox *combo_box)
|
2007-05-02 22:19:45 +00:00
|
|
|
|
{
|
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
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
return combo_box->priv->popup_fixed_width;
|
|
|
|
|
}
|
2004-03-08 18:39:44 +00:00
|
|
|
|
|
2004-02-26 20:51:02 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_get_popup_accessible:
|
|
|
|
|
* @combo_box: a #GtkComboBox
|
|
|
|
|
*
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* Gets the accessible object corresponding to the combo box’s popup.
|
2010-11-24 09:14:36 +00:00
|
|
|
|
*
|
|
|
|
|
* This function is mostly intended for use by accessibility technologies;
|
|
|
|
|
* applications should have little use for it.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer none): the accessible object corresponding
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* to the combo box’s popup.
|
2010-11-24 09:14:36 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.6
|
|
|
|
|
*/
|
|
|
|
|
AtkObject*
|
|
|
|
|
gtk_combo_box_get_popup_accessible (GtkComboBox *combo_box)
|
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
GtkComboBoxPrivate *priv;
|
2010-11-24 09:14:36 +00:00
|
|
|
|
AtkObject *atk_obj;
|
2004-02-26 20:51:02 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL);
|
2004-02-26 20:51:02 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
priv = combo_box->priv;
|
|
|
|
|
|
|
|
|
|
if (priv->popup_widget)
|
2004-07-16 20:27:40 +00:00
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
atk_obj = gtk_widget_get_accessible (priv->popup_widget);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
return atk_obj;
|
2004-07-16 20:27:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
return NULL;
|
2004-07-16 20:27:40 +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)
|
2010-11-24 09:14:36 +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
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the current row separator function.
|
2010-11-24 09:14:36 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.6
|
|
|
|
|
*/
|
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
|
|
|
|
{
|
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
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
return combo_box->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:
|
|
|
|
|
* @combo_box: a #GtkComboBox
|
|
|
|
|
* @func: a #GtkTreeViewRowSeparatorFunc
|
|
|
|
|
* @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
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.6
|
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
GtkComboBoxPrivate *priv;
|
|
|
|
|
|
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
|
|
|
|
priv = combo_box->priv;
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
/* Provoke the underlying treeview/menu to rebuild themselves with the new separator func */
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (priv->tree_view)
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->tree_view), NULL);
|
|
|
|
|
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->tree_view), priv->model);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
2005-07-22 03:38:14 +00:00
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
if (GTK_IS_TREE_MENU (priv->popup_widget))
|
2010-11-24 09:14:36 +00:00
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
_gtk_tree_menu_set_model (GTK_TREE_MENU (priv->popup_widget), NULL);
|
|
|
|
|
_gtk_tree_menu_set_model (GTK_TREE_MENU (priv->popup_widget), priv->model);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
}
|
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
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_set_button_sensitivity:
|
|
|
|
|
* @combo_box: a #GtkComboBox
|
|
|
|
|
* @sensitivity: specify the sensitivity of the dropdown button
|
|
|
|
|
*
|
|
|
|
|
* Sets whether the dropdown button of the combo box should be
|
|
|
|
|
* always sensitive (%GTK_SENSITIVITY_ON), never sensitive (%GTK_SENSITIVITY_OFF)
|
|
|
|
|
* or only if there is at least one item to display (%GTK_SENSITIVITY_AUTO).
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.14
|
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
gtk_combo_box_set_button_sensitivity (GtkComboBox *combo_box,
|
|
|
|
|
GtkSensitivityType sensitivity)
|
2004-07-16 20:27:40 +00:00
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
GtkComboBoxPrivate *priv;
|
|
|
|
|
|
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
|
|
|
|
priv = combo_box->priv;
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_get_button_sensitivity:
|
|
|
|
|
* @combo_box: a #GtkComboBox
|
|
|
|
|
*
|
|
|
|
|
* 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
|
2010-11-24 09:14:36 +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.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.14
|
|
|
|
|
**/
|
|
|
|
|
GtkSensitivityType
|
|
|
|
|
gtk_combo_box_get_button_sensitivity (GtkComboBox *combo_box)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), FALSE);
|
2007-12-25 04:04:21 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
return combo_box->priv->button_sensitivity;
|
2004-07-16 20:27:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* gtk_combo_box_get_has_entry:
|
2004-07-16 20:27:40 +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.
|
2010-11-24 09:14:36 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.24
|
|
|
|
|
**/
|
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
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), FALSE);
|
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
return combo_box->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:
|
|
|
|
|
* @combo_box: A #GtkComboBox
|
|
|
|
|
* @text_column: A column in @model to get the strings from for
|
|
|
|
|
* the internal entry
|
2004-07-16 20:27:40 +00:00
|
|
|
|
*
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* Sets the model column which @combo_box should use to get strings from
|
|
|
|
|
* to be @text_column. The column @text_column in the model of @combo_box
|
|
|
|
|
* must be of type %G_TYPE_STRING.
|
|
|
|
|
*
|
|
|
|
|
* This is only relevant if @combo_box has been created with
|
|
|
|
|
* #GtkComboBox:has-entry as %TRUE.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.24
|
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,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gint text_column)
|
2004-05-10 14:07:35 +00:00
|
|
|
|
{
|
2010-11-24 09:14:36 +00:00
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
|
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
|
|
|
|
model = gtk_combo_box_get_model (combo_box);
|
2004-05-10 14:07:35 +00:00
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
g_return_if_fail (text_column >= 0);
|
|
|
|
|
g_return_if_fail (model == NULL || text_column < gtk_tree_model_get_n_columns (model));
|
|
|
|
|
|
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:
|
|
|
|
|
* @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
|
|
|
|
*
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* Since: 2.24
|
2005-11-21 16:01:56 +00:00
|
|
|
|
*/
|
2010-11-24 09:14:36 +00:00
|
|
|
|
gint
|
|
|
|
|
gtk_combo_box_get_entry_text_column (GtkComboBox *combo_box)
|
2005-11-21 16:01:56 +00:00
|
|
|
|
{
|
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
|
|
|
|
|
2010-11-24 09:14:36 +00:00
|
|
|
|
return combo_box->priv->text_column;
|
2005-11-21 16:01:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* gtk_combo_box_set_focus_on_click:
|
|
|
|
|
* @combo: a #GtkComboBox
|
2011-01-04 15:14:25 +00:00
|
|
|
|
* @focus_on_click: whether the combo box grabs focus when clicked
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* with the mouse
|
2011-01-04 15:14:25 +00:00
|
|
|
|
*
|
|
|
|
|
* Sets whether the combo box will grab focus when it is clicked with
|
|
|
|
|
* the mouse. Making mouse clicks not grab focus is useful in places
|
2014-02-07 18:32:47 +00:00
|
|
|
|
* like toolbars where you don’t want the keyboard focus removed from
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* the main area of the application.
|
2005-11-21 16:01:56 +00:00
|
|
|
|
*
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* Since: 2.6
|
2016-06-09 20:37:53 +00:00
|
|
|
|
*
|
|
|
|
|
* Deprecated: 3.20: Use gtk_widget_set_focus_on_click() instead
|
2005-11-21 16:01:56 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
2010-11-24 09:14:36 +00:00
|
|
|
|
gtk_combo_box_set_focus_on_click (GtkComboBox *combo_box,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
gboolean focus_on_click)
|
2010-10-16 09:01:33 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
2011-01-04 15:14:25 +00:00
|
|
|
|
|
2015-10-23 16:39:01 +00:00
|
|
|
|
gtk_widget_set_focus_on_click (GTK_WIDGET (combo_box), focus_on_click);
|
2010-10-16 09:01:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* gtk_combo_box_get_focus_on_click:
|
|
|
|
|
* @combo: a #GtkComboBox
|
2011-01-04 15:14:25 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns whether the combo box grabs focus when it is clicked
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* with the mouse. See gtk_combo_box_set_focus_on_click().
|
2010-10-16 09:01:33 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE if the combo box grabs focus when it is
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* clicked with the mouse.
|
2010-10-23 21:02:40 +00:00
|
|
|
|
*
|
2010-11-24 09:14:36 +00:00
|
|
|
|
* Since: 2.6
|
2016-06-09 20:37:53 +00:00
|
|
|
|
*
|
|
|
|
|
* Deprecated: 3.20: Use gtk_widget_get_focus_on_click() instead
|
2010-11-24 09:14:36 +00:00
|
|
|
|
*/
|
2010-10-16 09:01:33 +00:00
|
|
|
|
gboolean
|
2010-11-24 09:14:36 +00:00
|
|
|
|
gtk_combo_box_get_focus_on_click (GtkComboBox *combo_box)
|
2010-10-16 09:01:33 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), FALSE);
|
2010-11-24 09:14:36 +00:00
|
|
|
|
|
2015-10-23 16:39:01 +00:00
|
|
|
|
return gtk_widget_get_focus_on_click (GTK_WIDGET (combo_box));
|
2010-10-16 09:01:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-25 22:06:46 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_combo_box_buildable_add_child (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
|
|
|
|
const gchar *type)
|
|
|
|
|
{
|
|
|
|
|
if (GTK_IS_WIDGET (child))
|
|
|
|
|
{
|
|
|
|
|
parent_buildable_iface->add_child (buildable, builder, child, type);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_gtk_cell_layout_buildable_add_child (buildable, builder, child, type);
|
|
|
|
|
}
|
2010-10-16 09:01:33 +00:00
|
|
|
|
|
2010-12-06 12:30:00 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_combo_box_buildable_custom_tag_start (GtkBuildable *buildable,
|
2011-01-04 15:14:25 +00:00
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
|
|
|
|
const gchar *tagname,
|
|
|
|
|
GMarkupParser *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,
|
|
|
|
|
const gchar *tagname,
|
|
|
|
|
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,
|
|
|
|
|
const gchar *childname)
|
2010-12-06 12:30:00 +00:00
|
|
|
|
{
|
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (buildable);
|
|
|
|
|
|
|
|
|
|
if (combo_box->priv->has_entry && strcmp (childname, "entry") == 0)
|
|
|
|
|
return G_OBJECT (gtk_bin_get_child (GTK_BIN (buildable)));
|
|
|
|
|
|
|
|
|
|
return parent_buildable_iface->get_internal_child (buildable, builder, childname);
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-30 05:07:08 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_set_id_column:
|
|
|
|
|
* @combo_box: A #GtkComboBox
|
|
|
|
|
* @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
|
|
|
|
|
* for values from. The column @id_column in the model of @combo_box
|
|
|
|
|
* must be of type %G_TYPE_STRING.
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_combo_box_set_id_column (GtkComboBox *combo_box,
|
|
|
|
|
gint id_column)
|
|
|
|
|
{
|
2015-12-22 02:32:14 +00:00
|
|
|
|
GtkComboBoxPrivate *priv;
|
2010-11-30 05:07:08 +00:00
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
|
|
|
|
|
2015-12-22 02:32:14 +00:00
|
|
|
|
priv = combo_box->priv;
|
|
|
|
|
|
2010-11-30 05:07:08 +00:00
|
|
|
|
if (id_column != priv->id_column)
|
|
|
|
|
{
|
|
|
|
|
model = gtk_combo_box_get_model (combo_box);
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (id_column >= 0);
|
|
|
|
|
g_return_if_fail (model == NULL ||
|
|
|
|
|
id_column < gtk_tree_model_get_n_columns (model));
|
|
|
|
|
|
|
|
|
|
priv->id_column = id_column;
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (combo_box), "id-column");
|
|
|
|
|
g_object_notify (G_OBJECT (combo_box), "active-id");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_get_id_column:
|
|
|
|
|
* @combo_box: A #GtkComboBox
|
|
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
gint
|
|
|
|
|
gtk_combo_box_get_id_column (GtkComboBox *combo_box)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), 0);
|
|
|
|
|
|
|
|
|
|
return combo_box->priv->id_column;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_get_active_id:
|
|
|
|
|
* @combo_box: a #GtkComboBox
|
|
|
|
|
*
|
|
|
|
|
* Returns the ID of the active row of @combo_box. This value is taken
|
2011-04-26 11:59:53 +00:00
|
|
|
|
* from the active row and the column specified by the #GtkComboBox:id-column
|
2010-11-30 05:07:08 +00:00
|
|
|
|
* property of @combo_box (see gtk_combo_box_set_id_column()).
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
2011-04-26 11:59:53 +00:00
|
|
|
|
* If the #GtkComboBox: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
|
2010-11-30 05:07:08 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
**/
|
|
|
|
|
const gchar *
|
|
|
|
|
gtk_combo_box_get_active_id (GtkComboBox *combo_box)
|
|
|
|
|
{
|
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
gint column;
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
column = combo_box->priv->id_column;
|
|
|
|
|
|
|
|
|
|
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))
|
|
|
|
|
{
|
|
|
|
|
const gchar *interned;
|
|
|
|
|
gchar *id;
|
|
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, &iter, column, &id, -1);
|
|
|
|
|
interned = g_intern_string (id);
|
|
|
|
|
g_free (id);
|
|
|
|
|
|
|
|
|
|
return interned;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_combo_box_set_active_id:
|
|
|
|
|
* @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
|
|
|
|
|
* @active_id, or unsets the active row if @active_id is %NULL. Rows having
|
|
|
|
|
* a %NULL ID string cannot be made active by this function.
|
2010-11-30 05:07:08 +00:00
|
|
|
|
*
|
2011-04-26 11:59:53 +00:00
|
|
|
|
* If the #GtkComboBox:id-column property of @combo_box is unset or if no
|
|
|
|
|
* row has the given ID then the function does nothing and returns %FALSE.
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
2010-11-30 05:07:08 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
**/
|
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,
|
|
|
|
|
const gchar *active_id)
|
|
|
|
|
{
|
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
GtkTreeIter iter;
|
2011-04-26 11:59:53 +00:00
|
|
|
|
gboolean match = FALSE;
|
2010-11-30 05:07:08 +00:00
|
|
|
|
gint column;
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
column = combo_box->priv->id_column;
|
|
|
|
|
|
|
|
|
|
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 {
|
|
|
|
|
gchar *id;
|
|
|
|
|
|
|
|
|
|
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 *
|
|
|
|
|
gtk_combo_box_get_popup (GtkComboBox *combo)
|
|
|
|
|
{
|
|
|
|
|
if (combo->priv->popup_window)
|
|
|
|
|
return combo->priv->popup_window;
|
|
|
|
|
else
|
|
|
|
|
return combo->priv->popup_widget;
|
|
|
|
|
}
|