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
|
|
|
|
* License along with this library; if not, write to the
|
2003-09-26 21:57:06 +00:00
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
2003-10-23 18:25:53 +00:00
|
|
|
#include "gtkcombobox.h"
|
2004-02-29 00:08:04 +00:00
|
|
|
|
|
|
|
#include "gtkarrow.h"
|
|
|
|
#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"
|
2004-02-29 00:08:04 +00:00
|
|
|
#include "gtkeventbox.h"
|
2003-10-23 18:25:53 +00:00
|
|
|
#include "gtkframe.h"
|
2004-04-14 20:26:26 +00:00
|
|
|
#include "gtkhbox.h"
|
2004-02-29 00:08:04 +00:00
|
|
|
#include "gtkliststore.h"
|
|
|
|
#include "gtkmain.h"
|
|
|
|
#include "gtkmenu.h"
|
2004-07-26 04:50:07 +00:00
|
|
|
#include "gtkscrolledwindow.h"
|
2004-07-07 15:15:35 +00:00
|
|
|
#include "gtkseparatormenuitem.h"
|
2004-05-10 14:07:35 +00:00
|
|
|
#include "gtktearoffmenuitem.h"
|
2003-10-23 18:25:53 +00:00
|
|
|
#include "gtktogglebutton.h"
|
2004-02-29 00:08:04 +00:00
|
|
|
#include "gtktreeselection.h"
|
2003-10-23 18:25:53 +00:00
|
|
|
#include "gtkvseparator.h"
|
|
|
|
#include "gtkwindow.h"
|
2005-03-22 02:14:55 +00:00
|
|
|
#include "gtkprivate.h"
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
#include <gdk/gdkkeysyms.h>
|
|
|
|
|
|
|
|
#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"
|
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
#include "gtktreeprivate.h"
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
/* WELCOME, to THE house of evil code */
|
|
|
|
|
|
|
|
typedef struct _ComboCellInfo ComboCellInfo;
|
|
|
|
struct _ComboCellInfo
|
|
|
|
{
|
|
|
|
GtkCellRenderer *cell;
|
|
|
|
GSList *attributes;
|
|
|
|
|
2003-10-01 20:51:54 +00:00
|
|
|
GtkCellLayoutDataFunc func;
|
|
|
|
gpointer func_data;
|
|
|
|
GDestroyNotify destroy;
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
guint expand : 1;
|
|
|
|
guint pack : 1;
|
|
|
|
};
|
|
|
|
|
2003-10-11 23:12:20 +00:00
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
struct _GtkComboBoxPrivate
|
|
|
|
{
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
|
|
|
gint col_column;
|
|
|
|
gint row_column;
|
|
|
|
|
|
|
|
gint wrap_width;
|
2007-03-08 02:36:46 +00:00
|
|
|
GtkShadowType shadow_type;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2008-12-13 08:11:54 +00:00
|
|
|
gint active; /* Only temporary */
|
2004-08-02 19:15:05 +00:00
|
|
|
GtkTreeRowReference *active_row;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
GtkWidget *tree_view;
|
|
|
|
GtkTreeViewColumn *column;
|
|
|
|
|
|
|
|
GtkWidget *cell_view;
|
|
|
|
GtkWidget *cell_view_frame;
|
|
|
|
|
|
|
|
GtkWidget *button;
|
2004-04-14 20:26:26 +00:00
|
|
|
GtkWidget *box;
|
2003-09-26 21:57:06 +00:00
|
|
|
GtkWidget *arrow;
|
|
|
|
GtkWidget *separator;
|
|
|
|
|
|
|
|
GtkWidget *popup_widget;
|
|
|
|
GtkWidget *popup_window;
|
2004-07-26 04:50:07 +00:00
|
|
|
GtkWidget *scrolled_window;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
guint inserted_id;
|
|
|
|
guint deleted_id;
|
2004-03-02 18:56:10 +00:00
|
|
|
guint reordered_id;
|
|
|
|
guint changed_id;
|
2004-07-16 20:27:40 +00:00
|
|
|
guint popup_idle_id;
|
2007-12-25 04:04:21 +00:00
|
|
|
guint activate_button;
|
|
|
|
guint32 activate_time;
|
2004-07-26 04:50:07 +00:00
|
|
|
guint scroll_timer;
|
2005-07-22 03:38:14 +00:00
|
|
|
guint resize_idle_id;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
gint width;
|
2006-06-24 17:53:45 +00:00
|
|
|
gint height;
|
2003-09-26 21:57:06 +00:00
|
|
|
GSList *cells;
|
|
|
|
|
|
|
|
guint popup_in_progress : 1;
|
2006-03-09 20:20:30 +00:00
|
|
|
guint popup_shown : 1;
|
2004-05-10 14:07:35 +00:00
|
|
|
guint add_tearoffs : 1;
|
2004-07-16 20:27:40 +00:00
|
|
|
guint has_frame : 1;
|
|
|
|
guint is_cell_renderer : 1;
|
|
|
|
guint editing_canceled : 1;
|
2004-07-26 04:50:07 +00:00
|
|
|
guint auto_scroll : 1;
|
2004-08-16 05:43:50 +00:00
|
|
|
guint focus_on_click : 1;
|
2008-08-04 23:40:36 +00:00
|
|
|
guint button_sensitivity : 2;
|
2004-07-30 20:55:17 +00:00
|
|
|
|
|
|
|
GtkTreeViewRowSeparatorFunc row_separator_func;
|
|
|
|
gpointer row_separator_data;
|
2008-06-18 09:12:32 +00:00
|
|
|
GDestroyNotify row_separator_destroy;
|
2005-11-21 16:01:56 +00:00
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
GdkDevice *grab_pointer;
|
|
|
|
GdkDevice *grab_keyboard;
|
|
|
|
|
2005-11-21 16:01:56 +00:00
|
|
|
gchar *tearoff_title;
|
2003-09-26 21:57:06 +00:00
|
|
|
};
|
|
|
|
|
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
|
|
|
|
* cell_view_frame -> NULL
|
|
|
|
* button -> GtkToggleButton set_parent to combo
|
|
|
|
* arrow -> GtkArrow set_parent to button
|
|
|
|
* separator -> GtkVSepator 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
|
|
|
|
* cell_view_frame -> NULL
|
|
|
|
* button -> GtkToggleButton set_parent to combo
|
|
|
|
* arrow -> GtkArrow, child of button
|
|
|
|
* separator -> NULL
|
|
|
|
* 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
|
|
|
|
* cell_view_frame -> GtkFrame, set parent to combo
|
|
|
|
* button -> GtkToggleButton, set_parent to combo
|
|
|
|
* arrow -> GtkArrow, child of button
|
|
|
|
* separator -> NULL
|
|
|
|
* 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
|
|
|
|
* cell_view_frame -> NULL
|
|
|
|
* button -> GtkToggleButton, set_parent to combo
|
|
|
|
* arrow -> GtkArrow, child of button
|
|
|
|
* separator -> NULL
|
|
|
|
* 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
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
enum {
|
|
|
|
CHANGED,
|
2006-10-12 13:04:44 +00:00
|
|
|
MOVE_ACTIVE,
|
|
|
|
POPUP,
|
2007-05-18 11:33:13 +00:00
|
|
|
POPDOWN,
|
2003-09-26 21:57:06 +00:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PROP_0,
|
|
|
|
PROP_MODEL,
|
|
|
|
PROP_WRAP_WIDTH,
|
|
|
|
PROP_ROW_SPAN_COLUMN,
|
|
|
|
PROP_COLUMN_SPAN_COLUMN,
|
2004-05-10 14:07:35 +00:00
|
|
|
PROP_ACTIVE,
|
2004-07-16 20:27:40 +00:00
|
|
|
PROP_ADD_TEAROFFS,
|
2005-11-21 16:01:56 +00:00
|
|
|
PROP_TEAROFF_TITLE,
|
2004-08-16 05:43:50 +00:00
|
|
|
PROP_HAS_FRAME,
|
2006-03-09 20:20:30 +00:00
|
|
|
PROP_FOCUS_ON_CLICK,
|
2008-08-04 23:40:36 +00:00
|
|
|
PROP_POPUP_SHOWN,
|
2009-10-21 16:40:19 +00:00
|
|
|
PROP_BUTTON_SENSITIVITY,
|
|
|
|
PROP_EDITING_CANCELED
|
2003-09-26 21:57:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static guint combo_box_signals[LAST_SIGNAL] = {0,};
|
|
|
|
|
|
|
|
#define BONUS_PADDING 4
|
2004-07-26 04:50:07 +00:00
|
|
|
#define SCROLL_TIME 100
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
/* common */
|
2005-11-10 21:17:19 +00:00
|
|
|
|
2003-10-01 20:51:54 +00:00
|
|
|
static void gtk_combo_box_cell_layout_init (GtkCellLayoutIface *iface);
|
2004-07-16 20:27:40 +00:00
|
|
|
static void gtk_combo_box_cell_editable_init (GtkCellEditableIface *iface);
|
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);
|
|
|
|
static void gtk_combo_box_destroy (GtkObject *object);
|
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);
|
|
|
|
|
2004-03-04 20:43:41 +00:00
|
|
|
static void gtk_combo_box_state_changed (GtkWidget *widget,
|
2005-07-22 03:38:14 +00:00
|
|
|
GtkStateType previous);
|
|
|
|
static void gtk_combo_box_grab_focus (GtkWidget *widget);
|
2003-09-26 21:57:06 +00:00
|
|
|
static void gtk_combo_box_style_set (GtkWidget *widget,
|
2004-02-29 00:08:04 +00:00
|
|
|
GtkStyle *previous);
|
2003-09-26 21:57:06 +00:00
|
|
|
static void gtk_combo_box_button_toggled (GtkWidget *widget,
|
|
|
|
gpointer data);
|
2004-12-24 03:44:17 +00:00
|
|
|
static void gtk_combo_box_button_state_changed (GtkWidget *widget,
|
|
|
|
GtkStateType 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 ComboCellInfo *gtk_combo_box_get_cell_info (GtkComboBox *combo_box,
|
|
|
|
GtkCellRenderer *cell);
|
|
|
|
|
|
|
|
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);
|
2004-03-03 22:30:36 +00:00
|
|
|
static void gtk_combo_box_menu_position_below (GtkMenu *menu,
|
|
|
|
gint *x,
|
|
|
|
gint *y,
|
|
|
|
gint *push_in,
|
|
|
|
gpointer user_data);
|
|
|
|
static void gtk_combo_box_menu_position_over (GtkMenu *menu,
|
|
|
|
gint *x,
|
|
|
|
gint *y,
|
|
|
|
gint *push_in,
|
|
|
|
gpointer user_data);
|
2003-09-26 21:57:06 +00:00
|
|
|
static void gtk_combo_box_menu_position (GtkMenu *menu,
|
|
|
|
gint *x,
|
|
|
|
gint *y,
|
|
|
|
gint *push_in,
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
static gint gtk_combo_box_calc_requested_width (GtkComboBox *combo_box,
|
|
|
|
GtkTreePath *path);
|
Fixes based on comments from Owen Taylor, #125264.
Tue Nov 18 19:47:59 2003 Kristian Rietveld <kris@gtk.org>
Fixes based on comments from Owen Taylor, #125264.
* gtk/gtkcellview.[ch] (gtk_cell_view_finalize): remove unused
variable,
(gtk_cell_view_set_value), (gtk_cell_view_set_displayed_model): queue
a resize,
(gtk_cell_view_get_size_of_row): new function,
(gtk_cell_view_set_value), (gtk_cell_view_set_valuesv),
(gtk_cell_view_set_values), (gtk_cell_view_set_model),
(gtk_cell_view_set_displayed_row), (gtk_cell_view_get_displayed_row):
s/cellview/cell_view/ in the function definitions, so they match
with the header file.
* gtk/gtkcombobox.c (gtk_combo_box_remeasure): remove the resize
flag again (:, and use gtk_cell_view_get_size_of_row instead of
the measurer, remove _set_size_request call,
(gtk_combo_box_calc_requested_width): use gtk_cell_view_get_size_of_row
instead of the measurer,
(gtk_combo_box_style_set): queue a resize,
(gtk_combo_box_size_request): update of _remeasure call,
(gtk_combo_box_init), (gtk_combo_box_cell_layout_pack_start),
(gtk_combo_box_cell_layout_pack_end),
(gtk_combo_box_cell_layout_clear),
(gtk_combo_box_set_model): get rid of the measurer,
(gtk_combo_box_cell_layout_add_attribute),
(gtk_combo_box_cell_layout_set_cell_data_func),
(gtk_combo_box_cell_layout_clear_attributes): ditto and queue a
resize instead of calling _remeasure.
2003-11-18 19:02:30 +00:00
|
|
|
static void gtk_combo_box_remeasure (GtkComboBox *combo_box);
|
2003-09-26 21:57:06 +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 gtk_combo_box_unset_model (GtkComboBox *combo_box);
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
static void gtk_combo_box_size_request (GtkWidget *widget,
|
|
|
|
GtkRequisition *requisition);
|
|
|
|
static void gtk_combo_box_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation);
|
|
|
|
static void gtk_combo_box_forall (GtkContainer *container,
|
|
|
|
gboolean include_internals,
|
|
|
|
GtkCallback callback,
|
|
|
|
gpointer callback_data);
|
|
|
|
static gboolean gtk_combo_box_expose_event (GtkWidget *widget,
|
|
|
|
GdkEventExpose *event);
|
2003-11-17 22:24:57 +00:00
|
|
|
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,
|
2004-08-02 19:15:05 +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);
|
2005-04-01 20:53:04 +00:00
|
|
|
static gchar * gtk_combo_box_real_get_active_text (GtkComboBox *combo_box);
|
2006-10-12 13:04:44 +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);
|
2007-05-18 11:33:13 +00:00
|
|
|
static gboolean gtk_combo_box_real_popdown (GtkComboBox *combo_box);
|
2004-07-16 20:27:40 +00:00
|
|
|
|
2004-03-02 18:56:10 +00:00
|
|
|
/* listening to the model */
|
|
|
|
static void gtk_combo_box_model_row_inserted (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gpointer user_data);
|
|
|
|
static void gtk_combo_box_model_row_deleted (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
gpointer user_data);
|
|
|
|
static void gtk_combo_box_model_rows_reordered (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gint *new_order,
|
|
|
|
gpointer user_data);
|
|
|
|
static void gtk_combo_box_model_row_changed (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gpointer data);
|
2004-08-02 19:15:05 +00:00
|
|
|
static void gtk_combo_box_model_row_expanded (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gpointer data);
|
2004-03-02 18:56:10 +00:00
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
/* list */
|
2004-02-29 01:33:01 +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,
|
|
|
|
gint x,
|
|
|
|
gint y);
|
|
|
|
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,
|
|
|
|
GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
gboolean path_currently_selected,
|
|
|
|
gpointer data);
|
|
|
|
|
2003-09-26 21:57:06 +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 */
|
|
|
|
static void gtk_combo_box_menu_setup (GtkComboBox *combo_box,
|
2004-03-08 18:39:44 +00:00
|
|
|
gboolean add_children);
|
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_menu_fill (GtkComboBox *combo_box);
|
2004-08-02 19:15:05 +00:00
|
|
|
static void gtk_combo_box_menu_fill_level (GtkComboBox *combo_box,
|
|
|
|
GtkWidget *menu,
|
|
|
|
GtkTreeIter *iter);
|
2005-11-21 16:01:56 +00:00
|
|
|
static void gtk_combo_box_update_title (GtkComboBox *combo_box);
|
2003-09-26 21:57:06 +00:00
|
|
|
static void gtk_combo_box_menu_destroy (GtkComboBox *combo_box);
|
|
|
|
|
|
|
|
static void gtk_combo_box_relayout_item (GtkComboBox *combo_box,
|
2004-08-03 05:22:21 +00:00
|
|
|
GtkWidget *item,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
GtkWidget *last);
|
2003-09-26 21:57:06 +00:00
|
|
|
static void gtk_combo_box_relayout (GtkComboBox *combo_box);
|
|
|
|
|
|
|
|
static gboolean gtk_combo_box_menu_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *event,
|
|
|
|
gpointer user_data);
|
|
|
|
static void gtk_combo_box_menu_item_activate (GtkWidget *item,
|
|
|
|
gpointer user_data);
|
2009-09-09 07:43:30 +00:00
|
|
|
|
|
|
|
static void gtk_combo_box_update_sensitivity (GtkComboBox *combo_box);
|
2003-09-26 21:57:06 +00:00
|
|
|
static void gtk_combo_box_menu_row_inserted (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gpointer user_data);
|
|
|
|
static void gtk_combo_box_menu_row_deleted (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
gpointer user_data);
|
2004-03-02 18:56:10 +00:00
|
|
|
static void gtk_combo_box_menu_rows_reordered (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gint *new_order,
|
|
|
|
gpointer user_data);
|
2003-09-26 21:57:06 +00:00
|
|
|
static void gtk_combo_box_menu_row_changed (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gpointer data);
|
2004-03-04 23:35:31 +00:00
|
|
|
static gboolean gtk_combo_box_menu_key_press (GtkWidget *widget,
|
|
|
|
GdkEventKey *event,
|
|
|
|
gpointer data);
|
2004-08-02 19:15:05 +00:00
|
|
|
static void gtk_combo_box_menu_popup (GtkComboBox *combo_box,
|
|
|
|
guint button,
|
|
|
|
guint32 activate_time);
|
|
|
|
static GtkWidget *gtk_cell_view_menu_item_new (GtkComboBox *combo_box,
|
|
|
|
GtkTreeModel *model,
|
|
|
|
GtkTreeIter *iter);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2003-10-01 20:51:54 +00:00
|
|
|
/* cell layout */
|
|
|
|
static void gtk_combo_box_cell_layout_pack_start (GtkCellLayout *layout,
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
gboolean expand);
|
|
|
|
static void gtk_combo_box_cell_layout_pack_end (GtkCellLayout *layout,
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
gboolean expand);
|
2007-09-07 11:02:04 +00:00
|
|
|
static GList *gtk_combo_box_cell_layout_get_cells (GtkCellLayout *layout);
|
2003-10-01 20:51:54 +00:00
|
|
|
static void gtk_combo_box_cell_layout_clear (GtkCellLayout *layout);
|
|
|
|
static void gtk_combo_box_cell_layout_add_attribute (GtkCellLayout *layout,
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
const gchar *attribute,
|
|
|
|
gint column);
|
|
|
|
static void gtk_combo_box_cell_layout_set_cell_data_func (GtkCellLayout *layout,
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
GtkCellLayoutDataFunc func,
|
|
|
|
gpointer func_data,
|
|
|
|
GDestroyNotify destroy);
|
|
|
|
static void gtk_combo_box_cell_layout_clear_attributes (GtkCellLayout *layout,
|
|
|
|
GtkCellRenderer *cell);
|
2003-12-19 22:47:20 +00:00
|
|
|
static void gtk_combo_box_cell_layout_reorder (GtkCellLayout *layout,
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
gint position);
|
2004-02-05 20:35:57 +00:00
|
|
|
static gboolean gtk_combo_box_mnemonic_activate (GtkWidget *widget,
|
|
|
|
gboolean group_cycling);
|
2003-10-01 20:51:54 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
static void gtk_combo_box_sync_cells (GtkComboBox *combo_box,
|
|
|
|
GtkCellLayout *cell_layout);
|
|
|
|
static void combo_cell_data_func (GtkCellLayout *cell_layout,
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
GtkTreeModel *tree_model,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gpointer data);
|
2005-11-10 21:17:19 +00:00
|
|
|
static void gtk_combo_box_child_show (GtkWidget *widget,
|
2006-03-09 20:20:30 +00:00
|
|
|
GtkComboBox *combo_box);
|
2005-11-10 21:17:19 +00:00
|
|
|
static void gtk_combo_box_child_hide (GtkWidget *widget,
|
2006-03-09 20:20:30 +00:00
|
|
|
GtkComboBox *combo_box);
|
2005-11-10 21:17:19 +00:00
|
|
|
|
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
|
|
|
/* GtkBuildable method implementation */
|
|
|
|
static GtkBuildableIface *parent_buildable_iface;
|
|
|
|
|
|
|
|
static void gtk_combo_box_buildable_init (GtkBuildableIface *iface);
|
|
|
|
static gboolean gtk_combo_box_buildable_custom_tag_start (GtkBuildable *buildable,
|
|
|
|
GtkBuilder *builder,
|
|
|
|
GObject *child,
|
|
|
|
const gchar *tagname,
|
|
|
|
GMarkupParser *parser,
|
|
|
|
gpointer *data);
|
|
|
|
static void gtk_combo_box_buildable_custom_tag_end (GtkBuildable *buildable,
|
|
|
|
GtkBuilder *builder,
|
|
|
|
GObject *child,
|
|
|
|
const gchar *tagname,
|
|
|
|
gpointer *data);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-07-16 20:27:40 +00:00
|
|
|
/* GtkCellEditable method implementations */
|
|
|
|
static void gtk_combo_box_start_editing (GtkCellEditable *cell_editable,
|
|
|
|
GdkEvent *event);
|
|
|
|
|
|
|
|
|
2006-05-02 23:56:43 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkComboBox, gtk_combo_box, GTK_TYPE_BIN,
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_LAYOUT,
|
|
|
|
gtk_combo_box_cell_layout_init)
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_EDITABLE,
|
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
|
|
|
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
|
|
|
|
|
|
|
/* common */
|
|
|
|
static void
|
|
|
|
gtk_combo_box_class_init (GtkComboBoxClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class;
|
2004-02-24 00:07:15 +00:00
|
|
|
GtkObjectClass *gtk_object_class;
|
2003-09-26 21:57:06 +00:00
|
|
|
GtkContainerClass *container_class;
|
|
|
|
GtkWidgetClass *widget_class;
|
2006-10-12 13:04:44 +00:00
|
|
|
GtkBindingSet *binding_set;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2005-04-01 20:53:04 +00:00
|
|
|
klass->get_active_text = gtk_combo_box_real_get_active_text;
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
container_class = (GtkContainerClass *)klass;
|
|
|
|
container_class->forall = gtk_combo_box_forall;
|
|
|
|
container_class->add = gtk_combo_box_add;
|
2004-03-13 00:36:27 +00:00
|
|
|
container_class->remove = gtk_combo_box_remove;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
widget_class = (GtkWidgetClass *)klass;
|
|
|
|
widget_class->size_allocate = gtk_combo_box_size_allocate;
|
|
|
|
widget_class->size_request = gtk_combo_box_size_request;
|
|
|
|
widget_class->expose_event = gtk_combo_box_expose_event;
|
2003-11-17 22:24:57 +00:00
|
|
|
widget_class->scroll_event = gtk_combo_box_scroll_event;
|
2004-02-05 20:35:57 +00:00
|
|
|
widget_class->mnemonic_activate = gtk_combo_box_mnemonic_activate;
|
2005-04-06 04:01:19 +00:00
|
|
|
widget_class->grab_focus = gtk_combo_box_grab_focus;
|
2004-02-28 22:28:37 +00:00
|
|
|
widget_class->style_set = gtk_combo_box_style_set;
|
2004-03-04 20:43:41 +00:00
|
|
|
widget_class->state_changed = gtk_combo_box_state_changed;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-02-24 00:07:15 +00:00
|
|
|
gtk_object_class = (GtkObjectClass *)klass;
|
|
|
|
gtk_object_class->destroy = gtk_combo_box_destroy;
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
object_class = (GObjectClass *)klass;
|
2007-05-02 22:19:45 +00:00
|
|
|
object_class->dispose = gtk_combo_box_dispose;
|
2004-02-05 23:45:21 +00:00
|
|
|
object_class->finalize = gtk_combo_box_finalize;
|
2003-09-26 21:57:06 +00:00
|
|
|
object_class->set_property = gtk_combo_box_set_property;
|
|
|
|
object_class->get_property = gtk_combo_box_get_property;
|
|
|
|
|
|
|
|
/* signals */
|
2004-11-12 22:57:09 +00:00
|
|
|
/**
|
|
|
|
* GtkComboBox::changed:
|
|
|
|
* @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
|
|
|
|
* a different item from the list, or due to a
|
|
|
|
* call to gtk_combo_box_set_active_iter().
|
2006-02-10 18:53:35 +00:00
|
|
|
* It will also be emitted while typing into a GtkComboBoxEntry,
|
|
|
|
* as well as when selecting an item from the GtkComboBoxEntry's list.
|
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
|
|
|
|
*
|
|
|
|
* The ::move-active signal is a
|
|
|
|
* <link linkend="keybinding-signals">keybinding signal</link>
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
* The ::popup signal is a
|
|
|
|
* <link linkend="keybinding-signals">keybinding signal</link>
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
* The ::popdown signal is a
|
|
|
|
* <link linkend="keybinding-signals">keybinding signal</link>
|
|
|
|
* 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
|
|
|
|
2006-10-12 13:04:44 +00:00
|
|
|
/* key bindings */
|
|
|
|
binding_set = gtk_binding_set_by_class (widget_class);
|
|
|
|
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_Down, GDK_MOD1_MASK,
|
|
|
|
"popup", 0);
|
2007-05-18 11:33:13 +00:00
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KP_Down, GDK_MOD1_MASK,
|
|
|
|
"popup", 0);
|
|
|
|
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_Up, GDK_MOD1_MASK,
|
|
|
|
"popdown", 0);
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KP_Up, GDK_MOD1_MASK,
|
|
|
|
"popdown", 0);
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0,
|
|
|
|
"popdown", 0);
|
2006-10-12 13:04:44 +00:00
|
|
|
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_Up, 0,
|
2006-10-12 13:48:07 +00:00
|
|
|
"move-active", 1,
|
2006-10-12 13:04:44 +00:00
|
|
|
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_UP);
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KP_Up, 0,
|
2006-10-12 13:48:07 +00:00
|
|
|
"move-active", 1,
|
2006-10-12 13:04:44 +00:00
|
|
|
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_UP);
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_Page_Up, 0,
|
2006-10-12 13:48:07 +00:00
|
|
|
"move-active", 1,
|
2006-10-12 13:04:44 +00:00
|
|
|
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_PAGE_UP);
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KP_Page_Up, 0,
|
2006-10-12 13:48:07 +00:00
|
|
|
"move-active", 1,
|
2006-10-12 13:04:44 +00:00
|
|
|
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_PAGE_UP);
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_Home, 0,
|
2006-10-12 13:48:07 +00:00
|
|
|
"move-active", 1,
|
2006-10-12 13:04:44 +00:00
|
|
|
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_START);
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KP_Home, 0,
|
2006-10-12 13:48:07 +00:00
|
|
|
"move-active", 1,
|
2006-10-12 13:04:44 +00:00
|
|
|
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_START);
|
|
|
|
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_Down, 0,
|
2006-10-12 13:48:07 +00:00
|
|
|
"move-active", 1,
|
2006-10-12 13:04:44 +00:00
|
|
|
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_DOWN);
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KP_Down, 0,
|
2006-10-12 13:48:07 +00:00
|
|
|
"move-active", 1,
|
2006-10-12 13:04:44 +00:00
|
|
|
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_DOWN);
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_Page_Down, 0,
|
2006-10-12 13:48:07 +00:00
|
|
|
"move-active", 1,
|
2006-10-12 13:04:44 +00:00
|
|
|
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_PAGE_DOWN);
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KP_Page_Down, 0,
|
2006-10-12 13:48:07 +00:00
|
|
|
"move-active", 1,
|
2006-10-12 13:04:44 +00:00
|
|
|
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_PAGE_DOWN);
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_End, 0,
|
2006-10-12 13:48:07 +00:00
|
|
|
"move-active", 1,
|
2006-10-12 13:04:44 +00:00
|
|
|
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_END);
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KP_End, 0,
|
2006-10-12 13:48:07 +00:00
|
|
|
"move-active", 1,
|
2006-10-12 13:04:44 +00:00
|
|
|
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_END);
|
|
|
|
|
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
|
|
|
|
* in the list.
|
|
|
|
*
|
|
|
|
* 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,
|
2005-03-22 02:14:55 +00:00
|
|
|
GTK_PARAM_READWRITE));
|
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,
|
2005-03-22 02:14:55 +00:00
|
|
|
GTK_PARAM_READWRITE));
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-11-12 22:57:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GtkComboBox:row-span-column:
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2007-03-12 06:04:44 +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
|
|
|
|
* 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,
|
2005-03-22 02:14:55 +00:00
|
|
|
GTK_PARAM_READWRITE));
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-11-12 22:57:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GtkComboBox:column-span-column:
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* The values of that column are used to determine how many columns a value
|
|
|
|
* in the list will span.
|
|
|
|
*
|
|
|
|
* 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,
|
2005-03-22 02:14:55 +00:00
|
|
|
GTK_PARAM_READWRITE));
|
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,
|
2007-03-12 06:04:44 +00:00
|
|
|
* this property has the value
|
2010-06-28 18:15:10 +00:00
|
|
|
* <literal>gtk_tree_path_get_indices (path)[0]</literal>,
|
2004-11-12 22:57:09 +00:00
|
|
|
* where <literal>path</literal> is the #GtkTreePath of the active item.
|
|
|
|
*
|
|
|
|
* 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,
|
2005-03-22 02:14:55 +00:00
|
|
|
GTK_PARAM_READWRITE));
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-05-10 14:07:35 +00:00
|
|
|
/**
|
|
|
|
* GtkComboBox:add-tearoffs:
|
|
|
|
*
|
2004-11-12 22:57:09 +00:00
|
|
|
* The add-tearoffs property controls whether generated menus
|
2004-05-10 14:07:35 +00:00
|
|
|
* have tearoff menu items.
|
|
|
|
*
|
|
|
|
* Note that this only affects menu style combo boxes.
|
|
|
|
*
|
|
|
|
* Since: 2.6
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_ADD_TEAROFFS,
|
|
|
|
g_param_spec_boolean ("add-tearoffs",
|
|
|
|
P_("Add tearoffs to menus"),
|
2004-07-16 20:27:40 +00:00
|
|
|
P_("Whether dropdowns should have a tearoff menu item"),
|
2004-05-10 14:07:35 +00:00
|
|
|
FALSE,
|
2005-03-22 02:14:55 +00:00
|
|
|
GTK_PARAM_READWRITE));
|
2004-05-10 14:07:35 +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,
|
|
|
|
g_param_spec_boolean ("has-frame",
|
|
|
|
P_("Has Frame"),
|
|
|
|
P_("Whether the combo box draws a frame around the child"),
|
|
|
|
TRUE,
|
2005-03-22 02:14:55 +00:00
|
|
|
GTK_PARAM_READWRITE));
|
2004-07-16 20:27:40 +00:00
|
|
|
|
2004-08-16 05:43:50 +00:00
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_FOCUS_ON_CLICK,
|
2005-03-09 06:15:13 +00:00
|
|
|
g_param_spec_boolean ("focus-on-click",
|
2004-08-16 05:43:50 +00:00
|
|
|
P_("Focus on click"),
|
|
|
|
P_("Whether the combo box grabs focus when it is clicked with the mouse"),
|
|
|
|
TRUE,
|
2005-03-22 02:14:55 +00:00
|
|
|
GTK_PARAM_READWRITE));
|
2004-08-16 05:43:50 +00:00
|
|
|
|
2005-11-21 16:01:56 +00:00
|
|
|
/**
|
|
|
|
* GtkComboBox:tearoff-title:
|
|
|
|
*
|
|
|
|
* A title that may be displayed by the window manager
|
|
|
|
* when the popup is torn-off.
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
|
|
|
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,
|
2005-11-21 16:01:56 +00:00
|
|
|
GTK_PARAM_READWRITE));
|
|
|
|
|
|
|
|
|
2006-03-09 20:20:30 +00:00
|
|
|
/**
|
|
|
|
* GtkComboBox:popup-shown:
|
|
|
|
*
|
|
|
|
* Whether the combo boxes dropdown is popped up.
|
|
|
|
* Note that this property is mainly useful, because
|
|
|
|
* it allows you to connect to notify::popup-shown.
|
|
|
|
*
|
|
|
|
* 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,
|
|
|
|
GTK_PARAM_READWRITE));
|
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
gtk_widget_class_install_style_property (widget_class,
|
|
|
|
g_param_spec_int ("arrow-size",
|
|
|
|
P_("Arrow Size"),
|
|
|
|
P_("The minimum size of the arrow in the combo box"),
|
|
|
|
0,
|
|
|
|
G_MAXINT,
|
|
|
|
15,
|
|
|
|
GTK_PARAM_READABLE));
|
|
|
|
|
2007-03-08 02:36:46 +00:00
|
|
|
/**
|
|
|
|
* GtkComboBox:shadow-type:
|
|
|
|
*
|
|
|
|
* Which kind of shadow to draw around the combo box.
|
|
|
|
*
|
|
|
|
* Since: 2.12
|
|
|
|
*/
|
|
|
|
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,
|
|
|
|
GTK_PARAM_READABLE));
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
g_type_class_add_private (object_class, sizeof (GtkComboBoxPrivate));
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
parent_buildable_iface = g_type_interface_peek_parent (iface);
|
2007-06-19 12:23:36 +00:00
|
|
|
iface->add_child = _gtk_cell_layout_buildable_add_child;
|
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
|
|
|
iface->custom_tag_start = gtk_combo_box_buildable_custom_tag_start;
|
|
|
|
iface->custom_tag_end = gtk_combo_box_buildable_custom_tag_end;
|
|
|
|
}
|
|
|
|
|
2003-10-01 20:51:54 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_cell_layout_init (GtkCellLayoutIface *iface)
|
|
|
|
{
|
|
|
|
iface->pack_start = gtk_combo_box_cell_layout_pack_start;
|
|
|
|
iface->pack_end = gtk_combo_box_cell_layout_pack_end;
|
2007-09-07 11:02:04 +00:00
|
|
|
iface->get_cells = gtk_combo_box_cell_layout_get_cells;
|
2003-10-01 20:51:54 +00:00
|
|
|
iface->clear = gtk_combo_box_cell_layout_clear;
|
|
|
|
iface->add_attribute = gtk_combo_box_cell_layout_add_attribute;
|
|
|
|
iface->set_cell_data_func = gtk_combo_box_cell_layout_set_cell_data_func;
|
|
|
|
iface->clear_attributes = gtk_combo_box_cell_layout_clear_attributes;
|
2003-12-19 22:47:20 +00:00
|
|
|
iface->reorder = gtk_combo_box_cell_layout_reorder;
|
2003-10-01 20:51:54 +00:00
|
|
|
}
|
|
|
|
|
2004-07-16 20:27:40 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
combo_box->priv = G_TYPE_INSTANCE_GET_PRIVATE (combo_box,
|
|
|
|
GTK_TYPE_COMBO_BOX,
|
|
|
|
GtkComboBoxPrivate);
|
|
|
|
priv = combo_box->priv;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->cell_view = gtk_cell_view_new ();
|
|
|
|
gtk_widget_set_parent (priv->cell_view, GTK_WIDGET (combo_box));
|
2010-05-28 03:49:30 +00:00
|
|
|
_gtk_bin_set_child (GTK_BIN (combo_box), priv->cell_view);
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_show (priv->cell_view);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->width = 0;
|
|
|
|
priv->height = 0;
|
|
|
|
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;
|
|
|
|
priv->focus_on_click = TRUE;
|
2008-08-04 23:40:36 +00:00
|
|
|
priv->button_sensitivity = GTK_SENSITIVITY_AUTO;
|
2007-12-28 06:56:48 +00:00
|
|
|
|
2006-01-15 04:08:31 +00:00
|
|
|
gtk_combo_box_check_appearance (combo_box);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2009-10-21 16:40:19 +00:00
|
|
|
case PROP_MODEL:
|
|
|
|
gtk_combo_box_set_model (combo_box, g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_WRAP_WIDTH:
|
|
|
|
gtk_combo_box_set_wrap_width (combo_box, g_value_get_int (value));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_ROW_SPAN_COLUMN:
|
|
|
|
gtk_combo_box_set_row_span_column (combo_box, g_value_get_int (value));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_COLUMN_SPAN_COLUMN:
|
|
|
|
gtk_combo_box_set_column_span_column (combo_box, g_value_get_int (value));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_ACTIVE:
|
|
|
|
gtk_combo_box_set_active (combo_box, g_value_get_int (value));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_ADD_TEAROFFS:
|
|
|
|
gtk_combo_box_set_add_tearoffs (combo_box, g_value_get_boolean (value));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_HAS_FRAME:
|
|
|
|
combo_box->priv->has_frame = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_FOCUS_ON_CLICK:
|
|
|
|
gtk_combo_box_set_focus_on_click (combo_box,
|
|
|
|
g_value_get_boolean (value));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_TEAROFF_TITLE:
|
|
|
|
gtk_combo_box_set_title (combo_box, g_value_get_string (value));
|
|
|
|
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;
|
|
|
|
|
2009-12-19 00:18:14 +00:00
|
|
|
case PROP_EDITING_CANCELED:
|
|
|
|
combo_box->priv->editing_canceled = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
|
2009-10-21 16:40:19 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (object);
|
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:
|
|
|
|
g_value_set_object (value, combo_box->priv->model);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_WRAP_WIDTH:
|
|
|
|
g_value_set_int (value, combo_box->priv->wrap_width);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_ROW_SPAN_COLUMN:
|
|
|
|
g_value_set_int (value, combo_box->priv->row_column);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_COLUMN_SPAN_COLUMN:
|
|
|
|
g_value_set_int (value, combo_box->priv->col_column);
|
|
|
|
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:
|
|
|
|
g_value_set_boolean (value, gtk_combo_box_get_add_tearoffs (combo_box));
|
|
|
|
break;
|
|
|
|
|
2004-07-16 20:27:40 +00:00
|
|
|
case PROP_HAS_FRAME:
|
|
|
|
g_value_set_boolean (value, combo_box->priv->has_frame);
|
|
|
|
break;
|
|
|
|
|
2004-08-16 05:43:50 +00:00
|
|
|
case PROP_FOCUS_ON_CLICK:
|
|
|
|
g_value_set_boolean (value, combo_box->priv->focus_on_click);
|
|
|
|
break;
|
|
|
|
|
2005-11-21 16:01:56 +00:00
|
|
|
case PROP_TEAROFF_TITLE:
|
|
|
|
g_value_set_string (value, gtk_combo_box_get_title (combo_box));
|
|
|
|
break;
|
|
|
|
|
2006-03-09 20:20:30 +00:00
|
|
|
case PROP_POPUP_SHOWN:
|
|
|
|
g_value_set_boolean (value, combo_box->priv->popup_shown);
|
|
|
|
break;
|
|
|
|
|
2008-08-04 23:40:36 +00:00
|
|
|
case PROP_BUTTON_SENSITIVITY:
|
|
|
|
g_value_set_enum (value, combo_box->priv->button_sensitivity);
|
|
|
|
break;
|
|
|
|
|
2009-10-21 16:40:19 +00:00
|
|
|
case PROP_EDITING_CANCELED:
|
|
|
|
g_value_set_boolean (value, priv->editing_canceled);
|
|
|
|
break;
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-04 20:43:41 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_state_changed (GtkWidget *widget,
|
|
|
|
GtkStateType previous)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2004-03-04 20:43:41 +00:00
|
|
|
|
2010-03-02 06:16:02 +00:00
|
|
|
if (gtk_widget_get_realized (widget))
|
2004-03-04 20:43:41 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->tree_view && priv->cell_view)
|
|
|
|
gtk_cell_view_set_background_color (GTK_CELL_VIEW (priv->cell_view),
|
2010-03-03 20:49:33 +00:00
|
|
|
&widget->style->base[gtk_widget_get_state (widget)]);
|
2004-03-04 20:43:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_queue_draw (widget);
|
|
|
|
}
|
|
|
|
|
2004-12-24 03:44:17 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_button_state_changed (GtkWidget *widget,
|
|
|
|
GtkStateType previous,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (data);
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2004-12-24 03:44:17 +00:00
|
|
|
|
2010-03-02 06:16:02 +00:00
|
|
|
if (gtk_widget_get_realized (widget))
|
2004-12-24 03:44:17 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
if (!priv->tree_view && priv->cell_view)
|
2004-12-30 16:15:53 +00:00
|
|
|
{
|
2010-03-03 20:49:33 +00:00
|
|
|
if ((gtk_widget_get_state (widget) == GTK_STATE_INSENSITIVE) !=
|
|
|
|
(gtk_widget_get_state (priv->cell_view) == GTK_STATE_INSENSITIVE))
|
2010-03-01 04:58:37 +00:00
|
|
|
gtk_widget_set_sensitive (priv->cell_view, gtk_widget_get_sensitive (widget));
|
2004-12-30 16:15:53 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_set_state (priv->cell_view,
|
2010-03-03 20:49:33 +00:00
|
|
|
gtk_widget_get_state (widget));
|
2004-12-30 16:15:53 +00:00
|
|
|
}
|
2004-12-24 03:44:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_queue_draw (widget);
|
|
|
|
}
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
static void
|
2004-03-08 18:39:44 +00:00
|
|
|
gtk_combo_box_check_appearance (GtkComboBox *combo_box)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2004-03-07 01:37:06 +00:00
|
|
|
gboolean appears_as_list;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
/* if wrap_width > 0, then we are in grid-mode and forced to use
|
|
|
|
* unix style
|
|
|
|
*/
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->wrap_width)
|
2004-03-08 18:39:44 +00:00
|
|
|
appears_as_list = FALSE;
|
|
|
|
else
|
|
|
|
gtk_widget_style_get (GTK_WIDGET (combo_box),
|
|
|
|
"appears-as-list", &appears_as_list,
|
|
|
|
NULL);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-03-07 01:37:06 +00:00
|
|
|
if (appears_as_list)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2004-02-27 20:41:14 +00:00
|
|
|
/* Destroy all the menu mode widgets, if they exist. */
|
2007-12-28 06:56:48 +00:00
|
|
|
if (GTK_IS_MENU (priv->popup_widget))
|
2004-02-27 20:41:14 +00:00
|
|
|
gtk_combo_box_menu_destroy (combo_box);
|
|
|
|
|
|
|
|
/* Create the list mode widgets, if they don't already exist. */
|
2007-12-28 06:56:48 +00:00
|
|
|
if (!GTK_IS_TREE_VIEW (priv->tree_view))
|
2004-02-27 20:41:14 +00:00
|
|
|
gtk_combo_box_list_setup (combo_box);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-02-27 20:41:14 +00:00
|
|
|
/* Destroy all the list mode widgets, if they exist. */
|
2007-12-28 06:56:48 +00:00
|
|
|
if (GTK_IS_TREE_VIEW (priv->tree_view))
|
2004-02-27 20:41:14 +00:00
|
|
|
gtk_combo_box_list_destroy (combo_box);
|
|
|
|
|
|
|
|
/* Create the menu mode widgets, if they don't already exist. */
|
2007-12-28 06:56:48 +00:00
|
|
|
if (!GTK_IS_MENU (priv->popup_widget))
|
2004-02-27 20:41:14 +00:00
|
|
|
gtk_combo_box_menu_setup (combo_box, TRUE);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
2007-03-08 02:36:46 +00:00
|
|
|
|
|
|
|
gtk_widget_style_get (GTK_WIDGET (combo_box),
|
2007-12-28 06:56:48 +00:00
|
|
|
"shadow-type", &priv->shadow_type,
|
2007-03-08 02:36:46 +00:00
|
|
|
NULL);
|
2004-03-08 18:39:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_style_set (GtkWidget *widget,
|
|
|
|
GtkStyle *previous)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2010-05-24 20:31:36 +00:00
|
|
|
GtkWidget *child;
|
2004-03-08 18:39:44 +00:00
|
|
|
|
|
|
|
gtk_combo_box_check_appearance (combo_box);
|
2004-03-04 20:43:41 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->tree_view && priv->cell_view)
|
|
|
|
gtk_cell_view_set_background_color (GTK_CELL_VIEW (priv->cell_view),
|
2010-03-03 20:49:33 +00:00
|
|
|
&widget->style->base[gtk_widget_get_state (widget)]);
|
2007-03-08 02:36:46 +00:00
|
|
|
|
2010-05-24 20:31:36 +00:00
|
|
|
child = gtk_bin_get_child (GTK_BIN (combo_box));
|
|
|
|
if (GTK_IS_ENTRY (child))
|
|
|
|
g_object_set (child, "shadow-type",
|
2007-12-28 06:56:48 +00:00
|
|
|
GTK_SHADOW_NONE == priv->shadow_type ?
|
2007-03-08 02:36:46 +00:00
|
|
|
GTK_SHADOW_IN : GTK_SHADOW_NONE, NULL);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_button_toggled (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (data);
|
|
|
|
|
|
|
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
|
|
|
|
{
|
|
|
|
if (!combo_box->priv->popup_in_progress)
|
|
|
|
gtk_combo_box_popup (combo_box);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
gtk_combo_box_popdown (combo_box);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_add (GtkContainer *container,
|
|
|
|
GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (container);
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->cell_view && priv->cell_view->parent)
|
2004-03-13 00:36:27 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_unparent (priv->cell_view);
|
2010-05-28 03:49:30 +00:00
|
|
|
_gtk_bin_set_child (GTK_BIN (container), NULL);
|
2004-03-13 00:36:27 +00:00
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (container));
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_set_parent (widget, GTK_WIDGET (container));
|
2010-05-28 03:49:30 +00:00
|
|
|
_gtk_bin_set_child (GTK_BIN (container), widget);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->cell_view &&
|
|
|
|
widget != priv->cell_view)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
|
|
|
/* since the cell_view was unparented, it's gone now */
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->cell_view = NULL;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (!priv->tree_view && priv->separator)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_container_remove (GTK_CONTAINER (priv->separator->parent),
|
|
|
|
priv->separator);
|
|
|
|
priv->separator = NULL;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (container));
|
|
|
|
}
|
2007-12-28 06:56:48 +00:00
|
|
|
else if (priv->cell_view_frame)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_unparent (priv->cell_view_frame);
|
|
|
|
priv->cell_view_frame = NULL;
|
|
|
|
priv->box = NULL;
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-13 00:36:27 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_remove (GtkContainer *container,
|
|
|
|
GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (container);
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2004-08-02 19:15:05 +00:00
|
|
|
GtkTreePath *path;
|
2004-03-13 00:36:27 +00:00
|
|
|
gboolean appears_as_list;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (widget == priv->cell_view)
|
|
|
|
priv->cell_view = NULL;
|
2006-08-14 20:12:10 +00:00
|
|
|
|
2004-03-13 00:36:27 +00:00
|
|
|
gtk_widget_unparent (widget);
|
2010-05-28 03:49:30 +00:00
|
|
|
_gtk_bin_set_child (GTK_BIN (container), NULL);
|
2004-03-13 00:36:27 +00:00
|
|
|
|
2006-03-21 00:12:48 +00:00
|
|
|
if (GTK_OBJECT_FLAGS (combo_box) & GTK_IN_DESTRUCTION)
|
2004-03-13 00:36:27 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (container));
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (!priv->tree_view)
|
2004-03-13 00:36:27 +00:00
|
|
|
appears_as_list = FALSE;
|
|
|
|
else
|
|
|
|
appears_as_list = TRUE;
|
|
|
|
|
|
|
|
if (appears_as_list)
|
|
|
|
gtk_combo_box_list_destroy (combo_box);
|
2007-12-28 06:56:48 +00:00
|
|
|
else if (GTK_IS_MENU (priv->popup_widget))
|
2004-03-13 00:36:27 +00:00
|
|
|
{
|
|
|
|
gtk_combo_box_menu_destroy (combo_box);
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_menu_detach (GTK_MENU (priv->popup_widget));
|
|
|
|
priv->popup_widget = NULL;
|
2004-03-13 00:36:27 +00:00
|
|
|
}
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (!priv->cell_view)
|
2004-03-13 00:36:27 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->cell_view = gtk_cell_view_new ();
|
|
|
|
gtk_widget_set_parent (priv->cell_view, GTK_WIDGET (container));
|
2010-05-28 03:49:30 +00:00
|
|
|
_gtk_bin_set_child (GTK_BIN (container), priv->cell_view);
|
2004-03-13 00:36:27 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_show (priv->cell_view);
|
|
|
|
gtk_cell_view_set_model (GTK_CELL_VIEW (priv->cell_view),
|
|
|
|
priv->model);
|
|
|
|
gtk_combo_box_sync_cells (combo_box, GTK_CELL_LAYOUT (priv->cell_view));
|
2004-03-13 00:36:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (appears_as_list)
|
2004-08-13 16:50:32 +00:00
|
|
|
gtk_combo_box_list_setup (combo_box);
|
2004-03-13 00:36:27 +00:00
|
|
|
else
|
|
|
|
gtk_combo_box_menu_setup (combo_box, TRUE);
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (gtk_tree_row_reference_valid (priv->active_row))
|
2004-08-02 19:15:05 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
path = gtk_tree_row_reference_get_path (priv->active_row);
|
2004-08-02 19:15:05 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
static ComboCellInfo *
|
|
|
|
gtk_combo_box_get_cell_info (GtkComboBox *combo_box,
|
|
|
|
GtkCellRenderer *cell)
|
|
|
|
{
|
|
|
|
GSList *i;
|
|
|
|
|
|
|
|
for (i = combo_box->priv->cells; i; i = i->next)
|
|
|
|
{
|
|
|
|
ComboCellInfo *info = (ComboCellInfo *)i->data;
|
|
|
|
|
2004-02-27 20:41:14 +00:00
|
|
|
if (info && info->cell == cell)
|
2003-09-26 21:57:06 +00:00
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_menu_show (GtkWidget *menu,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2005-11-10 21:17:19 +00:00
|
|
|
gtk_combo_box_child_show (menu, user_data);
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->popup_in_progress = TRUE;
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button),
|
2003-09-26 21:57:06 +00:00
|
|
|
TRUE);
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->popup_in_progress = FALSE;
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_menu_hide (GtkWidget *menu,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_combo_box_child_hide (menu,user_data);
|
2005-11-10 21:17:19 +00:00
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button),
|
|
|
|
FALSE);
|
|
|
|
}
|
|
|
|
|
2004-02-08 00:42:59 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_detacher (GtkWidget *widget,
|
|
|
|
GtkMenu *menu)
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2004-02-08 00:42:59 +00:00
|
|
|
|
2008-01-09 17:02:50 +00:00
|
|
|
g_return_if_fail (priv->popup_widget == (GtkWidget *) menu);
|
2004-02-08 00:42:59 +00:00
|
|
|
|
2004-05-10 14:07:35 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (menu->toplevel,
|
2004-02-08 00:42:59 +00:00
|
|
|
gtk_combo_box_menu_show,
|
|
|
|
combo_box);
|
2004-05-10 14:07:35 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (menu->toplevel,
|
2004-02-08 00:42:59 +00:00
|
|
|
gtk_combo_box_menu_hide,
|
|
|
|
combo_box);
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->popup_widget = NULL;
|
2004-02-08 00:42:59 +00:00
|
|
|
}
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_set_popup_widget (GtkComboBox *combo_box,
|
|
|
|
GtkWidget *popup)
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
|
|
|
if (GTK_IS_MENU (priv->popup_widget))
|
2004-02-08 00:42:59 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_menu_detach (GTK_MENU (priv->popup_widget));
|
|
|
|
priv->popup_widget = NULL;
|
2004-02-08 00:42:59 +00:00
|
|
|
}
|
2007-12-28 06:56:48 +00:00
|
|
|
else if (priv->popup_widget)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_container_remove (GTK_CONTAINER (priv->scrolled_window),
|
|
|
|
priv->popup_widget);
|
|
|
|
g_object_unref (priv->popup_widget);
|
|
|
|
priv->popup_widget = NULL;
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (GTK_IS_MENU (popup))
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->popup_window)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_destroy (priv->popup_window);
|
|
|
|
priv->popup_window = NULL;
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->popup_widget = popup;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-05-10 14:07:35 +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.
|
|
|
|
*/
|
|
|
|
g_signal_connect (GTK_MENU (popup)->toplevel, "show",
|
2003-09-26 21:57:06 +00:00
|
|
|
G_CALLBACK (gtk_combo_box_menu_show), combo_box);
|
2004-05-10 14:07:35 +00:00
|
|
|
g_signal_connect (GTK_MENU (popup)->toplevel, "hide",
|
2003-09-26 21:57:06 +00:00
|
|
|
G_CALLBACK (gtk_combo_box_menu_hide), combo_box);
|
|
|
|
|
2004-02-08 00:42:59 +00:00
|
|
|
gtk_menu_attach_to_widget (GTK_MENU (popup),
|
|
|
|
GTK_WIDGET (combo_box),
|
|
|
|
gtk_combo_box_detacher);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
if (!priv->popup_window)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2005-02-16 16:37:24 +00:00
|
|
|
GtkWidget *toplevel;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->popup_window = gtk_window_new (GTK_WINDOW_POPUP);
|
|
|
|
gtk_widget_set_name (priv->popup_window, "gtk-combobox-popup-window");
|
2005-02-16 16:37:24 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_window_set_type_hint (GTK_WINDOW (priv->popup_window),
|
2006-04-25 14:27:32 +00:00
|
|
|
GDK_WINDOW_TYPE_HINT_COMBO);
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
g_signal_connect (GTK_WINDOW (priv->popup_window),"show",
|
2005-11-10 21:17:19 +00:00
|
|
|
G_CALLBACK (gtk_combo_box_child_show),
|
|
|
|
combo_box);
|
2007-12-28 06:56:48 +00:00
|
|
|
g_signal_connect (GTK_WINDOW (priv->popup_window),"hide",
|
2005-11-10 21:17:19 +00:00
|
|
|
G_CALLBACK (gtk_combo_box_child_hide),
|
|
|
|
combo_box);
|
|
|
|
|
2005-02-17 22:54:37 +00:00
|
|
|
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (combo_box));
|
2005-02-16 16:37:24 +00:00
|
|
|
if (GTK_IS_WINDOW (toplevel))
|
2006-04-25 14:27:32 +00:00
|
|
|
{
|
|
|
|
gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)),
|
2007-12-28 06:56:48 +00:00
|
|
|
GTK_WINDOW (priv->popup_window));
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (priv->popup_window),
|
2006-04-25 14:27:32 +00:00
|
|
|
GTK_WINDOW (toplevel));
|
|
|
|
}
|
2005-02-16 16:37:24 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_window_set_resizable (GTK_WINDOW (priv->popup_window), FALSE);
|
|
|
|
gtk_window_set_screen (GTK_WINDOW (priv->popup_window),
|
2004-02-08 09:29:11 +00:00
|
|
|
gtk_widget_get_screen (GTK_WIDGET (combo_box)));
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
2004-07-26 04:50:07 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
|
2004-07-26 04:50:07 +00:00
|
|
|
GTK_POLICY_NEVER,
|
|
|
|
GTK_POLICY_NEVER);
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (priv->scrolled_window),
|
2007-06-13 23:15:42 +00:00
|
|
|
GTK_SHADOW_IN);
|
2004-07-26 04:50:07 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_show (priv->scrolled_window);
|
2004-07-26 04:50:07 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (priv->popup_window),
|
|
|
|
priv->scrolled_window);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (priv->scrolled_window),
|
2003-09-26 21:57:06 +00:00
|
|
|
popup);
|
2004-07-26 04:50:07 +00:00
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
gtk_widget_show (popup);
|
2004-11-19 23:18:38 +00:00
|
|
|
g_object_ref (popup);
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->popup_widget = popup;
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-03 22:30:36 +00:00
|
|
|
gtk_combo_box_menu_position_below (GtkMenu *menu,
|
|
|
|
gint *x,
|
|
|
|
gint *y,
|
|
|
|
gint *push_in,
|
|
|
|
gpointer user_data)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2004-05-10 18:17:47 +00:00
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
|
2003-09-26 21:57:06 +00:00
|
|
|
gint sx, sy;
|
|
|
|
GtkWidget *child;
|
|
|
|
GtkRequisition req;
|
2004-05-10 18:17:47 +00:00
|
|
|
GdkScreen *screen;
|
|
|
|
gint monitor_num;
|
|
|
|
GdkRectangle monitor;
|
2004-03-03 22:30:36 +00:00
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
/* FIXME: is using the size request here broken? */
|
2010-05-24 20:31:36 +00:00
|
|
|
child = gtk_bin_get_child (GTK_BIN (combo_box));
|
2009-06-08 15:05:51 +00:00
|
|
|
|
|
|
|
sx = sy = 0;
|
|
|
|
|
2010-01-04 06:49:26 +00:00
|
|
|
if (!gtk_widget_get_has_window (child))
|
2007-12-28 06:56:48 +00:00
|
|
|
{
|
|
|
|
sx += child->allocation.x;
|
|
|
|
sy += child->allocation.y;
|
|
|
|
}
|
2004-05-10 18:17:47 +00:00
|
|
|
|
2009-06-08 15:05:51 +00:00
|
|
|
gdk_window_get_root_coords (child->window, sx, sy, &sx, &sy);
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (GTK_SHADOW_NONE != combo_box->priv->shadow_type)
|
|
|
|
sx -= GTK_WIDGET (combo_box)->style->xthickness;
|
2007-03-08 02:36:46 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_size_request (GTK_WIDGET (menu), &req);
|
2004-05-10 18:17:47 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (gtk_widget_get_direction (GTK_WIDGET (combo_box)) == GTK_TEXT_DIR_LTR)
|
|
|
|
*x = sx;
|
|
|
|
else
|
|
|
|
*x = sx + child->allocation.width - req.width;
|
|
|
|
*y = sy;
|
2004-05-10 18:17:47 +00:00
|
|
|
|
|
|
|
screen = gtk_widget_get_screen (GTK_WIDGET (combo_box));
|
|
|
|
monitor_num = gdk_screen_get_monitor_at_window (screen,
|
|
|
|
GTK_WIDGET (combo_box)->window);
|
|
|
|
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
|
|
|
|
|
|
|
|
if (*x < monitor.x)
|
|
|
|
*x = monitor.x;
|
|
|
|
else if (*x + req.width > monitor.x + monitor.width)
|
|
|
|
*x = monitor.x + monitor.width - req.width;
|
|
|
|
|
2004-06-26 03:39:35 +00:00
|
|
|
if (monitor.y + monitor.height - *y - child->allocation.height >= req.height)
|
|
|
|
*y += child->allocation.height;
|
|
|
|
else if (*y - monitor.y >= req.height)
|
|
|
|
*y -= req.height;
|
|
|
|
else if (monitor.y + monitor.height - *y - child->allocation.height > *y - monitor.y)
|
2004-05-10 18:17:47 +00:00
|
|
|
*y += child->allocation.height;
|
|
|
|
else
|
|
|
|
*y -= req.height;
|
|
|
|
|
2004-06-26 03:39:35 +00:00
|
|
|
*push_in = FALSE;
|
2004-03-03 22:30:36 +00:00
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-03-03 22:30:36 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_menu_position_over (GtkMenu *menu,
|
|
|
|
gint *x,
|
|
|
|
gint *y,
|
|
|
|
gboolean *push_in,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box;
|
|
|
|
GtkWidget *active;
|
|
|
|
GtkWidget *child;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkRequisition requisition;
|
|
|
|
GList *children;
|
|
|
|
gint screen_width;
|
|
|
|
gint menu_xpos;
|
|
|
|
gint menu_ypos;
|
|
|
|
gint menu_width;
|
|
|
|
|
|
|
|
combo_box = GTK_COMBO_BOX (user_data);
|
|
|
|
widget = GTK_WIDGET (combo_box);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-03-03 22:30:36 +00:00
|
|
|
gtk_widget_get_child_requisition (GTK_WIDGET (menu), &requisition);
|
|
|
|
menu_width = requisition.width;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-03-03 22:30:36 +00:00
|
|
|
active = gtk_menu_get_active (GTK_MENU (combo_box->priv->popup_widget));
|
|
|
|
|
2009-06-08 15:05:51 +00:00
|
|
|
menu_xpos = widget->allocation.x;
|
|
|
|
menu_ypos = widget->allocation.y + widget->allocation.height / 2 - 2;
|
2004-03-03 22:30:36 +00:00
|
|
|
|
|
|
|
if (active != NULL)
|
|
|
|
{
|
|
|
|
gtk_widget_get_child_requisition (active, &requisition);
|
|
|
|
menu_ypos -= requisition.height / 2;
|
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-03-03 22:30:36 +00:00
|
|
|
children = GTK_MENU_SHELL (combo_box->priv->popup_widget)->children;
|
|
|
|
while (children)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2004-03-03 22:30:36 +00:00
|
|
|
child = children->data;
|
|
|
|
|
|
|
|
if (active == child)
|
|
|
|
break;
|
|
|
|
|
2010-03-01 06:47:38 +00:00
|
|
|
if (gtk_widget_get_visible (child))
|
2004-03-03 22:30:36 +00:00
|
|
|
{
|
|
|
|
gtk_widget_get_child_requisition (child, &requisition);
|
|
|
|
menu_ypos -= requisition.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
children = children->next;
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
2004-03-03 22:30:36 +00:00
|
|
|
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
|
|
|
|
menu_xpos = menu_xpos + widget->allocation.width - menu_width;
|
|
|
|
|
2009-06-08 15:05:51 +00:00
|
|
|
gdk_window_get_root_coords (widget->window, menu_xpos, menu_ypos,
|
|
|
|
&menu_xpos, &menu_ypos);
|
|
|
|
|
2004-03-03 22:30:36 +00:00
|
|
|
/* Clamp the position on screen */
|
|
|
|
screen_width = gdk_screen_get_width (gtk_widget_get_screen (widget));
|
|
|
|
|
|
|
|
if (menu_xpos < 0)
|
|
|
|
menu_xpos = 0;
|
|
|
|
else if ((menu_xpos + menu_width) > screen_width)
|
|
|
|
menu_xpos -= ((menu_xpos + menu_width) - screen_width);
|
|
|
|
|
|
|
|
*x = menu_xpos;
|
|
|
|
*y = menu_ypos;
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
*push_in = TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-03 22:30:36 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_menu_position (GtkMenu *menu,
|
|
|
|
gint *x,
|
|
|
|
gint *y,
|
|
|
|
gint *push_in,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2004-03-04 23:35:31 +00:00
|
|
|
GtkWidget *menu_item;
|
2004-03-03 22:30:36 +00:00
|
|
|
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->wrap_width > 0 || priv->cell_view == NULL)
|
2004-03-03 22:30:36 +00:00
|
|
|
gtk_combo_box_menu_position_below (menu, x, y, push_in, user_data);
|
|
|
|
else
|
2004-03-04 23:35:31 +00:00
|
|
|
{
|
2004-08-02 19:15:05 +00:00
|
|
|
/* FIXME handle nested menus better */
|
2007-12-28 06:56:48 +00:00
|
|
|
menu_item = gtk_menu_get_active (GTK_MENU (priv->popup_widget));
|
2004-03-04 23:35:31 +00:00
|
|
|
if (menu_item)
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_menu_shell_select_item (GTK_MENU_SHELL (priv->popup_widget),
|
2004-03-04 23:35:31 +00:00
|
|
|
menu_item);
|
|
|
|
|
|
|
|
gtk_combo_box_menu_position_over (menu, x, y, push_in, user_data);
|
|
|
|
}
|
2008-06-11 03:36:32 +00:00
|
|
|
|
2010-03-01 06:47:38 +00:00
|
|
|
if (!gtk_widget_get_visible (GTK_MENU (priv->popup_widget)->toplevel))
|
2008-09-03 12:38:32 +00:00
|
|
|
gtk_window_set_type_hint (GTK_WINDOW (GTK_MENU (priv->popup_widget)->toplevel),
|
|
|
|
GDK_WINDOW_TYPE_HINT_COMBO);
|
2004-03-03 22:30:36 +00:00
|
|
|
}
|
|
|
|
|
2004-02-29 01:33:01 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_list_position (GtkComboBox *combo_box,
|
|
|
|
gint *x,
|
|
|
|
gint *y,
|
|
|
|
gint *width,
|
|
|
|
gint *height)
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2004-02-29 01:33:01 +00:00
|
|
|
GdkScreen *screen;
|
|
|
|
gint monitor_num;
|
|
|
|
GdkRectangle monitor;
|
2004-03-02 18:53:55 +00:00
|
|
|
GtkRequisition popup_req;
|
2004-07-26 04:50:07 +00:00
|
|
|
GtkPolicyType hpolicy, vpolicy;
|
2004-02-29 01:33:01 +00:00
|
|
|
|
2006-12-15 19:08:15 +00:00
|
|
|
/* under windows, the drop down list is as wide as the combo box itself.
|
|
|
|
see bug #340204 */
|
2007-02-01 11:42:38 +00:00
|
|
|
GtkWidget *sample = GTK_WIDGET (combo_box);
|
2004-02-29 01:33:01 +00:00
|
|
|
|
2009-06-08 15:05:51 +00:00
|
|
|
*x = *y = 0;
|
2004-02-29 01:33:01 +00:00
|
|
|
|
2010-01-04 06:49:26 +00:00
|
|
|
if (!gtk_widget_get_has_window (sample))
|
2004-07-26 04:50:07 +00:00
|
|
|
{
|
|
|
|
*x += sample->allocation.x;
|
|
|
|
*y += sample->allocation.y;
|
|
|
|
}
|
|
|
|
|
2009-06-08 15:05:51 +00:00
|
|
|
gdk_window_get_root_coords (sample->window, *x, *y, x, y);
|
|
|
|
|
2004-07-26 04:50:07 +00:00
|
|
|
*width = sample->allocation.width;
|
2004-02-29 01:33:01 +00:00
|
|
|
|
2004-07-26 04:50:07 +00:00
|
|
|
hpolicy = vpolicy = GTK_POLICY_NEVER;
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
|
2004-07-26 04:50:07 +00:00
|
|
|
hpolicy, vpolicy);
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_size_request (priv->scrolled_window, &popup_req);
|
2004-07-26 04:50:07 +00:00
|
|
|
|
|
|
|
if (popup_req.width > *width)
|
2004-02-29 01:33:01 +00:00
|
|
|
{
|
2004-07-26 04:50:07 +00:00
|
|
|
hpolicy = GTK_POLICY_ALWAYS;
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
|
2004-07-26 04:50:07 +00:00
|
|
|
hpolicy, vpolicy);
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_size_request (priv->scrolled_window, &popup_req);
|
2004-02-29 01:33:01 +00:00
|
|
|
}
|
2004-07-26 04:50:07 +00:00
|
|
|
|
|
|
|
*height = popup_req.height;
|
|
|
|
|
2004-02-29 01:33:01 +00:00
|
|
|
screen = gtk_widget_get_screen (GTK_WIDGET (combo_box));
|
|
|
|
monitor_num = gdk_screen_get_monitor_at_window (screen,
|
|
|
|
GTK_WIDGET (combo_box)->window);
|
|
|
|
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
|
2004-07-26 04:50:07 +00:00
|
|
|
|
2004-02-29 01:33:01 +00:00
|
|
|
if (*x < monitor.x)
|
|
|
|
*x = monitor.x;
|
|
|
|
else if (*x + *width > monitor.x + monitor.width)
|
|
|
|
*x = monitor.x + monitor.width - *width;
|
2004-03-02 18:53:55 +00:00
|
|
|
|
|
|
|
if (*y + sample->allocation.height + *height <= monitor.y + monitor.height)
|
|
|
|
*y += sample->allocation.height;
|
2004-07-26 04:50:07 +00:00
|
|
|
else if (*y - *height >= monitor.y)
|
2004-03-02 18:53:55 +00:00
|
|
|
*y -= *height;
|
2004-07-26 04:50:07 +00:00
|
|
|
else if (monitor.y + monitor.height - (*y + sample->allocation.height) > *y - monitor.y)
|
|
|
|
{
|
|
|
|
*y += sample->allocation.height;
|
|
|
|
*height = monitor.y + monitor.height - *y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*height = *y - monitor.y;
|
|
|
|
*y = monitor.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (popup_req.height > *height)
|
|
|
|
{
|
|
|
|
vpolicy = GTK_POLICY_ALWAYS;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
|
2004-07-26 04:50:07 +00:00
|
|
|
hpolicy, vpolicy);
|
|
|
|
}
|
2004-02-29 01:33:01 +00:00
|
|
|
}
|
|
|
|
|
2004-05-27 03:31:17 +00:00
|
|
|
static gboolean
|
2004-08-02 19:15:05 +00:00
|
|
|
cell_view_is_sensitive (GtkCellView *cell_view)
|
2004-05-27 03:31:17 +00:00
|
|
|
{
|
|
|
|
GList *cells, *list;
|
|
|
|
gboolean sensitive;
|
2004-07-07 15:15:35 +00:00
|
|
|
|
2009-06-16 15:27:06 +00:00
|
|
|
cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (cell_view));
|
2004-05-27 03:31:17 +00:00
|
|
|
|
|
|
|
sensitive = FALSE;
|
2007-12-28 06:56:48 +00:00
|
|
|
for (list = cells; list; list = list->next)
|
2004-05-27 03:31:17 +00:00
|
|
|
{
|
2004-11-19 23:18:38 +00:00
|
|
|
g_object_get (list->data, "sensitive", &sensitive, NULL);
|
2004-05-27 03:31:17 +00:00
|
|
|
|
|
|
|
if (sensitive)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
g_list_free (cells);
|
|
|
|
|
|
|
|
return sensitive;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
tree_column_row_is_sensitive (GtkComboBox *combo_box,
|
|
|
|
GtkTreeIter *iter)
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2004-05-27 03:31:17 +00:00
|
|
|
GList *cells, *list;
|
|
|
|
gboolean sensitive;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (!priv->column)
|
2004-05-27 03:31:17 +00:00
|
|
|
return TRUE;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->row_separator_func)
|
2004-07-07 15:15:35 +00:00
|
|
|
{
|
2008-08-12 09:51:16 +00:00
|
|
|
if (priv->row_separator_func (priv->model, iter,
|
|
|
|
priv->row_separator_data))
|
2004-07-07 15:15:35 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_tree_view_column_cell_set_cell_data (priv->column,
|
|
|
|
priv->model,
|
2004-05-27 03:31:17 +00:00
|
|
|
iter, FALSE, FALSE);
|
|
|
|
|
2009-06-16 16:21:36 +00:00
|
|
|
cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (priv->column));
|
2004-05-27 03:31:17 +00:00
|
|
|
|
|
|
|
sensitive = FALSE;
|
2007-12-28 06:56:48 +00:00
|
|
|
for (list = cells; list; list = list->next)
|
2004-05-27 03:31:17 +00:00
|
|
|
{
|
2004-11-19 23:18:38 +00:00
|
|
|
g_object_get (list->data, "sensitive", &sensitive, NULL);
|
2004-05-27 03:31:17 +00:00
|
|
|
|
|
|
|
if (sensitive)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
g_list_free (cells);
|
|
|
|
|
|
|
|
return sensitive;
|
|
|
|
}
|
2004-08-02 19:15:05 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
update_menu_sensitivity (GtkComboBox *combo_box,
|
|
|
|
GtkWidget *menu)
|
2004-05-27 03:31:17 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2004-08-02 19:15:05 +00:00
|
|
|
GList *children, *child;
|
|
|
|
GtkWidget *item, *submenu, *separator;
|
|
|
|
GtkWidget *cell_view;
|
2004-05-27 03:31:17 +00:00
|
|
|
gboolean sensitive;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (!priv->model)
|
2004-08-02 19:15:05 +00:00
|
|
|
return;
|
2004-05-27 03:31:17 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
children = gtk_container_get_children (GTK_CONTAINER (menu));
|
2004-05-27 03:31:17 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
for (child = children; child; child = child->next)
|
2004-05-27 03:31:17 +00:00
|
|
|
{
|
2004-08-02 19:15:05 +00:00
|
|
|
item = GTK_WIDGET (child->data);
|
2010-05-24 20:31:36 +00:00
|
|
|
cell_view = gtk_bin_get_child (GTK_BIN (item));
|
2004-05-27 03:31:17 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
if (!GTK_IS_CELL_VIEW (cell_view))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (item));
|
|
|
|
if (submenu != NULL)
|
|
|
|
{
|
|
|
|
gtk_widget_set_sensitive (item, TRUE);
|
|
|
|
update_menu_sensitivity (combo_box, submenu);
|
|
|
|
}
|
2004-05-27 03:31:17 +00:00
|
|
|
else
|
2004-08-02 19:15:05 +00:00
|
|
|
{
|
|
|
|
sensitive = cell_view_is_sensitive (GTK_CELL_VIEW (cell_view));
|
2004-05-27 03:31:17 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (menu != priv->popup_widget && child == children)
|
2004-08-02 19:15:05 +00:00
|
|
|
{
|
|
|
|
separator = GTK_WIDGET (child->next->data);
|
2004-11-19 23:18:38 +00:00
|
|
|
g_object_set (item, "visible", sensitive, NULL);
|
|
|
|
g_object_set (separator, "visible", sensitive, NULL);
|
2004-08-02 19:15:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
gtk_widget_set_sensitive (item, sensitive);
|
|
|
|
}
|
2004-05-27 03:31:17 +00:00
|
|
|
}
|
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
g_list_free (children);
|
2004-05-27 03:31:17 +00:00
|
|
|
}
|
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_menu_popup (GtkComboBox *combo_box,
|
|
|
|
guint button,
|
|
|
|
guint32 activate_time)
|
2004-05-27 03:31:17 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2004-08-02 19:15:05 +00:00
|
|
|
GtkTreePath *path;
|
|
|
|
gint active_item;
|
|
|
|
GtkRequisition requisition;
|
|
|
|
gint width;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
update_menu_sensitivity (combo_box, priv->popup_widget);
|
2004-05-27 03:31:17 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
active_item = -1;
|
2007-12-28 06:56:48 +00:00
|
|
|
if (gtk_tree_row_reference_valid (priv->active_row))
|
2004-05-27 03:31:17 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
path = gtk_tree_row_reference_get_path (priv->active_row);
|
2010-06-28 18:15:10 +00:00
|
|
|
active_item = gtk_tree_path_get_indices (path)[0];
|
2005-02-24 17:57:07 +00:00
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->add_tearoffs)
|
2005-02-24 17:57:07 +00:00
|
|
|
active_item++;
|
2004-08-02 19:15:05 +00:00
|
|
|
}
|
2004-07-07 15:15:35 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
/* FIXME handle nested menus better */
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_menu_set_active (GTK_MENU (priv->popup_widget), active_item);
|
2004-08-02 19:15:05 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->wrap_width == 0)
|
2004-08-02 19:15:05 +00:00
|
|
|
{
|
|
|
|
width = GTK_WIDGET (combo_box)->allocation.width;
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_set_size_request (priv->popup_widget, -1, -1);
|
|
|
|
gtk_widget_size_request (priv->popup_widget, &requisition);
|
2004-08-02 19:15:05 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_set_size_request (priv->popup_widget,
|
2004-08-02 19:15:05 +00:00
|
|
|
MAX (width, requisition.width), -1);
|
2004-05-27 03:31:17 +00:00
|
|
|
}
|
2004-08-02 19:15:05 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_menu_popup (GTK_MENU (priv->popup_widget),
|
2004-08-02 19:15:05 +00:00
|
|
|
NULL, NULL,
|
|
|
|
gtk_combo_box_menu_position, combo_box,
|
|
|
|
button, activate_time);
|
2004-05-27 03:31:17 +00:00
|
|
|
}
|
|
|
|
|
2005-06-26 06:26:47 +00:00
|
|
|
static gboolean
|
|
|
|
popup_grab_on_window (GdkWindow *window,
|
2010-05-25 22:38:44 +00:00
|
|
|
GdkDevice *keyboard,
|
|
|
|
GdkDevice *pointer,
|
|
|
|
guint32 activate_time)
|
2005-06-26 06:26:47 +00:00
|
|
|
{
|
2010-05-25 22:38:44 +00:00
|
|
|
if (keyboard &&
|
|
|
|
gdk_device_grab (keyboard, window,
|
|
|
|
GDK_OWNERSHIP_WINDOW, TRUE,
|
|
|
|
GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
|
|
|
|
NULL, activate_time) != GDK_GRAB_SUCCESS)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (pointer &&
|
|
|
|
gdk_device_grab (pointer, window,
|
|
|
|
GDK_OWNERSHIP_WINDOW, TRUE,
|
|
|
|
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
|
|
|
|
GDK_POINTER_MOTION_MASK,
|
|
|
|
NULL, activate_time) != GDK_GRAB_SUCCESS)
|
2005-06-26 06:26:47 +00:00
|
|
|
{
|
2010-05-25 22:38:44 +00:00
|
|
|
if (keyboard)
|
|
|
|
gdk_device_ungrab (keyboard, activate_time);
|
|
|
|
|
|
|
|
return FALSE;
|
2005-06-26 06:26:47 +00:00
|
|
|
}
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
return TRUE;
|
2005-06-26 06:26:47 +00:00
|
|
|
}
|
|
|
|
|
2004-02-15 23:05:48 +00:00
|
|
|
/**
|
|
|
|
* gtk_combo_box_popup:
|
|
|
|
* @combo_box: a #GtkComboBox
|
|
|
|
*
|
|
|
|
* Pops up the menu or dropdown list of @combo_box.
|
|
|
|
*
|
|
|
|
* This function is mostly intended for use by accessibility technologies;
|
|
|
|
* applications should have little use for it.
|
|
|
|
*
|
|
|
|
* Since: 2.4
|
2007-03-12 06:04:44 +00:00
|
|
|
*/
|
2004-02-15 23:05:48 +00:00
|
|
|
void
|
2003-09-26 21:57:06 +00:00
|
|
|
gtk_combo_box_popup (GtkComboBox *combo_box)
|
2006-10-12 13:04:44 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
|
|
|
|
|
|
|
g_signal_emit (combo_box, combo_box_signals[POPUP], 0);
|
|
|
|
}
|
|
|
|
|
2010-05-25 22:38:44 +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
|
|
|
|
* are the only #GdkDevice<!-- -->s able to send events to it.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gtk_combo_box_popup_for_device (GtkComboBox *combo_box,
|
|
|
|
GdkDevice *device)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2004-02-29 00:08:04 +00:00
|
|
|
gint x, y, width, height;
|
2007-01-05 05:41:25 +00:00
|
|
|
GtkTreePath *path = NULL, *ppath;
|
2005-02-16 16:37:24 +00:00
|
|
|
GtkWidget *toplevel;
|
2010-05-25 22:38:44 +00:00
|
|
|
GdkDevice *keyboard, *pointer;
|
|
|
|
guint32 time;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
|
|
|
g_return_if_fail (GDK_IS_DEVICE (device));
|
2005-02-16 16:37:24 +00:00
|
|
|
|
2010-03-02 06:16:02 +00:00
|
|
|
if (!gtk_widget_get_realized (GTK_WIDGET (combo_box)))
|
2005-03-30 17:09:13 +00:00
|
|
|
return;
|
|
|
|
|
2010-03-02 04:19:28 +00:00
|
|
|
if (gtk_widget_get_mapped (priv->popup_widget))
|
2003-09-26 21:57:06 +00:00
|
|
|
return;
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
if (priv->grab_pointer && priv->grab_keyboard)
|
|
|
|
return;
|
|
|
|
|
|
|
|
time = gtk_get_current_event_time ();
|
|
|
|
|
|
|
|
if (device->source == GDK_SOURCE_KEYBOARD)
|
|
|
|
{
|
|
|
|
keyboard = device;
|
|
|
|
pointer = gdk_device_get_associated_device (device);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pointer = device;
|
|
|
|
keyboard = gdk_device_get_associated_device (device);
|
|
|
|
}
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (GTK_IS_MENU (priv->popup_widget))
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2007-12-25 04:04:21 +00:00
|
|
|
gtk_combo_box_menu_popup (combo_box,
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->activate_button,
|
|
|
|
priv->activate_time);
|
2003-09-26 21:57:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-02-17 22:54:37 +00:00
|
|
|
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (combo_box));
|
2005-02-16 16:37:24 +00:00
|
|
|
if (GTK_IS_WINDOW (toplevel))
|
2006-01-10 04:33:30 +00:00
|
|
|
gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)),
|
2007-12-28 06:56:48 +00:00
|
|
|
GTK_WINDOW (priv->popup_window));
|
2005-02-16 16:37:24 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_show_all (priv->scrolled_window);
|
2004-02-29 01:33:01 +00:00
|
|
|
gtk_combo_box_list_position (combo_box, &x, &y, &width, &height);
|
2004-07-07 15:15:35 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_set_size_request (priv->popup_window, width, height);
|
|
|
|
gtk_window_move (GTK_WINDOW (priv->popup_window), x, y);
|
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))
|
2004-08-02 19:15:05 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
path = gtk_tree_row_reference_get_path (priv->active_row);
|
2004-08-02 19:15:05 +00:00
|
|
|
ppath = gtk_tree_path_copy (path);
|
|
|
|
if (gtk_tree_path_up (ppath))
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_tree_view_expand_to_path (GTK_TREE_VIEW (priv->tree_view),
|
2004-08-02 19:15:05 +00:00
|
|
|
ppath);
|
|
|
|
gtk_tree_path_free (ppath);
|
|
|
|
}
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_tree_view_set_hover_expand (GTK_TREE_VIEW (priv->tree_view),
|
2004-08-02 19:15:05 +00:00
|
|
|
TRUE);
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
/* popup */
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_show (priv->popup_window);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-01-05 05:41:25 +00:00
|
|
|
if (path)
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->tree_view),
|
2007-01-05 05:41:25 +00:00
|
|
|
path, NULL, FALSE);
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_grab_focus (priv->popup_window);
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button),
|
2003-09-26 21:57:06 +00:00
|
|
|
TRUE);
|
|
|
|
|
2010-03-01 03:21:41 +00:00
|
|
|
if (!gtk_widget_has_focus (priv->tree_view))
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_grab_focus (priv->tree_view);
|
2005-06-26 06:26:47 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (!popup_grab_on_window (priv->popup_window->window,
|
2010-05-25 22:38:44 +00:00
|
|
|
keyboard, pointer, time))
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_hide (priv->popup_window);
|
2005-06-26 06:26:47 +00:00
|
|
|
return;
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
2004-02-26 22:40:12 +00:00
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
gtk_device_grab_add (priv->popup_window, pointer, TRUE);
|
|
|
|
priv->grab_pointer = pointer;
|
|
|
|
priv->grab_keyboard = keyboard;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_real_popup (GtkComboBox *combo_box)
|
|
|
|
{
|
|
|
|
GdkDevice *device;
|
|
|
|
|
|
|
|
device = gtk_get_current_event_device ();
|
|
|
|
|
|
|
|
if (!device)
|
|
|
|
{
|
|
|
|
GdkDeviceManager *device_manager;
|
|
|
|
GdkDisplay *display;
|
|
|
|
GList *devices;
|
|
|
|
|
|
|
|
display = gtk_widget_get_display (GTK_WIDGET (combo_box));
|
|
|
|
device_manager = gdk_display_get_device_manager (display);
|
|
|
|
|
|
|
|
/* No device was set, pick the first master device */
|
|
|
|
devices = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
|
|
|
|
device = devices->data;
|
|
|
|
g_list_free (devices);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_combo_box_popup_for_device (combo_box, device);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
2007-05-18 11:33:13 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_combo_box_real_popdown (GtkComboBox *combo_box)
|
|
|
|
{
|
|
|
|
if (combo_box->priv->popup_shown)
|
|
|
|
{
|
|
|
|
gtk_combo_box_popdown (combo_box);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-02-15 23:05:48 +00:00
|
|
|
/**
|
|
|
|
* gtk_combo_box_popdown:
|
|
|
|
* @combo_box: a #GtkComboBox
|
|
|
|
*
|
|
|
|
* 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
|
2007-03-12 06:04:44 +00:00
|
|
|
*/
|
2004-02-15 23:05:48 +00:00
|
|
|
void
|
2003-09-26 21:57:06 +00:00
|
|
|
gtk_combo_box_popdown (GtkComboBox *combo_box)
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
2004-02-15 23:05:48 +00:00
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (GTK_IS_MENU (priv->popup_widget))
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_menu_popdown (GTK_MENU (priv->popup_widget));
|
2003-09-26 21:57:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-03-02 06:16:02 +00:00
|
|
|
if (!gtk_widget_get_realized (GTK_WIDGET (combo_box)))
|
2005-04-08 22:07:35 +00:00
|
|
|
return;
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
gtk_device_grab_remove (priv->popup_window, priv->grab_pointer);
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_hide_all (priv->popup_window);
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button),
|
2003-09-26 21:57:06 +00:00
|
|
|
FALSE);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
priv->grab_pointer = NULL;
|
|
|
|
priv->grab_keyboard = NULL;
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
gtk_combo_box_calc_requested_width (GtkComboBox *combo_box,
|
|
|
|
GtkTreePath *path)
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2003-09-26 21:57:06 +00:00
|
|
|
gint padding;
|
|
|
|
GtkRequisition req;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->cell_view)
|
|
|
|
gtk_widget_style_get (priv->cell_view,
|
Fixes based on comments from Owen Taylor, #125264.
Tue Nov 18 19:47:59 2003 Kristian Rietveld <kris@gtk.org>
Fixes based on comments from Owen Taylor, #125264.
* gtk/gtkcellview.[ch] (gtk_cell_view_finalize): remove unused
variable,
(gtk_cell_view_set_value), (gtk_cell_view_set_displayed_model): queue
a resize,
(gtk_cell_view_get_size_of_row): new function,
(gtk_cell_view_set_value), (gtk_cell_view_set_valuesv),
(gtk_cell_view_set_values), (gtk_cell_view_set_model),
(gtk_cell_view_set_displayed_row), (gtk_cell_view_get_displayed_row):
s/cellview/cell_view/ in the function definitions, so they match
with the header file.
* gtk/gtkcombobox.c (gtk_combo_box_remeasure): remove the resize
flag again (:, and use gtk_cell_view_get_size_of_row instead of
the measurer, remove _set_size_request call,
(gtk_combo_box_calc_requested_width): use gtk_cell_view_get_size_of_row
instead of the measurer,
(gtk_combo_box_style_set): queue a resize,
(gtk_combo_box_size_request): update of _remeasure call,
(gtk_combo_box_init), (gtk_combo_box_cell_layout_pack_start),
(gtk_combo_box_cell_layout_pack_end),
(gtk_combo_box_cell_layout_clear),
(gtk_combo_box_set_model): get rid of the measurer,
(gtk_combo_box_cell_layout_add_attribute),
(gtk_combo_box_cell_layout_set_cell_data_func),
(gtk_combo_box_cell_layout_clear_attributes): ditto and queue a
resize instead of calling _remeasure.
2003-11-18 19:02:30 +00:00
|
|
|
"focus-line-width", &padding,
|
|
|
|
NULL);
|
|
|
|
else
|
|
|
|
padding = 0;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
/* add some pixels for good measure */
|
|
|
|
padding += BONUS_PADDING;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->cell_view)
|
|
|
|
gtk_cell_view_get_size_of_row (GTK_CELL_VIEW (priv->cell_view),
|
Fixes based on comments from Owen Taylor, #125264.
Tue Nov 18 19:47:59 2003 Kristian Rietveld <kris@gtk.org>
Fixes based on comments from Owen Taylor, #125264.
* gtk/gtkcellview.[ch] (gtk_cell_view_finalize): remove unused
variable,
(gtk_cell_view_set_value), (gtk_cell_view_set_displayed_model): queue
a resize,
(gtk_cell_view_get_size_of_row): new function,
(gtk_cell_view_set_value), (gtk_cell_view_set_valuesv),
(gtk_cell_view_set_values), (gtk_cell_view_set_model),
(gtk_cell_view_set_displayed_row), (gtk_cell_view_get_displayed_row):
s/cellview/cell_view/ in the function definitions, so they match
with the header file.
* gtk/gtkcombobox.c (gtk_combo_box_remeasure): remove the resize
flag again (:, and use gtk_cell_view_get_size_of_row instead of
the measurer, remove _set_size_request call,
(gtk_combo_box_calc_requested_width): use gtk_cell_view_get_size_of_row
instead of the measurer,
(gtk_combo_box_style_set): queue a resize,
(gtk_combo_box_size_request): update of _remeasure call,
(gtk_combo_box_init), (gtk_combo_box_cell_layout_pack_start),
(gtk_combo_box_cell_layout_pack_end),
(gtk_combo_box_cell_layout_clear),
(gtk_combo_box_set_model): get rid of the measurer,
(gtk_combo_box_cell_layout_add_attribute),
(gtk_combo_box_cell_layout_set_cell_data_func),
(gtk_combo_box_cell_layout_clear_attributes): ditto and queue a
resize instead of calling _remeasure.
2003-11-18 19:02:30 +00:00
|
|
|
path, &req);
|
|
|
|
else
|
|
|
|
req.width = 0;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
return req.width + padding;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
Fixes based on comments from Owen Taylor, #125264.
Tue Nov 18 19:47:59 2003 Kristian Rietveld <kris@gtk.org>
Fixes based on comments from Owen Taylor, #125264.
* gtk/gtkcellview.[ch] (gtk_cell_view_finalize): remove unused
variable,
(gtk_cell_view_set_value), (gtk_cell_view_set_displayed_model): queue
a resize,
(gtk_cell_view_get_size_of_row): new function,
(gtk_cell_view_set_value), (gtk_cell_view_set_valuesv),
(gtk_cell_view_set_values), (gtk_cell_view_set_model),
(gtk_cell_view_set_displayed_row), (gtk_cell_view_get_displayed_row):
s/cellview/cell_view/ in the function definitions, so they match
with the header file.
* gtk/gtkcombobox.c (gtk_combo_box_remeasure): remove the resize
flag again (:, and use gtk_cell_view_get_size_of_row instead of
the measurer, remove _set_size_request call,
(gtk_combo_box_calc_requested_width): use gtk_cell_view_get_size_of_row
instead of the measurer,
(gtk_combo_box_style_set): queue a resize,
(gtk_combo_box_size_request): update of _remeasure call,
(gtk_combo_box_init), (gtk_combo_box_cell_layout_pack_start),
(gtk_combo_box_cell_layout_pack_end),
(gtk_combo_box_cell_layout_clear),
(gtk_combo_box_set_model): get rid of the measurer,
(gtk_combo_box_cell_layout_add_attribute),
(gtk_combo_box_cell_layout_set_cell_data_func),
(gtk_combo_box_cell_layout_clear_attributes): ditto and queue a
resize instead of calling _remeasure.
2003-11-18 19:02:30 +00:00
|
|
|
gtk_combo_box_remeasure (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
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (!priv->model ||
|
|
|
|
!gtk_tree_model_get_iter_first (priv->model, &iter))
|
2003-09-26 21:57:06 +00:00
|
|
|
return;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->width = 0;
|
|
|
|
priv->height = 0;
|
Fixes based on comments from Owen Taylor, #125264.
Tue Nov 18 19:47:59 2003 Kristian Rietveld <kris@gtk.org>
Fixes based on comments from Owen Taylor, #125264.
* gtk/gtkcellview.[ch] (gtk_cell_view_finalize): remove unused
variable,
(gtk_cell_view_set_value), (gtk_cell_view_set_displayed_model): queue
a resize,
(gtk_cell_view_get_size_of_row): new function,
(gtk_cell_view_set_value), (gtk_cell_view_set_valuesv),
(gtk_cell_view_set_values), (gtk_cell_view_set_model),
(gtk_cell_view_set_displayed_row), (gtk_cell_view_get_displayed_row):
s/cellview/cell_view/ in the function definitions, so they match
with the header file.
* gtk/gtkcombobox.c (gtk_combo_box_remeasure): remove the resize
flag again (:, and use gtk_cell_view_get_size_of_row instead of
the measurer, remove _set_size_request call,
(gtk_combo_box_calc_requested_width): use gtk_cell_view_get_size_of_row
instead of the measurer,
(gtk_combo_box_style_set): queue a resize,
(gtk_combo_box_size_request): update of _remeasure call,
(gtk_combo_box_init), (gtk_combo_box_cell_layout_pack_start),
(gtk_combo_box_cell_layout_pack_end),
(gtk_combo_box_cell_layout_clear),
(gtk_combo_box_set_model): get rid of the measurer,
(gtk_combo_box_cell_layout_add_attribute),
(gtk_combo_box_cell_layout_set_cell_data_func),
(gtk_combo_box_cell_layout_clear_attributes): ditto and queue a
resize instead of calling _remeasure.
2003-11-18 19:02:30 +00:00
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
path = gtk_tree_path_new_from_indices (0, -1);
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
GtkRequisition req;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->cell_view)
|
|
|
|
gtk_cell_view_get_size_of_row (GTK_CELL_VIEW (priv->cell_view),
|
Fixes based on comments from Owen Taylor, #125264.
Tue Nov 18 19:47:59 2003 Kristian Rietveld <kris@gtk.org>
Fixes based on comments from Owen Taylor, #125264.
* gtk/gtkcellview.[ch] (gtk_cell_view_finalize): remove unused
variable,
(gtk_cell_view_set_value), (gtk_cell_view_set_displayed_model): queue
a resize,
(gtk_cell_view_get_size_of_row): new function,
(gtk_cell_view_set_value), (gtk_cell_view_set_valuesv),
(gtk_cell_view_set_values), (gtk_cell_view_set_model),
(gtk_cell_view_set_displayed_row), (gtk_cell_view_get_displayed_row):
s/cellview/cell_view/ in the function definitions, so they match
with the header file.
* gtk/gtkcombobox.c (gtk_combo_box_remeasure): remove the resize
flag again (:, and use gtk_cell_view_get_size_of_row instead of
the measurer, remove _set_size_request call,
(gtk_combo_box_calc_requested_width): use gtk_cell_view_get_size_of_row
instead of the measurer,
(gtk_combo_box_style_set): queue a resize,
(gtk_combo_box_size_request): update of _remeasure call,
(gtk_combo_box_init), (gtk_combo_box_cell_layout_pack_start),
(gtk_combo_box_cell_layout_pack_end),
(gtk_combo_box_cell_layout_clear),
(gtk_combo_box_set_model): get rid of the measurer,
(gtk_combo_box_cell_layout_add_attribute),
(gtk_combo_box_cell_layout_set_cell_data_func),
(gtk_combo_box_cell_layout_clear_attributes): ditto and queue a
resize instead of calling _remeasure.
2003-11-18 19:02:30 +00:00
|
|
|
path, &req);
|
|
|
|
else
|
2006-06-24 17:53:45 +00:00
|
|
|
{
|
|
|
|
req.width = 0;
|
|
|
|
req.height = 0;
|
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->width = MAX (priv->width, req.width);
|
|
|
|
priv->height = MAX (priv->height, req.height);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
gtk_tree_path_next (path);
|
|
|
|
}
|
2007-12-28 06:56:48 +00:00
|
|
|
while (gtk_tree_model_iter_next (priv->model, &iter));
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_size_request (GtkWidget *widget,
|
|
|
|
GtkRequisition *requisition)
|
|
|
|
{
|
|
|
|
gint width, height;
|
2004-07-16 20:27:40 +00:00
|
|
|
gint focus_width, focus_pad;
|
2006-11-01 19:15:54 +00:00
|
|
|
gint font_size;
|
|
|
|
gint arrow_size;
|
2010-06-02 04:28:22 +00:00
|
|
|
guint border_width;
|
2003-09-26 21:57:06 +00:00
|
|
|
GtkRequisition bin_req;
|
2006-11-01 19:15:54 +00:00
|
|
|
PangoContext *context;
|
|
|
|
PangoFontMetrics *metrics;
|
|
|
|
PangoFontDescription *font_desc;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2006-01-15 04:08:31 +00:00
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
/* common */
|
2010-05-24 20:31:36 +00:00
|
|
|
gtk_widget_size_request (gtk_bin_get_child (GTK_BIN (widget)), &bin_req);
|
Fixes based on comments from Owen Taylor, #125264.
Tue Nov 18 19:47:59 2003 Kristian Rietveld <kris@gtk.org>
Fixes based on comments from Owen Taylor, #125264.
* gtk/gtkcellview.[ch] (gtk_cell_view_finalize): remove unused
variable,
(gtk_cell_view_set_value), (gtk_cell_view_set_displayed_model): queue
a resize,
(gtk_cell_view_get_size_of_row): new function,
(gtk_cell_view_set_value), (gtk_cell_view_set_valuesv),
(gtk_cell_view_set_values), (gtk_cell_view_set_model),
(gtk_cell_view_set_displayed_row), (gtk_cell_view_get_displayed_row):
s/cellview/cell_view/ in the function definitions, so they match
with the header file.
* gtk/gtkcombobox.c (gtk_combo_box_remeasure): remove the resize
flag again (:, and use gtk_cell_view_get_size_of_row instead of
the measurer, remove _set_size_request call,
(gtk_combo_box_calc_requested_width): use gtk_cell_view_get_size_of_row
instead of the measurer,
(gtk_combo_box_style_set): queue a resize,
(gtk_combo_box_size_request): update of _remeasure call,
(gtk_combo_box_init), (gtk_combo_box_cell_layout_pack_start),
(gtk_combo_box_cell_layout_pack_end),
(gtk_combo_box_cell_layout_clear),
(gtk_combo_box_set_model): get rid of the measurer,
(gtk_combo_box_cell_layout_add_attribute),
(gtk_combo_box_cell_layout_set_cell_data_func),
(gtk_combo_box_cell_layout_clear_attributes): ditto and queue a
resize instead of calling _remeasure.
2003-11-18 19:02:30 +00:00
|
|
|
gtk_combo_box_remeasure (combo_box);
|
2007-12-28 06:56:48 +00:00
|
|
|
bin_req.width = MAX (bin_req.width, priv->width);
|
|
|
|
bin_req.height = MAX (bin_req.height, priv->height);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-07-16 20:27:40 +00:00
|
|
|
gtk_widget_style_get (GTK_WIDGET (widget),
|
|
|
|
"focus-line-width", &focus_width,
|
|
|
|
"focus-padding", &focus_pad,
|
2006-11-01 19:15:54 +00:00
|
|
|
"arrow-size", &arrow_size,
|
2004-07-16 20:27:40 +00:00
|
|
|
NULL);
|
|
|
|
|
2010-05-24 20:31:36 +00:00
|
|
|
font_desc = gtk_bin_get_child (GTK_BIN (widget))->style->font_desc;
|
2006-11-01 19:15:54 +00:00
|
|
|
context = gtk_widget_get_pango_context (widget);
|
|
|
|
metrics = pango_context_get_metrics (context, font_desc,
|
|
|
|
pango_context_get_language (context));
|
|
|
|
font_size = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
|
|
|
|
pango_font_metrics_get_descent (metrics));
|
|
|
|
pango_font_metrics_unref (metrics);
|
|
|
|
|
|
|
|
arrow_size = MAX (arrow_size, font_size);
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_set_size_request (priv->arrow, arrow_size, arrow_size);
|
2006-11-01 19:15:54 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (!priv->tree_view)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
|
|
|
/* menu mode */
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->cell_view)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2004-03-07 01:37:06 +00:00
|
|
|
GtkRequisition button_req, sep_req, arrow_req;
|
2010-06-02 04:28:22 +00:00
|
|
|
gint xthickness, ythickness;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_size_request (priv->button, &button_req);
|
2010-06-02 04:28:22 +00:00
|
|
|
border_width = gtk_container_get_border_width (GTK_CONTAINER (combo_box));
|
2007-12-28 06:56:48 +00:00
|
|
|
xthickness = priv->button->style->xthickness;
|
|
|
|
ythickness = priv->button->style->ythickness;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
bin_req.width = MAX (bin_req.width, priv->width);
|
|
|
|
bin_req.height = MAX (bin_req.height, priv->height);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_size_request (priv->separator, &sep_req);
|
|
|
|
gtk_widget_size_request (priv->arrow, &arrow_req);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
height = MAX (sep_req.height, arrow_req.height);
|
|
|
|
height = MAX (height, bin_req.height);
|
|
|
|
|
|
|
|
width = bin_req.width + sep_req.width + arrow_req.width;
|
|
|
|
|
2004-07-16 20:27:40 +00:00
|
|
|
height += 2*(border_width + ythickness + focus_width + focus_pad);
|
|
|
|
width += 2*(border_width + xthickness + focus_width + focus_pad);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2003-10-10 17:18:34 +00:00
|
|
|
requisition->width = width;
|
|
|
|
requisition->height = height;
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GtkRequisition but_req;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_size_request (priv->button, &but_req);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
requisition->width = bin_req.width + but_req.width;
|
|
|
|
requisition->height = MAX (bin_req.height, but_req.height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* list mode */
|
2004-03-07 01:37:06 +00:00
|
|
|
GtkRequisition button_req, frame_req;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
/* sample + frame */
|
|
|
|
*requisition = bin_req;
|
|
|
|
|
2004-07-26 04:50:07 +00:00
|
|
|
requisition->width += 2 * focus_width;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->cell_view_frame)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_size_request (priv->cell_view_frame, &frame_req);
|
|
|
|
if (priv->has_frame)
|
2004-07-16 20:27:40 +00:00
|
|
|
{
|
2010-06-02 04:28:22 +00:00
|
|
|
border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame));
|
|
|
|
|
|
|
|
requisition->width += 2 * (border_width + GTK_WIDGET (priv->cell_view_frame)->style->xthickness);
|
|
|
|
requisition->height += 2 * (border_width + GTK_WIDGET (priv->cell_view_frame)->style->ythickness);
|
2004-07-16 20:27:40 +00:00
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* the button */
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_size_request (priv->button, &button_req);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
requisition->height = MAX (requisition->height, button_req.height);
|
|
|
|
requisition->width += button_req.width;
|
|
|
|
}
|
2007-03-08 02:36:46 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (GTK_SHADOW_NONE != priv->shadow_type)
|
2007-03-08 02:36:46 +00:00
|
|
|
{
|
|
|
|
requisition->height += 2 * widget->style->ythickness;
|
|
|
|
requisition->width += 2 * widget->style->xthickness;
|
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
2007-03-08 02:36:46 +00:00
|
|
|
#define GTK_COMBO_BOX_SIZE_ALLOCATE_BUTTON \
|
|
|
|
gtk_widget_size_request (combo_box->priv->button, &req); \
|
|
|
|
\
|
|
|
|
if (is_rtl) \
|
|
|
|
child.x = allocation->x + shadow_width; \
|
|
|
|
else \
|
|
|
|
child.x = allocation->x + allocation->width - req.width - shadow_width; \
|
|
|
|
\
|
|
|
|
child.y = allocation->y + shadow_height; \
|
|
|
|
child.width = req.width; \
|
|
|
|
child.height = allocation->height - 2 * shadow_height; \
|
|
|
|
child.width = MAX (1, child.width); \
|
|
|
|
child.height = MAX (1, child.height); \
|
|
|
|
\
|
|
|
|
gtk_widget_size_allocate (combo_box->priv->button, &child);
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2010-05-24 20:31:36 +00:00
|
|
|
GtkWidget *child_widget;
|
2007-03-08 02:36:46 +00:00
|
|
|
gint shadow_width, shadow_height;
|
2004-07-16 20:27:40 +00:00
|
|
|
gint focus_width, focus_pad;
|
2003-09-26 21:57:06 +00:00
|
|
|
GtkAllocation child;
|
|
|
|
GtkRequisition req;
|
2003-12-12 20:08:58 +00:00
|
|
|
gboolean is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
widget->allocation = *allocation;
|
2010-05-24 20:31:36 +00:00
|
|
|
child_widget = gtk_bin_get_child (GTK_BIN (widget));
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-07-16 20:27:40 +00:00
|
|
|
gtk_widget_style_get (GTK_WIDGET (widget),
|
|
|
|
"focus-line-width", &focus_width,
|
|
|
|
"focus-padding", &focus_pad,
|
|
|
|
NULL);
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (GTK_SHADOW_NONE != priv->shadow_type)
|
2007-03-08 02:36:46 +00:00
|
|
|
{
|
|
|
|
shadow_width = widget->style->xthickness;
|
|
|
|
shadow_height = widget->style->ythickness;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
shadow_width = 0;
|
|
|
|
shadow_height = 0;
|
|
|
|
}
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (!priv->tree_view)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->cell_view)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2010-06-02 04:28:22 +00:00
|
|
|
gint xthickness, ythickness;
|
2003-09-26 21:57:06 +00:00
|
|
|
gint width;
|
2010-06-02 04:28:22 +00:00
|
|
|
guint border_width;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
/* menu mode */
|
2007-03-08 02:36:46 +00:00
|
|
|
allocation->x += shadow_width;
|
|
|
|
allocation->y += shadow_height;
|
|
|
|
allocation->width -= 2 * shadow_width;
|
|
|
|
allocation->height -= 2 * shadow_height;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_size_allocate (priv->button, allocation);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
/* set some things ready */
|
2010-06-02 04:28:22 +00:00
|
|
|
border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->button));
|
2007-12-28 06:56:48 +00:00
|
|
|
xthickness = priv->button->style->xthickness;
|
|
|
|
ythickness = priv->button->style->ythickness;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-07-16 20:27:40 +00:00
|
|
|
child.x = allocation->x;
|
|
|
|
child.y = allocation->y;
|
|
|
|
width = allocation->width;
|
|
|
|
child.height = allocation->height;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (!priv->is_cell_renderer)
|
2004-07-16 20:27:40 +00:00
|
|
|
{
|
|
|
|
child.x += border_width + xthickness + focus_width + focus_pad;
|
|
|
|
child.y += border_width + ythickness + focus_width + focus_pad;
|
|
|
|
width -= 2 * (child.x - allocation->x);
|
|
|
|
child.height -= 2 * (child.y - allocation->y);
|
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
|
2004-03-08 18:39:44 +00:00
|
|
|
/* handle the children */
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_size_request (priv->arrow, &req);
|
2003-09-26 21:57:06 +00:00
|
|
|
child.width = req.width;
|
2003-12-12 20:08:58 +00:00
|
|
|
if (!is_rtl)
|
|
|
|
child.x += width - req.width;
|
2004-08-13 04:00:29 +00:00
|
|
|
child.width = MAX (1, child.width);
|
|
|
|
child.height = MAX (1, child.height);
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_size_allocate (priv->arrow, &child);
|
2003-12-12 20:08:58 +00:00
|
|
|
if (is_rtl)
|
|
|
|
child.x += req.width;
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_size_request (priv->separator, &req);
|
2003-09-26 21:57:06 +00:00
|
|
|
child.width = req.width;
|
2003-12-12 20:08:58 +00:00
|
|
|
if (!is_rtl)
|
|
|
|
child.x -= req.width;
|
2004-08-13 04:00:29 +00:00
|
|
|
child.width = MAX (1, child.width);
|
|
|
|
child.height = MAX (1, child.height);
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_size_allocate (priv->separator, &child);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2003-12-12 20:08:58 +00:00
|
|
|
if (is_rtl)
|
|
|
|
{
|
|
|
|
child.x += req.width;
|
|
|
|
child.width = allocation->x + allocation->width
|
2004-07-16 20:27:40 +00:00
|
|
|
- (border_width + xthickness + focus_width + focus_pad)
|
|
|
|
- child.x;
|
2003-12-12 20:08:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
child.width = child.x;
|
2004-07-16 20:27:40 +00:00
|
|
|
child.x = allocation->x
|
|
|
|
+ border_width + xthickness + focus_width + focus_pad;
|
2003-12-12 20:08:58 +00:00
|
|
|
child.width -= child.x;
|
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2010-03-01 06:47:38 +00:00
|
|
|
if (gtk_widget_get_visible (priv->popup_widget))
|
2008-09-03 12:38:32 +00:00
|
|
|
{
|
|
|
|
gint width;
|
|
|
|
GtkRequisition requisition;
|
|
|
|
|
|
|
|
/* Warning here, without the check in the position func */
|
|
|
|
gtk_menu_reposition (GTK_MENU (priv->popup_widget));
|
|
|
|
if (priv->wrap_width == 0)
|
|
|
|
{
|
|
|
|
width = GTK_WIDGET (combo_box)->allocation.width;
|
|
|
|
gtk_widget_set_size_request (priv->popup_widget, -1, -1);
|
|
|
|
gtk_widget_size_request (priv->popup_widget, &requisition);
|
|
|
|
gtk_widget_set_size_request (priv->popup_widget,
|
|
|
|
MAX (width, requisition.width), -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-13 04:00:29 +00:00
|
|
|
child.width = MAX (1, child.width);
|
|
|
|
child.height = MAX (1, child.height);
|
2010-05-24 20:31:36 +00:00
|
|
|
gtk_widget_size_allocate (child_widget, &child);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-03-08 02:36:46 +00:00
|
|
|
GTK_COMBO_BOX_SIZE_ALLOCATE_BUTTON
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2003-12-12 20:08:58 +00:00
|
|
|
if (is_rtl)
|
2007-03-08 02:36:46 +00:00
|
|
|
child.x = allocation->x + req.width + shadow_width;
|
2003-12-12 20:08:58 +00:00
|
|
|
else
|
2007-03-08 02:36:46 +00:00
|
|
|
child.x = allocation->x + shadow_width;
|
|
|
|
child.y = allocation->y + shadow_height;
|
|
|
|
child.width = allocation->width - req.width - 2 * shadow_width;
|
2004-08-13 04:00:29 +00:00
|
|
|
child.width = MAX (1, child.width);
|
|
|
|
child.height = MAX (1, child.height);
|
2010-05-24 20:31:36 +00:00
|
|
|
gtk_widget_size_allocate (child_widget, &child);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* list mode */
|
|
|
|
|
2008-03-16 01:37:12 +00:00
|
|
|
/* Combobox thickness + border-width */
|
2010-06-02 04:28:22 +00:00
|
|
|
guint border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
|
|
|
|
int delta_x = shadow_width + border_width;
|
|
|
|
int delta_y = shadow_height + border_width;
|
2008-03-16 01:37:12 +00:00
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
/* button */
|
2007-03-08 02:36:46 +00:00
|
|
|
GTK_COMBO_BOX_SIZE_ALLOCATE_BUTTON
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
/* frame */
|
2003-12-12 20:08:58 +00:00
|
|
|
if (is_rtl)
|
|
|
|
child.x = allocation->x + req.width;
|
|
|
|
else
|
|
|
|
child.x = allocation->x;
|
2008-03-16 01:37:12 +00:00
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
child.y = allocation->y;
|
|
|
|
child.width = allocation->width - req.width;
|
2003-10-10 17:18:34 +00:00
|
|
|
child.height = allocation->height;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->cell_view_frame)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2008-03-16 01:37:12 +00:00
|
|
|
child.x += delta_x;
|
|
|
|
child.y += delta_y;
|
|
|
|
child.width = MAX (1, child.width - delta_x * 2);
|
|
|
|
child.height = MAX (1, child.height - delta_y * 2);
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_size_allocate (priv->cell_view_frame, &child);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
/* the sample */
|
2008-03-16 01:37:12 +00:00
|
|
|
if (priv->has_frame)
|
|
|
|
{
|
2010-06-02 04:28:22 +00:00
|
|
|
border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame));
|
|
|
|
delta_x = border_width + GTK_WIDGET (priv->cell_view_frame)->style->xthickness;
|
|
|
|
delta_y = border_width + GTK_WIDGET (priv->cell_view_frame)->style->ythickness;
|
2008-03-16 01:37:12 +00:00
|
|
|
|
|
|
|
child.x += delta_x;
|
|
|
|
child.y += delta_y;
|
|
|
|
child.width -= delta_x * 2;
|
|
|
|
child.height -= delta_y * 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
child.x += delta_x;
|
|
|
|
child.y += delta_y;
|
|
|
|
child.width -= delta_x * 2;
|
|
|
|
child.height -= delta_y * 2;
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
2008-09-03 12:38:32 +00:00
|
|
|
|
2010-03-01 06:47:38 +00:00
|
|
|
if (gtk_widget_get_visible (priv->popup_window))
|
2008-09-03 12:38:32 +00:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2008-03-11 13:46:37 +00:00
|
|
|
|
2004-08-13 04:00:29 +00:00
|
|
|
child.width = MAX (1, child.width);
|
|
|
|
child.height = MAX (1, child.height);
|
2008-03-11 13:46:37 +00:00
|
|
|
|
2010-05-24 20:31:36 +00:00
|
|
|
gtk_widget_size_allocate (child_widget, &child);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-08 02:36:46 +00:00
|
|
|
#undef GTK_COMBO_BOX_ALLOCATE_BUTTON
|
|
|
|
|
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)
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
|
|
|
if (priv->model)
|
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
|
|
|
g_signal_handler_disconnect (priv->model,
|
|
|
|
priv->inserted_id);
|
|
|
|
g_signal_handler_disconnect (priv->model,
|
|
|
|
priv->deleted_id);
|
|
|
|
g_signal_handler_disconnect (priv->model,
|
|
|
|
priv->reordered_id);
|
|
|
|
g_signal_handler_disconnect (priv->model,
|
|
|
|
priv->changed_id);
|
2004-02-24 23:12:57 +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
|
|
|
|
2004-02-24 23:12:57 +00:00
|
|
|
/* menu mode */
|
2007-12-28 06:56:48 +00:00
|
|
|
if (!priv->tree_view)
|
2004-02-24 23:12:57 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->popup_widget)
|
|
|
|
gtk_container_foreach (GTK_CONTAINER (priv->popup_widget),
|
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
|
|
|
(GtkCallback)gtk_widget_destroy, NULL);
|
|
|
|
}
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->model)
|
2004-04-12 20:06:52 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
g_object_unref (priv->model);
|
|
|
|
priv->model = NULL;
|
2004-04-12 20:06:52 +00:00
|
|
|
}
|
2004-07-03 03:37:44 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->active_row)
|
2004-08-02 19:15:05 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_tree_row_reference_free (priv->active_row);
|
|
|
|
priv->active_row = NULL;
|
2004-08-02 19:15:05 +00:00
|
|
|
}
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->cell_view)
|
|
|
|
gtk_cell_view_set_model (GTK_CELL_VIEW (priv->cell_view), NULL);
|
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
|
|
|
}
|
|
|
|
|
2003-09-26 21:57:06 +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);
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2010-05-24 20:31:36 +00:00
|
|
|
GtkWidget *child;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
if (include_internals)
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->button)
|
|
|
|
(* callback) (priv->button, callback_data);
|
|
|
|
if (priv->cell_view_frame)
|
|
|
|
(* callback) (priv->cell_view_frame, callback_data);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
2010-05-24 20:31:36 +00:00
|
|
|
child = gtk_bin_get_child (GTK_BIN (container));
|
|
|
|
if (child)
|
|
|
|
(* callback) (child, callback_data);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
2005-11-10 21:17:19 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_child_show (GtkWidget *widget,
|
2006-03-09 20:20:30 +00:00
|
|
|
GtkComboBox *combo_box)
|
2005-11-10 21:17:19 +00:00
|
|
|
{
|
2006-03-09 20:20:30 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
|
|
|
priv->popup_shown = TRUE;
|
|
|
|
g_object_notify (G_OBJECT (combo_box), "popup-shown");
|
2005-11-10 21:17:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_child_hide (GtkWidget *widget,
|
2006-03-09 20:20:30 +00:00
|
|
|
GtkComboBox *combo_box)
|
2005-11-10 21:17:19 +00:00
|
|
|
{
|
2006-03-09 20:20:30 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
|
|
|
priv->popup_shown = FALSE;
|
|
|
|
g_object_notify (G_OBJECT (combo_box), "popup-shown");
|
2005-11-10 21:17:19 +00:00
|
|
|
}
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_combo_box_expose_event (GtkWidget *widget,
|
|
|
|
GdkEventExpose *event)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2010-01-07 15:47:35 +00:00
|
|
|
if (gtk_widget_is_drawable (widget) &&
|
2007-12-28 06:56:48 +00:00
|
|
|
GTK_SHADOW_NONE != priv->shadow_type)
|
2007-03-08 02:36:46 +00:00
|
|
|
{
|
|
|
|
gtk_paint_shadow (widget->style, widget->window,
|
2007-12-28 06:56:48 +00:00
|
|
|
GTK_STATE_NORMAL, priv->shadow_type,
|
2007-03-08 02:36:46 +00:00
|
|
|
NULL, widget, "combobox",
|
|
|
|
widget->allocation.x, widget->allocation.y,
|
|
|
|
widget->allocation.width, widget->allocation.height);
|
|
|
|
}
|
|
|
|
|
2007-02-16 16:00:19 +00:00
|
|
|
gtk_container_propagate_expose (GTK_CONTAINER (widget),
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->button, event);
|
2007-02-16 16:00:19 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->tree_view && priv->cell_view_frame)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
|
|
|
gtk_container_propagate_expose (GTK_CONTAINER (widget),
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->cell_view_frame, event);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_container_propagate_expose (GTK_CONTAINER (widget),
|
2010-05-24 20:31:36 +00:00
|
|
|
gtk_bin_get_child (GTK_BIN (widget)),
|
|
|
|
event);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
typedef struct {
|
|
|
|
GtkComboBox *combo;
|
|
|
|
GtkTreePath *path;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gboolean found;
|
|
|
|
gboolean set;
|
|
|
|
gboolean visible;
|
|
|
|
} SearchData;
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
path_visible (GtkTreeView *view,
|
|
|
|
GtkTreePath *path)
|
|
|
|
{
|
|
|
|
GtkRBTree *tree;
|
|
|
|
GtkRBNode *node;
|
|
|
|
|
|
|
|
/* Note that we rely on the fact that collapsed rows don't have nodes
|
|
|
|
*/
|
|
|
|
return _gtk_tree_view_find_node (view, path, &tree, &node);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
tree_next_func (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
SearchData *search_data = (SearchData *)data;
|
|
|
|
|
|
|
|
if (search_data->found)
|
|
|
|
{
|
|
|
|
if (!tree_column_row_is_sensitive (search_data->combo, iter))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (search_data->visible &&
|
|
|
|
!path_visible (GTK_TREE_VIEW (search_data->combo->priv->tree_view), path))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
search_data->set = TRUE;
|
|
|
|
search_data->iter = *iter;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gtk_tree_path_compare (path, search_data->path) == 0)
|
|
|
|
search_data->found = TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
tree_next (GtkComboBox *combo,
|
|
|
|
GtkTreeModel *model,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
GtkTreeIter *next,
|
|
|
|
gboolean visible)
|
|
|
|
{
|
|
|
|
SearchData search_data;
|
|
|
|
|
|
|
|
search_data.combo = combo;
|
|
|
|
search_data.path = gtk_tree_model_get_path (model, iter);
|
|
|
|
search_data.visible = visible;
|
|
|
|
search_data.found = FALSE;
|
|
|
|
search_data.set = FALSE;
|
|
|
|
|
|
|
|
gtk_tree_model_foreach (model, tree_next_func, &search_data);
|
|
|
|
|
|
|
|
*next = search_data.iter;
|
|
|
|
|
|
|
|
gtk_tree_path_free (search_data.path);
|
|
|
|
|
|
|
|
return search_data.set;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
tree_prev_func (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
SearchData *search_data = (SearchData *)data;
|
|
|
|
|
|
|
|
if (gtk_tree_path_compare (path, search_data->path) == 0)
|
|
|
|
{
|
|
|
|
search_data->found = TRUE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!tree_column_row_is_sensitive (search_data->combo, iter))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (search_data->visible &&
|
|
|
|
!path_visible (GTK_TREE_VIEW (search_data->combo->priv->tree_view), path))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
search_data->set = TRUE;
|
|
|
|
search_data->iter = *iter;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
tree_prev (GtkComboBox *combo,
|
|
|
|
GtkTreeModel *model,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
GtkTreeIter *prev,
|
|
|
|
gboolean visible)
|
|
|
|
{
|
|
|
|
SearchData search_data;
|
|
|
|
|
|
|
|
search_data.combo = combo;
|
|
|
|
search_data.path = gtk_tree_model_get_path (model, iter);
|
|
|
|
search_data.visible = visible;
|
|
|
|
search_data.found = FALSE;
|
|
|
|
search_data.set = FALSE;
|
|
|
|
|
|
|
|
gtk_tree_model_foreach (model, tree_prev_func, &search_data);
|
|
|
|
|
|
|
|
*prev = search_data.iter;
|
|
|
|
|
|
|
|
gtk_tree_path_free (search_data.path);
|
|
|
|
|
|
|
|
return search_data.set;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
tree_last_func (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
SearchData *search_data = (SearchData *)data;
|
|
|
|
|
|
|
|
if (!tree_column_row_is_sensitive (search_data->combo, iter))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* Note that we rely on the fact that collapsed rows don't have nodes
|
|
|
|
*/
|
|
|
|
if (search_data->visible &&
|
|
|
|
!path_visible (GTK_TREE_VIEW (search_data->combo->priv->tree_view), path))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
search_data->set = TRUE;
|
|
|
|
search_data->iter = *iter;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
tree_last (GtkComboBox *combo,
|
|
|
|
GtkTreeModel *model,
|
|
|
|
GtkTreeIter *last,
|
|
|
|
gboolean visible)
|
|
|
|
{
|
|
|
|
SearchData search_data;
|
|
|
|
|
|
|
|
search_data.combo = combo;
|
|
|
|
search_data.visible = visible;
|
|
|
|
search_data.set = FALSE;
|
|
|
|
|
|
|
|
gtk_tree_model_foreach (model, tree_last_func, &search_data);
|
|
|
|
|
|
|
|
*last = search_data.iter;
|
|
|
|
|
|
|
|
return search_data.set;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
tree_first_func (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
SearchData *search_data = (SearchData *)data;
|
|
|
|
|
|
|
|
if (!tree_column_row_is_sensitive (search_data->combo, iter))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (search_data->visible &&
|
|
|
|
!path_visible (GTK_TREE_VIEW (search_data->combo->priv->tree_view), path))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
search_data->set = TRUE;
|
|
|
|
search_data->iter = *iter;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
tree_first (GtkComboBox *combo,
|
|
|
|
GtkTreeModel *model,
|
|
|
|
GtkTreeIter *first,
|
|
|
|
gboolean visible)
|
|
|
|
{
|
|
|
|
SearchData search_data;
|
|
|
|
|
|
|
|
search_data.combo = combo;
|
|
|
|
search_data.visible = visible;
|
|
|
|
search_data.set = FALSE;
|
|
|
|
|
|
|
|
gtk_tree_model_foreach (model, tree_first_func, &search_data);
|
|
|
|
|
|
|
|
*first = search_data.iter;
|
|
|
|
|
|
|
|
return search_data.set;
|
|
|
|
}
|
|
|
|
|
2003-11-19 22:26:42 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_combo_box_scroll_event (GtkWidget *widget,
|
|
|
|
GdkEventScroll *event)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
|
2004-08-02 19:15:05 +00:00
|
|
|
gboolean found;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeIter new_iter;
|
2003-11-19 22:26:42 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
if (!gtk_combo_box_get_active_iter (combo_box, &iter))
|
|
|
|
return TRUE;
|
2004-07-16 21:13:21 +00:00
|
|
|
|
|
|
|
if (event->direction == GDK_SCROLL_UP)
|
2004-08-02 19:15:05 +00:00
|
|
|
found = tree_prev (combo_box, combo_box->priv->model,
|
|
|
|
&iter, &new_iter, FALSE);
|
2004-07-16 21:13:21 +00:00
|
|
|
else
|
2004-08-02 19:15:05 +00:00
|
|
|
found = tree_next (combo_box, combo_box->priv->model,
|
|
|
|
&iter, &new_iter, FALSE);
|
|
|
|
|
|
|
|
if (found)
|
|
|
|
gtk_combo_box_set_active_iter (combo_box, &new_iter);
|
2003-11-19 22:26:42 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
/*
|
|
|
|
* menu style
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2004-08-02 19:15:05 +00:00
|
|
|
gtk_combo_box_sync_cells (GtkComboBox *combo_box,
|
|
|
|
GtkCellLayout *cell_layout)
|
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
|
|
|
GSList *k;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
for (k = priv->cells; k; k = k->next)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
|
|
|
GSList *j;
|
|
|
|
ComboCellInfo *info = (ComboCellInfo *)k->data;
|
|
|
|
|
|
|
|
if (info->pack == GTK_PACK_START)
|
2004-08-02 19:15:05 +00:00
|
|
|
gtk_cell_layout_pack_start (cell_layout,
|
2003-10-01 20:51:54 +00:00
|
|
|
info->cell, info->expand);
|
2003-09-26 21:57:06 +00:00
|
|
|
else if (info->pack == GTK_PACK_END)
|
2004-08-02 19:15:05 +00:00
|
|
|
gtk_cell_layout_pack_end (cell_layout,
|
2003-10-01 20:51:54 +00:00
|
|
|
info->cell, info->expand);
|
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
gtk_cell_layout_set_cell_data_func (cell_layout,
|
2003-10-01 20:51:54 +00:00
|
|
|
info->cell,
|
2004-08-02 19:15:05 +00:00
|
|
|
combo_cell_data_func, info, NULL);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
for (j = info->attributes; j; j = j->next->next)
|
|
|
|
{
|
2004-08-02 19:15:05 +00:00
|
|
|
gtk_cell_layout_add_attribute (cell_layout,
|
2003-10-01 20:51:54 +00:00
|
|
|
info->cell,
|
|
|
|
j->data,
|
|
|
|
GPOINTER_TO_INT (j->next->data));
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_menu_setup (GtkComboBox *combo_box,
|
2004-03-08 18:39:44 +00:00
|
|
|
gboolean add_children)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2010-05-24 20:31:36 +00:00
|
|
|
GtkWidget *child;
|
2004-04-14 20:26:26 +00:00
|
|
|
GtkWidget *menu;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2010-05-24 20:31:36 +00:00
|
|
|
child = gtk_bin_get_child (GTK_BIN (combo_box));
|
|
|
|
|
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
|
|
|
priv->button = gtk_toggle_button_new ();
|
|
|
|
gtk_button_set_focus_on_click (GTK_BUTTON (priv->button),
|
|
|
|
priv->focus_on_click);
|
2004-11-07 04:10:01 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
g_signal_connect (priv->button, "toggled",
|
2003-09-26 21:57:06 +00:00
|
|
|
G_CALLBACK (gtk_combo_box_button_toggled), combo_box);
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_set_parent (priv->button,
|
2010-05-24 20:31:36 +00:00
|
|
|
gtk_widget_get_parent (child));
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->box = gtk_hbox_new (FALSE, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (priv->button), priv->box);
|
2004-04-14 20:26:26 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->separator = gtk_vseparator_new ();
|
|
|
|
gtk_container_add (GTK_CONTAINER (priv->box), priv->separator);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
|
|
|
|
gtk_container_add (GTK_CONTAINER (priv->box), priv->arrow);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_show_all (priv->button);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->button = gtk_toggle_button_new ();
|
|
|
|
gtk_button_set_focus_on_click (GTK_BUTTON (priv->button),
|
|
|
|
priv->focus_on_click);
|
2005-07-18 14:47:55 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
g_signal_connect (priv->button, "toggled",
|
2003-09-26 21:57:06 +00:00
|
|
|
G_CALLBACK (gtk_combo_box_button_toggled), combo_box);
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_set_parent (priv->button,
|
2010-05-24 20:31:36 +00:00
|
|
|
gtk_widget_get_parent (child));
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
|
|
|
|
gtk_container_add (GTK_CONTAINER (priv->button), priv->arrow);
|
|
|
|
gtk_widget_show_all (priv->button);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
2008-08-11 09:17:49 +00:00
|
|
|
g_signal_connect (priv->button, "button-press-event",
|
2003-09-26 21:57:06 +00:00
|
|
|
G_CALLBACK (gtk_combo_box_menu_button_press),
|
|
|
|
combo_box);
|
2008-08-11 09:17:49 +00:00
|
|
|
g_signal_connect (priv->button, "state-changed",
|
2004-12-24 03:44:17 +00:00
|
|
|
G_CALLBACK (gtk_combo_box_button_state_changed),
|
|
|
|
combo_box);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
/* create our funky menu */
|
2004-04-14 20:26:26 +00:00
|
|
|
menu = gtk_menu_new ();
|
2007-03-07 21:10:45 +00:00
|
|
|
gtk_widget_set_name (menu, "gtk-combobox-popup-menu");
|
2009-06-24 05:01:51 +00:00
|
|
|
gtk_menu_set_reserve_toggle_size (GTK_MENU (menu), FALSE);
|
2007-03-07 21:10:45 +00:00
|
|
|
|
2008-08-11 09:17:49 +00:00
|
|
|
g_signal_connect (menu, "key-press-event",
|
2004-03-04 23:35:31 +00:00
|
|
|
G_CALLBACK (gtk_combo_box_menu_key_press), combo_box);
|
2004-04-14 20:26:26 +00:00
|
|
|
gtk_combo_box_set_popup_widget (combo_box, menu);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
/* add items */
|
2004-03-08 18:39:44 +00:00
|
|
|
if (add_children)
|
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
|
|
|
gtk_combo_box_menu_fill (combo_box);
|
2004-02-24 23:12:57 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
/* the column is needed in tree_column_row_is_sensitive() */
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->column = gtk_tree_view_column_new ();
|
|
|
|
g_object_ref_sink (priv->column);
|
|
|
|
gtk_combo_box_sync_cells (combo_box, GTK_CELL_LAYOUT (priv->column));
|
2005-11-21 16:01:56 +00:00
|
|
|
|
|
|
|
gtk_combo_box_update_title (combo_box);
|
2009-09-09 07:43:30 +00:00
|
|
|
gtk_combo_box_update_sensitivity (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
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_menu_fill (GtkComboBox *combo_box)
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
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
|
|
|
GtkWidget *menu;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (!priv->model)
|
2003-09-26 21:57:06 +00:00
|
|
|
return;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
menu = priv->popup_widget;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->add_tearoffs)
|
2004-05-10 14:07:35 +00:00
|
|
|
{
|
|
|
|
GtkWidget *tearoff = gtk_tearoff_menu_item_new ();
|
|
|
|
|
|
|
|
gtk_widget_show (tearoff);
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->wrap_width)
|
|
|
|
gtk_menu_attach (GTK_MENU (menu), tearoff, 0, priv->wrap_width, 0, 1);
|
2004-05-10 14:07:35 +00:00
|
|
|
else
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), tearoff);
|
|
|
|
}
|
2004-08-02 19:15:05 +00:00
|
|
|
|
|
|
|
gtk_combo_box_menu_fill_level (combo_box, menu, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
gtk_cell_view_menu_item_new (GtkComboBox *combo_box,
|
|
|
|
GtkTreeModel *model,
|
|
|
|
GtkTreeIter *iter)
|
|
|
|
{
|
|
|
|
GtkWidget *cell_view;
|
|
|
|
GtkWidget *item;
|
|
|
|
GtkTreePath *path;
|
|
|
|
GtkRequisition req;
|
2004-05-10 14:07:35 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
cell_view = gtk_cell_view_new ();
|
2006-06-26 10:25:14 +00:00
|
|
|
item = gtk_menu_item_new ();
|
|
|
|
gtk_container_add (GTK_CONTAINER (item), cell_view);
|
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
gtk_cell_view_set_model (GTK_CELL_VIEW (cell_view), model);
|
|
|
|
path = gtk_tree_model_get_path (model, iter);
|
|
|
|
gtk_cell_view_set_displayed_row (GTK_CELL_VIEW (cell_view), path);
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
|
|
|
gtk_combo_box_sync_cells (combo_box, GTK_CELL_LAYOUT (cell_view));
|
|
|
|
gtk_widget_size_request (cell_view, &req);
|
|
|
|
gtk_widget_show (cell_view);
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_menu_fill_level (GtkComboBox *combo_box,
|
|
|
|
GtkWidget *menu,
|
|
|
|
GtkTreeIter *parent)
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
GtkTreeModel *model = priv->model;
|
2004-08-02 19:15:05 +00:00
|
|
|
GtkWidget *item, *submenu, *subitem, *separator;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gboolean is_separator;
|
|
|
|
gint i, n_children;
|
2004-08-03 05:22:21 +00:00
|
|
|
GtkWidget *last;
|
2004-11-09 16:38:57 +00:00
|
|
|
GtkTreePath *path;
|
2004-08-03 05:22:21 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
n_children = gtk_tree_model_iter_n_children (model, parent);
|
|
|
|
|
2004-08-03 05:22:21 +00:00
|
|
|
last = NULL;
|
2004-08-02 19:15:05 +00:00
|
|
|
for (i = 0; i < n_children; i++)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2004-08-02 19:15:05 +00:00
|
|
|
gtk_tree_model_iter_nth_child (model, &iter, parent, i);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->row_separator_func)
|
2008-08-12 09:51:16 +00:00
|
|
|
is_separator = priv->row_separator_func (priv->model, &iter,
|
|
|
|
priv->row_separator_data);
|
2004-07-07 15:15:35 +00:00
|
|
|
else
|
|
|
|
is_separator = FALSE;
|
2004-08-02 19:15:05 +00:00
|
|
|
|
2004-07-07 15:15:35 +00:00
|
|
|
if (is_separator)
|
2004-08-07 22:21:25 +00:00
|
|
|
{
|
|
|
|
item = gtk_separator_menu_item_new ();
|
2004-11-09 16:38:57 +00:00
|
|
|
path = gtk_tree_model_get_path (model, &iter);
|
2004-08-07 22:21:25 +00:00
|
|
|
g_object_set_data_full (G_OBJECT (item),
|
2005-09-01 05:11:46 +00:00
|
|
|
I_("gtk-combo-box-item-path"),
|
2004-11-09 16:38:57 +00:00
|
|
|
gtk_tree_row_reference_new (model, path),
|
|
|
|
(GDestroyNotify)gtk_tree_row_reference_free);
|
2005-02-25 19:14:18 +00:00
|
|
|
gtk_tree_path_free (path);
|
2004-08-07 22:21:25 +00:00
|
|
|
}
|
2004-07-07 15:15:35 +00:00
|
|
|
else
|
|
|
|
{
|
2004-08-02 19:15:05 +00:00
|
|
|
item = gtk_cell_view_menu_item_new (combo_box, model, &iter);
|
|
|
|
if (gtk_tree_model_iter_has_child (model, &iter))
|
|
|
|
{
|
|
|
|
submenu = gtk_menu_new ();
|
2009-06-24 05:01:51 +00:00
|
|
|
gtk_menu_set_reserve_toggle_size (GTK_MENU (submenu), FALSE);
|
2004-08-02 19:15:05 +00:00
|
|
|
gtk_widget_show (submenu);
|
|
|
|
gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
|
|
|
|
|
|
|
|
/* Ugly - since menus can only activate leafs, we have to
|
|
|
|
* duplicate the item inside the submenu.
|
|
|
|
*/
|
|
|
|
subitem = gtk_cell_view_menu_item_new (combo_box, model, &iter);
|
|
|
|
separator = gtk_separator_menu_item_new ();
|
|
|
|
gtk_widget_show (subitem);
|
|
|
|
gtk_widget_show (separator);
|
|
|
|
g_signal_connect (subitem, "activate",
|
|
|
|
G_CALLBACK (gtk_combo_box_menu_item_activate),
|
|
|
|
combo_box);
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (submenu), subitem);
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (submenu), separator);
|
|
|
|
|
|
|
|
gtk_combo_box_menu_fill_level (combo_box, submenu, &iter);
|
|
|
|
}
|
2006-12-27 06:12:53 +00:00
|
|
|
g_signal_connect (item, "activate",
|
|
|
|
G_CALLBACK (gtk_combo_box_menu_item_activate),
|
|
|
|
combo_box);
|
2004-07-07 15:15:35 +00:00
|
|
|
}
|
2004-08-02 19:15:05 +00:00
|
|
|
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->wrap_width && menu == priv->popup_widget)
|
2004-08-03 05:22:21 +00:00
|
|
|
gtk_combo_box_relayout_item (combo_box, item, &iter, last);
|
2004-08-02 19:15:05 +00:00
|
|
|
gtk_widget_show (item);
|
2004-08-03 05:22:21 +00:00
|
|
|
|
|
|
|
last = item;
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_menu_destroy (GtkComboBox *combo_box)
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
|
|
|
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_menu_button_press, NULL);
|
2007-12-28 06:56:48 +00:00
|
|
|
g_signal_handlers_disconnect_matched (priv->button,
|
2004-12-24 03:44:17 +00:00
|
|
|
G_SIGNAL_MATCH_DATA,
|
|
|
|
0, 0, NULL,
|
|
|
|
gtk_combo_box_button_state_changed, combo_box);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
/* unparent will remove our latest ref */
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_unparent (priv->button);
|
2004-04-14 20:26:26 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->box = NULL;
|
|
|
|
priv->button = NULL;
|
|
|
|
priv->arrow = NULL;
|
|
|
|
priv->separator = NULL;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
g_object_unref (priv->column);
|
|
|
|
priv->column = NULL;
|
2004-08-09 03:39:06 +00:00
|
|
|
|
2004-03-08 18:39:44 +00:00
|
|
|
/* changing the popup window will unref the menu and the children */
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* grid
|
|
|
|
*/
|
|
|
|
|
|
|
|
static gboolean
|
2004-08-03 05:22:21 +00:00
|
|
|
menu_occupied (GtkMenu *menu,
|
|
|
|
guint left_attach,
|
|
|
|
guint right_attach,
|
|
|
|
guint top_attach,
|
|
|
|
guint bottom_attach)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
|
|
|
GList *i;
|
|
|
|
|
|
|
|
for (i = GTK_MENU_SHELL (menu)->children; i; i = i->next)
|
|
|
|
{
|
|
|
|
guint l, r, b, t;
|
|
|
|
|
2004-08-03 05:22:21 +00:00
|
|
|
gtk_container_child_get (GTK_CONTAINER (menu),
|
|
|
|
i->data,
|
2005-03-26 05:49:15 +00:00
|
|
|
"left-attach", &l,
|
|
|
|
"right-attach", &r,
|
|
|
|
"bottom-attach", &b,
|
|
|
|
"top-attach", &t,
|
2003-09-26 21:57:06 +00:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
/* look if this item intersects with the given coordinates */
|
2004-05-10 14:07:35 +00:00
|
|
|
if (right_attach > l && left_attach < r && bottom_attach > t && top_attach < b)
|
|
|
|
return TRUE;
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_relayout_item (GtkComboBox *combo_box,
|
2004-08-03 05:22:21 +00:00
|
|
|
GtkWidget *item,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
GtkWidget *last)
|
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
|
|
|
gint current_col = 0, current_row = 0;
|
2004-08-03 05:22:21 +00:00
|
|
|
gint rows = 1, cols = 1;
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkWidget *menu = priv->popup_widget;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
if (!GTK_IS_MENU_SHELL (menu))
|
|
|
|
return;
|
2004-08-03 05:22:21 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->col_column == -1 &&
|
|
|
|
priv->row_column == -1 &&
|
2004-08-03 05:22:21 +00:00
|
|
|
last)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2004-08-03 05:22:21 +00:00
|
|
|
gtk_container_child_get (GTK_CONTAINER (menu),
|
|
|
|
last,
|
2006-07-06 05:14:03 +00:00
|
|
|
"right-attach", ¤t_col,
|
|
|
|
"top-attach", ¤t_row,
|
2004-08-03 05:22:21 +00:00
|
|
|
NULL);
|
2007-12-28 06:56:48 +00:00
|
|
|
if (current_col + cols > priv->wrap_width)
|
2004-08-03 05:22:21 +00:00
|
|
|
{
|
|
|
|
current_col = 0;
|
|
|
|
current_row++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->col_column != -1)
|
|
|
|
gtk_tree_model_get (priv->model, iter,
|
|
|
|
priv->col_column, &cols,
|
2004-08-03 05:22:21 +00:00
|
|
|
-1);
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->row_column != -1)
|
|
|
|
gtk_tree_model_get (priv->model, iter,
|
|
|
|
priv->row_column, &rows,
|
2004-08-03 05:22:21 +00:00
|
|
|
-1);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-08-03 05:22:21 +00:00
|
|
|
while (1)
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
if (current_col + cols > priv->wrap_width)
|
2004-08-03 05:22:21 +00:00
|
|
|
{
|
|
|
|
current_col = 0;
|
|
|
|
current_row++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!menu_occupied (GTK_MENU (menu),
|
|
|
|
current_col, current_col + cols,
|
|
|
|
current_row, current_row + rows))
|
|
|
|
break;
|
|
|
|
|
|
|
|
current_col++;
|
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* set attach props */
|
|
|
|
gtk_menu_attach (GTK_MENU (menu), item,
|
|
|
|
current_col, current_col + cols,
|
|
|
|
current_row, current_row + rows);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_relayout (GtkComboBox *combo_box)
|
|
|
|
{
|
|
|
|
GList *list, *j;
|
2004-08-07 22:21:25 +00:00
|
|
|
GtkWidget *menu;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
menu = combo_box->priv->popup_widget;
|
2004-04-14 13:53:57 +00:00
|
|
|
|
|
|
|
/* do nothing unless we are in menu style and realized */
|
|
|
|
if (combo_box->priv->tree_view || !GTK_IS_MENU_SHELL (menu))
|
|
|
|
return;
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
list = gtk_container_get_children (GTK_CONTAINER (menu));
|
2004-04-14 13:53:57 +00:00
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
for (j = g_list_last (list); j; j = j->prev)
|
|
|
|
gtk_container_remove (GTK_CONTAINER (menu), j->data);
|
2004-04-14 13:53:57 +00:00
|
|
|
|
2004-03-08 18:39:44 +00:00
|
|
|
gtk_combo_box_menu_fill (combo_box);
|
2004-08-03 05:22:21 +00:00
|
|
|
|
|
|
|
g_list_free (list);
|
2003-09-26 21:57:06 +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);
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (GTK_IS_MENU (priv->popup_widget) &&
|
2004-08-02 19:15:05 +00:00
|
|
|
event->type == GDK_BUTTON_PRESS && event->button == 1)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->focus_on_click &&
|
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
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
gtk_combo_box_menu_popup (combo_box, event->button, event->time);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_menu_item_activate (GtkWidget *item,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
|
2004-08-02 19:15:05 +00:00
|
|
|
GtkWidget *cell_view;
|
|
|
|
GtkTreePath *path;
|
|
|
|
GtkTreeIter iter;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2010-05-24 20:31:36 +00:00
|
|
|
cell_view = gtk_bin_get_child (GTK_BIN (item));
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
g_return_if_fail (GTK_IS_CELL_VIEW (cell_view));
|
2004-05-10 14:07:35 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
path = gtk_cell_view_get_displayed_row (GTK_CELL_VIEW (cell_view));
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
if (gtk_tree_model_get_iter (combo_box->priv->model, &iter, path))
|
2006-12-27 06:12:53 +00:00
|
|
|
{
|
|
|
|
if (gtk_menu_item_get_submenu (GTK_MENU_ITEM (item)) == NULL)
|
|
|
|
gtk_combo_box_set_active_iter (combo_box, &iter);
|
|
|
|
}
|
2004-08-02 19:15:05 +00:00
|
|
|
|
|
|
|
gtk_tree_path_free (path);
|
2004-07-16 20:27:40 +00:00
|
|
|
|
2009-12-04 01:15:00 +00:00
|
|
|
g_object_set (combo_box,
|
|
|
|
"editing-canceled", FALSE,
|
|
|
|
NULL);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
2008-08-04 23:40:36 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_update_sensitivity (GtkComboBox *combo_box)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gboolean sensitive = TRUE; /* fool code checkers */
|
|
|
|
|
2008-08-05 15:44:04 +00:00
|
|
|
if (!combo_box->priv->button)
|
|
|
|
return;
|
|
|
|
|
2008-08-04 23:40:36 +00:00
|
|
|
switch (combo_box->priv->button_sensitivity)
|
|
|
|
{
|
|
|
|
case GTK_SENSITIVITY_ON:
|
|
|
|
sensitive = TRUE;
|
|
|
|
break;
|
|
|
|
case GTK_SENSITIVITY_OFF:
|
|
|
|
sensitive = FALSE;
|
|
|
|
break;
|
|
|
|
case GTK_SENSITIVITY_AUTO:
|
|
|
|
sensitive = combo_box->priv->model &&
|
|
|
|
gtk_tree_model_get_iter_first (combo_box->priv->model, &iter);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive (combo_box->priv->button, sensitive);
|
2009-09-09 07:43:30 +00:00
|
|
|
|
|
|
|
/* In list-mode, we also need to update sensitivity of the event box */
|
2009-09-21 10:57:39 +00:00
|
|
|
if (GTK_IS_TREE_VIEW (combo_box->priv->tree_view)
|
|
|
|
&& combo_box->priv->cell_view)
|
2009-09-09 07:43:30 +00:00
|
|
|
gtk_widget_set_sensitive (combo_box->priv->box, sensitive);
|
2008-08-04 23:40:36 +00:00
|
|
|
}
|
|
|
|
|
2004-03-02 18:56:10 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_model_row_inserted (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
|
2004-03-02 20:42:14 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
if (combo_box->priv->tree_view)
|
|
|
|
gtk_combo_box_list_popup_resize (combo_box);
|
|
|
|
else
|
2004-03-02 18:56:10 +00:00
|
|
|
gtk_combo_box_menu_row_inserted (model, path, iter, user_data);
|
2008-08-04 23:40:36 +00:00
|
|
|
|
|
|
|
gtk_combo_box_update_sensitivity (combo_box);
|
2004-03-02 18:56:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_model_row_deleted (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2004-03-02 18:56:10 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (!gtk_tree_row_reference_valid (priv->active_row))
|
2005-02-24 17:57:07 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->cell_view)
|
|
|
|
gtk_cell_view_set_displayed_row (GTK_CELL_VIEW (priv->cell_view), NULL);
|
2007-07-09 18:23:49 +00:00
|
|
|
g_signal_emit (combo_box, combo_box_signals[CHANGED], 0);
|
2005-02-24 17:57:07 +00:00
|
|
|
}
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->tree_view)
|
2004-08-02 19:15:05 +00:00
|
|
|
gtk_combo_box_list_popup_resize (combo_box);
|
|
|
|
else
|
2005-02-24 17:57:07 +00:00
|
|
|
gtk_combo_box_menu_row_deleted (model, path, user_data);
|
2008-08-04 23:40:36 +00:00
|
|
|
|
|
|
|
gtk_combo_box_update_sensitivity (combo_box);
|
2004-03-02 18:56:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_model_rows_reordered (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gint *new_order,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
|
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
gtk_tree_row_reference_reordered (G_OBJECT (user_data), path, iter, new_order);
|
2004-03-02 18:56:10 +00:00
|
|
|
|
|
|
|
if (!combo_box->priv->tree_view)
|
|
|
|
gtk_combo_box_menu_rows_reordered (model, path, iter, new_order, user_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_model_row_changed (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2004-08-02 19:15:05 +00:00
|
|
|
GtkTreePath *active_path;
|
2004-03-02 18:56:10 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
/* FIXME this belongs to GtkCellView */
|
2007-12-28 06:56:48 +00:00
|
|
|
if (gtk_tree_row_reference_valid (priv->active_row))
|
2004-08-02 19:15:05 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
active_path = gtk_tree_row_reference_get_path (priv->active_row);
|
2005-02-24 17:57:07 +00:00
|
|
|
if (gtk_tree_path_compare (path, active_path) == 0 &&
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->cell_view)
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (priv->cell_view));
|
2005-02-24 17:57:07 +00:00
|
|
|
gtk_tree_path_free (active_path);
|
2004-08-02 19:15:05 +00:00
|
|
|
}
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->tree_view)
|
2004-03-02 18:56:10 +00:00
|
|
|
gtk_combo_box_list_row_changed (model, path, iter, user_data);
|
|
|
|
else
|
|
|
|
gtk_combo_box_menu_row_changed (model, path, iter, user_data);
|
|
|
|
}
|
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
static gboolean
|
|
|
|
list_popup_resize_idle (gpointer user_data)
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2004-08-02 19:15:05 +00:00
|
|
|
gint x, y, width, height;
|
|
|
|
|
2010-03-02 04:19:28 +00:00
|
|
|
if (priv->tree_view && gtk_widget_get_mapped (priv->popup_window))
|
2004-08-02 19:15:05 +00:00
|
|
|
{
|
|
|
|
gtk_combo_box_list_position (combo_box, &x, &y, &width, &height);
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_set_size_request (priv->popup_window, width, height);
|
|
|
|
gtk_window_move (GTK_WINDOW (priv->popup_window), x, y);
|
2004-08-02 19:15:05 +00:00
|
|
|
}
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->resize_idle_id = 0;
|
2005-07-22 03:38:14 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_list_popup_resize (GtkComboBox *combo_box)
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
|
|
|
|
|
|
|
if (!priv->resize_idle_id)
|
|
|
|
priv->resize_idle_id =
|
2006-12-22 19:10:43 +00:00
|
|
|
gdk_threads_add_idle (list_popup_resize_idle, combo_box);
|
2004-08-02 19:15:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_model_row_expanded (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
|
|
|
|
|
|
|
|
gtk_combo_box_list_popup_resize (combo_box);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
find_menu_by_path (GtkWidget *menu,
|
|
|
|
GtkTreePath *path,
|
|
|
|
gboolean skip_first)
|
|
|
|
{
|
|
|
|
GList *i, *list;
|
2010-05-24 20:31:36 +00:00
|
|
|
GtkWidget *child;
|
2004-08-02 19:15:05 +00:00
|
|
|
GtkWidget *item;
|
|
|
|
GtkWidget *submenu;
|
2004-11-09 16:38:57 +00:00
|
|
|
GtkTreeRowReference *mref;
|
2004-08-02 19:15:05 +00:00
|
|
|
GtkTreePath *mpath;
|
|
|
|
gboolean skip;
|
|
|
|
|
|
|
|
list = gtk_container_get_children (GTK_CONTAINER (menu));
|
|
|
|
skip = skip_first;
|
|
|
|
item = NULL;
|
|
|
|
for (i = list; i; i = i->next)
|
|
|
|
{
|
2010-05-24 20:31:36 +00:00
|
|
|
child = gtk_bin_get_child (i->data);
|
2004-08-07 22:21:25 +00:00
|
|
|
if (GTK_IS_SEPARATOR_MENU_ITEM (i->data))
|
|
|
|
{
|
2004-11-09 16:38:57 +00:00
|
|
|
mref = g_object_get_data (G_OBJECT (i->data), "gtk-combo-box-item-path");
|
|
|
|
if (!mref)
|
2004-08-09 02:53:31 +00:00
|
|
|
continue;
|
2004-11-09 16:38:57 +00:00
|
|
|
else if (!gtk_tree_row_reference_valid (mref))
|
|
|
|
mpath = NULL;
|
|
|
|
else
|
|
|
|
mpath = gtk_tree_row_reference_get_path (mref);
|
2004-08-07 22:21:25 +00:00
|
|
|
}
|
2010-05-24 20:31:36 +00:00
|
|
|
else if (GTK_IS_CELL_VIEW (child))
|
2004-08-02 19:15:05 +00:00
|
|
|
{
|
|
|
|
if (skip)
|
|
|
|
{
|
|
|
|
skip = FALSE;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-05-24 20:31:36 +00:00
|
|
|
mpath = gtk_cell_view_get_displayed_row (GTK_CELL_VIEW (child));
|
2004-08-07 22:21:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* this case is necessary, since the row reference of
|
|
|
|
* the cell view may already be updated after a deletion
|
|
|
|
*/
|
|
|
|
if (!mpath)
|
|
|
|
{
|
|
|
|
item = i->data;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (gtk_tree_path_compare (mpath, path) == 0)
|
|
|
|
{
|
|
|
|
gtk_tree_path_free (mpath);
|
|
|
|
item = i->data;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (gtk_tree_path_is_ancestor (mpath, path))
|
|
|
|
{
|
|
|
|
submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
|
|
|
|
if (submenu != NULL)
|
2004-08-02 19:15:05 +00:00
|
|
|
{
|
|
|
|
gtk_tree_path_free (mpath);
|
2004-08-07 22:21:25 +00:00
|
|
|
item = find_menu_by_path (submenu, path, TRUE);
|
2004-08-02 19:15:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-08-07 22:21:25 +00:00
|
|
|
gtk_tree_path_free (mpath);
|
2004-08-02 19:15:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (list);
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
static void
|
|
|
|
dump_menu_tree (GtkWidget *menu,
|
|
|
|
gint level)
|
|
|
|
{
|
|
|
|
GList *i, *list;
|
|
|
|
GtkWidget *submenu;
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
|
|
|
list = gtk_container_get_children (GTK_CONTAINER (menu));
|
|
|
|
for (i = list; i; i = i->next)
|
|
|
|
{
|
|
|
|
if (GTK_IS_CELL_VIEW (GTK_BIN (i->data)->child))
|
|
|
|
{
|
|
|
|
path = gtk_cell_view_get_displayed_row (GTK_CELL_VIEW (GTK_BIN (i->data)->child));
|
|
|
|
g_print ("%*s%s\n", 2 * level, " ", gtk_tree_path_to_string (path));
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
|
|
|
submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
|
|
|
|
if (submenu != NULL)
|
|
|
|
dump_menu_tree (submenu, level + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (list);
|
|
|
|
}
|
|
|
|
#endif
|
2004-03-02 18:56:10 +00:00
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_menu_row_inserted (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2004-08-02 19:15:05 +00:00
|
|
|
GtkWidget *parent;
|
|
|
|
GtkWidget *item, *menu, *separator;
|
|
|
|
GtkTreePath *ppath;
|
|
|
|
GtkTreeIter piter;
|
|
|
|
gint depth, pos;
|
2004-08-07 22:21:25 +00:00
|
|
|
gboolean is_separator;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (!priv->popup_widget)
|
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
|
|
|
return;
|
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
depth = gtk_tree_path_get_depth (path);
|
2010-06-28 18:15:10 +00:00
|
|
|
pos = gtk_tree_path_get_indices (path)[depth - 1];
|
2004-08-02 19:15:05 +00:00
|
|
|
if (depth > 1)
|
|
|
|
{
|
|
|
|
ppath = gtk_tree_path_copy (path);
|
|
|
|
gtk_tree_path_up (ppath);
|
2007-12-28 06:56:48 +00:00
|
|
|
parent = find_menu_by_path (priv->popup_widget, ppath, FALSE);
|
2004-08-02 19:15:05 +00:00
|
|
|
gtk_tree_path_free (ppath);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (parent));
|
|
|
|
if (!menu)
|
|
|
|
{
|
|
|
|
menu = gtk_menu_new ();
|
2009-06-24 05:01:51 +00:00
|
|
|
gtk_menu_set_reserve_toggle_size (GTK_MENU (menu), FALSE);
|
2004-08-02 19:15:05 +00:00
|
|
|
gtk_widget_show (menu);
|
|
|
|
gtk_menu_item_set_submenu (GTK_MENU_ITEM (parent), menu);
|
|
|
|
|
|
|
|
/* Ugly - since menus can only activate leaves, we have to
|
|
|
|
* duplicate the item inside the submenu.
|
|
|
|
*/
|
|
|
|
gtk_tree_model_iter_parent (model, &piter, iter);
|
|
|
|
item = gtk_cell_view_menu_item_new (combo_box, model, &piter);
|
|
|
|
separator = gtk_separator_menu_item_new ();
|
|
|
|
g_signal_connect (item, "activate",
|
|
|
|
G_CALLBACK (gtk_combo_box_menu_item_activate),
|
|
|
|
combo_box);
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), separator);
|
2010-05-24 20:31:36 +00:00
|
|
|
if (cell_view_is_sensitive (GTK_CELL_VIEW (gtk_bin_get_child (GTK_BIN (item)))))
|
2004-08-02 19:15:05 +00:00
|
|
|
{
|
|
|
|
gtk_widget_show (item);
|
|
|
|
gtk_widget_show (separator);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pos += 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
menu = priv->popup_widget;
|
|
|
|
if (priv->add_tearoffs)
|
2004-08-02 19:15:05 +00:00
|
|
|
pos += 1;
|
|
|
|
}
|
2004-07-19 19:07:27 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->row_separator_func)
|
2008-08-12 09:51:16 +00:00
|
|
|
is_separator = priv->row_separator_func (model, iter,
|
|
|
|
priv->row_separator_data);
|
2004-08-07 22:21:25 +00:00
|
|
|
else
|
|
|
|
is_separator = FALSE;
|
2004-07-19 19:07:27 +00:00
|
|
|
|
2004-08-07 22:21:25 +00:00
|
|
|
if (is_separator)
|
|
|
|
{
|
|
|
|
item = gtk_separator_menu_item_new ();
|
|
|
|
g_object_set_data_full (G_OBJECT (item),
|
2005-09-01 05:11:46 +00:00
|
|
|
I_("gtk-combo-box-item-path"),
|
2004-11-09 16:38:57 +00:00
|
|
|
gtk_tree_row_reference_new (model, path),
|
|
|
|
(GDestroyNotify)gtk_tree_row_reference_free);
|
2004-08-07 22:21:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item = gtk_cell_view_menu_item_new (combo_box, model, iter);
|
|
|
|
|
|
|
|
g_signal_connect (item, "activate",
|
|
|
|
G_CALLBACK (gtk_combo_box_menu_item_activate),
|
|
|
|
combo_box);
|
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-08-07 22:21:25 +00:00
|
|
|
gtk_widget_show (item);
|
2004-08-02 19:15:05 +00:00
|
|
|
gtk_menu_shell_insert (GTK_MENU_SHELL (menu), item, pos);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_menu_row_deleted (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2004-08-02 19:15:05 +00:00
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2003-09-26 21:57:06 +00:00
|
|
|
GtkWidget *menu;
|
|
|
|
GtkWidget *item;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (!priv->popup_widget)
|
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
|
|
|
return;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
item = find_menu_by_path (priv->popup_widget, path, FALSE);
|
2004-08-02 19:15:05 +00:00
|
|
|
menu = gtk_widget_get_parent (item);
|
2003-09-26 21:57:06 +00:00
|
|
|
gtk_container_remove (GTK_CONTAINER (menu), item);
|
2006-12-27 06:12:53 +00:00
|
|
|
|
|
|
|
if (gtk_tree_path_get_depth (path) > 1)
|
|
|
|
{
|
|
|
|
GtkTreePath *parent_path;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkWidget *parent;
|
|
|
|
|
|
|
|
parent_path = gtk_tree_path_copy (path);
|
|
|
|
gtk_tree_path_up (parent_path);
|
|
|
|
gtk_tree_model_get_iter (model, &iter, parent_path);
|
|
|
|
|
|
|
|
if (!gtk_tree_model_iter_has_child (model, &iter))
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
parent = find_menu_by_path (priv->popup_widget,
|
2006-12-27 06:12:53 +00:00
|
|
|
parent_path, FALSE);
|
2007-06-13 15:21:10 +00:00
|
|
|
gtk_menu_item_set_submenu (GTK_MENU_ITEM (parent), NULL);
|
2006-12-27 06:12:53 +00:00
|
|
|
}
|
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
2004-03-02 18:56:10 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_menu_rows_reordered (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter,
|
2004-08-02 19:15:05 +00:00
|
|
|
gint *new_order,
|
2004-03-02 18:56:10 +00:00
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
|
|
|
|
|
|
|
|
gtk_combo_box_relayout (combo_box);
|
|
|
|
}
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_menu_row_changed (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2004-08-03 05:22:21 +00:00
|
|
|
GtkWidget *item;
|
2003-09-26 21:57:06 +00:00
|
|
|
gint width;
|
2004-08-07 22:21:25 +00:00
|
|
|
gboolean is_separator;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (!priv->popup_widget)
|
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
|
|
|
return;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
item = find_menu_by_path (priv->popup_widget, path, FALSE);
|
2004-08-07 22:21:25 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->row_separator_func)
|
2008-08-12 09:51:16 +00:00
|
|
|
is_separator = priv->row_separator_func (model, iter,
|
|
|
|
priv->row_separator_data);
|
2004-08-07 22:21:25 +00:00
|
|
|
else
|
|
|
|
is_separator = FALSE;
|
|
|
|
|
|
|
|
if (is_separator != GTK_IS_SEPARATOR_MENU_ITEM (item))
|
2004-08-03 05:22:21 +00:00
|
|
|
{
|
2004-08-07 22:21:25 +00:00
|
|
|
gtk_combo_box_menu_row_deleted (model, path, combo_box);
|
|
|
|
gtk_combo_box_menu_row_inserted (model, path, iter, combo_box);
|
2004-08-03 05:22:21 +00:00
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->wrap_width && item->parent == priv->popup_widget)
|
2004-12-13 04:22:07 +00:00
|
|
|
{
|
|
|
|
GtkWidget *pitem = NULL;
|
|
|
|
GtkTreePath *prev;
|
|
|
|
|
|
|
|
prev = gtk_tree_path_copy (path);
|
|
|
|
|
|
|
|
if (gtk_tree_path_prev (prev))
|
2007-12-28 06:56:48 +00:00
|
|
|
pitem = find_menu_by_path (priv->popup_widget, prev, FALSE);
|
2004-12-13 04:22:07 +00:00
|
|
|
|
|
|
|
gtk_tree_path_free (prev);
|
|
|
|
|
|
|
|
/* unattach item so gtk_combo_box_relayout_item() won't spuriously
|
|
|
|
move it */
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_container_child_set (GTK_CONTAINER (priv->popup_widget),
|
2004-12-13 04:22:07 +00:00
|
|
|
item,
|
2005-03-26 05:49:15 +00:00
|
|
|
"left-attach", -1,
|
|
|
|
"right-attach", -1,
|
|
|
|
"top-attach", -1,
|
|
|
|
"bottom-attach", -1,
|
2004-12-13 04:22:07 +00:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
gtk_combo_box_relayout_item (combo_box, item, iter, pitem);
|
|
|
|
}
|
2004-08-07 22:21:25 +00:00
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
width = gtk_combo_box_calc_requested_width (combo_box, path);
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (width > priv->width)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->cell_view)
|
2004-02-24 23:12:57 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_set_size_request (priv->cell_view, width, -1);
|
|
|
|
gtk_widget_queue_resize (priv->cell_view);
|
2004-02-24 23:12:57 +00:00
|
|
|
}
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->width = width;
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* list style
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_list_setup (GtkComboBox *combo_box)
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2003-09-26 21:57:06 +00:00
|
|
|
GtkTreeSelection *sel;
|
2010-03-03 20:49:33 +00:00
|
|
|
GtkStyle *style;
|
2010-05-24 20:31:36 +00:00
|
|
|
GtkWidget *child;
|
2010-03-03 20:49:33 +00:00
|
|
|
GtkWidget *widget = GTK_WIDGET (combo_box);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->button = gtk_toggle_button_new ();
|
2010-05-24 20:31:36 +00:00
|
|
|
child = gtk_bin_get_child (GTK_BIN (combo_box));
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_set_parent (priv->button,
|
2010-05-24 20:31:36 +00:00
|
|
|
gtk_widget_get_parent (child));
|
2008-08-11 09:17:49 +00:00
|
|
|
g_signal_connect (priv->button, "button-press-event",
|
2003-09-26 21:57:06 +00:00
|
|
|
G_CALLBACK (gtk_combo_box_list_button_pressed), combo_box);
|
2007-12-28 06:56:48 +00:00
|
|
|
g_signal_connect (priv->button, "toggled",
|
2003-09-26 21:57:06 +00:00
|
|
|
G_CALLBACK (gtk_combo_box_button_toggled), combo_box);
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
|
|
|
|
gtk_container_add (GTK_CONTAINER (priv->button), priv->arrow);
|
|
|
|
priv->separator = NULL;
|
|
|
|
gtk_widget_show_all (priv->button);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->cell_view)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2010-03-03 20:49:33 +00:00
|
|
|
style = gtk_widget_get_style (widget);
|
|
|
|
gtk_cell_view_set_background_color (GTK_CELL_VIEW (priv->cell_view),
|
|
|
|
&style->base[gtk_widget_get_state (widget)]);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->box = gtk_event_box_new ();
|
|
|
|
gtk_event_box_set_visible_window (GTK_EVENT_BOX (priv->box),
|
2004-05-09 06:01:57 +00:00
|
|
|
FALSE);
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->has_frame)
|
2004-07-16 20:27:40 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->cell_view_frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (priv->cell_view_frame),
|
2004-07-16 20:27:40 +00:00
|
|
|
GTK_SHADOW_IN);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
combo_box->priv->cell_view_frame = gtk_event_box_new ();
|
|
|
|
gtk_event_box_set_visible_window (GTK_EVENT_BOX (combo_box->priv->cell_view_frame),
|
|
|
|
FALSE);
|
|
|
|
}
|
2010-05-24 20:31:36 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_set_parent (priv->cell_view_frame,
|
2010-05-24 20:31:36 +00:00
|
|
|
gtk_widget_get_parent (child));
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (priv->cell_view_frame), priv->box);
|
|
|
|
gtk_widget_show_all (priv->cell_view_frame);
|
2004-05-09 06:01:57 +00:00
|
|
|
|
2008-08-11 09:17:49 +00:00
|
|
|
g_signal_connect (priv->box, "button-press-event",
|
2004-05-09 06:01:57 +00:00
|
|
|
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,
|
|
|
|
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),
|
2004-05-10 17:15:14 +00:00
|
|
|
TRUE);
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->row_separator_func)
|
|
|
|
gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (priv->tree_view),
|
|
|
|
priv->row_separator_func,
|
|
|
|
priv->row_separator_data,
|
2004-07-30 20:55:17 +00:00
|
|
|
NULL);
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->model)
|
|
|
|
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->tree_view), priv->model);
|
2004-03-08 18:39:44 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->column = gtk_tree_view_column_new ();
|
|
|
|
gtk_tree_view_append_column (GTK_TREE_VIEW (priv->tree_view), priv->column);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
/* sync up */
|
2004-08-02 19:15:05 +00:00
|
|
|
gtk_combo_box_sync_cells (combo_box,
|
2007-12-28 06:56:48 +00:00
|
|
|
GTK_CELL_LAYOUT (priv->column));
|
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),
|
2004-08-02 19:15:05 +00:00
|
|
|
path, NULL, FALSE);
|
|
|
|
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",
|
2004-08-02 19:15:05 +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",
|
2004-08-02 19:15:05 +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,
|
2005-11-10 21:17:19 +00:00
|
|
|
G_SIGNAL_MATCH_DATA,
|
|
|
|
0, 0, NULL,
|
|
|
|
gtk_combo_box_child_show,
|
|
|
|
NULL);
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
g_signal_handlers_disconnect_matched (priv->popup_window,
|
2005-11-10 21:17:19 +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->box)
|
|
|
|
g_signal_handlers_disconnect_matched (priv->box,
|
2004-05-27 04:08:26 +00:00
|
|
|
G_SIGNAL_MATCH_DATA,
|
|
|
|
0, 0, NULL,
|
|
|
|
gtk_combo_box_list_button_pressed,
|
|
|
|
NULL);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
/* destroy things (unparent will kill the latest ref from us)
|
|
|
|
* last unref on button will destroy the arrow
|
|
|
|
*/
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_unparent (priv->button);
|
|
|
|
priv->button = NULL;
|
|
|
|
priv->arrow = NULL;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
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->cell_view_frame)
|
2004-04-14 20:26:26 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_unparent (priv->cell_view_frame);
|
|
|
|
priv->cell_view_frame = NULL;
|
|
|
|
priv->box = NULL;
|
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;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if ((ewidget != priv->button && ewidget != priv->box) ||
|
|
|
|
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->button)))
|
2003-09-26 21:57:06 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->focus_on_click &&
|
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;
|
|
|
|
if (priv->scroll_timer == 0)
|
|
|
|
priv->scroll_timer = gdk_threads_add_timeout (SCROLL_TIME,
|
|
|
|
(GSourceFunc) gtk_combo_box_list_scroll_timeout,
|
2004-07-26 04:50:07 +00:00
|
|
|
combo_box);
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_tree_view_set_hover_expand (GTK_TREE_VIEW (priv->tree_view),
|
2004-08-02 19:15:05 +00:00
|
|
|
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
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
if ((ewidget == priv->button ||
|
|
|
|
ewidget == priv->box) &&
|
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 */
|
2007-12-28 06:56:48 +00:00
|
|
|
if (ewidget != priv->button && ewidget != priv->box)
|
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,
|
|
|
|
GdkEventKey *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (data);
|
|
|
|
|
2007-05-18 11:33:13 +00:00
|
|
|
if (!gtk_bindings_activate_event (GTK_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
|
|
|
|
*/
|
|
|
|
gtk_bindings_activate_event (GTK_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);
|
2004-08-02 19:15:05 +00:00
|
|
|
GtkTreeIter iter;
|
2004-03-04 23:35:31 +00:00
|
|
|
|
2008-02-12 15:51:09 +00:00
|
|
|
if (event->keyval == GDK_Return || event->keyval == GDK_ISO_Enter || event->keyval == GDK_KP_Enter ||
|
2004-03-04 23:35:31 +00:00
|
|
|
event->keyval == GDK_space || event->keyval == GDK_KP_Space)
|
|
|
|
{
|
|
|
|
GtkTreeModel *model = NULL;
|
|
|
|
|
2006-03-15 19:03:46 +00:00
|
|
|
gtk_combo_box_popdown (combo_box);
|
|
|
|
|
2004-06-15 05:12:27 +00:00
|
|
|
if (combo_box->priv->model)
|
|
|
|
{
|
2006-03-15 19:00:59 +00:00
|
|
|
GtkTreeSelection *sel;
|
|
|
|
|
|
|
|
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (combo_box->priv->tree_view));
|
|
|
|
|
2004-08-02 19:15:05 +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
|
|
|
}
|
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
|
|
|
|
2007-05-18 11:33:13 +00:00
|
|
|
if (!gtk_bindings_activate_event (GTK_OBJECT (widget), event))
|
|
|
|
{
|
|
|
|
/* The list hasn't managed the
|
|
|
|
* event, forward it to the combobox
|
|
|
|
*/
|
|
|
|
gtk_bindings_activate_event (GTK_OBJECT (combo_box), event);
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
gint x,
|
|
|
|
gint y)
|
|
|
|
{
|
|
|
|
GtkWidget *tree_view = combo_box->priv->tree_view;
|
|
|
|
GtkAdjustment *adj;
|
|
|
|
gdouble value;
|
|
|
|
|
|
|
|
adj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (combo_box->priv->scrolled_window));
|
|
|
|
if (adj && adj->upper - adj->lower > adj->page_size)
|
|
|
|
{
|
|
|
|
if (x <= tree_view->allocation.x &&
|
|
|
|
adj->lower < adj->value)
|
|
|
|
{
|
|
|
|
value = adj->value - (tree_view->allocation.x - x + 1);
|
2010-05-24 02:04:10 +00:00
|
|
|
gtk_adjustment_set_value (adj, value);
|
2004-07-26 04:50:07 +00:00
|
|
|
}
|
|
|
|
else if (x >= tree_view->allocation.x + tree_view->allocation.width &&
|
|
|
|
adj->upper - adj->page_size > adj->value)
|
|
|
|
{
|
|
|
|
value = adj->value + (x - tree_view->allocation.x - tree_view->allocation.width + 1);
|
2010-05-24 02:04:10 +00:00
|
|
|
gtk_adjustment_set_value (adj, MAX (value, 0.0));
|
2004-07-26 04:50:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (combo_box->priv->scrolled_window));
|
|
|
|
if (adj && adj->upper - adj->lower > adj->page_size)
|
|
|
|
{
|
|
|
|
if (y <= tree_view->allocation.y &&
|
|
|
|
adj->lower < adj->value)
|
|
|
|
{
|
|
|
|
value = adj->value - (tree_view->allocation.y - y + 1);
|
2010-05-24 02:04:10 +00:00
|
|
|
gtk_adjustment_set_value (adj, value);
|
2004-07-26 04:50:07 +00:00
|
|
|
}
|
2005-05-26 17:26:29 +00:00
|
|
|
else if (y >= tree_view->allocation.height &&
|
2004-07-26 04:50:07 +00:00
|
|
|
adj->upper - adj->page_size > adj->value)
|
|
|
|
{
|
2005-05-26 17:26:29 +00:00
|
|
|
value = adj->value + (y - tree_view->allocation.height + 1);
|
2010-05-24 02:04:10 +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-05-25 22:38:44 +00:00
|
|
|
gdk_window_get_device_position (priv->tree_view->window,
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gtk_combo_box_list_enter_notify (GtkWidget *widget,
|
|
|
|
GdkEventCrossing *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
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,
|
|
|
|
GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
gboolean path_currently_selected,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
gboolean sensitive = FALSE;
|
|
|
|
|
|
|
|
for (list = selection->tree_view->priv->columns; list && !sensitive; list = list->next)
|
|
|
|
{
|
|
|
|
GList *cells, *cell;
|
|
|
|
gboolean cell_sensitive, cell_visible;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN (list->data);
|
|
|
|
|
|
|
|
if (!column->visible)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
gtk_tree_model_get_iter (model, &iter, path);
|
|
|
|
gtk_tree_view_column_cell_set_cell_data (column, model, &iter,
|
|
|
|
FALSE, FALSE);
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
g_object_get (cell->data,
|
|
|
|
"sensitive", &cell_sensitive,
|
|
|
|
"visible", &cell_visible,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (cell_visible && cell_sensitive)
|
|
|
|
break;
|
|
|
|
|
|
|
|
cell = cell->next;
|
|
|
|
}
|
|
|
|
g_list_free (cells);
|
|
|
|
|
|
|
|
sensitive = cell_sensitive;
|
|
|
|
}
|
|
|
|
|
|
|
|
return sensitive;
|
|
|
|
}
|
2004-07-26 04:50:07 +00:00
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_list_row_changed (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
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
|
|
|
gint width;
|
|
|
|
|
|
|
|
width = gtk_combo_box_calc_requested_width (combo_box, path);
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (width > priv->width)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->cell_view)
|
2004-02-24 23:12:57 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_widget_set_size_request (priv->cell_view, width, -1);
|
|
|
|
gtk_widget_queue_resize (priv->cell_view);
|
2004-02-24 23:12:57 +00:00
|
|
|
}
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->width = width;
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2003-10-01 20:51:54 +00:00
|
|
|
* GtkCellLayout implementation
|
2003-09-26 21:57:06 +00:00
|
|
|
*/
|
2004-08-02 19:15:05 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
pack_start_recurse (GtkWidget *menu,
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
gboolean expand)
|
|
|
|
{
|
|
|
|
GList *i, *list;
|
2010-05-24 20:31:36 +00:00
|
|
|
GtkWidget *child;
|
2004-08-02 19:15:05 +00:00
|
|
|
GtkWidget *submenu;
|
|
|
|
|
|
|
|
list = gtk_container_get_children (GTK_CONTAINER (menu));
|
|
|
|
for (i = list; i; i = i->next)
|
|
|
|
{
|
2010-05-24 20:31:36 +00:00
|
|
|
child = gtk_bin_get_child (GTK_BIN (i->data));
|
|
|
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (child),
|
|
|
|
cell, expand);
|
2004-08-02 19:15:05 +00:00
|
|
|
|
|
|
|
submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
|
|
|
|
if (submenu != NULL)
|
|
|
|
pack_start_recurse (submenu, cell, expand);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (list);
|
|
|
|
}
|
|
|
|
|
2003-10-01 20:51:54 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_cell_layout_pack_start (GtkCellLayout *layout,
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
gboolean expand)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2008-02-09 04:03:25 +00:00
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (layout);
|
2003-09-26 21:57:06 +00:00
|
|
|
ComboCellInfo *info;
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv = combo_box->priv;
|
2004-02-15 23:05:48 +00:00
|
|
|
|
2005-11-23 18:06:58 +00:00
|
|
|
g_object_ref_sink (cell);
|
2004-02-26 20:51:02 +00:00
|
|
|
|
2008-07-04 10:52:52 +00:00
|
|
|
info = g_slice_new0 (ComboCellInfo);
|
2003-09-26 21:57:06 +00:00
|
|
|
info->cell = cell;
|
|
|
|
info->expand = expand;
|
|
|
|
info->pack = GTK_PACK_START;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->cells = g_slist_append (priv->cells, info);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->cell_view)
|
|
|
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (priv->cell_view),
|
2003-10-01 20:51:54 +00:00
|
|
|
cell, expand);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->column)
|
|
|
|
gtk_tree_view_column_pack_start (priv->column, cell, expand);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (GTK_IS_MENU (priv->popup_widget))
|
|
|
|
pack_start_recurse (priv->popup_widget, cell, expand);
|
2004-08-02 19:15:05 +00:00
|
|
|
}
|
2004-05-10 14:07:35 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
static void
|
|
|
|
pack_end_recurse (GtkWidget *menu,
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
gboolean expand)
|
|
|
|
{
|
|
|
|
GList *i, *list;
|
2010-05-24 20:31:36 +00:00
|
|
|
GtkWidget *child;
|
2004-08-02 19:15:05 +00:00
|
|
|
GtkWidget *submenu;
|
|
|
|
|
|
|
|
list = gtk_container_get_children (GTK_CONTAINER (menu));
|
|
|
|
for (i = list; i; i = i->next)
|
|
|
|
{
|
2010-05-24 20:31:36 +00:00
|
|
|
child = gtk_bin_get_child (GTK_BIN (i->data));
|
|
|
|
gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (child),
|
|
|
|
cell, expand);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
|
|
|
|
if (submenu != NULL)
|
|
|
|
pack_end_recurse (submenu, cell, expand);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
2004-08-02 19:15:05 +00:00
|
|
|
|
|
|
|
g_list_free (list);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
2003-10-01 20:51:54 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_cell_layout_pack_end (GtkCellLayout *layout,
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
gboolean expand)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2008-02-07 15:50:39 +00:00
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (layout);
|
2003-09-26 21:57:06 +00:00
|
|
|
ComboCellInfo *info;
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv = combo_box->priv;
|
2004-02-15 23:05:48 +00:00
|
|
|
|
2005-11-23 18:06:58 +00:00
|
|
|
g_object_ref_sink (cell);
|
2004-02-26 20:51:02 +00:00
|
|
|
|
2008-07-04 10:52:52 +00:00
|
|
|
info = g_slice_new0 (ComboCellInfo);
|
2003-09-26 21:57:06 +00:00
|
|
|
info->cell = cell;
|
|
|
|
info->expand = expand;
|
|
|
|
info->pack = GTK_PACK_END;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->cells = g_slist_append (priv->cells, info);
|
2004-11-06 20:16:40 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->cell_view)
|
|
|
|
gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (priv->cell_view),
|
2003-10-01 20:51:54 +00:00
|
|
|
cell, expand);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->column)
|
|
|
|
gtk_tree_view_column_pack_end (priv->column, cell, expand);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (GTK_IS_MENU (priv->popup_widget))
|
|
|
|
pack_end_recurse (priv->popup_widget, cell, expand);
|
2004-08-02 19:15:05 +00:00
|
|
|
}
|
2004-05-10 14:07:35 +00:00
|
|
|
|
2007-09-07 11:02:04 +00:00
|
|
|
static GList *
|
|
|
|
gtk_combo_box_cell_layout_get_cells (GtkCellLayout *layout)
|
|
|
|
{
|
2008-02-07 15:50:39 +00:00
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (layout);
|
2007-09-07 11:02:04 +00:00
|
|
|
GSList *list;
|
|
|
|
GList *retval = NULL;
|
|
|
|
|
|
|
|
for (list = combo_box->priv->cells; list; list = list->next)
|
|
|
|
{
|
|
|
|
ComboCellInfo *info = (ComboCellInfo *)list->data;
|
|
|
|
|
|
|
|
retval = g_list_prepend (retval, info->cell);
|
|
|
|
}
|
|
|
|
|
|
|
|
return g_list_reverse (retval);
|
|
|
|
}
|
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
static void
|
|
|
|
clear_recurse (GtkWidget *menu)
|
|
|
|
{
|
|
|
|
GList *i, *list;
|
2010-05-24 20:31:36 +00:00
|
|
|
GtkWidget *child;
|
2004-08-02 19:15:05 +00:00
|
|
|
GtkWidget *submenu;
|
|
|
|
|
|
|
|
list = gtk_container_get_children (GTK_CONTAINER (menu));
|
|
|
|
for (i = list; i; i = i->next)
|
|
|
|
{
|
2010-05-24 20:31:36 +00:00
|
|
|
child = gtk_bin_get_child (GTK_BIN (i->data));
|
|
|
|
gtk_cell_layout_clear (GTK_CELL_LAYOUT (child));
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
|
|
|
|
if (submenu != NULL)
|
|
|
|
clear_recurse (submenu);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
2004-08-02 19:15:05 +00:00
|
|
|
|
|
|
|
g_list_free (list);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
2003-10-01 20:51:54 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_cell_layout_clear (GtkCellLayout *layout)
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (layout);
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2004-02-11 01:09:25 +00:00
|
|
|
GSList *i;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->cell_view)
|
|
|
|
gtk_cell_layout_clear (GTK_CELL_LAYOUT (priv->cell_view));
|
2003-10-01 20:51:54 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->column)
|
|
|
|
gtk_tree_view_column_clear (priv->column);
|
2003-10-01 20:51:54 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
for (i = priv->cells; i; i = i->next)
|
2004-02-11 01:09:25 +00:00
|
|
|
{
|
2008-07-04 10:52:52 +00:00
|
|
|
ComboCellInfo *info = (ComboCellInfo *)i->data;
|
2004-02-11 01:09:25 +00:00
|
|
|
|
|
|
|
gtk_combo_box_cell_layout_clear_attributes (layout, info->cell);
|
2004-11-19 23:18:38 +00:00
|
|
|
g_object_unref (info->cell);
|
2008-07-04 10:52:52 +00:00
|
|
|
g_slice_free (ComboCellInfo, info);
|
2004-02-27 20:41:14 +00:00
|
|
|
i->data = NULL;
|
2004-02-11 01:09:25 +00:00
|
|
|
}
|
2007-12-28 06:56:48 +00:00
|
|
|
g_slist_free (priv->cells);
|
|
|
|
priv->cells = NULL;
|
2004-02-11 01:09:25 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (GTK_IS_MENU (priv->popup_widget))
|
|
|
|
clear_recurse (priv->popup_widget);
|
2004-08-02 19:15:05 +00:00
|
|
|
}
|
2004-05-10 14:07:35 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
static void
|
|
|
|
add_attribute_recurse (GtkWidget *menu,
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
const gchar *attribute,
|
|
|
|
gint column)
|
|
|
|
{
|
|
|
|
GList *i, *list;
|
2010-05-24 20:31:36 +00:00
|
|
|
GtkWidget *child;
|
2004-08-02 19:15:05 +00:00
|
|
|
GtkWidget *submenu;
|
2010-05-24 20:31:36 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
list = gtk_container_get_children (GTK_CONTAINER (menu));
|
|
|
|
for (i = list; i; i = i->next)
|
|
|
|
{
|
2010-05-24 20:31:36 +00:00
|
|
|
child = gtk_bin_get_child (GTK_BIN (i->data));
|
|
|
|
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (child),
|
|
|
|
cell, attribute, column);
|
2003-10-01 20:51:54 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
|
|
|
|
if (submenu != NULL)
|
|
|
|
add_attribute_recurse (submenu, cell, attribute, column);
|
2003-10-01 20:51:54 +00:00
|
|
|
}
|
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
g_list_free (list);
|
|
|
|
}
|
|
|
|
|
2003-10-01 20:51:54 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_cell_layout_add_attribute (GtkCellLayout *layout,
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
const gchar *attribute,
|
|
|
|
gint column)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2008-02-07 15:50:39 +00:00
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (layout);
|
2003-09-26 21:57:06 +00:00
|
|
|
ComboCellInfo *info;
|
2004-02-15 23:05:48 +00:00
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
info = gtk_combo_box_get_cell_info (combo_box, cell);
|
2008-02-04 23:01:00 +00:00
|
|
|
g_return_if_fail (info != NULL);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2003-10-01 20:51:54 +00:00
|
|
|
info->attributes = g_slist_prepend (info->attributes,
|
|
|
|
GINT_TO_POINTER (column));
|
|
|
|
info->attributes = g_slist_prepend (info->attributes,
|
|
|
|
g_strdup (attribute));
|
|
|
|
|
|
|
|
if (combo_box->priv->cell_view)
|
|
|
|
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo_box->priv->cell_view),
|
|
|
|
cell, attribute, column);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2003-10-01 20:51:54 +00:00
|
|
|
if (combo_box->priv->column)
|
|
|
|
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo_box->priv->column),
|
|
|
|
cell, attribute, column);
|
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
if (GTK_IS_MENU (combo_box->priv->popup_widget))
|
|
|
|
add_attribute_recurse (combo_box->priv->popup_widget, cell, attribute, column);
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (combo_box));
|
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
static void
|
|
|
|
combo_cell_data_func (GtkCellLayout *cell_layout,
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
GtkTreeModel *tree_model,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
ComboCellInfo *info = (ComboCellInfo *)data;
|
|
|
|
GtkWidget *parent = NULL;
|
|
|
|
|
|
|
|
if (!info->func)
|
|
|
|
return;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2008-08-12 09:51:16 +00:00
|
|
|
info->func (cell_layout, cell, tree_model, iter, info->func_data);
|
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
if (GTK_IS_WIDGET (cell_layout))
|
|
|
|
parent = gtk_widget_get_parent (GTK_WIDGET (cell_layout));
|
|
|
|
|
|
|
|
if (GTK_IS_MENU_ITEM (parent) &&
|
|
|
|
gtk_menu_item_get_submenu (GTK_MENU_ITEM (parent)))
|
2004-11-19 23:18:38 +00:00
|
|
|
g_object_set (cell, "sensitive", TRUE, NULL);
|
2004-08-02 19:15:05 +00:00
|
|
|
}
|
2004-05-10 14:07:35 +00:00
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
static void
|
2007-12-28 06:56:48 +00:00
|
|
|
set_cell_data_func_recurse (GtkWidget *menu,
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
ComboCellInfo *info)
|
2004-08-02 19:15:05 +00:00
|
|
|
{
|
|
|
|
GList *i, *list;
|
|
|
|
GtkWidget *submenu;
|
|
|
|
GtkWidget *cell_view;
|
|
|
|
|
|
|
|
list = gtk_container_get_children (GTK_CONTAINER (menu));
|
|
|
|
for (i = list; i; i = i->next)
|
|
|
|
{
|
2010-05-24 20:31:36 +00:00
|
|
|
cell_view = gtk_bin_get_child (GTK_BIN (i->data));
|
2004-08-02 19:15:05 +00:00
|
|
|
if (GTK_IS_CELL_LAYOUT (cell_view))
|
|
|
|
{
|
|
|
|
/* Override sensitivity for inner nodes; we don't
|
|
|
|
* want menuitems with submenus to appear insensitive
|
|
|
|
*/
|
|
|
|
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (cell_view),
|
|
|
|
cell,
|
|
|
|
combo_cell_data_func,
|
|
|
|
info, NULL);
|
|
|
|
submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
|
|
|
|
if (submenu != NULL)
|
|
|
|
set_cell_data_func_recurse (submenu, cell, info);
|
|
|
|
}
|
2003-10-01 20:51:54 +00:00
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
g_list_free (list);
|
2003-10-01 20:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_cell_layout_set_cell_data_func (GtkCellLayout *layout,
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
GtkCellLayoutDataFunc func,
|
|
|
|
gpointer func_data,
|
|
|
|
GDestroyNotify destroy)
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (layout);
|
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2003-10-01 20:51:54 +00:00
|
|
|
ComboCellInfo *info;
|
|
|
|
|
|
|
|
info = gtk_combo_box_get_cell_info (combo_box, cell);
|
|
|
|
g_return_if_fail (info != NULL);
|
2004-08-02 19:15:05 +00:00
|
|
|
|
2003-10-01 20:51:54 +00:00
|
|
|
if (info->destroy)
|
|
|
|
{
|
|
|
|
GDestroyNotify d = info->destroy;
|
|
|
|
|
|
|
|
info->destroy = NULL;
|
|
|
|
d (info->func_data);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
2003-10-01 20:51:54 +00:00
|
|
|
info->func = func;
|
|
|
|
info->func_data = func_data;
|
|
|
|
info->destroy = destroy;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->cell_view)
|
|
|
|
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (priv->cell_view), cell, func, func_data, NULL);
|
2003-10-01 20:51:54 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->column)
|
|
|
|
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (priv->column), cell, func, func_data, NULL);
|
2004-05-06 20:14:46 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (GTK_IS_MENU (priv->popup_widget))
|
|
|
|
set_cell_data_func_recurse (priv->popup_widget, cell, info);
|
2004-05-10 14:07:35 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (combo_box));
|
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
static void
|
2007-12-28 06:56:48 +00:00
|
|
|
clear_attributes_recurse (GtkWidget *menu,
|
|
|
|
GtkCellRenderer *cell)
|
2004-08-02 19:15:05 +00:00
|
|
|
{
|
|
|
|
GList *i, *list;
|
2010-05-24 20:31:36 +00:00
|
|
|
GtkWidget *submenu;
|
|
|
|
GtkWidget *child;
|
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
list = gtk_container_get_children (GTK_CONTAINER (menu));
|
|
|
|
for (i = list; i; i = i->next)
|
|
|
|
{
|
2010-05-24 20:31:36 +00:00
|
|
|
child = gtk_bin_get_child (GTK_BIN (i->data));
|
|
|
|
gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (child), cell);
|
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
|
|
|
|
if (submenu != NULL)
|
|
|
|
clear_attributes_recurse (submenu, cell);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
g_list_free (list);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
2003-10-01 20:51:54 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_cell_layout_clear_attributes (GtkCellLayout *layout,
|
|
|
|
GtkCellRenderer *cell)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2008-02-07 15:50:39 +00:00
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (layout);
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv;
|
2008-02-07 15:50:39 +00:00
|
|
|
ComboCellInfo *info;
|
2004-02-11 01:09:25 +00:00
|
|
|
GSList *list;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv = combo_box->priv;
|
2004-02-15 23:05:48 +00:00
|
|
|
|
2003-10-01 20:51:54 +00:00
|
|
|
info = gtk_combo_box_get_cell_info (combo_box, cell);
|
|
|
|
g_return_if_fail (info != NULL);
|
|
|
|
|
2004-02-11 01:09:25 +00:00
|
|
|
list = info->attributes;
|
|
|
|
while (list && list->next)
|
|
|
|
{
|
|
|
|
g_free (list->data);
|
|
|
|
list = list->next->next;
|
|
|
|
}
|
2004-02-06 22:25:01 +00:00
|
|
|
g_slist_free (info->attributes);
|
2003-10-01 20:51:54 +00:00
|
|
|
info->attributes = NULL;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->cell_view)
|
|
|
|
gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (priv->cell_view), cell);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->column)
|
|
|
|
gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (priv->column), cell);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (GTK_IS_MENU (priv->popup_widget))
|
|
|
|
clear_attributes_recurse (priv->popup_widget, cell);
|
2004-05-10 14:07:35 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (combo_box));
|
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
static void
|
|
|
|
reorder_recurse (GtkWidget *menu,
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
gint position)
|
|
|
|
{
|
|
|
|
GList *i, *list;
|
2010-05-24 20:31:36 +00:00
|
|
|
GtkWidget *child;
|
2004-08-02 19:15:05 +00:00
|
|
|
GtkWidget *submenu;
|
2010-05-24 20:31:36 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
list = gtk_container_get_children (GTK_CONTAINER (menu));
|
|
|
|
for (i = list; i; i = i->next)
|
|
|
|
{
|
2010-05-24 20:31:36 +00:00
|
|
|
child = gtk_bin_get_child (GTK_BIN (i->data));
|
|
|
|
gtk_cell_layout_reorder (GTK_CELL_LAYOUT (child),
|
|
|
|
cell, position);
|
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
|
|
|
|
if (submenu != NULL)
|
|
|
|
reorder_recurse (submenu, cell, position);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
2003-10-01 20:51:54 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
g_list_free (list);
|
2003-10-01 20:51:54 +00:00
|
|
|
}
|
|
|
|
|
2003-12-19 22:47:20 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_cell_layout_reorder (GtkCellLayout *layout,
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
gint position)
|
|
|
|
{
|
2008-02-07 15:50:39 +00:00
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (layout);
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv;
|
2008-02-07 15:50:39 +00:00
|
|
|
ComboCellInfo *info;
|
2003-12-19 22:47:20 +00:00
|
|
|
GSList *link;
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv = combo_box->priv;
|
2004-02-15 23:05:48 +00:00
|
|
|
|
2003-12-19 22:47:20 +00:00
|
|
|
info = gtk_combo_box_get_cell_info (combo_box, cell);
|
|
|
|
|
|
|
|
g_return_if_fail (info != NULL);
|
|
|
|
g_return_if_fail (position >= 0);
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
link = g_slist_find (priv->cells, info);
|
2003-12-19 22:47:20 +00:00
|
|
|
|
|
|
|
g_return_if_fail (link != NULL);
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->cells = g_slist_delete_link (priv->cells, link);
|
|
|
|
priv->cells = g_slist_insert (priv->cells, info, position);
|
2003-12-19 22:47:20 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->cell_view)
|
|
|
|
gtk_cell_layout_reorder (GTK_CELL_LAYOUT (priv->cell_view),
|
2003-12-19 22:47:20 +00:00
|
|
|
cell, position);
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->column)
|
|
|
|
gtk_cell_layout_reorder (GTK_CELL_LAYOUT (priv->column),
|
2003-12-19 22:47:20 +00:00
|
|
|
cell, position);
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (GTK_IS_MENU (priv->popup_widget))
|
|
|
|
reorder_recurse (priv->popup_widget, cell, position);
|
2003-12-19 22:47:20 +00:00
|
|
|
|
|
|
|
gtk_widget_queue_draw (GTK_WIDGET (combo_box));
|
|
|
|
}
|
|
|
|
|
2003-10-01 20:51:54 +00:00
|
|
|
/*
|
|
|
|
* public API
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_combo_box_new:
|
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
|
|
|
*
|
|
|
|
* Creates a new empty #GtkComboBox.
|
|
|
|
*
|
|
|
|
* Return value: A new #GtkComboBox.
|
|
|
|
*
|
|
|
|
* Since: 2.4
|
|
|
|
*/
|
|
|
|
GtkWidget *
|
|
|
|
gtk_combo_box_new (void)
|
|
|
|
{
|
2004-11-19 23:18:38 +00:00
|
|
|
return g_object_new (GTK_TYPE_COMBO_BOX, NULL);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_combo_box_new_with_model:
|
2003-10-01 20:51:54 +00:00
|
|
|
* @model: A #GtkTreeModel.
|
|
|
|
*
|
|
|
|
* Creates a new #GtkComboBox with the model initialized to @model.
|
|
|
|
*
|
|
|
|
* Return value: A new #GtkComboBox.
|
2003-10-02 21:30:11 +00:00
|
|
|
*
|
|
|
|
* Since: 2.4
|
2003-10-01 20:51:54 +00:00
|
|
|
*/
|
|
|
|
GtkWidget *
|
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
|
|
|
gtk_combo_box_new_with_model (GtkTreeModel *model)
|
2003-10-01 20:51:54 +00:00
|
|
|
{
|
|
|
|
GtkComboBox *combo_box;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_TREE_MODEL (model), NULL);
|
|
|
|
|
2004-11-19 23:18:38 +00:00
|
|
|
combo_box = g_object_new (GTK_TYPE_COMBO_BOX, "model", model, NULL);
|
2003-10-01 20:51:54 +00:00
|
|
|
|
|
|
|
return GTK_WIDGET (combo_box);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
2004-05-06 04:06:35 +00:00
|
|
|
/**
|
|
|
|
* gtk_combo_box_get_wrap_width:
|
2007-03-12 06:04:44 +00:00
|
|
|
* @combo_box: A #GtkComboBox
|
2004-05-06 04:06:35 +00:00
|
|
|
*
|
2007-03-12 06:04:44 +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
|
|
|
|
* is in table mode.
|
2004-05-06 04:06:35 +00:00
|
|
|
*
|
|
|
|
* Returns: the wrap width.
|
|
|
|
*
|
|
|
|
* Since: 2.6
|
|
|
|
*/
|
|
|
|
gint
|
|
|
|
gtk_combo_box_get_wrap_width (GtkComboBox *combo_box)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), -1);
|
|
|
|
|
|
|
|
return combo_box->priv->wrap_width;
|
|
|
|
}
|
|
|
|
|
2003-10-02 21:30:11 +00:00
|
|
|
/**
|
|
|
|
* gtk_combo_box_set_wrap_width:
|
2007-03-12 06:04:44 +00:00
|
|
|
* @combo_box: A #GtkComboBox
|
|
|
|
* @width: Preferred number of columns
|
2003-10-02 21:30:11 +00:00
|
|
|
*
|
|
|
|
* Sets the wrap width of @combo_box to be @width. The wrap width is basically
|
2004-12-09 03:58:24 +00:00
|
|
|
* the preferred number of columns when you want the popup to be layed out
|
2003-10-02 21:30:11 +00:00
|
|
|
* in a table.
|
|
|
|
*
|
|
|
|
* Since: 2.4
|
|
|
|
*/
|
2003-09-26 21:57:06 +00:00
|
|
|
void
|
|
|
|
gtk_combo_box_set_wrap_width (GtkComboBox *combo_box,
|
|
|
|
gint width)
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv;
|
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
2004-02-28 00:40:00 +00:00
|
|
|
g_return_if_fail (width >= 0);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv = combo_box->priv;
|
|
|
|
|
|
|
|
if (width != priv->wrap_width)
|
2004-02-23 00:53:05 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->wrap_width = width;
|
2004-03-08 18:39:44 +00:00
|
|
|
|
|
|
|
gtk_combo_box_check_appearance (combo_box);
|
2004-02-23 00:53:05 +00:00
|
|
|
gtk_combo_box_relayout (combo_box);
|
|
|
|
|
2005-03-26 05:49:15 +00:00
|
|
|
g_object_notify (G_OBJECT (combo_box), "wrap-width");
|
2004-02-23 00:53:05 +00:00
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
2004-05-06 04:06:35 +00:00
|
|
|
/**
|
|
|
|
* gtk_combo_box_get_row_span_column:
|
2007-03-12 06:04:44 +00:00
|
|
|
* @combo_box: A #GtkComboBox
|
2004-05-06 04:06:35 +00:00
|
|
|
*
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
2003-10-02 21:30:11 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2003-09-26 21:57:06 +00:00
|
|
|
void
|
|
|
|
gtk_combo_box_set_row_span_column (GtkComboBox *combo_box,
|
|
|
|
gint row_span)
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv;
|
2003-09-26 21:57:06 +00:00
|
|
|
gint col;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv = combo_box->priv;
|
|
|
|
|
|
|
|
col = gtk_tree_model_get_n_columns (priv->model);
|
2004-07-07 15:15:35 +00:00
|
|
|
g_return_if_fail (row_span >= -1 && row_span < col);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (row_span != priv->row_column)
|
2004-02-23 00:53:05 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->row_column = row_span;
|
2004-02-23 00:53:05 +00:00
|
|
|
|
|
|
|
gtk_combo_box_relayout (combo_box);
|
|
|
|
|
2005-03-26 05:49:15 +00:00
|
|
|
g_object_notify (G_OBJECT (combo_box), "row-span-column");
|
2004-02-23 00:53:05 +00:00
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
2004-05-06 04:06:35 +00:00
|
|
|
/**
|
|
|
|
* gtk_combo_box_get_column_span_column:
|
2007-03-12 06:04:44 +00:00
|
|
|
* @combo_box: A #GtkComboBox
|
2004-05-06 04:06:35 +00:00
|
|
|
*
|
|
|
|
* Returns the column with column span information for @combo_box.
|
|
|
|
*
|
|
|
|
* Returns: the column span column.
|
|
|
|
*
|
|
|
|
* Since: 2.6
|
|
|
|
*/
|
|
|
|
gint
|
|
|
|
gtk_combo_box_get_column_span_column (GtkComboBox *combo_box)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), -1);
|
|
|
|
|
|
|
|
return combo_box->priv->col_column;
|
|
|
|
}
|
|
|
|
|
2003-10-02 21:30:11 +00:00
|
|
|
/**
|
|
|
|
* gtk_combo_box_set_column_span_column:
|
2007-03-12 06:04:44 +00:00
|
|
|
* @combo_box: A #GtkComboBox
|
|
|
|
* @column_span: A column in the model passed during construction
|
2003-10-02 21:30:11 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
2003-09-26 21:57:06 +00:00
|
|
|
void
|
|
|
|
gtk_combo_box_set_column_span_column (GtkComboBox *combo_box,
|
|
|
|
gint column_span)
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv;
|
2003-09-26 21:57:06 +00:00
|
|
|
gint col;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv = combo_box->priv;
|
|
|
|
|
|
|
|
col = gtk_tree_model_get_n_columns (priv->model);
|
2004-07-07 15:15:35 +00:00
|
|
|
g_return_if_fail (column_span >= -1 && column_span < col);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (column_span != priv->col_column)
|
2004-02-23 00:53:05 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->col_column = column_span;
|
2004-02-23 00:53:05 +00:00
|
|
|
|
|
|
|
gtk_combo_box_relayout (combo_box);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2005-03-26 05:49:15 +00:00
|
|
|
g_object_notify (G_OBJECT (combo_box), "column-span-column");
|
2004-02-23 00:53:05 +00:00
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
2003-10-02 21:30:11 +00:00
|
|
|
/**
|
|
|
|
* gtk_combo_box_get_active:
|
2007-03-12 06:04:44 +00:00
|
|
|
* @combo_box: A #GtkComboBox
|
2003-10-02 21:30:11 +00:00
|
|
|
*
|
2003-10-15 20:18:01 +00:00
|
|
|
* Returns the index of the currently active item, or -1 if there's no
|
2004-11-12 22:57:09 +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
|
2010-06-28 18:15:10 +00:00
|
|
|
* <literal>gtk_tree_path_get_indices (path)[0]</literal>, where
|
2004-11-12 22:57:09 +00:00
|
|
|
* <literal>path</literal> is the #GtkTreePath of the active item.
|
2003-10-02 21:30:11 +00:00
|
|
|
*
|
2007-03-12 06:04:44 +00:00
|
|
|
* Return value: An integer which is the index of the currently active item,
|
|
|
|
* or -1 if there's no active item.
|
2003-10-02 21:30:11 +00:00
|
|
|
*
|
|
|
|
* Since: 2.4
|
|
|
|
*/
|
2003-09-26 21:57:06 +00:00
|
|
|
gint
|
|
|
|
gtk_combo_box_get_active (GtkComboBox *combo_box)
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv;
|
2004-08-02 19:15:05 +00:00
|
|
|
gint result;
|
2007-12-28 06:56:48 +00:00
|
|
|
|
2003-09-26 21:57:06 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), 0);
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
priv = combo_box->priv;
|
|
|
|
|
|
|
|
if (gtk_tree_row_reference_valid (priv->active_row))
|
2004-08-02 19:15:05 +00:00
|
|
|
{
|
|
|
|
GtkTreePath *path;
|
2005-02-24 17:57:07 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
path = gtk_tree_row_reference_get_path (priv->active_row);
|
2010-06-28 18:15:10 +00:00
|
|
|
result = gtk_tree_path_get_indices (path)[0];
|
2005-02-24 17:57:07 +00:00
|
|
|
gtk_tree_path_free (path);
|
2004-08-02 19:15:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
result = -1;
|
|
|
|
|
|
|
|
return result;
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
2003-10-02 21:30:11 +00:00
|
|
|
/**
|
|
|
|
* gtk_combo_box_set_active:
|
2007-03-12 06:04:44 +00:00
|
|
|
* @combo_box: A #GtkComboBox
|
2004-06-02 03:16:03 +00:00
|
|
|
* @index_: An index in the model passed during construction, or -1 to have
|
2007-03-12 06:04:44 +00:00
|
|
|
* no active item
|
2003-10-02 21:30:11 +00:00
|
|
|
*
|
|
|
|
* Sets the active item of @combo_box to be the item at @index.
|
|
|
|
*
|
|
|
|
* Since: 2.4
|
|
|
|
*/
|
2003-09-26 21:57:06 +00:00
|
|
|
void
|
|
|
|
gtk_combo_box_set_active (GtkComboBox *combo_box,
|
2004-06-02 03:16:03 +00:00
|
|
|
gint index_)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2004-08-09 02:46:46 +00:00
|
|
|
GtkTreePath *path = NULL;
|
2003-09-26 21:57:06 +00:00
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
2004-06-02 03:16:03 +00:00
|
|
|
g_return_if_fail (index_ >= -1);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2008-12-13 08:11:54 +00:00
|
|
|
if (combo_box->priv->model == NULL)
|
|
|
|
{
|
|
|
|
/* Save index, in case the model is set after the index */
|
|
|
|
combo_box->priv->active = index_;
|
2009-01-21 00:03:00 +00:00
|
|
|
if (index_ != -1)
|
|
|
|
return;
|
2008-12-13 08:11:54 +00:00
|
|
|
}
|
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
if (index_ != -1)
|
|
|
|
path = gtk_tree_path_new_from_indices (index_, -1);
|
2004-08-09 02:53:31 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
gtk_combo_box_set_active_internal (combo_box, path);
|
2004-08-09 02:45:18 +00:00
|
|
|
|
2004-08-09 02:46:46 +00:00
|
|
|
if (path)
|
|
|
|
gtk_tree_path_free (path);
|
2004-03-03 22:30:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_set_active_internal (GtkComboBox *combo_box,
|
2004-08-02 19:15:05 +00:00
|
|
|
GtkTreePath *path)
|
2004-03-03 22:30:36 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkComboBoxPrivate *priv = combo_box->priv;
|
2004-08-02 19:15:05 +00:00
|
|
|
GtkTreePath *active_path;
|
|
|
|
gint path_cmp;
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2009-02-22 17:21:37 +00:00
|
|
|
/* Remember whether the initially active row is valid. */
|
|
|
|
gboolean is_valid_row_reference = gtk_tree_row_reference_valid (priv->active_row);
|
|
|
|
|
|
|
|
if (path && is_valid_row_reference)
|
2004-08-02 19:15:05 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
active_path = gtk_tree_row_reference_get_path (priv->active_row);
|
2005-02-24 17:57:07 +00:00
|
|
|
path_cmp = gtk_tree_path_compare (path, active_path);
|
|
|
|
gtk_tree_path_free (active_path);
|
|
|
|
if (path_cmp == 0)
|
|
|
|
return;
|
2004-08-02 19:15:05 +00:00
|
|
|
}
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->active_row)
|
2004-08-02 19:15:05 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_tree_row_reference_free (priv->active_row);
|
|
|
|
priv->active_row = NULL;
|
2004-08-02 19:15:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!path)
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->tree_view)
|
|
|
|
gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view)));
|
2003-09-26 21:57:06 +00:00
|
|
|
else
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
GtkMenu *menu = GTK_MENU (priv->popup_widget);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
if (GTK_IS_MENU (menu))
|
|
|
|
gtk_menu_set_active (menu, -1);
|
|
|
|
}
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->cell_view)
|
|
|
|
gtk_cell_view_set_displayed_row (GTK_CELL_VIEW (priv->cell_view), NULL);
|
2009-02-22 17:21:37 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Do not emit a "changed" signal when an already invalid selection was
|
|
|
|
* now set to invalid.
|
|
|
|
*/
|
|
|
|
if (!is_valid_row_reference)
|
|
|
|
return;
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
priv->active_row =
|
|
|
|
gtk_tree_row_reference_new (priv->model, path);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->tree_view)
|
2004-08-02 19:15:05 +00:00
|
|
|
{
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->tree_view),
|
2004-08-02 19:15:05 +00:00
|
|
|
path, NULL, FALSE);
|
|
|
|
}
|
2007-12-28 06:56:48 +00:00
|
|
|
else if (GTK_IS_MENU (priv->popup_widget))
|
2003-09-26 21:57:06 +00:00
|
|
|
{
|
2004-08-02 19:15:05 +00:00
|
|
|
/* FIXME handle nested menus better */
|
2007-12-28 06:56:48 +00:00
|
|
|
gtk_menu_set_active (GTK_MENU (priv->popup_widget),
|
2010-06-28 18:15:10 +00:00
|
|
|
gtk_tree_path_get_indices (path)[0]);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
2007-12-28 06:56:48 +00:00
|
|
|
if (priv->cell_view)
|
|
|
|
gtk_cell_view_set_displayed_row (GTK_CELL_VIEW (priv->cell_view),
|
2004-08-02 19:15:05 +00:00
|
|
|
path);
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
2005-11-21 14:34:52 +00:00
|
|
|
g_signal_emit (combo_box, combo_box_signals[CHANGED], 0);
|
|
|
|
g_object_notify (G_OBJECT (combo_box), "active");
|
2003-09-26 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
2003-10-14 20:09:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_combo_box_get_active_iter:
|
|
|
|
* @combo_box: A #GtkComboBox
|
2010-07-07 16:20:37 +00:00
|
|
|
* @iter: (out): The uninitialized #GtkTreeIter
|
2003-10-14 20:09:39 +00:00
|
|
|
*
|
2004-02-28 00:40:00 +00:00
|
|
|
* Sets @iter to point to the current active item, if it exists.
|
2003-10-14 20:09:39 +00:00
|
|
|
*
|
|
|
|
* Return value: %TRUE, if @iter was set
|
|
|
|
*
|
|
|
|
* Since: 2.4
|
2007-03-12 06:04:44 +00:00
|
|
|
*/
|
2003-10-14 20:09:39 +00:00
|
|
|
gboolean
|
|
|
|
gtk_combo_box_get_active_iter (GtkComboBox *combo_box,
|
|
|
|
GtkTreeIter *iter)
|
|
|
|
{
|
|
|
|
GtkTreePath *path;
|
2004-08-02 19:15:05 +00:00
|
|
|
gboolean result;
|
2003-10-14 20:09:39 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), FALSE);
|
|
|
|
|
2005-02-24 17:57:07 +00:00
|
|
|
if (!gtk_tree_row_reference_valid (combo_box->priv->active_row))
|
2003-10-14 20:09:39 +00:00
|
|
|
return FALSE;
|
2005-02-24 17:57:07 +00:00
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
path = gtk_tree_row_reference_get_path (combo_box->priv->active_row);
|
|
|
|
result = gtk_tree_model_get_iter (combo_box->priv->model, iter, path);
|
2003-10-14 20:09:39 +00:00
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
return result;
|
2003-10-14 20:09:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_combo_box_set_active_iter:
|
|
|
|
* @combo_box: A #GtkComboBox
|
2010-02-19 16:53:17 +00:00
|
|
|
* @iter: (allow-none): The #GtkTreeIter, or %NULL
|
2003-10-14 20:09:39 +00:00
|
|
|
*
|
2010-01-06 17:46:37 +00:00
|
|
|
* Sets the current active item to be the one referenced by @iter, or
|
|
|
|
* unsets the active item if @iter is %NULL.
|
|
|
|
*
|
|
|
|
* @iter must correspond to a path of depth one, or be %NULL.
|
2003-10-14 20:09:39 +00:00
|
|
|
*
|
|
|
|
* Since: 2.4
|
2007-03-12 06:04:44 +00:00
|
|
|
*/
|
2003-10-14 20:09:39 +00:00
|
|
|
void
|
|
|
|
gtk_combo_box_set_active_iter (GtkComboBox *combo_box,
|
|
|
|
GtkTreeIter *iter)
|
|
|
|
{
|
2010-01-06 17:46:37 +00:00
|
|
|
GtkTreePath *path = NULL;
|
2003-10-14 20:09:39 +00:00
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
|
|
|
|
2010-01-06 17:46:37 +00:00
|
|
|
if (iter)
|
|
|
|
path = gtk_tree_model_get_path (gtk_combo_box_get_model (combo_box), iter);
|
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
gtk_combo_box_set_active_internal (combo_box, path);
|
2004-08-09 03:39:06 +00:00
|
|
|
gtk_tree_path_free (path);
|
2003-10-14 20:09:39 +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
|
|
|
/**
|
|
|
|
* gtk_combo_box_set_model:
|
2007-03-12 06:04:44 +00:00
|
|
|
* @combo_box: A #GtkComboBox
|
2009-12-10 10:23:40 +00:00
|
|
|
* @model: (allow-none): A #GtkTreeModel
|
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
|
|
|
*
|
2009-12-10 10:23:40 +00:00
|
|
|
* Sets the model used by @combo_box to be @model. Will unset a previously set
|
2004-10-01 19:00:47 +00:00
|
|
|
* model (if applicable). If model is %NULL, then it will unset the model.
|
|
|
|
*
|
|
|
|
* Note that this function does not clear the cell renderers, you have to
|
2007-03-12 06:04:44 +00:00
|
|
|
* call gtk_cell_layout_clear() yourself if you need to set up different
|
|
|
|
* cell renderers for the new model.
|
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
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_combo_box_set_model (GtkComboBox *combo_box,
|
|
|
|
GtkTreeModel *model)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
2007-05-21 12:43:50 +00:00
|
|
|
g_return_if_fail (model == NULL || GTK_IS_TREE_MODEL (model));
|
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
|
|
|
|
2004-03-08 18:39:44 +00:00
|
|
|
if (model == combo_box->priv->model)
|
|
|
|
return;
|
|
|
|
|
2006-12-27 07:17:53 +00:00
|
|
|
gtk_combo_box_unset_model (combo_box);
|
|
|
|
|
|
|
|
if (model == NULL)
|
2008-01-16 05:25:35 +00:00
|
|
|
goto out;
|
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
|
|
|
|
|
|
|
combo_box->priv->model = model;
|
2004-11-19 23:18:38 +00:00
|
|
|
g_object_ref (combo_box->priv->model);
|
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
|
|
|
|
2004-03-08 18:39:44 +00:00
|
|
|
combo_box->priv->inserted_id =
|
2008-08-11 09:17:49 +00:00
|
|
|
g_signal_connect (combo_box->priv->model, "row-inserted",
|
2004-03-08 18:39:44 +00:00
|
|
|
G_CALLBACK (gtk_combo_box_model_row_inserted),
|
|
|
|
combo_box);
|
|
|
|
combo_box->priv->deleted_id =
|
2008-08-11 09:17:49 +00:00
|
|
|
g_signal_connect (combo_box->priv->model, "row-deleted",
|
2004-03-08 18:39:44 +00:00
|
|
|
G_CALLBACK (gtk_combo_box_model_row_deleted),
|
|
|
|
combo_box);
|
|
|
|
combo_box->priv->reordered_id =
|
2008-08-11 09:17:49 +00:00
|
|
|
g_signal_connect (combo_box->priv->model, "rows-reordered",
|
2004-03-08 18:39:44 +00:00
|
|
|
G_CALLBACK (gtk_combo_box_model_rows_reordered),
|
|
|
|
combo_box);
|
|
|
|
combo_box->priv->changed_id =
|
2008-08-11 09:17:49 +00:00
|
|
|
g_signal_connect (combo_box->priv->model, "row-changed",
|
2004-03-08 18:39:44 +00:00
|
|
|
G_CALLBACK (gtk_combo_box_model_row_changed),
|
|
|
|
combo_box);
|
|
|
|
|
|
|
|
if (combo_box->priv->tree_view)
|
|
|
|
{
|
|
|
|
/* list mode */
|
|
|
|
gtk_tree_view_set_model (GTK_TREE_VIEW (combo_box->priv->tree_view),
|
|
|
|
combo_box->priv->model);
|
2004-10-05 04:37:29 +00:00
|
|
|
gtk_combo_box_list_popup_resize (combo_box);
|
2004-03-08 18:39:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* menu mode */
|
|
|
|
if (combo_box->priv->popup_widget)
|
|
|
|
gtk_combo_box_menu_fill (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
|
|
|
|
|
|
|
if (combo_box->priv->cell_view)
|
|
|
|
gtk_cell_view_set_model (GTK_CELL_VIEW (combo_box->priv->cell_view),
|
|
|
|
combo_box->priv->model);
|
2008-01-16 05:25:35 +00:00
|
|
|
|
2008-12-13 08:11:54 +00:00
|
|
|
if (combo_box->priv->active != -1)
|
|
|
|
{
|
|
|
|
/* If an index was set in advance, apply it now */
|
|
|
|
gtk_combo_box_set_active (combo_box, combo_box->priv->active);
|
|
|
|
combo_box->priv->active = -1;
|
|
|
|
}
|
|
|
|
|
2008-01-16 05:25:35 +00:00
|
|
|
out:
|
2008-08-04 23:40:36 +00:00
|
|
|
gtk_combo_box_update_sensitivity (combo_box);
|
|
|
|
|
2008-01-16 05:25:35 +00:00
|
|
|
g_object_notify (G_OBJECT (combo_box), "model");
|
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
|
|
|
}
|
|
|
|
|
2003-10-02 21:30:11 +00:00
|
|
|
/**
|
|
|
|
* gtk_combo_box_get_model
|
2007-03-12 06:04:44 +00:00
|
|
|
* @combo_box: A #GtkComboBox
|
2003-10-02 21:30:11 +00:00
|
|
|
*
|
|
|
|
* Returns the #GtkTreeModel which is acting as data source for @combo_box.
|
|
|
|
*
|
2009-12-10 10:23:40 +00:00
|
|
|
* Return value: (transfer none): A #GtkTreeModel which was passed during construction.
|
2003-10-02 21:30:11 +00:00
|
|
|
*
|
|
|
|
* Since: 2.4
|
|
|
|
*/
|
2003-09-26 21:57:06 +00:00
|
|
|
GtkTreeModel *
|
|
|
|
gtk_combo_box_get_model (GtkComboBox *combo_box)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL);
|
|
|
|
|
|
|
|
return combo_box->priv->model;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-01 20:51:54 +00:00
|
|
|
/* convenience API for simple text combos */
|
2003-10-02 21:30:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_combo_box_new_text:
|
|
|
|
*
|
|
|
|
* Convenience function which constructs a new text combo box, which is a
|
|
|
|
* #GtkComboBox just displaying strings. If you use this function to create
|
2004-02-26 21:40:09 +00:00
|
|
|
* a text combo box, you should only manipulate its data source with the
|
2003-10-02 21:30:11 +00:00
|
|
|
* following convenience functions: gtk_combo_box_append_text(),
|
2004-02-26 21:40:09 +00:00
|
|
|
* gtk_combo_box_insert_text(), gtk_combo_box_prepend_text() and
|
|
|
|
* gtk_combo_box_remove_text().
|
2003-10-02 21:30:11 +00:00
|
|
|
*
|
2009-12-10 10:23:40 +00:00
|
|
|
* Return value: (transfer none): A new text combo box.
|
2003-10-02 21:30:11 +00:00
|
|
|
*
|
|
|
|
* Since: 2.4
|
|
|
|
*/
|
2003-09-26 21:57:06 +00:00
|
|
|
GtkWidget *
|
|
|
|
gtk_combo_box_new_text (void)
|
|
|
|
{
|
|
|
|
GtkWidget *combo_box;
|
|
|
|
GtkCellRenderer *cell;
|
|
|
|
GtkListStore *store;
|
|
|
|
|
|
|
|
store = gtk_list_store_new (1, G_TYPE_STRING);
|
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
|
|
|
combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
|
2004-07-22 02:48:11 +00:00
|
|
|
g_object_unref (store);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
cell = gtk_cell_renderer_text_new ();
|
2003-10-01 20:51:54 +00:00
|
|
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell, TRUE);
|
|
|
|
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell,
|
|
|
|
"text", 0,
|
|
|
|
NULL);
|
2003-09-26 21:57:06 +00:00
|
|
|
|
|
|
|
return combo_box;
|
|
|
|
}
|
|
|
|
|
2003-10-02 21:30:11 +00:00
|
|
|
/**
|
|
|
|
* gtk_combo_box_append_text:
|
2007-03-12 06:04:44 +00:00
|
|
|
* @combo_box: A #GtkComboBox constructed using gtk_combo_box_new_text()
|
|
|
|
* @text: A string
|
2003-10-02 21:30:11 +00:00
|
|
|
*
|
|
|
|
* Appends @string to the list of strings stored in @combo_box. Note that
|
|
|
|
* you can only use this function with combo boxes constructed with
|
|
|
|
* gtk_combo_box_new_text().
|
|
|
|
*
|
|
|
|
* Since: 2.4
|
|
|
|
*/
|
2003-09-26 21:57:06 +00:00
|
|
|
void
|
|
|
|
gtk_combo_box_append_text (GtkComboBox *combo_box,
|
|
|
|
const gchar *text)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkListStore *store;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
|
|
|
g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model));
|
2008-06-20 10:00:40 +00:00
|
|
|
g_return_if_fail (gtk_tree_model_get_column_type (combo_box->priv->model, 0)
|
|
|
|
== G_TYPE_STRING);
|
2003-09-26 21:57:06 +00:00
|
|
|
g_return_if_fail (text != NULL);
|
|
|
|
|
|
|
|
store = GTK_LIST_STORE (combo_box->priv->model);
|
|
|
|
|
|
|
|
gtk_list_store_append (store, &iter);
|
|
|
|
gtk_list_store_set (store, &iter, 0, text, -1);
|
|
|
|
}
|
|
|
|
|
2003-10-02 21:30:11 +00:00
|
|
|
/**
|
|
|
|
* gtk_combo_box_insert_text:
|
2007-03-12 06:04:44 +00:00
|
|
|
* @combo_box: A #GtkComboBox constructed using gtk_combo_box_new_text()
|
|
|
|
* @position: An index to insert @text
|
|
|
|
* @text: A string
|
2003-10-02 21:30:11 +00:00
|
|
|
*
|
|
|
|
* Inserts @string at @position in the list of strings stored in @combo_box.
|
|
|
|
* Note that you can only use this function with combo boxes constructed
|
|
|
|
* with gtk_combo_box_new_text().
|
|
|
|
*
|
|
|
|
* Since: 2.4
|
|
|
|
*/
|
2003-09-26 21:57:06 +00:00
|
|
|
void
|
|
|
|
gtk_combo_box_insert_text (GtkComboBox *combo_box,
|
|
|
|
gint position,
|
|
|
|
const gchar *text)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkListStore *store;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
|
|
|
g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model));
|
|
|
|
g_return_if_fail (position >= 0);
|
2008-06-20 10:00:40 +00:00
|
|
|
g_return_if_fail (gtk_tree_model_get_column_type (combo_box->priv->model, 0)
|
|
|
|
== G_TYPE_STRING);
|
2003-09-26 21:57:06 +00:00
|
|
|
g_return_if_fail (text != NULL);
|
|
|
|
|
|
|
|
store = GTK_LIST_STORE (combo_box->priv->model);
|
|
|
|
|
|
|
|
gtk_list_store_insert (store, &iter, position);
|
|
|
|
gtk_list_store_set (store, &iter, 0, text, -1);
|
|
|
|
}
|
|
|
|
|
2003-10-02 21:30:11 +00:00
|
|
|
/**
|
|
|
|
* gtk_combo_box_prepend_text:
|
2007-03-12 06:04:44 +00:00
|
|
|
* @combo_box: A #GtkComboBox constructed with gtk_combo_box_new_text()
|
|
|
|
* @text: A string
|
2003-10-02 21:30:11 +00:00
|
|
|
*
|
|
|
|
* Prepends @string to the list of strings stored in @combo_box. Note that
|
|
|
|
* you can only use this function with combo boxes constructed with
|
|
|
|
* gtk_combo_box_new_text().
|
|
|
|
*
|
|
|
|
* Since: 2.4
|
|
|
|
*/
|
2003-09-26 21:57:06 +00:00
|
|
|
void
|
|
|
|
gtk_combo_box_prepend_text (GtkComboBox *combo_box,
|
|
|
|
const gchar *text)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkListStore *store;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
|
|
|
g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model));
|
2008-06-20 10:00:40 +00:00
|
|
|
g_return_if_fail (gtk_tree_model_get_column_type (combo_box->priv->model, 0)
|
|
|
|
== G_TYPE_STRING);
|
2003-09-26 21:57:06 +00:00
|
|
|
g_return_if_fail (text != NULL);
|
|
|
|
|
|
|
|
store = GTK_LIST_STORE (combo_box->priv->model);
|
|
|
|
|
|
|
|
gtk_list_store_prepend (store, &iter);
|
|
|
|
gtk_list_store_set (store, &iter, 0, text, -1);
|
|
|
|
}
|
2003-11-17 22:24:57 +00:00
|
|
|
|
2003-11-19 22:26:42 +00:00
|
|
|
/**
|
|
|
|
* gtk_combo_box_remove_text:
|
2007-03-12 06:04:44 +00:00
|
|
|
* @combo_box: A #GtkComboBox constructed with gtk_combo_box_new_text()
|
|
|
|
* @position: Index of the item to remove
|
2003-11-19 22:26:42 +00:00
|
|
|
*
|
|
|
|
* Removes the string at @position from @combo_box. Note that you can only use
|
|
|
|
* this function with combo boxes constructed with gtk_combo_box_new_text().
|
|
|
|
*
|
|
|
|
* Since: 2.4
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_combo_box_remove_text (GtkComboBox *combo_box,
|
|
|
|
gint position)
|
2003-11-17 22:24:57 +00:00
|
|
|
{
|
2003-11-19 22:26:42 +00:00
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkListStore *store;
|
2003-11-17 22:24:57 +00:00
|
|
|
|
2003-11-19 22:26:42 +00:00
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
|
|
|
g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model));
|
2008-06-20 10:00:40 +00:00
|
|
|
g_return_if_fail (gtk_tree_model_get_column_type (combo_box->priv->model, 0)
|
|
|
|
== G_TYPE_STRING);
|
2003-11-19 22:26:42 +00:00
|
|
|
g_return_if_fail (position >= 0);
|
2003-11-17 22:24:57 +00:00
|
|
|
|
2003-11-19 22:26:42 +00:00
|
|
|
store = GTK_LIST_STORE (combo_box->priv->model);
|
2003-11-17 22:24:57 +00:00
|
|
|
|
2003-11-19 22:26:42 +00:00
|
|
|
if (gtk_tree_model_iter_nth_child (combo_box->priv->model, &iter,
|
|
|
|
NULL, position))
|
|
|
|
gtk_list_store_remove (store, &iter);
|
2003-11-17 22:24:57 +00:00
|
|
|
}
|
2004-02-05 20:35:57 +00:00
|
|
|
|
2004-05-06 03:49:15 +00:00
|
|
|
/**
|
|
|
|
* gtk_combo_box_get_active_text:
|
2007-03-12 06:04:44 +00:00
|
|
|
* @combo_box: A #GtkComboBox constructed with gtk_combo_box_new_text()
|
2004-05-06 03:49:15 +00:00
|
|
|
*
|
|
|
|
* Returns the currently active string in @combo_box or %NULL if none
|
|
|
|
* is selected. Note that you can only use this function with combo
|
2009-05-23 05:20:39 +00:00
|
|
|
* boxes constructed with gtk_combo_box_new_text() and with
|
2005-04-01 20:53:04 +00:00
|
|
|
* #GtkComboBoxEntry<!-- -->s.
|
2004-05-06 03:49:15 +00:00
|
|
|
*
|
|
|
|
* Returns: a newly allocated string containing the currently active text.
|
2009-05-23 05:20:39 +00:00
|
|
|
* Must be freed with g_free().
|
2004-05-06 03:49:15 +00:00
|
|
|
*
|
|
|
|
* Since: 2.6
|
|
|
|
*/
|
|
|
|
gchar *
|
|
|
|
gtk_combo_box_get_active_text (GtkComboBox *combo_box)
|
2005-04-01 20:53:04 +00:00
|
|
|
{
|
|
|
|
GtkComboBoxClass *class;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL);
|
|
|
|
|
|
|
|
class = GTK_COMBO_BOX_GET_CLASS (combo_box);
|
|
|
|
|
|
|
|
if (class->get_active_text)
|
2008-08-12 09:51:16 +00:00
|
|
|
return class->get_active_text (combo_box);
|
2005-04-01 20:53:04 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
gtk_combo_box_real_get_active_text (GtkComboBox *combo_box)
|
2004-05-06 03:49:15 +00:00
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gchar *text = NULL;
|
|
|
|
|
2004-05-08 16:25:15 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model), NULL);
|
2008-06-20 10:00:40 +00:00
|
|
|
g_return_val_if_fail (gtk_tree_model_get_column_type (combo_box->priv->model, 0)
|
|
|
|
== G_TYPE_STRING, NULL);
|
2004-05-06 03:49:15 +00:00
|
|
|
|
|
|
|
if (gtk_combo_box_get_active_iter (combo_box, &iter))
|
|
|
|
gtk_tree_model_get (combo_box->priv->model, &iter,
|
|
|
|
0, &text, -1);
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
2004-02-05 20:35:57 +00:00
|
|
|
|
2006-10-12 13:04:44 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_real_move_active (GtkComboBox *combo_box,
|
|
|
|
GtkScrollType scroll)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeIter new_iter;
|
|
|
|
gboolean active_iter;
|
|
|
|
gboolean found;
|
|
|
|
|
|
|
|
if (!combo_box->priv->model)
|
2006-11-16 12:56:30 +00:00
|
|
|
{
|
|
|
|
gtk_widget_error_bell (GTK_WIDGET (combo_box));
|
|
|
|
return;
|
|
|
|
}
|
2006-10-12 13:04:44 +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)
|
|
|
|
{
|
|
|
|
found = tree_prev (combo_box, combo_box->priv->model,
|
|
|
|
&iter, &new_iter, FALSE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* else fall through */
|
|
|
|
|
|
|
|
case GTK_SCROLL_PAGE_FORWARD:
|
|
|
|
case GTK_SCROLL_PAGE_DOWN:
|
|
|
|
case GTK_SCROLL_PAGE_RIGHT:
|
|
|
|
case GTK_SCROLL_END:
|
|
|
|
found = tree_last (combo_box, combo_box->priv->model, &new_iter, FALSE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GTK_SCROLL_STEP_FORWARD:
|
|
|
|
case GTK_SCROLL_STEP_DOWN:
|
|
|
|
case GTK_SCROLL_STEP_RIGHT:
|
|
|
|
if (active_iter)
|
|
|
|
{
|
|
|
|
found = tree_next (combo_box, combo_box->priv->model,
|
|
|
|
&iter, &new_iter, FALSE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* else fall through */
|
|
|
|
|
|
|
|
case GTK_SCROLL_PAGE_BACKWARD:
|
|
|
|
case GTK_SCROLL_PAGE_UP:
|
|
|
|
case GTK_SCROLL_PAGE_LEFT:
|
|
|
|
case GTK_SCROLL_START:
|
|
|
|
found = tree_first (combo_box, combo_box->priv->model, &new_iter, FALSE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-11-16 12:56:30 +00:00
|
|
|
if (found && active_iter)
|
2006-10-12 13:04:44 +00:00
|
|
|
{
|
2006-11-16 12:56:30 +00:00
|
|
|
GtkTreePath *old_path;
|
|
|
|
GtkTreePath *new_path;
|
2006-10-12 13:04:44 +00:00
|
|
|
|
2006-11-16 12:56:30 +00:00
|
|
|
old_path = gtk_tree_model_get_path (combo_box->priv->model, &iter);
|
|
|
|
new_path = gtk_tree_model_get_path (combo_box->priv->model, &new_iter);
|
2006-10-12 13:04:44 +00:00
|
|
|
|
2006-11-16 12:56:30 +00:00
|
|
|
if (gtk_tree_path_compare (old_path, new_path) == 0)
|
|
|
|
found = FALSE;
|
2006-10-12 13:04:44 +00:00
|
|
|
|
2006-11-16 12:56:30 +00:00
|
|
|
gtk_tree_path_free (old_path);
|
|
|
|
gtk_tree_path_free (new_path);
|
|
|
|
}
|
2006-10-12 13:04:44 +00:00
|
|
|
|
2006-11-16 12:56:30 +00:00
|
|
|
if (found)
|
|
|
|
{
|
|
|
|
gtk_combo_box_set_active_iter (combo_box, &new_iter);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_widget_error_bell (GTK_WIDGET (combo_box));
|
2006-10-12 13:04:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-02-05 20:35:57 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_combo_box_mnemonic_activate (GtkWidget *widget,
|
|
|
|
gboolean group_cycling)
|
|
|
|
{
|
2004-02-05 22:46:22 +00:00
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
|
|
|
|
|
2004-02-05 23:14:37 +00:00
|
|
|
gtk_widget_grab_focus (combo_box->priv->button);
|
2004-02-05 22:46:22 +00:00
|
|
|
|
2004-02-05 20:35:57 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2004-02-05 22:46:22 +00:00
|
|
|
|
2005-04-06 04:01:19 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_grab_focus (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
|
|
|
|
|
|
|
|
gtk_widget_grab_focus (combo_box->priv->button);
|
|
|
|
}
|
|
|
|
|
2004-02-24 00:07:15 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_box_destroy (GtkObject *object)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (object);
|
|
|
|
|
2004-07-16 20:27:40 +00:00
|
|
|
if (combo_box->priv->popup_idle_id > 0)
|
|
|
|
{
|
|
|
|
g_source_remove (combo_box->priv->popup_idle_id);
|
|
|
|
combo_box->priv->popup_idle_id = 0;
|
|
|
|
}
|
|
|
|
|
2004-07-12 16:15:55 +00:00
|
|
|
gtk_combo_box_popdown (combo_box);
|
2004-07-16 20:27:40 +00:00
|
|
|
|
2004-07-30 22:55:28 +00:00
|
|
|
if (combo_box->priv->row_separator_destroy)
|
2008-08-12 09:51:16 +00:00
|
|
|
combo_box->priv->row_separator_destroy (combo_box->priv->row_separator_data);
|
2004-07-30 22:55:28 +00:00
|
|
|
|
|
|
|
combo_box->priv->row_separator_func = NULL;
|
|
|
|
combo_box->priv->row_separator_data = NULL;
|
|
|
|
combo_box->priv->row_separator_destroy = NULL;
|
|
|
|
|
2006-05-02 23:56:43 +00:00
|
|
|
GTK_OBJECT_CLASS (gtk_combo_box_parent_class)->destroy (object);
|
2004-02-24 00:07:15 +00:00
|
|
|
combo_box->priv->cell_view = NULL;
|
|
|
|
}
|
2004-02-05 23:45:21 +00:00
|
|
|
|
|
|
|
static void
|
2007-05-02 22:19:45 +00:00
|
|
|
gtk_combo_box_dispose(GObject* object)
|
2004-02-05 23:45:21 +00:00
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (object);
|
2007-05-02 22:19:45 +00:00
|
|
|
|
2004-02-05 23:45:21 +00:00
|
|
|
if (GTK_IS_MENU (combo_box->priv->popup_widget))
|
2004-07-22 02:36:54 +00:00
|
|
|
{
|
|
|
|
gtk_combo_box_menu_destroy (combo_box);
|
|
|
|
gtk_menu_detach (GTK_MENU (combo_box->priv->popup_widget));
|
|
|
|
combo_box->priv->popup_widget = NULL;
|
|
|
|
}
|
2007-05-02 22:19:45 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_combo_box_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (object);
|
|
|
|
GSList *i;
|
2004-02-05 23:45:21 +00:00
|
|
|
|
|
|
|
if (GTK_IS_TREE_VIEW (combo_box->priv->tree_view))
|
|
|
|
gtk_combo_box_list_destroy (combo_box);
|
|
|
|
|
|
|
|
if (combo_box->priv->popup_window)
|
|
|
|
gtk_widget_destroy (combo_box->priv->popup_window);
|
|
|
|
|
2004-03-08 18:39:44 +00:00
|
|
|
gtk_combo_box_unset_model (combo_box);
|
|
|
|
|
2004-02-26 20:51:02 +00:00
|
|
|
for (i = combo_box->priv->cells; i; i = i->next)
|
|
|
|
{
|
|
|
|
ComboCellInfo *info = (ComboCellInfo *)i->data;
|
|
|
|
GSList *list = info->attributes;
|
|
|
|
|
|
|
|
if (info->destroy)
|
|
|
|
info->destroy (info->func_data);
|
|
|
|
|
|
|
|
while (list && list->next)
|
|
|
|
{
|
|
|
|
g_free (list->data);
|
|
|
|
list = list->next->next;
|
|
|
|
}
|
|
|
|
g_slist_free (info->attributes);
|
|
|
|
|
2004-11-19 23:18:38 +00:00
|
|
|
g_object_unref (info->cell);
|
2008-07-04 10:52:52 +00:00
|
|
|
g_slice_free (ComboCellInfo, info);
|
2004-02-26 20:51:02 +00:00
|
|
|
}
|
2004-02-11 01:09:25 +00:00
|
|
|
g_slist_free (combo_box->priv->cells);
|
2004-02-05 23:45:21 +00:00
|
|
|
|
2006-04-20 15:00:01 +00:00
|
|
|
g_free (combo_box->priv->tearoff_title);
|
|
|
|
|
2006-05-02 23:56:43 +00:00
|
|
|
G_OBJECT_CLASS (gtk_combo_box_parent_class)->finalize (object);
|
2004-02-05 23:45:21 +00:00
|
|
|
}
|
2004-05-10 14:07:35 +00:00
|
|
|
|
2004-07-16 20:27:40 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_cell_editable_key_press (GtkWidget *widget,
|
|
|
|
GdkEventKey *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (data);
|
|
|
|
|
|
|
|
if (event->keyval == GDK_Escape)
|
|
|
|
{
|
2009-12-04 01:15:00 +00:00
|
|
|
g_object_set (combo_box,
|
|
|
|
"editing-canceled", TRUE,
|
|
|
|
NULL);
|
2004-07-16 20:27:40 +00:00
|
|
|
gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (combo_box));
|
|
|
|
gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (combo_box));
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2008-02-12 15:51:09 +00:00
|
|
|
else if (event->keyval == GDK_Return ||
|
|
|
|
event->keyval == GDK_ISO_Enter ||
|
|
|
|
event->keyval == GDK_KP_Enter)
|
2004-07-16 20:27:40 +00:00
|
|
|
{
|
2004-10-28 16:50:10 +00:00
|
|
|
gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (combo_box));
|
|
|
|
gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (combo_box));
|
2004-07-16 20:27:40 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-08-02 19:15:05 +00:00
|
|
|
popdown_idle (gpointer data)
|
2004-07-16 20:27:40 +00:00
|
|
|
{
|
2004-08-30 13:16:39 +00:00
|
|
|
GtkComboBox *combo_box;
|
|
|
|
|
|
|
|
combo_box = GTK_COMBO_BOX (data);
|
2004-07-16 20:27:40 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
popdown_handler (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2006-12-22 19:10:43 +00:00
|
|
|
gdk_threads_add_idle (popdown_idle, g_object_ref (data));
|
2004-07-16 20:27:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
popup_idle (gpointer data)
|
|
|
|
{
|
2004-08-30 13:16:39 +00:00
|
|
|
GtkComboBox *combo_box;
|
|
|
|
|
|
|
|
combo_box = GTK_COMBO_BOX (data);
|
2004-07-16 20:27:40 +00:00
|
|
|
|
|
|
|
if (GTK_IS_MENU (combo_box->priv->popup_widget) &&
|
|
|
|
combo_box->priv->cell_view)
|
|
|
|
g_signal_connect_object (combo_box->priv->popup_widget,
|
|
|
|
"unmap", G_CALLBACK (popdown_handler),
|
|
|
|
combo_box, 0);
|
|
|
|
|
|
|
|
/* we unset this if a menu item is activated */
|
2009-12-04 01:15:00 +00:00
|
|
|
g_object_set (combo_box,
|
|
|
|
"editing-canceled", TRUE,
|
|
|
|
NULL);
|
2004-07-16 20:27:40 +00:00
|
|
|
gtk_combo_box_popup (combo_box);
|
2005-07-22 03:38:14 +00:00
|
|
|
|
|
|
|
combo_box->priv->popup_idle_id = 0;
|
2007-12-25 04:04:21 +00:00
|
|
|
combo_box->priv->activate_button = 0;
|
|
|
|
combo_box->priv->activate_time = 0;
|
2005-07-22 03:38:14 +00:00
|
|
|
|
2004-07-16 20:27:40 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_start_editing (GtkCellEditable *cell_editable,
|
|
|
|
GdkEvent *event)
|
|
|
|
{
|
|
|
|
GtkComboBox *combo_box = GTK_COMBO_BOX (cell_editable);
|
2010-05-24 20:31:36 +00:00
|
|
|
GtkWidget *child;
|
2004-07-16 20:27:40 +00:00
|
|
|
|
|
|
|
combo_box->priv->is_cell_renderer = TRUE;
|
|
|
|
|
|
|
|
if (combo_box->priv->cell_view)
|
|
|
|
{
|
2008-08-11 09:17:49 +00:00
|
|
|
g_signal_connect_object (combo_box->priv->button, "key-press-event",
|
2004-10-28 16:50:10 +00:00
|
|
|
G_CALLBACK (gtk_cell_editable_key_press),
|
|
|
|
cell_editable, 0);
|
2004-07-16 20:27:40 +00:00
|
|
|
|
|
|
|
gtk_widget_grab_focus (combo_box->priv->button);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-05-24 20:31:36 +00:00
|
|
|
child = gtk_bin_get_child (GTK_BIN (combo_box));
|
|
|
|
|
|
|
|
g_signal_connect_object (child, "key-press-event",
|
2004-10-28 16:50:10 +00:00
|
|
|
G_CALLBACK (gtk_cell_editable_key_press),
|
|
|
|
cell_editable, 0);
|
2004-07-16 20:27:40 +00:00
|
|
|
|
2010-05-24 20:31:36 +00:00
|
|
|
gtk_widget_grab_focus (child);
|
2010-03-02 03:40:38 +00:00
|
|
|
gtk_widget_set_can_focus (combo_box->priv->button, FALSE);
|
2004-07-16 20:27:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* we do the immediate popup only for the optionmenu-like
|
|
|
|
* appearance
|
|
|
|
*/
|
|
|
|
if (combo_box->priv->is_cell_renderer &&
|
|
|
|
combo_box->priv->cell_view && !combo_box->priv->tree_view)
|
2007-12-25 04:04:21 +00:00
|
|
|
{
|
|
|
|
if (event && event->type == GDK_BUTTON_PRESS)
|
|
|
|
{
|
|
|
|
GdkEventButton *event_button = (GdkEventButton *)event;
|
|
|
|
|
|
|
|
combo_box->priv->activate_button = event_button->button;
|
|
|
|
combo_box->priv->activate_time = event_button->time;
|
|
|
|
}
|
|
|
|
|
|
|
|
combo_box->priv->popup_idle_id =
|
|
|
|
gdk_threads_add_idle (popup_idle, combo_box);
|
|
|
|
}
|
2004-07-16 20:27:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_combo_box_get_add_tearoffs:
|
|
|
|
* @combo_box: a #GtkComboBox
|
|
|
|
*
|
|
|
|
* Gets the current value of the :add-tearoffs property.
|
|
|
|
*
|
|
|
|
* Return value: the current value of the :add-tearoffs property.
|
2007-03-12 06:04:44 +00:00
|
|
|
*/
|
2004-05-10 14:07:35 +00:00
|
|
|
gboolean
|
|
|
|
gtk_combo_box_get_add_tearoffs (GtkComboBox *combo_box)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), FALSE);
|
|
|
|
|
|
|
|
return combo_box->priv->add_tearoffs;
|
|
|
|
}
|
|
|
|
|
2004-07-16 20:27:40 +00:00
|
|
|
/**
|
|
|
|
* gtk_combo_box_set_add_tearoffs:
|
|
|
|
* @combo_box: a #GtkComboBox
|
|
|
|
* @add_tearoffs: %TRUE to add tearoff menu items
|
|
|
|
*
|
|
|
|
* Sets whether the popup menu should have a tearoff
|
|
|
|
* menu item.
|
|
|
|
*
|
|
|
|
* Since: 2.6
|
2007-03-12 06:04:44 +00:00
|
|
|
*/
|
2004-05-10 14:07:35 +00:00
|
|
|
void
|
|
|
|
gtk_combo_box_set_add_tearoffs (GtkComboBox *combo_box,
|
|
|
|
gboolean add_tearoffs)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
|
|
|
|
|
|
|
add_tearoffs = add_tearoffs != FALSE;
|
|
|
|
|
|
|
|
if (combo_box->priv->add_tearoffs != add_tearoffs)
|
|
|
|
{
|
|
|
|
combo_box->priv->add_tearoffs = add_tearoffs;
|
|
|
|
gtk_combo_box_check_appearance (combo_box);
|
|
|
|
gtk_combo_box_relayout (combo_box);
|
2005-03-26 05:49:15 +00:00
|
|
|
g_object_notify (G_OBJECT (combo_box), "add-tearoffs");
|
2004-05-10 14:07:35 +00:00
|
|
|
}
|
|
|
|
}
|
2004-07-07 15:15:35 +00:00
|
|
|
|
2005-11-21 16:01:56 +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().
|
|
|
|
*
|
|
|
|
* Returns: the menu's title in tearoff mode. This is an internal copy of the
|
|
|
|
* string which must not be freed.
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
|
|
|
G_CONST_RETURN gchar*
|
|
|
|
gtk_combo_box_get_title (GtkComboBox *combo_box)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL);
|
|
|
|
|
|
|
|
return combo_box->priv->tearoff_title;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_update_title (GtkComboBox *combo_box)
|
|
|
|
{
|
|
|
|
gtk_combo_box_check_appearance (combo_box);
|
|
|
|
|
|
|
|
if (combo_box->priv->popup_widget &&
|
|
|
|
GTK_IS_MENU (combo_box->priv->popup_widget))
|
|
|
|
gtk_menu_set_title (GTK_MENU (combo_box->priv->popup_widget),
|
|
|
|
combo_box->priv->tearoff_title);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_combo_box_set_title:
|
|
|
|
* @combo_box: a #GtkComboBox
|
2007-03-12 06:04:44 +00:00
|
|
|
* @title: a title for the menu in tearoff mode
|
2005-11-21 16:01:56 +00:00
|
|
|
*
|
|
|
|
* Sets the menu's title in tearoff mode.
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_combo_box_set_title (GtkComboBox *combo_box,
|
|
|
|
const gchar *title)
|
|
|
|
{
|
2007-12-28 05:49:21 +00:00
|
|
|
GtkComboBoxPrivate *priv;
|
|
|
|
|
2005-11-21 16:01:56 +00:00
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
|
|
|
|
2007-12-28 05:49:21 +00:00
|
|
|
priv = combo_box->priv;
|
|
|
|
|
2005-11-21 16:01:56 +00:00
|
|
|
if (strcmp (title ? title : "",
|
2007-12-28 05:49:21 +00:00
|
|
|
priv->tearoff_title ? priv->tearoff_title : "") != 0)
|
2005-11-21 16:01:56 +00:00
|
|
|
{
|
2007-12-28 05:49:21 +00:00
|
|
|
g_free (priv->tearoff_title);
|
|
|
|
priv->tearoff_title = g_strdup (title);
|
2005-11-21 16:01:56 +00:00
|
|
|
|
|
|
|
gtk_combo_box_update_title (combo_box);
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (combo_box), "tearoff-title");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-07 15:15:35 +00:00
|
|
|
/**
|
2004-08-02 19:15:05 +00:00
|
|
|
* gtk_combo_box_get_popup_accessible:
|
2004-07-07 15:15:35 +00:00
|
|
|
* @combo_box: a #GtkComboBox
|
2004-08-02 19:15:05 +00:00
|
|
|
*
|
2004-07-30 20:55:17 +00:00
|
|
|
* Gets the accessible object corresponding to the combo box's popup.
|
|
|
|
*
|
|
|
|
* This function is mostly intended for use by accessibility technologies;
|
|
|
|
* applications should have little use for it.
|
2004-07-07 15:15:35 +00:00
|
|
|
*
|
2004-09-01 21:26:35 +00:00
|
|
|
* Returns: the accessible object corresponding to the combo box's popup.
|
|
|
|
*
|
2004-07-07 15:15:35 +00:00
|
|
|
* Since: 2.6
|
2007-03-12 06:04:44 +00:00
|
|
|
*/
|
2004-07-30 20:55:17 +00:00
|
|
|
AtkObject*
|
|
|
|
gtk_combo_box_get_popup_accessible (GtkComboBox *combo_box)
|
2004-07-07 15:15:35 +00:00
|
|
|
{
|
2004-07-30 20:55:17 +00:00
|
|
|
AtkObject *atk_obj;
|
2004-07-07 15:15:35 +00:00
|
|
|
|
2004-07-30 20:55:17 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL);
|
2004-07-07 15:15:35 +00:00
|
|
|
|
2004-07-30 20:55:17 +00:00
|
|
|
if (combo_box->priv->popup_widget)
|
2004-07-07 15:15:35 +00:00
|
|
|
{
|
2004-07-30 20:55:17 +00:00
|
|
|
atk_obj = gtk_widget_get_accessible (combo_box->priv->popup_widget);
|
|
|
|
return atk_obj;
|
2004-07-07 15:15:35 +00:00
|
|
|
}
|
2004-07-30 20:55:17 +00:00
|
|
|
|
|
|
|
return NULL;
|
2004-07-07 15:15:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2004-07-30 20:55:17 +00:00
|
|
|
* gtk_combo_box_get_row_separator_func:
|
2004-07-07 15:15:35 +00:00
|
|
|
* @combo_box: a #GtkComboBox
|
|
|
|
*
|
2004-07-30 20:55:17 +00:00
|
|
|
* Returns the current row separator function.
|
2004-07-07 15:15:35 +00:00
|
|
|
*
|
2004-07-30 20:55:17 +00:00
|
|
|
* Return value: the current row separator function.
|
2004-07-07 15:15:35 +00:00
|
|
|
*
|
|
|
|
* Since: 2.6
|
2007-03-12 06:04:44 +00:00
|
|
|
*/
|
2004-07-30 20:55:17 +00:00
|
|
|
GtkTreeViewRowSeparatorFunc
|
|
|
|
gtk_combo_box_get_row_separator_func (GtkComboBox *combo_box)
|
2004-07-07 15:15:35 +00:00
|
|
|
{
|
2004-07-30 20:55:17 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL);
|
2004-07-16 20:27:40 +00:00
|
|
|
|
2004-07-30 20:55:17 +00:00
|
|
|
return combo_box->priv->row_separator_func;
|
2004-07-16 20:27:40 +00:00
|
|
|
}
|
2004-07-27 16:37:37 +00:00
|
|
|
|
|
|
|
/**
|
2004-07-30 20:55:17 +00:00
|
|
|
* gtk_combo_box_set_row_separator_func:
|
2004-07-27 16:37:37 +00:00
|
|
|
* @combo_box: a #GtkComboBox
|
2004-07-30 20:55:17 +00:00
|
|
|
* @func: a #GtkTreeViewRowSeparatorFunc
|
2010-02-19 16:53:17 +00:00
|
|
|
* @data: (allow-none): user data to pass to @func, or %NULL
|
|
|
|
* @destroy: (allow-none): destroy notifier for @data, or %NULL
|
2004-07-27 16:37:37 +00:00
|
|
|
*
|
2004-07-30 20:55:17 +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.
|
2004-07-27 16:37:37 +00:00
|
|
|
*
|
|
|
|
* Since: 2.6
|
2007-03-12 06:04:44 +00:00
|
|
|
*/
|
2004-07-30 20:55:17 +00:00
|
|
|
void
|
|
|
|
gtk_combo_box_set_row_separator_func (GtkComboBox *combo_box,
|
|
|
|
GtkTreeViewRowSeparatorFunc func,
|
|
|
|
gpointer data,
|
2008-06-18 09:12:32 +00:00
|
|
|
GDestroyNotify destroy)
|
2004-07-27 16:37:37 +00:00
|
|
|
{
|
2004-07-30 20:55:17 +00:00
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
2004-07-27 16:37:37 +00:00
|
|
|
|
2004-07-30 20:55:17 +00:00
|
|
|
if (combo_box->priv->row_separator_destroy)
|
2008-08-12 09:51:16 +00:00
|
|
|
combo_box->priv->row_separator_destroy (combo_box->priv->row_separator_data);
|
2004-07-27 16:37:37 +00:00
|
|
|
|
2004-07-30 20:55:17 +00:00
|
|
|
combo_box->priv->row_separator_func = func;
|
|
|
|
combo_box->priv->row_separator_data = data;
|
|
|
|
combo_box->priv->row_separator_destroy = destroy;
|
2004-07-27 16:37:37 +00:00
|
|
|
|
2004-07-30 20:55:17 +00:00
|
|
|
if (combo_box->priv->tree_view)
|
|
|
|
gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (combo_box->priv->tree_view),
|
|
|
|
func, data, NULL);
|
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
gtk_combo_box_relayout (combo_box);
|
|
|
|
|
2004-07-30 20:55:17 +00:00
|
|
|
gtk_widget_queue_draw (GTK_WIDGET (combo_box));
|
2004-07-27 16:37:37 +00:00
|
|
|
}
|
2004-08-02 19:15:05 +00:00
|
|
|
|
2008-08-04 23:40: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)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
|
|
|
|
|
|
|
if (combo_box->priv->button_sensitivity != sensitivity)
|
|
|
|
{
|
|
|
|
combo_box->priv->button_sensitivity = sensitivity;
|
|
|
|
gtk_combo_box_update_sensitivity (combo_box);
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (combo_box), "button-sensitivity");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* Return Value: %GTK_SENSITIVITY_ON if the dropdown button
|
|
|
|
* 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);
|
|
|
|
|
|
|
|
return combo_box->priv->button_sensitivity;
|
|
|
|
}
|
|
|
|
|
2004-08-02 19:15:05 +00:00
|
|
|
|
2004-08-16 05:43:50 +00:00
|
|
|
/**
|
|
|
|
* gtk_combo_box_set_focus_on_click:
|
|
|
|
* @combo: a #GtkComboBox
|
|
|
|
* @focus_on_click: whether the combo box grabs focus when clicked
|
|
|
|
* with the mouse
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* like toolbars where you don't want the keyboard focus removed from
|
|
|
|
* the main area of the application.
|
|
|
|
*
|
|
|
|
* Since: 2.6
|
2007-03-12 06:04:44 +00:00
|
|
|
*/
|
2004-08-16 05:43:50 +00:00
|
|
|
void
|
2005-07-18 14:47:55 +00:00
|
|
|
gtk_combo_box_set_focus_on_click (GtkComboBox *combo_box,
|
2004-08-16 05:43:50 +00:00
|
|
|
gboolean focus_on_click)
|
|
|
|
{
|
2005-07-18 14:47:55 +00:00
|
|
|
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
|
2004-08-16 05:43:50 +00:00
|
|
|
|
|
|
|
focus_on_click = focus_on_click != FALSE;
|
|
|
|
|
2005-07-18 14:47:55 +00:00
|
|
|
if (combo_box->priv->focus_on_click != focus_on_click)
|
2004-08-16 05:43:50 +00:00
|
|
|
{
|
2005-07-18 14:47:55 +00:00
|
|
|
combo_box->priv->focus_on_click = focus_on_click;
|
|
|
|
|
|
|
|
if (combo_box->priv->button)
|
|
|
|
gtk_button_set_focus_on_click (GTK_BUTTON (combo_box->priv->button),
|
|
|
|
focus_on_click);
|
2004-08-16 05:43:50 +00:00
|
|
|
|
2005-07-18 14:47:55 +00:00
|
|
|
g_object_notify (G_OBJECT (combo_box), "focus-on-click");
|
2004-08-16 05:43:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_combo_box_get_focus_on_click:
|
|
|
|
* @combo: a #GtkComboBox
|
|
|
|
*
|
|
|
|
* Returns whether the combo box grabs focus when it is clicked
|
|
|
|
* with the mouse. See gtk_combo_box_set_focus_on_click().
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if the combo box grabs focus when it is
|
|
|
|
* clicked with the mouse.
|
|
|
|
*
|
|
|
|
* Since: 2.6
|
2007-03-12 06:04:44 +00:00
|
|
|
*/
|
2004-08-16 05:43:50 +00:00
|
|
|
gboolean
|
2005-07-18 14:47:55 +00:00
|
|
|
gtk_combo_box_get_focus_on_click (GtkComboBox *combo_box)
|
2004-08-16 05:43:50 +00:00
|
|
|
{
|
2005-07-18 14:47:55 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), FALSE);
|
2004-08-16 05:43:50 +00:00
|
|
|
|
2005-07-18 14:47:55 +00:00
|
|
|
return combo_box->priv->focus_on_click;
|
2004-08-16 05:43:50 +00:00
|
|
|
}
|
2005-03-20 07:01:23 +00:00
|
|
|
|
2005-04-06 04:01:19 +00:00
|
|
|
|
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,
|
|
|
|
GtkBuilder *builder,
|
|
|
|
GObject *child,
|
|
|
|
const gchar *tagname,
|
|
|
|
GMarkupParser *parser,
|
|
|
|
gpointer *data)
|
|
|
|
{
|
|
|
|
if (parent_buildable_iface->custom_tag_start (buildable, builder, child,
|
|
|
|
tagname, parser, data))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return _gtk_cell_layout_buildable_custom_tag_start (buildable, builder, child,
|
|
|
|
tagname, parser, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_box_buildable_custom_tag_end (GtkBuildable *buildable,
|
|
|
|
GtkBuilder *builder,
|
|
|
|
GObject *child,
|
|
|
|
const gchar *tagname,
|
|
|
|
gpointer *data)
|
|
|
|
{
|
|
|
|
if (strcmp (tagname, "attributes") == 0)
|
|
|
|
_gtk_cell_layout_buildable_custom_tag_end (buildable, builder, child, tagname,
|
|
|
|
data);
|
|
|
|
else
|
|
|
|
parent_buildable_iface->custom_tag_end (buildable, builder, child, tagname,
|
|
|
|
data);
|
|
|
|
}
|