2003-07-11 12:51:24 +00:00
|
|
|
|
/* gtkentrycompletion.c
|
|
|
|
|
* Copyright (C) 2003 Kristian Rietveld <kris@gtk.org>
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Library General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2003-07-11 12:51:24 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2011-01-04 22:54:47 +00:00
|
|
|
|
/**
|
|
|
|
|
* SECTION:gtkentrycompletion
|
|
|
|
|
* @Short_description: Completion functionality for GtkEntry
|
|
|
|
|
* @Title: GtkEntryCompletion
|
|
|
|
|
*
|
|
|
|
|
* #GtkEntryCompletion is an auxiliary object to be used in conjunction with
|
|
|
|
|
* #GtkEntry to provide the completion functionality. It implements the
|
|
|
|
|
* #GtkCellLayout interface, to allow the user to add extra cells to the
|
|
|
|
|
* #GtkTreeView with completion matches.
|
|
|
|
|
*
|
2014-02-05 18:07:34 +00:00
|
|
|
|
* “Completion functionality” means that when the user modifies the text
|
2011-01-04 22:54:47 +00:00
|
|
|
|
* in the entry, #GtkEntryCompletion checks which rows in the model match
|
|
|
|
|
* the current content of the entry, and displays a list of matches.
|
|
|
|
|
* By default, the matching is done by comparing the entry text
|
|
|
|
|
* case-insensitively against the text column of the model (see
|
|
|
|
|
* gtk_entry_completion_set_text_column()), but this can be overridden
|
|
|
|
|
* with a custom match function (see gtk_entry_completion_set_match_func()).
|
|
|
|
|
*
|
|
|
|
|
* When the user selects a completion, the content of the entry is
|
|
|
|
|
* updated. By default, the content of the entry is replaced by the
|
|
|
|
|
* text column of the model, but this can be overridden by connecting
|
|
|
|
|
* to the #GtkEntryCompletion::match-selected signal and updating the
|
|
|
|
|
* entry in the signal handler. Note that you should return %TRUE from
|
|
|
|
|
* the signal handler to suppress the default behaviour.
|
|
|
|
|
*
|
|
|
|
|
* To add completion functionality to an entry, use gtk_entry_set_completion().
|
|
|
|
|
*
|
2011-01-31 23:49:20 +00:00
|
|
|
|
* GtkEntryCompletion uses a #GtkTreeModelFilter model to represent the
|
|
|
|
|
* subset of the entire model that is currently matching. While the
|
|
|
|
|
* GtkEntryCompletion signals #GtkEntryCompletion::match-selected and
|
|
|
|
|
* #GtkEntryCompletion::cursor-on-match take the original model and an
|
|
|
|
|
* iter pointing to that model as arguments, other callbacks and signals
|
|
|
|
|
* (such as #GtkCellLayoutDataFuncs or #GtkCellArea::apply-attributes)
|
|
|
|
|
* will generally take the filter model as argument. As long as you are
|
|
|
|
|
* only calling gtk_tree_model_get(), this will make no difference to
|
|
|
|
|
* you. If for some reason, you need the original model, use
|
2014-02-07 18:32:47 +00:00
|
|
|
|
* gtk_tree_model_filter_get_model(). Don’t forget to use
|
2011-01-31 23:49:20 +00:00
|
|
|
|
* gtk_tree_model_filter_convert_iter_to_child_iter() to obtain a
|
|
|
|
|
* matching iter.
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
|
#include "config.h"
|
2010-09-14 01:33:06 +00:00
|
|
|
|
|
2003-10-23 18:25:53 +00:00
|
|
|
|
#include "gtkentrycompletion.h"
|
2010-09-14 01:33:06 +00:00
|
|
|
|
|
2003-10-23 18:25:53 +00:00
|
|
|
|
#include "gtkentryprivate.h"
|
2019-02-18 04:03:27 +00:00
|
|
|
|
#include "gtktextprivate.h"
|
2003-10-23 18:25:53 +00:00
|
|
|
|
#include "gtkcelllayout.h"
|
2010-12-04 07:55:49 +00:00
|
|
|
|
#include "gtkcellareabox.h"
|
2003-10-23 18:25:53 +00:00
|
|
|
|
|
|
|
|
|
#include "gtkintl.h"
|
|
|
|
|
#include "gtkcellrenderertext.h"
|
|
|
|
|
#include "gtktreeselection.h"
|
|
|
|
|
#include "gtktreeview.h"
|
|
|
|
|
#include "gtkscrolledwindow.h"
|
2010-09-14 01:33:06 +00:00
|
|
|
|
#include "gtksizerequest.h"
|
2011-08-28 05:40:10 +00:00
|
|
|
|
#include "gtkbox.h"
|
2019-04-20 04:32:29 +00:00
|
|
|
|
#include "gtkpopover.h"
|
2003-10-23 18:25:53 +00:00
|
|
|
|
#include "gtkentry.h"
|
2011-10-23 11:57:07 +00:00
|
|
|
|
#include "gtkmain.h"
|
2003-10-23 18:25:53 +00:00
|
|
|
|
#include "gtkmarshalers.h"
|
2020-02-20 01:51:03 +00:00
|
|
|
|
#include "gtkeventcontrollerfocus.h"
|
2018-06-08 11:18:34 +00:00
|
|
|
|
#include "gtkeventcontrollerkey.h"
|
2019-05-29 17:10:46 +00:00
|
|
|
|
#include "gtkgestureclick.h"
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
2005-03-22 02:14:55 +00:00
|
|
|
|
#include "gtkprivate.h"
|
2014-08-21 15:36:45 +00:00
|
|
|
|
#include "gtkwindowprivate.h"
|
2017-06-28 06:19:35 +00:00
|
|
|
|
#include "gtkwidgetprivate.h"
|
2019-05-20 00:38:08 +00:00
|
|
|
|
#include "gtknative.h"
|
2005-03-22 02:14:55 +00:00
|
|
|
|
|
2003-07-11 12:51:24 +00:00
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2012-08-31 14:47:23 +00:00
|
|
|
|
#define PAGE_STEP 14
|
2015-12-05 19:12:27 +00:00
|
|
|
|
#define COMPLETION_TIMEOUT 100
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
|
|
|
|
/* signals */
|
|
|
|
|
enum
|
|
|
|
|
{
|
2004-07-19 18:15:48 +00:00
|
|
|
|
INSERT_PREFIX,
|
2003-07-11 12:51:24 +00:00
|
|
|
|
MATCH_SELECTED,
|
2007-04-27 16:50:04 +00:00
|
|
|
|
CURSOR_ON_MATCH,
|
2014-06-27 16:41:09 +00:00
|
|
|
|
NO_MATCHES,
|
2003-07-11 12:51:24 +00:00
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_MODEL,
|
2004-05-27 04:46:42 +00:00
|
|
|
|
PROP_MINIMUM_KEY_LENGTH,
|
2004-07-19 18:15:48 +00:00
|
|
|
|
PROP_TEXT_COLUMN,
|
|
|
|
|
PROP_INLINE_COMPLETION,
|
2005-04-04 05:15:32 +00:00
|
|
|
|
PROP_POPUP_COMPLETION,
|
2005-05-26 20:36:36 +00:00
|
|
|
|
PROP_POPUP_SET_WIDTH,
|
2007-04-27 16:50:04 +00:00
|
|
|
|
PROP_POPUP_SINGLE_MATCH,
|
2010-12-04 07:55:49 +00:00
|
|
|
|
PROP_INLINE_SELECTION,
|
2015-09-06 02:35:22 +00:00
|
|
|
|
PROP_CELL_AREA,
|
|
|
|
|
NUM_PROPERTIES
|
2003-07-11 12:51:24 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2010-12-04 07:55:49 +00:00
|
|
|
|
static void gtk_entry_completion_cell_layout_init (GtkCellLayoutIface *iface);
|
|
|
|
|
static GtkCellArea* gtk_entry_completion_get_area (GtkCellLayout *cell_layout);
|
|
|
|
|
|
2014-06-26 22:22:42 +00:00
|
|
|
|
static void gtk_entry_completion_constructed (GObject *object);
|
2007-04-28 07:47:08 +00:00
|
|
|
|
static void gtk_entry_completion_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
static void gtk_entry_completion_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
2010-12-04 07:55:49 +00:00
|
|
|
|
static void gtk_entry_completion_finalize (GObject *object);
|
|
|
|
|
static void gtk_entry_completion_dispose (GObject *object);
|
2007-04-28 07:47:08 +00:00
|
|
|
|
|
|
|
|
|
static gboolean gtk_entry_completion_visible_func (GtkTreeModel *model,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data);
|
2018-01-10 23:51:01 +00:00
|
|
|
|
static void gtk_entry_completion_list_activated (GtkTreeView *treeview,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeViewColumn *column,
|
2007-04-28 07:47:08 +00:00
|
|
|
|
gpointer user_data);
|
|
|
|
|
static void gtk_entry_completion_selection_changed (GtkTreeSelection *selection,
|
|
|
|
|
gpointer data);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
2004-05-10 19:10:27 +00:00
|
|
|
|
static gboolean gtk_entry_completion_match_selected (GtkEntryCompletion *completion,
|
2011-01-04 22:54:47 +00:00
|
|
|
|
GtkTreeModel *model,
|
|
|
|
|
GtkTreeIter *iter);
|
2004-07-19 18:15:48 +00:00
|
|
|
|
static gboolean gtk_entry_completion_real_insert_prefix (GtkEntryCompletion *completion,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *prefix);
|
2007-04-27 16:50:04 +00:00
|
|
|
|
static gboolean gtk_entry_completion_cursor_on_match (GtkEntryCompletion *completion,
|
2011-01-04 22:54:47 +00:00
|
|
|
|
GtkTreeModel *model,
|
|
|
|
|
GtkTreeIter *iter);
|
2007-04-28 07:47:08 +00:00
|
|
|
|
static gboolean gtk_entry_completion_insert_completion (GtkEntryCompletion *completion,
|
|
|
|
|
GtkTreeModel *model,
|
|
|
|
|
GtkTreeIter *iter);
|
|
|
|
|
static void gtk_entry_completion_insert_completion_text (GtkEntryCompletion *completion,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *text);
|
2012-08-31 14:47:23 +00:00
|
|
|
|
static void connect_completion_signals (GtkEntryCompletion *completion);
|
|
|
|
|
static void disconnect_completion_signals (GtkEntryCompletion *completion);
|
|
|
|
|
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
2015-09-06 02:35:22 +00:00
|
|
|
|
static GParamSpec *entry_completion_props[NUM_PROPERTIES] = { NULL, };
|
|
|
|
|
|
2003-07-11 12:51:24 +00:00
|
|
|
|
static guint entry_completion_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
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 */
|
|
|
|
|
static void gtk_entry_completion_buildable_init (GtkBuildableIface *iface);
|
|
|
|
|
|
2006-05-02 23:56:43 +00:00
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkEntryCompletion, gtk_entry_completion, G_TYPE_OBJECT,
|
2011-01-04 22:54:47 +00:00
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_LAYOUT,
|
|
|
|
|
gtk_entry_completion_cell_layout_init)
|
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
|
|
|
|
|
gtk_entry_completion_buildable_init))
|
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
|
|
|
|
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_entry_completion_class_init (GtkEntryCompletionClass *klass)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class;
|
|
|
|
|
|
|
|
|
|
object_class = (GObjectClass *)klass;
|
|
|
|
|
|
2014-06-26 22:22:42 +00:00
|
|
|
|
object_class->constructed = gtk_entry_completion_constructed;
|
2003-07-11 12:51:24 +00:00
|
|
|
|
object_class->set_property = gtk_entry_completion_set_property;
|
|
|
|
|
object_class->get_property = gtk_entry_completion_get_property;
|
2010-12-04 07:55:49 +00:00
|
|
|
|
object_class->dispose = gtk_entry_completion_dispose;
|
2003-07-11 12:51:24 +00:00
|
|
|
|
object_class->finalize = gtk_entry_completion_finalize;
|
|
|
|
|
|
2004-05-10 19:10:27 +00:00
|
|
|
|
klass->match_selected = gtk_entry_completion_match_selected;
|
2004-07-19 18:15:48 +00:00
|
|
|
|
klass->insert_prefix = gtk_entry_completion_real_insert_prefix;
|
2007-04-27 16:50:04 +00:00
|
|
|
|
klass->cursor_on_match = gtk_entry_completion_cursor_on_match;
|
2014-06-27 16:41:09 +00:00
|
|
|
|
klass->no_matches = NULL;
|
2004-07-19 18:15:48 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkEntryCompletion::insert-prefix:
|
|
|
|
|
* @widget: the object which received the signal
|
|
|
|
|
* @prefix: the common prefix of all possible completions
|
2010-05-22 03:50:46 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets emitted when the inline autocompletion is triggered.
|
|
|
|
|
* The default behaviour is to make the entry display the
|
2004-07-19 18:15:48 +00:00
|
|
|
|
* whole prefix and select the newly inserted part.
|
|
|
|
|
*
|
|
|
|
|
* Applications may connect to this signal in order to insert only a
|
|
|
|
|
* smaller part of the @prefix into the entry - e.g. the entry used in
|
2010-05-22 03:50:46 +00:00
|
|
|
|
* the #GtkFileChooser inserts only the part of the prefix up to the
|
2004-07-19 18:15:48 +00:00
|
|
|
|
* next '/'.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE if the signal has been handled
|
2010-05-22 03:50:46 +00:00
|
|
|
|
*/
|
2004-07-19 18:15:48 +00:00
|
|
|
|
entry_completion_signals[INSERT_PREFIX] =
|
2008-08-11 12:54:57 +00:00
|
|
|
|
g_signal_new (I_("insert-prefix"),
|
2004-07-19 18:15:48 +00:00
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (GtkEntryCompletionClass, insert_prefix),
|
|
|
|
|
_gtk_boolean_handled_accumulator, NULL,
|
|
|
|
|
_gtk_marshal_BOOLEAN__STRING,
|
|
|
|
|
G_TYPE_BOOLEAN, 1,
|
|
|
|
|
G_TYPE_STRING);
|
2004-05-10 19:10:27 +00:00
|
|
|
|
|
2004-03-15 01:32:20 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkEntryCompletion::match-selected:
|
|
|
|
|
* @widget: the object which received the signal
|
|
|
|
|
* @model: the #GtkTreeModel containing the matches
|
|
|
|
|
* @iter: a #GtkTreeIter positioned at the selected match
|
2010-05-22 03:50:46 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets emitted when a match from the list is selected.
|
|
|
|
|
* The default behaviour is to replace the contents of the
|
|
|
|
|
* entry with the contents of the text column in the row
|
2004-10-31 18:01:07 +00:00
|
|
|
|
* pointed to by @iter.
|
2004-03-15 01:32:20 +00:00
|
|
|
|
*
|
2011-01-31 23:49:20 +00:00
|
|
|
|
* Note that @model is the model that was passed to
|
|
|
|
|
* gtk_entry_completion_set_model().
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE if the signal has been handled
|
2010-05-22 03:50:46 +00:00
|
|
|
|
*/
|
2003-07-11 12:51:24 +00:00
|
|
|
|
entry_completion_signals[MATCH_SELECTED] =
|
2008-08-11 12:54:57 +00:00
|
|
|
|
g_signal_new (I_("match-selected"),
|
2003-07-11 12:51:24 +00:00
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (GtkEntryCompletionClass, match_selected),
|
|
|
|
|
_gtk_boolean_handled_accumulator, NULL,
|
|
|
|
|
_gtk_marshal_BOOLEAN__OBJECT_BOXED,
|
|
|
|
|
G_TYPE_BOOLEAN, 2,
|
|
|
|
|
GTK_TYPE_TREE_MODEL,
|
|
|
|
|
GTK_TYPE_TREE_ITER);
|
2010-05-22 03:50:46 +00:00
|
|
|
|
|
2007-04-27 16:50:04 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkEntryCompletion::cursor-on-match:
|
|
|
|
|
* @widget: the object which received the signal
|
|
|
|
|
* @model: the #GtkTreeModel containing the matches
|
|
|
|
|
* @iter: a #GtkTreeIter positioned at the selected match
|
2010-05-22 03:50:46 +00:00
|
|
|
|
*
|
2007-04-27 16:50:04 +00:00
|
|
|
|
* Gets emitted when a match from the cursor is on a match
|
2010-05-22 03:50:46 +00:00
|
|
|
|
* of the list. The default behaviour is to replace the contents
|
|
|
|
|
* of the entry with the contents of the text column in the row
|
2007-04-27 16:50:04 +00:00
|
|
|
|
* pointed to by @iter.
|
|
|
|
|
*
|
2011-01-31 23:49:20 +00:00
|
|
|
|
* Note that @model is the model that was passed to
|
|
|
|
|
* gtk_entry_completion_set_model().
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE if the signal has been handled
|
2010-05-22 03:50:46 +00:00
|
|
|
|
*/
|
2007-04-27 16:50:04 +00:00
|
|
|
|
entry_completion_signals[CURSOR_ON_MATCH] =
|
2008-08-11 12:54:57 +00:00
|
|
|
|
g_signal_new (I_("cursor-on-match"),
|
2011-01-04 22:54:47 +00:00
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (GtkEntryCompletionClass, cursor_on_match),
|
|
|
|
|
_gtk_boolean_handled_accumulator, NULL,
|
|
|
|
|
_gtk_marshal_BOOLEAN__OBJECT_BOXED,
|
|
|
|
|
G_TYPE_BOOLEAN, 2,
|
|
|
|
|
GTK_TYPE_TREE_MODEL,
|
|
|
|
|
GTK_TYPE_TREE_ITER);
|
2010-05-22 03:50:46 +00:00
|
|
|
|
|
2014-06-27 16:41:09 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkEntryCompletion::no-matches:
|
|
|
|
|
* @widget: the object which received the signal
|
|
|
|
|
*
|
|
|
|
|
* Gets emitted when the filter model has zero
|
|
|
|
|
* number of rows in completion_complete method.
|
|
|
|
|
* (In other words when GtkEntryCompletion is out of
|
|
|
|
|
* suggestions)
|
|
|
|
|
*/
|
|
|
|
|
entry_completion_signals[NO_MATCHES] =
|
|
|
|
|
g_signal_new (I_("no-matches"),
|
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (GtkEntryCompletionClass, no_matches),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
2015-09-06 02:35:22 +00:00
|
|
|
|
entry_completion_props[PROP_MODEL] =
|
|
|
|
|
g_param_spec_object ("model",
|
|
|
|
|
P_("Completion Model"),
|
|
|
|
|
P_("The model to find matches in"),
|
|
|
|
|
GTK_TYPE_TREE_MODEL,
|
|
|
|
|
GTK_PARAM_READWRITE);
|
|
|
|
|
|
|
|
|
|
entry_completion_props[PROP_MINIMUM_KEY_LENGTH] =
|
|
|
|
|
g_param_spec_int ("minimum-key-length",
|
|
|
|
|
P_("Minimum Key Length"),
|
|
|
|
|
P_("Minimum length of the search key in order to look up matches"),
|
|
|
|
|
0, G_MAXINT, 1,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
|
|
|
|
|
2004-05-27 04:46:42 +00:00
|
|
|
|
/**
|
2004-07-19 18:15:48 +00:00
|
|
|
|
* GtkEntryCompletion:text-column:
|
2004-05-27 04:46:42 +00:00
|
|
|
|
*
|
|
|
|
|
* The column of the model containing the strings.
|
2007-10-17 03:09:12 +00:00
|
|
|
|
* Note that the strings must be UTF-8.
|
2004-05-27 04:46:42 +00:00
|
|
|
|
*/
|
2015-09-06 02:35:22 +00:00
|
|
|
|
entry_completion_props[PROP_TEXT_COLUMN] =
|
|
|
|
|
g_param_spec_int ("text-column",
|
|
|
|
|
P_("Text column"),
|
|
|
|
|
P_("The column of the model containing the strings."),
|
|
|
|
|
-1, G_MAXINT, -1,
|
|
|
|
|
GTK_PARAM_READWRITE);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
2004-07-19 18:15:48 +00:00
|
|
|
|
/**
|
2004-10-31 18:01:07 +00:00
|
|
|
|
* GtkEntryCompletion:inline-completion:
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*
|
|
|
|
|
* Determines whether the common prefix of the possible completions
|
2005-03-15 15:00:11 +00:00
|
|
|
|
* should be inserted automatically in the entry. Note that this
|
|
|
|
|
* requires text-column to be set, even if you are using a custom
|
|
|
|
|
* match function.
|
2004-07-19 18:15:48 +00:00
|
|
|
|
**/
|
2015-09-06 02:35:22 +00:00
|
|
|
|
entry_completion_props[PROP_INLINE_COMPLETION] =
|
|
|
|
|
g_param_spec_boolean ("inline-completion",
|
|
|
|
|
P_("Inline completion"),
|
|
|
|
|
P_("Whether the common prefix should be inserted automatically"),
|
|
|
|
|
FALSE,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
2014-06-08 15:34:28 +00:00
|
|
|
|
|
2004-07-19 18:15:48 +00:00
|
|
|
|
/**
|
2004-10-31 18:01:07 +00:00
|
|
|
|
* GtkEntryCompletion:popup-completion:
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*
|
|
|
|
|
* Determines whether the possible completions should be
|
|
|
|
|
* shown in a popup window.
|
2004-07-19 18:15:48 +00:00
|
|
|
|
**/
|
2015-09-06 02:35:22 +00:00
|
|
|
|
entry_completion_props[PROP_POPUP_COMPLETION] =
|
|
|
|
|
g_param_spec_boolean ("popup-completion",
|
|
|
|
|
P_("Popup completion"),
|
|
|
|
|
P_("Whether the completions should be shown in a popup window"),
|
|
|
|
|
TRUE,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
2004-07-19 18:15:48 +00:00
|
|
|
|
|
2005-04-04 05:15:32 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkEntryCompletion:popup-set-width:
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*
|
2005-04-04 05:15:32 +00:00
|
|
|
|
* Determines whether the completions popup window will be
|
|
|
|
|
* resized to the width of the entry.
|
|
|
|
|
*/
|
2015-09-06 02:35:22 +00:00
|
|
|
|
entry_completion_props[PROP_POPUP_SET_WIDTH] =
|
|
|
|
|
g_param_spec_boolean ("popup-set-width",
|
|
|
|
|
P_("Popup set width"),
|
|
|
|
|
P_("If TRUE, the popup window will have the same size as the entry"),
|
|
|
|
|
TRUE,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
2005-04-04 05:15:32 +00:00
|
|
|
|
|
2005-05-26 20:36:36 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkEntryCompletion:popup-single-match:
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*
|
2005-05-26 20:36:36 +00:00
|
|
|
|
* Determines whether the completions popup window will shown
|
|
|
|
|
* for a single possible completion. You probably want to set
|
2011-01-04 22:54:47 +00:00
|
|
|
|
* this to %FALSE if you are using
|
2014-02-07 02:07:03 +00:00
|
|
|
|
* [inline completion][GtkEntryCompletion--inline-completion].
|
2005-05-26 20:36:36 +00:00
|
|
|
|
*/
|
2015-09-06 02:35:22 +00:00
|
|
|
|
entry_completion_props[PROP_POPUP_SINGLE_MATCH] =
|
|
|
|
|
g_param_spec_boolean ("popup-single-match",
|
|
|
|
|
P_("Popup single match"),
|
|
|
|
|
P_("If TRUE, the popup window will appear for a single match."),
|
|
|
|
|
TRUE,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
|
|
|
|
|
2007-04-27 16:50:04 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkEntryCompletion:inline-selection:
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*
|
2007-04-27 16:50:04 +00:00
|
|
|
|
* Determines whether the possible completions on the popup
|
|
|
|
|
* will appear in the entry as you navigate through them.
|
|
|
|
|
*/
|
2015-09-06 02:35:22 +00:00
|
|
|
|
entry_completion_props[PROP_INLINE_SELECTION] =
|
|
|
|
|
g_param_spec_boolean ("inline-selection",
|
|
|
|
|
P_("Inline selection"),
|
|
|
|
|
P_("Your description here"),
|
|
|
|
|
FALSE,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
2010-12-04 07:55:49 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkEntryCompletion:cell-area:
|
|
|
|
|
*
|
|
|
|
|
* The #GtkCellArea used to layout cell renderers in the treeview column.
|
|
|
|
|
*
|
2015-09-06 02:35:22 +00:00
|
|
|
|
* If no area is specified when creating the entry completion with
|
|
|
|
|
* gtk_entry_completion_new_with_area() a horizontally oriented
|
|
|
|
|
* #GtkCellAreaBox will be used.
|
2010-12-04 07:55:49 +00:00
|
|
|
|
*/
|
2015-09-06 02:35:22 +00:00
|
|
|
|
entry_completion_props[PROP_CELL_AREA] =
|
|
|
|
|
g_param_spec_object ("cell-area",
|
|
|
|
|
P_("Cell Area"),
|
|
|
|
|
P_("The GtkCellArea used to layout cells"),
|
|
|
|
|
GTK_TYPE_CELL_AREA,
|
|
|
|
|
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
|
|
|
|
|
|
|
|
|
g_object_class_install_properties (object_class, NUM_PROPERTIES, entry_completion_props);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-04 07:55:49 +00:00
|
|
|
|
|
|
|
|
|
static void
|
2010-12-04 08:10:31 +00:00
|
|
|
|
gtk_entry_completion_buildable_custom_tag_end (GtkBuildable *buildable,
|
2011-01-04 22:54:47 +00:00
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *tagname,
|
2018-10-07 22:34:43 +00:00
|
|
|
|
gpointer data)
|
2010-12-04 07:55:49 +00:00
|
|
|
|
{
|
|
|
|
|
/* Just ignore the boolean return from here */
|
|
|
|
|
_gtk_cell_layout_buildable_custom_tag_end (buildable, builder, child, tagname, data);
|
|
|
|
|
}
|
|
|
|
|
|
Add GtkBuilder, fixes #172535
2007-06-15 Johan Dahlin <jdahlin@async.com.br>
* demos/gtk-demo/Makefile.am:
* demos/gtk-demo/builder.c: (quit_activate), (about_activate),
(do_builder):
* demos/gtk-demo/demo.ui:
* docs/reference/gtk/gtk-docs.sgml:
* docs/reference/gtk/gtk-sections.txt:
* docs/reference/gtk/gtk.types:
* docs/reference/gtk/tmpl/gtkbuildable.sgml:
* docs/reference/gtk/tmpl/gtkbuilder.sgml:
* gtk/Makefile.am:
* gtk/gtk.h:
* gtk/gtk.symbols:
* gtk/gtkaction.c: (gtk_action_buildable_init),
(gtk_action_buildable_set_name), (gtk_action_buildable_get_name):
* gtk/gtkactiongroup.c: (gtk_action_group_get_type),
(gtk_action_group_buildable_init),
(gtk_action_group_buildable_add),
(gtk_action_group_buildable_set_name),
(gtk_action_group_buildable_get_name):
* gtk/gtkbuildable.c: (gtk_buildable_get_type),
(gtk_buildable_set_name), (gtk_buildable_get_name),
(gtk_buildable_add), (gtk_buildable_set_property),
(gtk_buildable_parser_finished), (gtk_buildable_construct_child),
(gtk_buildable_custom_tag_start), (gtk_buildable_custom_tag_end),
(gtk_buildable_custom_finished),
(gtk_buildable_get_internal_child):
* gtk/gtkbuildable.h:
* gtk/gtkbuilder.c: (gtk_builder_class_init), (gtk_builder_init),
(gtk_builder_finalize), (gtk_builder_set_property),
(gtk_builder_get_property), (_gtk_builder_resolve_type_lazily),
(gtk_builder_real_get_type_from_name),
(gtk_builder_get_parameters), (gtk_builder_get_internal_child),
(_gtk_builder_construct), (_gtk_builder_add),
(apply_delayed_properties), (_gtk_builder_finish),
(gtk_builder_new), (gtk_builder_add_from_file),
(gtk_builder_add_from_string), (gtk_builder_get_object),
(object_add_to_list), (gtk_builder_get_objects),
(gtk_builder_set_translation_domain),
(gtk_builder_get_translation_domain),
(gtk_builder_connect_signals_default),
(gtk_builder_connect_signals), (gtk_builder_connect_signals_full),
(gtk_builder_value_from_string),
(gtk_builder_value_from_string_type),
(_gtk_builder_enum_from_string), (_gtk_builder_flags_from_string),
(gtk_builder_get_type_from_name), (gtk_builder_error_quark):
* gtk/gtkbuilder.h:
* gtk/gtkbuilderparser.c: (state_push), (state_peek), (state_pop),
(error_missing_attribute), (error_invalid_attribute),
(error_invalid_tag), (builder_construct), (parse_object),
(free_object_info), (_get_type_by_symbol), (parse_child),
(free_child_info), (parse_property), (free_property_info),
(parse_signal), (_free_signal_info), (parse_interface),
(create_subparser), (free_subparser), (subparser_start),
(subparser_end), (parse_custom), (start_element), (end_element),
(text), (_gtk_builder_parser_parse_buffer):
* gtk/gtkbuilderprivate.h:
* gtk/gtkcelllayout.c: (attributes_start_element),
(attributes_text_element),
(_gtk_cell_layout_buildable_custom_tag_start),
(_gtk_cell_layout_buildable_custom_tag_end),
(_gtk_cell_layout_buildable_add):
* gtk/gtkcelllayout.h:
* gtk/gtkcellview.c: (gtk_cell_view_buildable_init),
(gtk_cell_view_buildable_custom_tag_start),
(gtk_cell_view_buildable_custom_tag_end):
* gtk/gtkcolorseldialog.c:
(gtk_color_selection_dialog_buildable_interface_init),
(gtk_color_selection_dialog_buildable_get_internal_child):
* gtk/gtkcombobox.c: (gtk_combo_box_buildable_init),
(gtk_combo_box_buildable_custom_tag_start),
(gtk_combo_box_buildable_custom_tag_end):
* gtk/gtkcomboboxentry.c:
(gtk_combo_box_entry_buildable_interface_init),
(gtk_combo_box_entry_buildable_get_internal_child):
* gtk/gtkcontainer.c: (gtk_container_get_type),
(gtk_container_buildable_init), (gtk_container_buildable_add),
(gtk_container_buildable_set_child_property),
(attributes_start_element), (attributes_text_element),
(gtk_container_buildable_custom_tag_start),
(gtk_container_buildable_custom_tag_end):
* gtk/gtkdebug.h:
* gtk/gtkdialog.c: (gtk_dialog_buildable_interface_init),
(gtk_dialog_buildable_get_internal_child),
(attributes_start_element), (attributes_text_element),
(gtk_dialog_buildable_custom_tag_start),
(gtk_dialog_buildable_custom_finished):
* gtk/gtkentrycompletion.c: (gtk_entry_completion_buildable_init):
* gtk/gtkexpander.c: (gtk_expander_buildable_add),
(gtk_expander_buildable_init):
* gtk/gtkfontsel.c:
(gtk_font_selection_dialog_buildable_interface_init),
(gtk_font_selection_dialog_buildable_get_internal_child):
* gtk/gtkframe.c: (gtk_frame_buildable_init),
(gtk_frame_buildable_add):
* gtk/gtkiconview.c: (gtk_icon_view_buildable_init),
(gtk_icon_view_buildable_custom_tag_start),
(gtk_icon_view_buildable_custom_tag_end):
* gtk/gtkliststore.c: (gtk_list_store_buildable_init),
(list_store_start_element), (list_store_end_element),
(list_store_text), (gtk_list_store_buildable_custom_tag_start),
(gtk_list_store_buildable_custom_tag_end):
* gtk/gtkmain.c:
* gtk/gtknotebook.c: (gtk_notebook_buildable_init),
(gtk_notebook_buildable_add):
* gtk/gtksizegroup.c: (gtk_size_group_buildable_init),
(size_group_start_element),
(gtk_size_group_buildable_custom_tag_start),
(gtk_size_group_buildable_custom_finished):
* gtk/gtktreestore.c: (gtk_tree_store_buildable_init),
(tree_model_start_element),
(gtk_tree_store_buildable_custom_tag_start),
(gtk_tree_store_buildable_custom_finished):
* gtk/gtktreeview.c: (gtk_tree_view_buildable_init),
(gtk_tree_view_buildable_add):
* gtk/gtktreeviewcolumn.c: (gtk_tree_view_column_buildable_init):
* gtk/gtkuimanager.c: (gtk_ui_manager_buildable_init),
(gtk_ui_manager_buildable_add),
(gtk_ui_manager_buildable_construct_child),
(gtk_ui_manager_buildable_custom_tag_start),
(gtk_ui_manager_buildable_custom_tag_end):
* gtk/gtkwidget.c: (gtk_widget_get_type),
(gtk_widget_buildable_interface_init),
(gtk_widget_buildable_set_name), (gtk_widget_buildable_get_name),
(gtk_widget_buildable_set_property),
(gtk_widget_buildable_parser_finshed), (accel_group_start_element),
(gtk_widget_buildable_custom_tag_start),
(gtk_widget_buildable_custom_finshed):
* gtk/gtkwindow.c: (gtk_window_buildable_interface_init),
(gtk_window_buildable_set_property),
(gtk_window_buildable_parser_finished):
* tests/Makefile.am:
* tests/buildertest.c: (builder_new_from_string), (test_parser),
(signal_normal), (signal_after), (signal_object),
(signal_object_after), (signal_first), (signal_second),
(signal_extra), (signal_extra2), (test_connect_signals),
(test_uimanager_simple), (test_domain), (test_translation),
(test_sizegroup), (test_list_store), (test_tree_store),
(test_types), (test_spin_button), (test_notebook),
(test_construct_only_property), (test_children),
(test_child_properties), (test_treeview_column), (test_icon_view),
(test_combo_box), (test_combo_box_entry), (test_cell_view),
(test_dialog), (test_accelerators), (test_widget), (main):
Add GtkBuilder, fixes #172535
svn path=/trunk/; revision=18141
2007-06-15 17:53:46 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_entry_completion_buildable_init (GtkBuildableIface *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_cell_layout_buildable_custom_tag_start;
|
2010-12-04 08:10:31 +00:00
|
|
|
|
iface->custom_tag_end = gtk_entry_completion_buildable_custom_tag_end;
|
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
|
|
|
|
}
|
|
|
|
|
|
2003-07-11 12:51:24 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_entry_completion_cell_layout_init (GtkCellLayoutIface *iface)
|
|
|
|
|
{
|
2010-12-04 07:55:49 +00:00
|
|
|
|
iface->get_area = gtk_entry_completion_get_area;
|
2003-07-11 12:51:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_entry_completion_init (GtkEntryCompletion *completion)
|
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->minimum_key_length = 1;
|
|
|
|
|
completion->text_column = -1;
|
|
|
|
|
completion->has_completion = FALSE;
|
|
|
|
|
completion->inline_completion = FALSE;
|
|
|
|
|
completion->popup_completion = TRUE;
|
|
|
|
|
completion->popup_set_width = TRUE;
|
|
|
|
|
completion->popup_single_match = TRUE;
|
|
|
|
|
completion->inline_selection = FALSE;
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->filter_model = NULL;
|
2010-12-04 07:55:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-08 11:18:34 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
propagate_to_entry (GtkEventControllerKey *key,
|
|
|
|
|
guint keyval,
|
|
|
|
|
guint keycode,
|
|
|
|
|
GdkModifierType modifiers,
|
|
|
|
|
GtkEntryCompletion *completion)
|
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (completion->entry));
|
2018-06-08 11:18:34 +00:00
|
|
|
|
|
2019-02-18 04:03:27 +00:00
|
|
|
|
return gtk_event_controller_key_forward (key, GTK_WIDGET (text));
|
2018-06-08 11:18:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-26 22:22:42 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_entry_completion_constructed (GObject *object)
|
2010-12-04 07:55:49 +00:00
|
|
|
|
{
|
2014-06-26 22:22:42 +00:00
|
|
|
|
GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (object);
|
2010-12-04 07:55:49 +00:00
|
|
|
|
GtkTreeSelection *sel;
|
2018-06-08 11:18:34 +00:00
|
|
|
|
GtkEventController *controller;
|
2010-12-04 07:55:49 +00:00
|
|
|
|
|
2014-06-26 22:22:42 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_entry_completion_parent_class)->constructed (object);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (!completion->cell_area)
|
2010-12-04 07:55:49 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->cell_area = gtk_cell_area_box_new ();
|
|
|
|
|
g_object_ref_sink (completion->cell_area);
|
2010-12-04 07:55:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* completions */
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->tree_view = gtk_tree_view_new ();
|
|
|
|
|
g_signal_connect (completion->tree_view, "row-activated",
|
2018-01-10 23:51:01 +00:00
|
|
|
|
G_CALLBACK (gtk_entry_completion_list_activated),
|
2003-07-11 12:51:24 +00:00
|
|
|
|
completion);
|
2007-04-27 16:50:04 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_tree_view_set_enable_search (GTK_TREE_VIEW (completion->tree_view), FALSE);
|
|
|
|
|
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (completion->tree_view), FALSE);
|
|
|
|
|
gtk_tree_view_set_hover_selection (GTK_TREE_VIEW (completion->tree_view), TRUE);
|
|
|
|
|
gtk_tree_view_set_activate_on_single_click (GTK_TREE_VIEW (completion->tree_view), TRUE);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->tree_view));
|
2003-07-11 12:51:24 +00:00
|
|
|
|
gtk_tree_selection_set_mode (sel, GTK_SELECTION_SINGLE);
|
|
|
|
|
gtk_tree_selection_unselect_all (sel);
|
2003-10-11 13:32:16 +00:00
|
|
|
|
g_signal_connect (sel, "changed",
|
|
|
|
|
G_CALLBACK (gtk_entry_completion_selection_changed),
|
|
|
|
|
completion);
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->first_sel_changed = TRUE;
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->column = gtk_tree_view_column_new_with_area (completion->cell_area);
|
|
|
|
|
gtk_tree_view_append_column (GTK_TREE_VIEW (completion->tree_view), completion->column);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
2020-06-24 15:25:09 +00:00
|
|
|
|
completion->scrolled_window = gtk_scrolled_window_new ();
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (completion->scrolled_window),
|
2003-07-11 12:51:24 +00:00
|
|
|
|
GTK_POLICY_NEVER,
|
|
|
|
|
GTK_POLICY_AUTOMATIC);
|
|
|
|
|
|
2003-11-19 21:26:27 +00:00
|
|
|
|
/* a nasty hack to get the completions treeview to size nicely */
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_widget_set_size_request (gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (completion->scrolled_window)),
|
2010-07-09 19:53:55 +00:00
|
|
|
|
-1, 0);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
|
|
|
|
/* pack it all */
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->popup_window = gtk_popover_new ();
|
|
|
|
|
gtk_popover_set_position (GTK_POPOVER (completion->popup_window), GTK_POS_BOTTOM);
|
|
|
|
|
gtk_popover_set_autohide (GTK_POPOVER (completion->popup_window), FALSE);
|
|
|
|
|
gtk_popover_set_has_arrow (GTK_POPOVER (completion->popup_window), FALSE);
|
|
|
|
|
gtk_widget_add_css_class (completion->popup_window, "entry-completion");
|
2014-08-21 15:36:45 +00:00
|
|
|
|
|
2018-06-08 11:18:34 +00:00
|
|
|
|
controller = gtk_event_controller_key_new ();
|
|
|
|
|
g_signal_connect (controller, "key-pressed",
|
|
|
|
|
G_CALLBACK (propagate_to_entry), completion);
|
|
|
|
|
g_signal_connect (controller, "key-released",
|
|
|
|
|
G_CALLBACK (propagate_to_entry), completion);
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_widget_add_controller (completion->popup_window, controller);
|
2018-06-08 11:18:34 +00:00
|
|
|
|
|
2019-05-29 17:10:46 +00:00
|
|
|
|
controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ());
|
2018-06-08 11:18:34 +00:00
|
|
|
|
g_signal_connect_swapped (controller, "released",
|
|
|
|
|
G_CALLBACK (_gtk_entry_completion_popdown),
|
|
|
|
|
completion);
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_widget_add_controller (completion->popup_window, controller);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (completion->scrolled_window),
|
|
|
|
|
completion->tree_view);
|
|
|
|
|
gtk_widget_set_hexpand (completion->scrolled_window, TRUE);
|
|
|
|
|
gtk_widget_set_vexpand (completion->scrolled_window, TRUE);
|
2020-08-22 00:18:31 +00:00
|
|
|
|
gtk_popover_set_child (GTK_POPOVER (completion->popup_window), completion->scrolled_window);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-04 07:55:49 +00:00
|
|
|
|
|
2003-07-11 12:51:24 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_entry_completion_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (object);
|
2010-12-04 07:55:49 +00:00
|
|
|
|
GtkCellArea *area;
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_MODEL:
|
|
|
|
|
gtk_entry_completion_set_model (completion,
|
|
|
|
|
g_value_get_object (value));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_MINIMUM_KEY_LENGTH:
|
|
|
|
|
gtk_entry_completion_set_minimum_key_length (completion,
|
|
|
|
|
g_value_get_int (value));
|
|
|
|
|
break;
|
|
|
|
|
|
2004-05-27 04:46:42 +00:00
|
|
|
|
case PROP_TEXT_COLUMN:
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->text_column = g_value_get_int (value);
|
2004-05-27 04:46:42 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2004-07-19 18:15:48 +00:00
|
|
|
|
case PROP_INLINE_COMPLETION:
|
2012-03-23 06:09:02 +00:00
|
|
|
|
gtk_entry_completion_set_inline_completion (completion,
|
|
|
|
|
g_value_get_boolean (value));
|
2004-07-19 18:15:48 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_POPUP_COMPLETION:
|
2012-03-23 06:09:02 +00:00
|
|
|
|
gtk_entry_completion_set_popup_completion (completion,
|
|
|
|
|
g_value_get_boolean (value));
|
2004-07-19 18:15:48 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2005-04-04 05:15:32 +00:00
|
|
|
|
case PROP_POPUP_SET_WIDTH:
|
2012-03-23 06:09:02 +00:00
|
|
|
|
gtk_entry_completion_set_popup_set_width (completion,
|
|
|
|
|
g_value_get_boolean (value));
|
2005-04-04 05:15:32 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2005-05-26 20:36:36 +00:00
|
|
|
|
case PROP_POPUP_SINGLE_MATCH:
|
2012-03-23 06:09:02 +00:00
|
|
|
|
gtk_entry_completion_set_popup_single_match (completion,
|
|
|
|
|
g_value_get_boolean (value));
|
2005-05-26 20:36:36 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2007-04-27 16:50:04 +00:00
|
|
|
|
case PROP_INLINE_SELECTION:
|
2012-03-23 06:09:02 +00:00
|
|
|
|
gtk_entry_completion_set_inline_selection (completion,
|
|
|
|
|
g_value_get_boolean (value));
|
2007-04-27 16:50:04 +00:00
|
|
|
|
break;
|
2010-12-04 07:55:49 +00:00
|
|
|
|
|
|
|
|
|
case PROP_CELL_AREA:
|
2011-01-04 22:54:47 +00:00
|
|
|
|
/* Construct-only, can only be assigned once */
|
|
|
|
|
area = g_value_get_object (value);
|
|
|
|
|
if (area)
|
2011-01-31 22:34:37 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->cell_area != NULL)
|
2011-01-31 22:34:37 +00:00
|
|
|
|
{
|
|
|
|
|
g_warning ("cell-area has already been set, ignoring construct property");
|
|
|
|
|
g_object_ref_sink (area);
|
|
|
|
|
g_object_unref (area);
|
|
|
|
|
}
|
|
|
|
|
else
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->cell_area = g_object_ref_sink (area);
|
2011-01-31 22:34:37 +00:00
|
|
|
|
}
|
2011-01-04 22:54:47 +00:00
|
|
|
|
break;
|
2010-12-04 07:55:49 +00:00
|
|
|
|
|
2003-07-11 12:51:24 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_entry_completion_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (object);
|
|
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_MODEL:
|
|
|
|
|
g_value_set_object (value,
|
|
|
|
|
gtk_entry_completion_get_model (completion));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_MINIMUM_KEY_LENGTH:
|
|
|
|
|
g_value_set_int (value, gtk_entry_completion_get_minimum_key_length (completion));
|
|
|
|
|
break;
|
|
|
|
|
|
2004-05-27 04:46:42 +00:00
|
|
|
|
case PROP_TEXT_COLUMN:
|
|
|
|
|
g_value_set_int (value, gtk_entry_completion_get_text_column (completion));
|
|
|
|
|
break;
|
|
|
|
|
|
2004-07-19 18:15:48 +00:00
|
|
|
|
case PROP_INLINE_COMPLETION:
|
|
|
|
|
g_value_set_boolean (value, gtk_entry_completion_get_inline_completion (completion));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_POPUP_COMPLETION:
|
|
|
|
|
g_value_set_boolean (value, gtk_entry_completion_get_popup_completion (completion));
|
|
|
|
|
break;
|
|
|
|
|
|
2005-04-04 05:15:32 +00:00
|
|
|
|
case PROP_POPUP_SET_WIDTH:
|
|
|
|
|
g_value_set_boolean (value, gtk_entry_completion_get_popup_set_width (completion));
|
|
|
|
|
break;
|
|
|
|
|
|
2005-05-26 20:36:36 +00:00
|
|
|
|
case PROP_POPUP_SINGLE_MATCH:
|
|
|
|
|
g_value_set_boolean (value, gtk_entry_completion_get_popup_single_match (completion));
|
|
|
|
|
break;
|
|
|
|
|
|
2007-04-27 16:50:04 +00:00
|
|
|
|
case PROP_INLINE_SELECTION:
|
|
|
|
|
g_value_set_boolean (value, gtk_entry_completion_get_inline_selection (completion));
|
|
|
|
|
break;
|
|
|
|
|
|
2010-12-04 07:55:49 +00:00
|
|
|
|
case PROP_CELL_AREA:
|
2020-06-21 19:28:56 +00:00
|
|
|
|
g_value_set_object (value, completion->cell_area);
|
2011-01-04 22:54:47 +00:00
|
|
|
|
break;
|
2010-12-04 07:55:49 +00:00
|
|
|
|
|
2003-07-11 12:51:24 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_entry_completion_finalize (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (object);
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
g_free (completion->case_normalized_key);
|
|
|
|
|
g_free (completion->completion_prefix);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->match_notify)
|
|
|
|
|
(* completion->match_notify) (completion->match_data);
|
2006-06-16 17:42:40 +00:00
|
|
|
|
|
2006-05-02 23:56:43 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_entry_completion_parent_class)->finalize (object);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-12-04 07:55:49 +00:00
|
|
|
|
gtk_entry_completion_dispose (GObject *object)
|
2003-07-11 12:51:24 +00:00
|
|
|
|
{
|
2010-12-04 07:55:49 +00:00
|
|
|
|
GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (object);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->entry)
|
|
|
|
|
gtk_entry_set_completion (GTK_ENTRY (completion->entry), NULL);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
g_clear_object (&completion->cell_area);
|
2003-12-19 22:47:20 +00:00
|
|
|
|
|
2010-12-04 07:55:49 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_entry_completion_parent_class)->dispose (object);
|
2003-12-19 22:47:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-03 10:50:54 +00:00
|
|
|
|
/* implement cell layout interface (only need to return the underlying cell area) */
|
2011-01-04 22:54:47 +00:00
|
|
|
|
static GtkCellArea*
|
2010-12-04 07:55:49 +00:00
|
|
|
|
gtk_entry_completion_get_area (GtkCellLayout *cell_layout)
|
2008-03-22 17:53:42 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (cell_layout);
|
2008-03-22 17:53:42 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (G_UNLIKELY (!completion->cell_area))
|
2011-01-31 22:34:37 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->cell_area = gtk_cell_area_box_new ();
|
|
|
|
|
g_object_ref_sink (completion->cell_area);
|
2011-01-31 22:34:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
return completion->cell_area;
|
2008-03-22 17:53:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-07-11 12:51:24 +00:00
|
|
|
|
/* all those callbacks */
|
|
|
|
|
static gboolean
|
|
|
|
|
gtk_entry_completion_default_completion_func (GtkEntryCompletion *completion,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *key,
|
2003-07-11 12:51:24 +00:00
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *item = NULL;
|
|
|
|
|
char *normalized_string;
|
|
|
|
|
char *case_normalized_string;
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
|
|
|
|
gboolean ret = FALSE;
|
|
|
|
|
|
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
model = gtk_tree_model_filter_get_model (completion->filter_model);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
g_return_val_if_fail (gtk_tree_model_get_column_type (model, completion->text_column) == G_TYPE_STRING,
|
2011-01-04 22:54:47 +00:00
|
|
|
|
FALSE);
|
2004-08-22 04:11:14 +00:00
|
|
|
|
|
2003-07-11 12:51:24 +00:00
|
|
|
|
gtk_tree_model_get (model, iter,
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->text_column, &item,
|
2003-07-11 12:51:24 +00:00
|
|
|
|
-1);
|
|
|
|
|
|
2004-02-22 01:07:39 +00:00
|
|
|
|
if (item != NULL)
|
|
|
|
|
{
|
|
|
|
|
normalized_string = g_utf8_normalize (item, -1, G_NORMALIZE_ALL);
|
2010-07-19 18:45:25 +00:00
|
|
|
|
|
|
|
|
|
if (normalized_string != NULL)
|
|
|
|
|
{
|
|
|
|
|
case_normalized_string = g_utf8_casefold (normalized_string, -1);
|
|
|
|
|
|
|
|
|
|
if (!strncmp (key, case_normalized_string, strlen (key)))
|
2011-01-04 22:54:47 +00:00
|
|
|
|
ret = TRUE;
|
2010-07-19 18:45:25 +00:00
|
|
|
|
|
|
|
|
|
g_free (case_normalized_string);
|
|
|
|
|
}
|
2004-02-22 01:07:39 +00:00
|
|
|
|
g_free (normalized_string);
|
|
|
|
|
}
|
2010-07-19 18:45:25 +00:00
|
|
|
|
g_free (item);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gtk_entry_completion_visible_func (GtkTreeModel *model,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
gboolean ret = FALSE;
|
|
|
|
|
|
|
|
|
|
GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (data);
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (!completion->case_normalized_key)
|
2003-07-11 12:51:24 +00:00
|
|
|
|
return ret;
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->match_func)
|
|
|
|
|
ret = (* completion->match_func) (completion,
|
|
|
|
|
completion->case_normalized_key,
|
2003-07-11 12:51:24 +00:00
|
|
|
|
iter,
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->match_data);
|
|
|
|
|
else if (completion->text_column >= 0)
|
2004-03-14 20:44:10 +00:00
|
|
|
|
ret = gtk_entry_completion_default_completion_func (completion,
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->case_normalized_key,
|
2004-03-14 20:44:10 +00:00
|
|
|
|
iter,
|
|
|
|
|
NULL);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-10 23:51:01 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_entry_completion_list_activated (GtkTreeView *treeview,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeViewColumn *column,
|
|
|
|
|
gpointer user_data)
|
2003-07-11 12:51:24 +00:00
|
|
|
|
{
|
|
|
|
|
GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (user_data);
|
2018-01-10 23:51:01 +00:00
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
gboolean entry_set;
|
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
GtkTreeIter child_iter;
|
2020-06-21 19:28:56 +00:00
|
|
|
|
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (completion->entry));
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_tree_model_get_iter (GTK_TREE_MODEL (completion->filter_model), &iter, path);
|
|
|
|
|
gtk_tree_model_filter_convert_iter_to_child_iter (completion->filter_model,
|
2018-01-10 23:51:01 +00:00
|
|
|
|
&child_iter,
|
|
|
|
|
&iter);
|
2020-06-21 19:28:56 +00:00
|
|
|
|
model = gtk_tree_model_filter_get_model (completion->filter_model);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
g_signal_handler_block (text, completion->changed_id);
|
2018-01-10 23:51:01 +00:00
|
|
|
|
g_signal_emit (completion, entry_completion_signals[MATCH_SELECTED],
|
|
|
|
|
0, model, &child_iter, &entry_set);
|
2020-06-21 19:28:56 +00:00
|
|
|
|
g_signal_handler_unblock (text, completion->changed_id);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
2018-01-10 23:51:01 +00:00
|
|
|
|
_gtk_entry_completion_popdown (completion);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-10-11 13:32:16 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_entry_completion_selection_changed (GtkTreeSelection *selection,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (data);
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->first_sel_changed)
|
2003-10-11 13:32:16 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->first_sel_changed = FALSE;
|
|
|
|
|
if (gtk_widget_is_focus (completion->tree_view))
|
2003-11-18 23:12:10 +00:00
|
|
|
|
gtk_tree_selection_unselect_all (selection);
|
2003-10-11 13:32:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-11 12:51:24 +00:00
|
|
|
|
/* public API */
|
2003-09-30 21:44:39 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_entry_completion_new:
|
|
|
|
|
*
|
|
|
|
|
* Creates a new #GtkEntryCompletion object.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: A newly created #GtkEntryCompletion object
|
2003-09-30 21:44:39 +00:00
|
|
|
|
*/
|
2003-07-11 12:51:24 +00:00
|
|
|
|
GtkEntryCompletion *
|
|
|
|
|
gtk_entry_completion_new (void)
|
|
|
|
|
{
|
|
|
|
|
GtkEntryCompletion *completion;
|
|
|
|
|
|
|
|
|
|
completion = g_object_new (GTK_TYPE_ENTRY_COMPLETION, NULL);
|
|
|
|
|
|
|
|
|
|
return completion;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-13 06:58:07 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_entry_completion_new_with_area:
|
|
|
|
|
* @area: the #GtkCellArea used to layout cells
|
|
|
|
|
*
|
|
|
|
|
* Creates a new #GtkEntryCompletion object using the
|
2011-01-04 22:54:47 +00:00
|
|
|
|
* specified @area to layout cells in the underlying
|
2010-12-13 06:58:07 +00:00
|
|
|
|
* #GtkTreeViewColumn for the drop-down menu.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: A newly created #GtkEntryCompletion object
|
2010-12-13 06:58:07 +00:00
|
|
|
|
*/
|
|
|
|
|
GtkEntryCompletion *
|
|
|
|
|
gtk_entry_completion_new_with_area (GtkCellArea *area)
|
|
|
|
|
{
|
|
|
|
|
GtkEntryCompletion *completion;
|
|
|
|
|
|
|
|
|
|
completion = g_object_new (GTK_TYPE_ENTRY_COMPLETION, "cell-area", area, NULL);
|
|
|
|
|
|
|
|
|
|
return completion;
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-30 21:44:39 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_entry_completion_get_entry:
|
2011-01-04 22:54:47 +00:00
|
|
|
|
* @completion: a #GtkEntryCompletion
|
2003-09-30 21:44:39 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets the entry @completion has been attached to.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: (transfer none): The entry @completion has been attached to
|
2003-09-30 21:44:39 +00:00
|
|
|
|
*/
|
2003-07-11 12:51:24 +00:00
|
|
|
|
GtkWidget *
|
|
|
|
|
gtk_entry_completion_get_entry (GtkEntryCompletion *completion)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_ENTRY_COMPLETION (completion), NULL);
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
return completion->entry;
|
2003-07-11 12:51:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-30 21:44:39 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_entry_completion_set_model:
|
2011-01-04 22:54:47 +00:00
|
|
|
|
* @completion: a #GtkEntryCompletion
|
|
|
|
|
* @model: (allow-none): the #GtkTreeModel
|
2003-09-30 21:44:39 +00:00
|
|
|
|
*
|
|
|
|
|
* Sets the model for a #GtkEntryCompletion. If @completion already has
|
|
|
|
|
* a model set, it will remove it before setting the new model.
|
2004-06-26 04:05:25 +00:00
|
|
|
|
* If model is %NULL, then it will unset the model.
|
2003-09-30 21:44:39 +00:00
|
|
|
|
*/
|
2003-07-11 12:51:24 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_entry_completion_set_model (GtkEntryCompletion *completion,
|
|
|
|
|
GtkTreeModel *model)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion));
|
2004-06-26 03:39:35 +00:00
|
|
|
|
g_return_if_fail (model == NULL || GTK_IS_TREE_MODEL (model));
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
2004-10-26 15:53:32 +00:00
|
|
|
|
if (!model)
|
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_tree_view_set_model (GTK_TREE_VIEW (completion->tree_view),
|
2011-01-04 22:54:47 +00:00
|
|
|
|
NULL);
|
2004-10-26 15:53:32 +00:00
|
|
|
|
_gtk_entry_completion_popdown (completion);
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->filter_model = NULL;
|
2004-10-26 15:53:32 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2011-01-04 22:54:47 +00:00
|
|
|
|
|
2003-07-11 12:51:24 +00:00
|
|
|
|
/* code will unref the old filter model (if any) */
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->filter_model =
|
2003-07-11 12:51:24 +00:00
|
|
|
|
GTK_TREE_MODEL_FILTER (gtk_tree_model_filter_new (model, NULL));
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_tree_model_filter_set_visible_func (completion->filter_model,
|
2003-07-11 12:51:24 +00:00
|
|
|
|
gtk_entry_completion_visible_func,
|
|
|
|
|
completion,
|
|
|
|
|
NULL);
|
2004-09-13 17:34:54 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_tree_view_set_model (GTK_TREE_VIEW (completion->tree_view),
|
|
|
|
|
GTK_TREE_MODEL (completion->filter_model));
|
|
|
|
|
g_object_unref (completion->filter_model);
|
2004-09-13 17:34:54 +00:00
|
|
|
|
|
2015-09-06 02:35:22 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (completion), entry_completion_props[PROP_MODEL]);
|
2005-01-26 06:46:51 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (gtk_widget_get_visible (completion->popup_window))
|
2004-09-13 17:34:54 +00:00
|
|
|
|
_gtk_entry_completion_resize_popup (completion);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-30 21:44:39 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_entry_completion_get_model:
|
2011-01-04 22:54:47 +00:00
|
|
|
|
* @completion: a #GtkEntryCompletion
|
2003-09-30 21:44:39 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns the model the #GtkEntryCompletion is using as data source.
|
|
|
|
|
* Returns %NULL if the model is unset.
|
|
|
|
|
*
|
2015-12-28 20:14:08 +00:00
|
|
|
|
* Returns: (nullable) (transfer none): A #GtkTreeModel, or %NULL if none
|
2011-01-04 22:54:47 +00:00
|
|
|
|
* is currently being used
|
2003-09-30 21:44:39 +00:00
|
|
|
|
*/
|
2003-07-11 12:51:24 +00:00
|
|
|
|
GtkTreeModel *
|
|
|
|
|
gtk_entry_completion_get_model (GtkEntryCompletion *completion)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_ENTRY_COMPLETION (completion), NULL);
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (!completion->filter_model)
|
2004-10-26 15:53:32 +00:00
|
|
|
|
return NULL;
|
2010-09-21 04:18:11 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
return gtk_tree_model_filter_get_model (completion->filter_model);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-30 21:44:39 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_entry_completion_set_match_func:
|
2011-01-04 22:54:47 +00:00
|
|
|
|
* @completion: a #GtkEntryCompletion
|
|
|
|
|
* @func: the #GtkEntryCompletionMatchFunc to use
|
|
|
|
|
* @func_data: user data for @func
|
|
|
|
|
* @func_notify: destroy notify for @func_data.
|
2003-09-30 21:44:39 +00:00
|
|
|
|
*
|
|
|
|
|
* Sets the match function for @completion to be @func. The match function
|
|
|
|
|
* is used to determine if a row should or should not be in the completion
|
|
|
|
|
* list.
|
|
|
|
|
*/
|
2003-07-11 12:51:24 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_entry_completion_set_match_func (GtkEntryCompletion *completion,
|
|
|
|
|
GtkEntryCompletionMatchFunc func,
|
|
|
|
|
gpointer func_data,
|
|
|
|
|
GDestroyNotify func_notify)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion));
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->match_notify)
|
|
|
|
|
(* completion->match_notify) (completion->match_data);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->match_func = func;
|
|
|
|
|
completion->match_data = func_data;
|
|
|
|
|
completion->match_notify = func_notify;
|
2003-07-11 12:51:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-30 21:44:39 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_entry_completion_set_minimum_key_length:
|
2011-01-04 22:54:47 +00:00
|
|
|
|
* @completion: a #GtkEntryCompletion
|
|
|
|
|
* @length: the minimum length of the key in order to start completing
|
2003-09-30 21:44:39 +00:00
|
|
|
|
*
|
|
|
|
|
* Requires the length of the search key for @completion to be at least
|
|
|
|
|
* @length. This is useful for long lists, where completing using a small
|
|
|
|
|
* key takes a lot of time and will come up with meaningless results anyway
|
|
|
|
|
* (ie, a too large dataset).
|
|
|
|
|
*/
|
2003-07-11 12:51:24 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_entry_completion_set_minimum_key_length (GtkEntryCompletion *completion,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int length)
|
2003-07-11 12:51:24 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion));
|
2005-01-26 06:46:51 +00:00
|
|
|
|
g_return_if_fail (length >= 0);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->minimum_key_length != length)
|
2005-01-26 06:46:51 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->minimum_key_length = length;
|
2011-01-04 22:54:47 +00:00
|
|
|
|
|
2015-09-06 02:35:22 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (completion),
|
|
|
|
|
entry_completion_props[PROP_MINIMUM_KEY_LENGTH]);
|
2005-01-26 06:46:51 +00:00
|
|
|
|
}
|
2003-07-11 12:51:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-30 21:44:39 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_entry_completion_get_minimum_key_length:
|
2011-01-04 22:54:47 +00:00
|
|
|
|
* @completion: a #GtkEntryCompletion
|
2003-09-30 21:44:39 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns the minimum key length as set for @completion.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: The currently used minimum key length
|
2003-09-30 21:44:39 +00:00
|
|
|
|
*/
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int
|
2003-07-11 12:51:24 +00:00
|
|
|
|
gtk_entry_completion_get_minimum_key_length (GtkEntryCompletion *completion)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_ENTRY_COMPLETION (completion), 0);
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
return completion->minimum_key_length;
|
2003-07-11 12:51:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-30 21:44:39 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_entry_completion_complete:
|
2011-01-04 22:54:47 +00:00
|
|
|
|
* @completion: a #GtkEntryCompletion
|
2003-09-30 21:44:39 +00:00
|
|
|
|
*
|
|
|
|
|
* Requests a completion operation, or in other words a refiltering of the
|
|
|
|
|
* current list with completions, using the current key. The completion list
|
|
|
|
|
* view will be updated accordingly.
|
|
|
|
|
*/
|
2003-07-11 12:51:24 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_entry_completion_complete (GtkEntryCompletion *completion)
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *tmp;
|
2014-06-27 16:41:09 +00:00
|
|
|
|
GtkTreeIter iter;
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion));
|
2020-06-21 19:28:56 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_ENTRY (completion->entry));
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (!completion->filter_model)
|
2004-10-26 15:53:32 +00:00
|
|
|
|
return;
|
2011-01-04 22:54:47 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
g_free (completion->case_normalized_key);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
tmp = g_utf8_normalize (gtk_editable_get_text (GTK_EDITABLE (completion->entry)),
|
2003-07-11 12:51:24 +00:00
|
|
|
|
-1, G_NORMALIZE_ALL);
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->case_normalized_key = g_utf8_casefold (tmp, -1);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
g_free (tmp);
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_tree_model_filter_refilter (completion->filter_model);
|
2005-06-17 18:26:25 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (completion->filter_model), &iter))
|
2014-06-27 16:41:09 +00:00
|
|
|
|
g_signal_emit (completion, entry_completion_signals[NO_MATCHES], 0);
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (gtk_widget_get_visible (completion->popup_window))
|
2005-06-17 18:26:25 +00:00
|
|
|
|
_gtk_entry_completion_resize_popup (completion);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-30 21:44:39 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_entry_completion_set_text_column:
|
2011-01-04 22:54:47 +00:00
|
|
|
|
* @completion: a #GtkEntryCompletion
|
|
|
|
|
* @column: the column in the model of @completion to get strings from
|
2003-09-30 21:44:39 +00:00
|
|
|
|
*
|
2004-03-03 22:55:46 +00:00
|
|
|
|
* Convenience function for setting up the most used case of this code: a
|
2003-09-30 21:44:39 +00:00
|
|
|
|
* completion list with just strings. This function will set up @completion
|
|
|
|
|
* to have a list displaying all (and just) strings in the completion list,
|
|
|
|
|
* and to get those strings from @column in the model of @completion.
|
|
|
|
|
*
|
2014-03-03 10:50:54 +00:00
|
|
|
|
* This functions creates and adds a #GtkCellRendererText for the selected
|
|
|
|
|
* column. If you need to set the text column, but don't want the cell
|
|
|
|
|
* renderer, use g_object_set() to set the #GtkEntryCompletion:text-column
|
|
|
|
|
* property directly.
|
2003-09-30 21:44:39 +00:00
|
|
|
|
*/
|
2003-07-11 12:51:24 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_entry_completion_set_text_column (GtkEntryCompletion *completion,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int column)
|
2003-07-11 12:51:24 +00:00
|
|
|
|
{
|
|
|
|
|
GtkCellRenderer *cell;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion));
|
|
|
|
|
g_return_if_fail (column >= 0);
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->text_column == column)
|
2014-06-08 15:34:28 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->text_column = column;
|
2013-11-02 13:22:33 +00:00
|
|
|
|
|
2014-03-03 10:50:54 +00:00
|
|
|
|
cell = gtk_cell_renderer_text_new ();
|
|
|
|
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion),
|
|
|
|
|
cell, TRUE);
|
|
|
|
|
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion),
|
|
|
|
|
cell,
|
|
|
|
|
"text", column);
|
2004-05-27 04:46:42 +00:00
|
|
|
|
|
2015-09-06 02:35:22 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (completion), entry_completion_props[PROP_TEXT_COLUMN]);
|
2004-05-27 04:46:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_entry_completion_get_text_column:
|
|
|
|
|
* @completion: a #GtkEntryCompletion
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*
|
2004-05-27 04:46:42 +00:00
|
|
|
|
* Returns the column in the model of @completion to get strings from.
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the column containing the strings
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*/
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int
|
2004-05-27 04:46:42 +00:00
|
|
|
|
gtk_entry_completion_get_text_column (GtkEntryCompletion *completion)
|
|
|
|
|
{
|
2004-07-12 14:38:10 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_ENTRY_COMPLETION (completion), -1);
|
2004-05-27 04:46:42 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
return completion->text_column;
|
2003-07-11 12:51:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* private */
|
|
|
|
|
|
2003-11-17 22:02:21 +00:00
|
|
|
|
/* some nasty size requisition */
|
2015-07-03 18:48:48 +00:00
|
|
|
|
void
|
2003-11-17 22:02:21 +00:00
|
|
|
|
_gtk_entry_completion_resize_popup (GtkEntryCompletion *completion)
|
2003-07-11 12:51:24 +00:00
|
|
|
|
{
|
2010-08-11 21:13:23 +00:00
|
|
|
|
GtkAllocation allocation;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int matches, items, height;
|
2018-03-21 10:49:14 +00:00
|
|
|
|
GdkSurface *surface;
|
2004-07-30 06:22:26 +00:00
|
|
|
|
GtkRequisition entry_req;
|
2014-12-03 08:24:43 +00:00
|
|
|
|
GtkRequisition tree_req;
|
2004-04-12 19:40:22 +00:00
|
|
|
|
GtkTreePath *path;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int width;
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
surface = gtk_native_get_surface (gtk_widget_get_native (completion->entry));
|
2010-08-11 21:13:23 +00:00
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
|
if (!surface)
|
2015-07-03 18:48:48 +00:00
|
|
|
|
return;
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (!completion->filter_model)
|
2015-07-03 18:48:48 +00:00
|
|
|
|
return;
|
2012-08-31 14:47:23 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_widget_get_surface_allocation (completion->entry, &allocation);
|
|
|
|
|
gtk_widget_get_preferred_size (completion->entry,
|
2010-10-21 11:09:25 +00:00
|
|
|
|
&entry_req, NULL);
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
matches = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (completion->filter_model), NULL);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
2014-12-03 08:24:43 +00:00
|
|
|
|
/* Call get preferred size on the on the tree view to force it to validate its
|
|
|
|
|
* cells before calling into the cell size functions.
|
|
|
|
|
*/
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_widget_get_preferred_size (completion->tree_view,
|
2014-12-03 08:24:43 +00:00
|
|
|
|
&tree_req, NULL);
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_tree_view_column_cell_get_size (completion->column,
|
2003-07-11 12:51:24 +00:00
|
|
|
|
NULL, NULL, NULL, &height);
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_widget_realize (completion->tree_view);
|
2005-07-13 11:57:10 +00:00
|
|
|
|
|
2019-05-29 03:07:02 +00:00
|
|
|
|
items = MIN (matches, 10);
|
2008-06-12 11:17:16 +00:00
|
|
|
|
|
|
|
|
|
if (items <= 0)
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_widget_hide (completion->scrolled_window);
|
2008-06-12 11:17:16 +00:00
|
|
|
|
else
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_widget_show (completion->scrolled_window);
|
2008-06-12 11:17:16 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->popup_set_width)
|
2019-05-29 03:07:02 +00:00
|
|
|
|
width = allocation.width;
|
2005-04-04 05:15:32 +00:00
|
|
|
|
else
|
|
|
|
|
width = -1;
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (completion->tree_view));
|
|
|
|
|
gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW (completion->scrolled_window), width);
|
|
|
|
|
gtk_widget_set_size_request (completion->popup_window, width, -1);
|
|
|
|
|
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (completion->scrolled_window), items * height);
|
2003-07-11 12:51:24 +00:00
|
|
|
|
|
2011-01-04 22:54:47 +00:00
|
|
|
|
if (matches > 0)
|
2004-04-21 21:47:53 +00:00
|
|
|
|
{
|
2019-05-29 03:07:02 +00:00
|
|
|
|
path = gtk_tree_path_new_from_indices (0, -1);
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (completion->tree_view), path,
|
2011-01-04 22:54:47 +00:00
|
|
|
|
NULL, FALSE, 0.0, 0.0);
|
2004-04-21 21:47:53 +00:00
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
}
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_native_check_resize (GTK_NATIVE (completion->popup_window));
|
2015-11-26 18:55:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-10-02 17:23:29 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_entry_completion_popup (GtkEntryCompletion *completion)
|
2003-11-17 22:02:21 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (completion->entry));
|
2003-11-17 22:02:21 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (gtk_widget_get_mapped (completion->popup_window))
|
2003-11-17 22:02:21 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2019-02-18 04:03:27 +00:00
|
|
|
|
if (!gtk_widget_get_mapped (GTK_WIDGET (text)))
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2019-02-18 04:03:27 +00:00
|
|
|
|
if (!gtk_widget_has_focus (GTK_WIDGET (text)))
|
2005-11-07 17:28:37 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2009-06-06 00:11:44 +00:00
|
|
|
|
/* default on no match */
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->current_selected = -1;
|
2009-06-06 00:11:44 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_widget_realize (completion->popup_window);
|
2006-01-09 19:22:33 +00:00
|
|
|
|
|
2018-03-14 03:54:02 +00:00
|
|
|
|
_gtk_entry_completion_resize_popup (completion);
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_popover_popup (GTK_POPOVER (completion->popup_window));
|
2003-07-11 12:51:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_gtk_entry_completion_popdown (GtkEntryCompletion *completion)
|
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (!gtk_widget_get_mapped (completion->popup_window))
|
2004-08-02 06:09:24 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_popover_popdown (GTK_POPOVER (completion->popup_window));
|
2003-07-11 12:51:24 +00:00
|
|
|
|
}
|
2004-05-10 19:10:27 +00:00
|
|
|
|
|
2011-01-04 22:54:47 +00:00
|
|
|
|
static gboolean
|
2004-05-10 19:10:27 +00:00
|
|
|
|
gtk_entry_completion_match_selected (GtkEntryCompletion *completion,
|
2011-01-04 22:54:47 +00:00
|
|
|
|
GtkTreeModel *model,
|
|
|
|
|
GtkTreeIter *iter)
|
2004-05-10 19:10:27 +00:00
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *str = NULL;
|
2004-05-10 19:10:27 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_tree_model_get (model, iter, completion->text_column, &str, -1);
|
|
|
|
|
gtk_editable_set_text (GTK_EDITABLE (completion->entry), str ? str : "");
|
2011-01-04 22:54:47 +00:00
|
|
|
|
|
2004-05-10 19:10:27 +00:00
|
|
|
|
/* move cursor to the end */
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_editable_set_position (GTK_EDITABLE (completion->entry), -1);
|
2011-01-04 22:54:47 +00:00
|
|
|
|
|
2004-05-10 19:10:27 +00:00
|
|
|
|
g_free (str);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2004-07-19 18:15:48 +00:00
|
|
|
|
|
2007-04-27 16:50:04 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_entry_completion_cursor_on_match (GtkEntryCompletion *completion,
|
2011-01-04 22:54:47 +00:00
|
|
|
|
GtkTreeModel *model,
|
|
|
|
|
GtkTreeIter *iter)
|
2007-04-27 16:50:04 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_entry_completion_insert_completion (completion, model, iter);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2004-07-19 18:15:48 +00:00
|
|
|
|
|
2011-11-05 19:38:28 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_entry_completion_compute_prefix:
|
|
|
|
|
* @completion: the entry completion
|
|
|
|
|
* @key: The text to complete for
|
|
|
|
|
*
|
|
|
|
|
* Computes the common prefix that is shared by all rows in @completion
|
|
|
|
|
* that start with @key. If no row matches @key, %NULL will be returned.
|
|
|
|
|
* Note that a text column must have been set for this function to work,
|
|
|
|
|
* see gtk_entry_completion_set_text_column() for details.
|
|
|
|
|
*
|
2015-12-28 20:14:08 +00:00
|
|
|
|
* Returns: (nullable) (transfer full): The common prefix all rows starting with
|
|
|
|
|
* @key or %NULL if no row matches @key.
|
2011-11-05 19:38:28 +00:00
|
|
|
|
**/
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *
|
2011-11-05 19:38:28 +00:00
|
|
|
|
gtk_entry_completion_compute_prefix (GtkEntryCompletion *completion,
|
|
|
|
|
const char *key)
|
2004-07-19 18:15:48 +00:00
|
|
|
|
{
|
|
|
|
|
GtkTreeIter iter;
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *prefix = NULL;
|
2004-07-19 18:15:48 +00:00
|
|
|
|
gboolean valid;
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->text_column < 0)
|
2005-03-15 15:00:11 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (completion->filter_model),
|
2011-01-04 22:54:47 +00:00
|
|
|
|
&iter);
|
|
|
|
|
|
2004-07-19 18:15:48 +00:00
|
|
|
|
while (valid)
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *text;
|
2011-01-04 22:54:47 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (completion->filter_model),
|
|
|
|
|
&iter, completion->text_column, &text,
|
2011-01-04 22:54:47 +00:00
|
|
|
|
-1);
|
2004-07-19 18:15:48 +00:00
|
|
|
|
|
2006-06-19 21:20:56 +00:00
|
|
|
|
if (text && g_str_has_prefix (text, key))
|
2011-01-04 22:54:47 +00:00
|
|
|
|
{
|
|
|
|
|
if (!prefix)
|
|
|
|
|
prefix = g_strdup (text);
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *p = prefix;
|
|
|
|
|
char *q = text;
|
2011-01-04 22:54:47 +00:00
|
|
|
|
|
|
|
|
|
while (*p && *p == *q)
|
|
|
|
|
{
|
|
|
|
|
p++;
|
|
|
|
|
q++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*p = '\0';
|
|
|
|
|
|
2007-03-19 04:27:45 +00:00
|
|
|
|
if (p > prefix)
|
|
|
|
|
{
|
|
|
|
|
/* strip a partial multibyte character */
|
|
|
|
|
q = g_utf8_find_prev_char (prefix, p);
|
|
|
|
|
switch (g_utf8_get_char_validated (q, p - q))
|
|
|
|
|
{
|
|
|
|
|
case (gunichar)-2:
|
|
|
|
|
case (gunichar)-1:
|
|
|
|
|
*q = 0;
|
2020-03-06 07:32:21 +00:00
|
|
|
|
break;
|
2007-03-19 04:27:45 +00:00
|
|
|
|
default: ;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-01-04 22:54:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-19 18:15:48 +00:00
|
|
|
|
g_free (text);
|
2020-06-21 19:28:56 +00:00
|
|
|
|
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (completion->filter_model),
|
2011-01-04 22:54:47 +00:00
|
|
|
|
&iter);
|
2004-07-19 18:15:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return prefix;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gtk_entry_completion_real_insert_prefix (GtkEntryCompletion *completion,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *prefix)
|
2004-07-19 18:15:48 +00:00
|
|
|
|
{
|
|
|
|
|
if (prefix)
|
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int key_len;
|
|
|
|
|
int prefix_len;
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *key;
|
2004-07-19 18:15:48 +00:00
|
|
|
|
|
|
|
|
|
prefix_len = g_utf8_strlen (prefix, -1);
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
key = gtk_editable_get_text (GTK_EDITABLE (completion->entry));
|
2004-07-19 18:15:48 +00:00
|
|
|
|
key_len = g_utf8_strlen (key, -1);
|
|
|
|
|
|
|
|
|
|
if (prefix_len > key_len)
|
2011-01-04 22:54:47 +00:00
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int pos = prefix_len;
|
2005-03-17 18:09:24 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_editable_insert_text (GTK_EDITABLE (completion->entry),
|
2011-01-04 22:54:47 +00:00
|
|
|
|
prefix + strlen (key), -1, &pos);
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_editable_select_region (GTK_EDITABLE (completion->entry),
|
2011-01-04 22:54:47 +00:00
|
|
|
|
key_len, prefix_len);
|
2004-07-19 18:15:48 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->has_completion = TRUE;
|
2011-01-04 22:54:47 +00:00
|
|
|
|
}
|
2004-07-19 18:15:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-28 07:47:08 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_entry_completion_get_completion_prefix:
|
|
|
|
|
* @completion: a #GtkEntryCompletion
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*
|
2007-04-28 07:47:08 +00:00
|
|
|
|
* Get the original text entered by the user that triggered
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* the completion or %NULL if there’s no completion ongoing.
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*
|
2020-10-17 13:17:56 +00:00
|
|
|
|
* Returns: (nullable): the prefix for the current completion
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*/
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *
|
2007-04-28 07:47:08 +00:00
|
|
|
|
gtk_entry_completion_get_completion_prefix (GtkEntryCompletion *completion)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_ENTRY_COMPLETION (completion), NULL);
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
return completion->completion_prefix;
|
2007-04-28 07:47:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2007-04-27 16:50:04 +00:00
|
|
|
|
gtk_entry_completion_insert_completion_text (GtkEntryCompletion *completion,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *new_text)
|
2007-04-27 16:50:04 +00:00
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int len;
|
2020-06-21 19:28:56 +00:00
|
|
|
|
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (completion->entry));
|
2020-06-24 04:26:27 +00:00
|
|
|
|
GtkEntryBuffer *buffer = gtk_text_get_buffer (text);
|
2007-04-28 07:47:08 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->changed_id > 0)
|
|
|
|
|
g_signal_handler_block (text, completion->changed_id);
|
2007-04-27 16:50:04 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->insert_text_id > 0)
|
2020-06-24 04:26:27 +00:00
|
|
|
|
g_signal_handler_block (buffer, completion->insert_text_id);
|
2007-04-27 16:50:04 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_editable_set_text (GTK_EDITABLE (completion->entry), new_text);
|
2007-07-16 16:43:54 +00:00
|
|
|
|
|
2020-06-24 04:26:27 +00:00
|
|
|
|
len = g_utf8_strlen (completion->completion_prefix, -1);
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_editable_select_region (GTK_EDITABLE (completion->entry), len, -1);
|
2007-04-27 16:50:04 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->changed_id > 0)
|
|
|
|
|
g_signal_handler_unblock (text, completion->changed_id);
|
2007-04-27 16:50:04 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->insert_text_id > 0)
|
2020-06-24 04:26:27 +00:00
|
|
|
|
g_signal_handler_unblock (buffer, completion->insert_text_id);
|
2007-04-27 16:50:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-04-28 07:47:08 +00:00
|
|
|
|
static gboolean
|
2007-04-27 16:50:04 +00:00
|
|
|
|
gtk_entry_completion_insert_completion (GtkEntryCompletion *completion,
|
2011-01-04 22:54:47 +00:00
|
|
|
|
GtkTreeModel *model,
|
|
|
|
|
GtkTreeIter *iter)
|
2007-04-27 16:50:04 +00:00
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *str = NULL;
|
2007-04-27 16:50:04 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->text_column < 0)
|
2007-04-27 16:50:04 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, iter,
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->text_column, &str,
|
2011-01-04 22:54:47 +00:00
|
|
|
|
-1);
|
2007-04-27 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
gtk_entry_completion_insert_completion_text (completion, str);
|
|
|
|
|
|
|
|
|
|
g_free (str);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-19 18:15:48 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_entry_completion_insert_prefix:
|
|
|
|
|
* @completion: a #GtkEntryCompletion
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*
|
|
|
|
|
* Requests a prefix insertion.
|
|
|
|
|
*/
|
2004-07-19 18:15:48 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_entry_completion_insert_prefix (GtkEntryCompletion *completion)
|
|
|
|
|
{
|
|
|
|
|
gboolean done;
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *prefix;
|
2020-06-21 19:28:56 +00:00
|
|
|
|
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (completion->entry));
|
2020-06-24 04:26:27 +00:00
|
|
|
|
GtkEntryBuffer *buffer = gtk_text_get_buffer (text);
|
2004-07-19 18:15:48 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->insert_text_id > 0)
|
2020-06-24 04:26:27 +00:00
|
|
|
|
g_signal_handler_block (buffer, completion->insert_text_id);
|
2007-01-26 11:39:16 +00:00
|
|
|
|
|
2011-11-05 19:38:28 +00:00
|
|
|
|
prefix = gtk_entry_completion_compute_prefix (completion,
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_editable_get_text (GTK_EDITABLE (completion->entry)));
|
2011-11-05 19:38:28 +00:00
|
|
|
|
|
2004-07-19 18:15:48 +00:00
|
|
|
|
if (prefix)
|
|
|
|
|
{
|
|
|
|
|
g_signal_emit (completion, entry_completion_signals[INSERT_PREFIX],
|
2011-01-04 22:54:47 +00:00
|
|
|
|
0, prefix, &done);
|
2004-07-19 18:15:48 +00:00
|
|
|
|
g_free (prefix);
|
|
|
|
|
}
|
2007-01-26 11:39:16 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->insert_text_id > 0)
|
2020-06-24 04:26:27 +00:00
|
|
|
|
g_signal_handler_unblock (buffer, completion->insert_text_id);
|
2004-07-19 18:15:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_entry_completion_set_inline_completion:
|
|
|
|
|
* @completion: a #GtkEntryCompletion
|
|
|
|
|
* @inline_completion: %TRUE to do inline completion
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*
|
2004-07-19 18:15:48 +00:00
|
|
|
|
* Sets whether the common prefix of the possible completions should
|
|
|
|
|
* be automatically inserted in the entry.
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
2004-07-19 18:15:48 +00:00
|
|
|
|
gtk_entry_completion_set_inline_completion (GtkEntryCompletion *completion,
|
2011-01-04 22:54:47 +00:00
|
|
|
|
gboolean inline_completion)
|
2004-07-19 18:15:48 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion));
|
2011-01-04 22:54:47 +00:00
|
|
|
|
|
2004-07-19 18:15:48 +00:00
|
|
|
|
inline_completion = inline_completion != FALSE;
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->inline_completion != inline_completion)
|
2004-07-19 18:15:48 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->inline_completion = inline_completion;
|
2004-07-19 18:15:48 +00:00
|
|
|
|
|
2015-09-06 02:35:22 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (completion), entry_completion_props[PROP_INLINE_COMPLETION]);
|
2004-07-19 18:15:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_entry_completion_get_inline_completion:
|
|
|
|
|
* @completion: a #GtkEntryCompletion
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*
|
2004-07-19 18:15:48 +00:00
|
|
|
|
* Returns whether the common prefix of the possible completions should
|
|
|
|
|
* be automatically inserted in the entry.
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE if inline completion is turned on
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*/
|
2004-07-19 18:15:48 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gtk_entry_completion_get_inline_completion (GtkEntryCompletion *completion)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_ENTRY_COMPLETION (completion), FALSE);
|
2011-01-04 22:54:47 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
return completion->inline_completion;
|
2004-07-19 18:15:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_entry_completion_set_popup_completion:
|
|
|
|
|
* @completion: a #GtkEntryCompletion
|
2004-07-19 19:33:05 +00:00
|
|
|
|
* @popup_completion: %TRUE to do popup completion
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*
|
2004-07-19 18:15:48 +00:00
|
|
|
|
* Sets whether the completions should be presented in a popup window.
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
2004-07-19 18:15:48 +00:00
|
|
|
|
gtk_entry_completion_set_popup_completion (GtkEntryCompletion *completion,
|
2011-01-04 22:54:47 +00:00
|
|
|
|
gboolean popup_completion)
|
2004-07-19 18:15:48 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion));
|
2011-01-04 22:54:47 +00:00
|
|
|
|
|
2004-07-19 18:15:48 +00:00
|
|
|
|
popup_completion = popup_completion != FALSE;
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->popup_completion != popup_completion)
|
2004-07-19 18:15:48 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->popup_completion = popup_completion;
|
2004-07-19 18:15:48 +00:00
|
|
|
|
|
2015-09-06 02:35:22 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (completion), entry_completion_props[PROP_POPUP_COMPLETION]);
|
2004-07-19 18:15:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_entry_completion_get_popup_completion:
|
|
|
|
|
* @completion: a #GtkEntryCompletion
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*
|
2004-07-19 18:15:48 +00:00
|
|
|
|
* Returns whether the completions should be presented in a popup window.
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE if popup completion is turned on
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*/
|
2004-07-19 18:15:48 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gtk_entry_completion_get_popup_completion (GtkEntryCompletion *completion)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_ENTRY_COMPLETION (completion), TRUE);
|
2011-01-04 22:54:47 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
return completion->popup_completion;
|
2004-07-19 18:15:48 +00:00
|
|
|
|
}
|
2005-03-20 07:01:23 +00:00
|
|
|
|
|
2005-04-04 05:15:32 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_entry_completion_set_popup_set_width:
|
|
|
|
|
* @completion: a #GtkEntryCompletion
|
|
|
|
|
* @popup_set_width: %TRUE to make the width of the popup the same as the entry
|
|
|
|
|
*
|
|
|
|
|
* Sets whether the completion popup window will be resized to be the same
|
|
|
|
|
* width as the entry.
|
|
|
|
|
*/
|
2011-01-04 22:54:47 +00:00
|
|
|
|
void
|
2005-04-04 05:15:32 +00:00
|
|
|
|
gtk_entry_completion_set_popup_set_width (GtkEntryCompletion *completion,
|
2011-01-04 22:54:47 +00:00
|
|
|
|
gboolean popup_set_width)
|
2005-04-04 05:15:32 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion));
|
2011-01-04 22:54:47 +00:00
|
|
|
|
|
2005-04-04 05:15:32 +00:00
|
|
|
|
popup_set_width = popup_set_width != FALSE;
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->popup_set_width != popup_set_width)
|
2005-04-04 05:15:32 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->popup_set_width = popup_set_width;
|
2005-04-04 05:15:32 +00:00
|
|
|
|
|
2015-09-06 02:35:22 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (completion), entry_completion_props[PROP_POPUP_SET_WIDTH]);
|
2005-04-04 05:15:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_entry_completion_get_popup_set_width:
|
|
|
|
|
* @completion: a #GtkEntryCompletion
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns whether the completion popup window will be resized to the
|
2005-04-04 05:15:32 +00:00
|
|
|
|
* width of the entry.
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE if the popup window will be resized to the width of
|
2005-04-04 05:15:32 +00:00
|
|
|
|
* the entry
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*/
|
2005-04-04 05:15:32 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gtk_entry_completion_get_popup_set_width (GtkEntryCompletion *completion)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_ENTRY_COMPLETION (completion), TRUE);
|
2011-01-04 22:54:47 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
return completion->popup_set_width;
|
2005-04-04 05:15:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-05-26 20:36:36 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_entry_completion_set_popup_single_match:
|
|
|
|
|
* @completion: a #GtkEntryCompletion
|
|
|
|
|
* @popup_single_match: %TRUE if the popup should appear even for a single
|
2011-01-04 22:54:47 +00:00
|
|
|
|
* match
|
2005-05-26 20:36:36 +00:00
|
|
|
|
*
|
|
|
|
|
* Sets whether the completion popup window will appear even if there is
|
|
|
|
|
* only a single match. You may want to set this to %FALSE if you
|
2014-02-07 02:07:03 +00:00
|
|
|
|
* are using [inline completion][GtkEntryCompletion--inline-completion].
|
2005-05-26 20:36:36 +00:00
|
|
|
|
*/
|
2011-01-04 22:54:47 +00:00
|
|
|
|
void
|
2005-05-26 20:36:36 +00:00
|
|
|
|
gtk_entry_completion_set_popup_single_match (GtkEntryCompletion *completion,
|
2011-01-04 22:54:47 +00:00
|
|
|
|
gboolean popup_single_match)
|
2005-05-26 20:36:36 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion));
|
2011-01-04 22:54:47 +00:00
|
|
|
|
|
2005-05-26 20:36:36 +00:00
|
|
|
|
popup_single_match = popup_single_match != FALSE;
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->popup_single_match != popup_single_match)
|
2005-05-26 20:36:36 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->popup_single_match = popup_single_match;
|
2005-05-26 20:36:36 +00:00
|
|
|
|
|
2015-09-06 02:35:22 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (completion), entry_completion_props[PROP_POPUP_SINGLE_MATCH]);
|
2005-05-26 20:36:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_entry_completion_get_popup_single_match:
|
|
|
|
|
* @completion: a #GtkEntryCompletion
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*
|
2005-05-26 20:36:36 +00:00
|
|
|
|
* Returns whether the completion popup window will appear even if there is
|
2011-01-04 22:54:47 +00:00
|
|
|
|
* only a single match.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE if the popup window will appear regardless of the
|
2011-01-04 22:54:47 +00:00
|
|
|
|
* number of matches
|
|
|
|
|
*/
|
2005-05-26 20:36:36 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gtk_entry_completion_get_popup_single_match (GtkEntryCompletion *completion)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_ENTRY_COMPLETION (completion), TRUE);
|
2011-01-04 22:54:47 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
return completion->popup_single_match;
|
2005-05-26 20:36:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-05-26 18:49:58 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_entry_completion_set_inline_selection:
|
|
|
|
|
* @completion: a #GtkEntryCompletion
|
|
|
|
|
* @inline_selection: %TRUE to do inline selection
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*
|
2007-05-26 18:49:58 +00:00
|
|
|
|
* Sets whether it is possible to cycle through the possible completions
|
|
|
|
|
* inside the entry.
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*/
|
2007-04-27 16:50:04 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_entry_completion_set_inline_selection (GtkEntryCompletion *completion,
|
2011-01-04 22:54:47 +00:00
|
|
|
|
gboolean inline_selection)
|
2007-04-27 16:50:04 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion));
|
|
|
|
|
|
|
|
|
|
inline_selection = inline_selection != FALSE;
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->inline_selection != inline_selection)
|
2007-04-27 16:50:04 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->inline_selection = inline_selection;
|
2007-04-27 16:50:04 +00:00
|
|
|
|
|
2015-09-06 02:35:22 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (completion), entry_completion_props[PROP_INLINE_SELECTION]);
|
2007-04-27 16:50:04 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-26 18:49:58 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_entry_completion_get_inline_selection:
|
|
|
|
|
* @completion: a #GtkEntryCompletion
|
|
|
|
|
*
|
|
|
|
|
* Returns %TRUE if inline-selection mode is turned on.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if inline-selection mode is on
|
2011-01-04 22:54:47 +00:00
|
|
|
|
*/
|
2007-04-27 16:50:04 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gtk_entry_completion_get_inline_selection (GtkEntryCompletion *completion)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_ENTRY_COMPLETION (completion), FALSE);
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
return completion->inline_selection;
|
2007-04-27 16:50:04 +00:00
|
|
|
|
}
|
2012-08-31 14:47:23 +00:00
|
|
|
|
|
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
|
static int
|
2012-08-31 14:47:23 +00:00
|
|
|
|
gtk_entry_completion_timeout (gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (data);
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->completion_timeout = 0;
|
2012-08-31 14:47:23 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->filter_model &&
|
|
|
|
|
g_utf8_strlen (gtk_editable_get_text (GTK_EDITABLE (completion->entry)), -1)
|
|
|
|
|
>= completion->minimum_key_length)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int matches;
|
2012-08-31 14:47:23 +00:00
|
|
|
|
gboolean popup_single;
|
|
|
|
|
|
|
|
|
|
gtk_entry_completion_complete (completion);
|
2020-06-21 19:28:56 +00:00
|
|
|
|
matches = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (completion->filter_model), NULL);
|
|
|
|
|
gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->tree_view)));
|
2012-08-31 14:47:23 +00:00
|
|
|
|
|
|
|
|
|
g_object_get (completion, "popup-single-match", &popup_single, NULL);
|
2020-06-22 18:12:45 +00:00
|
|
|
|
if (matches > (popup_single ? 0: 1))
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (gtk_widget_get_visible (completion->popup_window))
|
2012-08-31 14:47:23 +00:00
|
|
|
|
_gtk_entry_completion_resize_popup (completion);
|
|
|
|
|
else
|
2012-10-02 17:23:29 +00:00
|
|
|
|
gtk_entry_completion_popup (completion);
|
2012-08-31 14:47:23 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
_gtk_entry_completion_popdown (completion);
|
|
|
|
|
}
|
2020-06-21 19:28:56 +00:00
|
|
|
|
else if (gtk_widget_get_visible (completion->popup_window))
|
2012-08-31 14:47:23 +00:00
|
|
|
|
_gtk_entry_completion_popdown (completion);
|
2019-04-20 04:32:29 +00:00
|
|
|
|
return G_SOURCE_REMOVE;
|
2012-08-31 14:47:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline gboolean
|
|
|
|
|
keyval_is_cursor_move (guint keyval)
|
|
|
|
|
{
|
|
|
|
|
if (keyval == GDK_KEY_Up || keyval == GDK_KEY_KP_Up)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
if (keyval == GDK_KEY_Down || keyval == GDK_KEY_KP_Down)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
if (keyval == GDK_KEY_Page_Up)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
if (keyval == GDK_KEY_Page_Down)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2018-03-06 16:53:53 +00:00
|
|
|
|
gtk_entry_completion_key_pressed (GtkEventControllerKey *controller,
|
|
|
|
|
guint keyval,
|
|
|
|
|
guint keycode,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
gpointer user_data)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int matches;
|
2012-08-31 14:47:23 +00:00
|
|
|
|
GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (user_data);
|
2020-06-21 19:28:56 +00:00
|
|
|
|
GtkWidget *widget = completion->entry;
|
2019-02-18 04:03:27 +00:00
|
|
|
|
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (widget));
|
2012-08-31 14:47:23 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (!completion->popup_completion)
|
2013-03-05 12:09:10 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
2017-08-25 14:45:20 +00:00
|
|
|
|
if (keyval == GDK_KEY_Return ||
|
|
|
|
|
keyval == GDK_KEY_KP_Enter ||
|
|
|
|
|
keyval == GDK_KEY_ISO_Enter ||
|
|
|
|
|
keyval == GDK_KEY_Escape)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->completion_timeout)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
g_source_remove (completion->completion_timeout);
|
|
|
|
|
completion->completion_timeout = 0;
|
2012-08-31 14:47:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (!gtk_widget_get_mapped (completion->popup_window))
|
2012-08-31 14:47:23 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
matches = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (completion->filter_model), NULL);
|
2012-08-31 14:47:23 +00:00
|
|
|
|
|
2017-08-25 14:45:20 +00:00
|
|
|
|
if (keyval_is_cursor_move (keyval))
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
|
|
|
|
GtkTreePath *path = NULL;
|
|
|
|
|
|
2017-08-25 14:45:20 +00:00
|
|
|
|
if (keyval == GDK_KEY_Up || keyval == GDK_KEY_KP_Up)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->current_selected < 0)
|
|
|
|
|
completion->current_selected = matches - 1;
|
2012-08-31 14:47:23 +00:00
|
|
|
|
else
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->current_selected--;
|
2012-08-31 14:47:23 +00:00
|
|
|
|
}
|
2017-08-25 14:45:20 +00:00
|
|
|
|
else if (keyval == GDK_KEY_Down || keyval == GDK_KEY_KP_Down)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->current_selected < matches - 1)
|
|
|
|
|
completion->current_selected++;
|
2012-08-31 14:47:23 +00:00
|
|
|
|
else
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->current_selected = -1;
|
2012-08-31 14:47:23 +00:00
|
|
|
|
}
|
2017-08-25 14:45:20 +00:00
|
|
|
|
else if (keyval == GDK_KEY_Page_Up)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->current_selected < 0)
|
|
|
|
|
completion->current_selected = matches - 1;
|
|
|
|
|
else if (completion->current_selected == 0)
|
|
|
|
|
completion->current_selected = -1;
|
|
|
|
|
else if (completion->current_selected < matches)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->current_selected -= PAGE_STEP;
|
|
|
|
|
if (completion->current_selected < 0)
|
|
|
|
|
completion->current_selected = 0;
|
2012-08-31 14:47:23 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->current_selected -= PAGE_STEP;
|
|
|
|
|
if (completion->current_selected < matches - 1)
|
|
|
|
|
completion->current_selected = matches - 1;
|
2012-08-31 14:47:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-08-25 14:45:20 +00:00
|
|
|
|
else if (keyval == GDK_KEY_Page_Down)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->current_selected < 0)
|
|
|
|
|
completion->current_selected = 0;
|
|
|
|
|
else if (completion->current_selected < matches - 1)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->current_selected += PAGE_STEP;
|
|
|
|
|
if (completion->current_selected > matches - 1)
|
|
|
|
|
completion->current_selected = matches - 1;
|
2012-08-31 14:47:23 +00:00
|
|
|
|
}
|
2020-06-21 19:28:56 +00:00
|
|
|
|
else if (completion->current_selected == matches - 1)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->current_selected = -1;
|
2012-08-31 14:47:23 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->current_selected += PAGE_STEP;
|
|
|
|
|
if (completion->current_selected > matches - 1)
|
|
|
|
|
completion->current_selected = matches - 1;
|
2012-08-31 14:47:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->current_selected < 0)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->tree_view)));
|
2012-08-31 14:47:23 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->inline_selection &&
|
|
|
|
|
completion->completion_prefix)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_editable_set_text (GTK_EDITABLE (completion->entry),
|
|
|
|
|
completion->completion_prefix);
|
2012-08-31 14:47:23 +00:00
|
|
|
|
gtk_editable_set_position (GTK_EDITABLE (widget), -1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-21 19:28:56 +00:00
|
|
|
|
else if (completion->current_selected < matches)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
path = gtk_tree_path_new_from_indices (completion->current_selected, -1);
|
|
|
|
|
gtk_tree_view_set_cursor (GTK_TREE_VIEW (completion->tree_view),
|
2012-08-31 14:47:23 +00:00
|
|
|
|
path, NULL, FALSE);
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->inline_selection)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
GtkTreeIter child_iter;
|
|
|
|
|
GtkTreeModel *model = NULL;
|
|
|
|
|
GtkTreeSelection *sel;
|
|
|
|
|
gboolean entry_set;
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->tree_view));
|
2012-08-31 14:47:23 +00:00
|
|
|
|
if (!gtk_tree_selection_get_selected (sel, &model, &iter))
|
|
|
|
|
return FALSE;
|
|
|
|
|
gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (model), &child_iter, &iter);
|
|
|
|
|
model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->completion_prefix == NULL)
|
|
|
|
|
completion->completion_prefix = g_strdup (gtk_editable_get_text (GTK_EDITABLE (completion->entry)));
|
2012-08-31 14:47:23 +00:00
|
|
|
|
|
|
|
|
|
g_signal_emit_by_name (completion, "cursor-on-match", model,
|
|
|
|
|
&child_iter, &entry_set);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2017-08-25 14:45:20 +00:00
|
|
|
|
else if (keyval == GDK_KEY_Escape ||
|
|
|
|
|
keyval == GDK_KEY_Left ||
|
|
|
|
|
keyval == GDK_KEY_KP_Left ||
|
|
|
|
|
keyval == GDK_KEY_Right ||
|
|
|
|
|
keyval == GDK_KEY_KP_Right)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
|
|
|
|
gboolean retval = TRUE;
|
|
|
|
|
|
|
|
|
|
gtk_entry_reset_im_context (GTK_ENTRY (widget));
|
|
|
|
|
_gtk_entry_completion_popdown (completion);
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->current_selected < 0)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
goto keypress_completion_out;
|
|
|
|
|
}
|
2020-06-21 19:28:56 +00:00
|
|
|
|
else if (completion->inline_selection)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
|
|
|
|
/* Escape rejects the tentative completion */
|
2017-08-25 14:45:20 +00:00
|
|
|
|
if (keyval == GDK_KEY_Escape)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->completion_prefix)
|
|
|
|
|
gtk_editable_set_text (GTK_EDITABLE (completion->entry),
|
|
|
|
|
completion->completion_prefix);
|
2012-08-31 14:47:23 +00:00
|
|
|
|
else
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_editable_set_text (GTK_EDITABLE (completion->entry), "");
|
2012-08-31 14:47:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Move the cursor to the end for Right/Esc */
|
2017-08-25 14:45:20 +00:00
|
|
|
|
if (keyval == GDK_KEY_Right ||
|
|
|
|
|
keyval == GDK_KEY_KP_Right ||
|
|
|
|
|
keyval == GDK_KEY_Escape)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
gtk_editable_set_position (GTK_EDITABLE (widget), -1);
|
|
|
|
|
/* Let the default keybindings run for Left, i.e. either move to the
|
|
|
|
|
* * previous character or select word if a modifier is used */
|
|
|
|
|
else
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
keypress_completion_out:
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->inline_selection)
|
2020-06-24 04:26:27 +00:00
|
|
|
|
g_clear_pointer (&completion->completion_prefix, g_free);
|
2012-08-31 14:47:23 +00:00
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
2017-08-25 14:45:20 +00:00
|
|
|
|
else if (keyval == GDK_KEY_Tab ||
|
|
|
|
|
keyval == GDK_KEY_KP_Tab ||
|
|
|
|
|
keyval == GDK_KEY_ISO_Left_Tab)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_entry_reset_im_context (GTK_ENTRY (widget));
|
|
|
|
|
_gtk_entry_completion_popdown (completion);
|
|
|
|
|
|
2020-06-24 04:26:27 +00:00
|
|
|
|
g_clear_pointer (&completion->completion_prefix, g_free);
|
2012-08-31 14:47:23 +00:00
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-08-25 14:45:20 +00:00
|
|
|
|
else if (keyval == GDK_KEY_ISO_Enter ||
|
|
|
|
|
keyval == GDK_KEY_KP_Enter ||
|
|
|
|
|
keyval == GDK_KEY_Return)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
GtkTreeModel *model = NULL;
|
|
|
|
|
GtkTreeModel *child_model;
|
|
|
|
|
GtkTreeIter child_iter;
|
|
|
|
|
GtkTreeSelection *sel;
|
|
|
|
|
gboolean retval = TRUE;
|
|
|
|
|
|
|
|
|
|
gtk_entry_reset_im_context (GTK_ENTRY (widget));
|
|
|
|
|
_gtk_entry_completion_popdown (completion);
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->current_selected < matches)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
|
|
|
|
gboolean entry_set;
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->tree_view));
|
2012-08-31 14:47:23 +00:00
|
|
|
|
if (gtk_tree_selection_get_selected (sel, &model, &iter))
|
|
|
|
|
{
|
|
|
|
|
gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (model), &child_iter, &iter);
|
|
|
|
|
child_model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));
|
2020-06-21 19:28:56 +00:00
|
|
|
|
g_signal_handler_block (text, completion->changed_id);
|
2012-08-31 14:47:23 +00:00
|
|
|
|
g_signal_emit_by_name (completion, "match-selected",
|
|
|
|
|
child_model, &child_iter, &entry_set);
|
2020-06-21 19:28:56 +00:00
|
|
|
|
g_signal_handler_unblock (text, completion->changed_id);
|
2012-08-31 14:47:23 +00:00
|
|
|
|
|
|
|
|
|
if (!entry_set)
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *str = NULL;
|
2012-08-31 14:47:23 +00:00
|
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, &iter,
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->text_column, &str,
|
2012-08-31 14:47:23 +00:00
|
|
|
|
-1);
|
|
|
|
|
|
2019-02-28 19:31:36 +00:00
|
|
|
|
gtk_editable_set_text (GTK_EDITABLE (widget), str);
|
2012-08-31 14:47:23 +00:00
|
|
|
|
|
|
|
|
|
/* move the cursor to the end */
|
|
|
|
|
gtk_editable_set_position (GTK_EDITABLE (widget), -1);
|
|
|
|
|
g_free (str);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-24 04:26:27 +00:00
|
|
|
|
g_clear_pointer (&completion->completion_prefix, g_free);
|
2012-08-31 14:47:23 +00:00
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-24 04:26:27 +00:00
|
|
|
|
g_clear_pointer (&completion->completion_prefix, g_free);
|
|
|
|
|
|
2012-08-31 14:47:23 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_entry_completion_changed (GtkWidget *widget,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (user_data);
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (!completion->popup_completion)
|
2013-03-05 12:09:10 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2012-08-31 14:47:23 +00:00
|
|
|
|
/* (re)install completion timeout */
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->completion_timeout)
|
2015-04-06 02:07:59 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
g_source_remove (completion->completion_timeout);
|
|
|
|
|
completion->completion_timeout = 0;
|
2015-04-06 02:07:59 +00:00
|
|
|
|
}
|
2012-08-31 14:47:23 +00:00
|
|
|
|
|
2019-02-18 04:03:27 +00:00
|
|
|
|
if (!gtk_editable_get_text (GTK_EDITABLE (widget)))
|
2012-08-31 14:47:23 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* no need to normalize for this test */
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->minimum_key_length > 0 &&
|
2019-02-18 04:03:27 +00:00
|
|
|
|
strcmp ("", gtk_editable_get_text (GTK_EDITABLE (widget))) == 0)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (gtk_widget_get_visible (completion->popup_window))
|
2012-08-31 14:47:23 +00:00
|
|
|
|
_gtk_entry_completion_popdown (completion);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->completion_timeout =
|
2018-02-02 14:51:47 +00:00
|
|
|
|
g_timeout_add (COMPLETION_TIMEOUT,
|
2012-08-31 14:47:23 +00:00
|
|
|
|
gtk_entry_completion_timeout,
|
|
|
|
|
completion);
|
2020-06-21 19:28:56 +00:00
|
|
|
|
g_source_set_name_by_id (completion->completion_timeout, "[gtk] gtk_entry_completion_timeout");
|
2012-08-31 14:47:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
check_completion_callback (GtkEntryCompletion *completion)
|
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->check_completion_idle = NULL;
|
2012-08-31 14:47:23 +00:00
|
|
|
|
|
|
|
|
|
gtk_entry_completion_complete (completion);
|
|
|
|
|
gtk_entry_completion_insert_prefix (completion);
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-02-18 04:03:27 +00:00
|
|
|
|
clear_completion_callback (GObject *text,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
GtkEntryCompletion *completion)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (!completion->inline_completion)
|
2013-03-05 12:09:10 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2012-08-31 14:47:23 +00:00
|
|
|
|
if (pspec->name == I_("cursor-position") ||
|
|
|
|
|
pspec->name == I_("selection-bound"))
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->has_completion = FALSE;
|
2012-08-31 14:47:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2019-02-18 04:03:27 +00:00
|
|
|
|
accept_completion_callback (GtkEntryCompletion *completion)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (!completion->inline_completion)
|
2013-03-05 12:09:10 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->has_completion)
|
|
|
|
|
gtk_editable_set_position (GTK_EDITABLE (completion->entry),
|
|
|
|
|
gtk_entry_buffer_get_length (gtk_entry_get_buffer (GTK_ENTRY (completion->entry))));
|
2012-08-31 14:47:23 +00:00
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-13 01:26:29 +00:00
|
|
|
|
static void
|
2020-02-20 01:51:03 +00:00
|
|
|
|
text_focus_out (GtkEntryCompletion *completion)
|
2019-04-20 04:32:29 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (!gtk_widget_get_mapped (completion->popup_window))
|
2020-02-13 01:26:29 +00:00
|
|
|
|
accept_completion_callback (completion);
|
2019-04-20 04:32:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-08-31 14:47:23 +00:00
|
|
|
|
static void
|
2020-06-24 04:26:27 +00:00
|
|
|
|
completion_inserted_text_callback (GtkEntryBuffer *buffer,
|
|
|
|
|
guint position,
|
|
|
|
|
const char *text,
|
|
|
|
|
guint length,
|
|
|
|
|
GtkEntryCompletion *completion)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (!completion->inline_completion)
|
2013-03-05 12:09:10 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2012-08-31 14:47:23 +00:00
|
|
|
|
/* idle to update the selection based on the file list */
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->check_completion_idle == NULL)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->check_completion_idle = g_idle_source_new ();
|
|
|
|
|
g_source_set_priority (completion->check_completion_idle, G_PRIORITY_HIGH);
|
|
|
|
|
g_source_set_closure (completion->check_completion_idle,
|
2012-08-31 14:47:23 +00:00
|
|
|
|
g_cclosure_new_object (G_CALLBACK (check_completion_callback),
|
|
|
|
|
G_OBJECT (completion)));
|
2020-06-21 19:28:56 +00:00
|
|
|
|
g_source_attach (completion->check_completion_idle, NULL);
|
|
|
|
|
g_source_set_name (completion->check_completion_idle, "[gtk] check_completion_callback");
|
2012-08-31 14:47:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
connect_completion_signals (GtkEntryCompletion *completion)
|
|
|
|
|
{
|
2018-04-20 17:58:06 +00:00
|
|
|
|
GtkEventController *controller;
|
2020-06-21 19:28:56 +00:00
|
|
|
|
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (completion->entry));
|
2020-06-24 04:26:27 +00:00
|
|
|
|
GtkEntryBuffer *buffer = gtk_text_get_buffer (text);
|
2018-04-20 17:58:06 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
controller = completion->entry_key_controller = gtk_event_controller_key_new ();
|
2020-06-22 16:31:15 +00:00
|
|
|
|
gtk_event_controller_set_name (controller, "gtk-entry-completion");
|
2018-04-20 17:58:06 +00:00
|
|
|
|
g_signal_connect (controller, "key-pressed",
|
2018-03-06 16:53:53 +00:00
|
|
|
|
G_CALLBACK (gtk_entry_completion_key_pressed), completion);
|
2020-08-02 15:54:03 +00:00
|
|
|
|
gtk_widget_add_controller (GTK_WIDGET (text), controller);
|
2020-06-21 19:28:56 +00:00
|
|
|
|
controller = completion->entry_focus_controller = gtk_event_controller_focus_new ();
|
2020-06-22 16:31:15 +00:00
|
|
|
|
gtk_event_controller_set_name (controller, "gtk-entry-completion");
|
2020-02-20 01:51:03 +00:00
|
|
|
|
g_signal_connect_swapped (controller, "leave", G_CALLBACK (text_focus_out), completion);
|
2019-02-18 04:03:27 +00:00
|
|
|
|
gtk_widget_add_controller (GTK_WIDGET (text), controller);
|
2018-03-06 16:53:53 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->changed_id =
|
2019-02-18 04:03:27 +00:00
|
|
|
|
g_signal_connect (text, "changed", G_CALLBACK (gtk_entry_completion_changed), completion);
|
2013-03-05 12:09:10 +00:00
|
|
|
|
|
2020-06-24 04:26:27 +00:00
|
|
|
|
completion->insert_text_id =
|
|
|
|
|
g_signal_connect (buffer, "inserted-text", G_CALLBACK (completion_inserted_text_callback), completion);
|
|
|
|
|
g_signal_connect (text, "notify", G_CALLBACK (clear_completion_callback), completion);
|
|
|
|
|
g_signal_connect_swapped (text, "activate", G_CALLBACK (accept_completion_callback), completion);
|
2012-08-31 14:47:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
disconnect_completion_signals (GtkEntryCompletion *completion)
|
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (completion->entry));
|
2020-06-24 04:26:27 +00:00
|
|
|
|
GtkEntryBuffer *buffer = gtk_text_get_buffer (text);
|
2019-02-18 04:03:27 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_widget_remove_controller (GTK_WIDGET (text), completion->entry_key_controller);
|
|
|
|
|
gtk_widget_remove_controller (GTK_WIDGET (text), completion->entry_focus_controller);
|
2018-06-08 11:31:32 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->changed_id > 0 &&
|
|
|
|
|
g_signal_handler_is_connected (text, completion->changed_id))
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
g_signal_handler_disconnect (text, completion->changed_id);
|
|
|
|
|
completion->changed_id = 0;
|
2012-08-31 14:47:23 +00:00
|
|
|
|
}
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->insert_text_id > 0 &&
|
2020-06-24 04:26:27 +00:00
|
|
|
|
g_signal_handler_is_connected (buffer, completion->insert_text_id))
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
2020-06-24 04:26:27 +00:00
|
|
|
|
g_signal_handler_disconnect (buffer, completion->insert_text_id);
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->insert_text_id = 0;
|
2012-08-31 14:47:23 +00:00
|
|
|
|
}
|
2019-02-18 04:03:27 +00:00
|
|
|
|
g_signal_handlers_disconnect_by_func (text, G_CALLBACK (clear_completion_callback), completion);
|
|
|
|
|
g_signal_handlers_disconnect_by_func (text, G_CALLBACK (accept_completion_callback), completion);
|
2012-08-31 14:47:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_gtk_entry_completion_disconnect (GtkEntryCompletion *completion)
|
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->completion_timeout)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
g_source_remove (completion->completion_timeout);
|
|
|
|
|
completion->completion_timeout = 0;
|
2012-08-31 14:47:23 +00:00
|
|
|
|
}
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (completion->check_completion_idle)
|
2012-08-31 14:47:23 +00:00
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
g_source_destroy (completion->check_completion_idle);
|
|
|
|
|
completion->check_completion_idle = NULL;
|
2012-08-31 14:47:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
if (gtk_widget_get_mapped (completion->popup_window))
|
2012-08-31 14:47:23 +00:00
|
|
|
|
_gtk_entry_completion_popdown (completion);
|
|
|
|
|
|
|
|
|
|
disconnect_completion_signals (completion);
|
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_widget_unparent (completion->popup_window);
|
2014-08-21 15:36:45 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->entry = NULL;
|
2012-08-31 14:47:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_gtk_entry_completion_connect (GtkEntryCompletion *completion,
|
|
|
|
|
GtkEntry *entry)
|
|
|
|
|
{
|
2020-06-21 19:28:56 +00:00
|
|
|
|
completion->entry = GTK_WIDGET (entry);
|
2013-02-03 21:32:21 +00:00
|
|
|
|
|
2020-06-21 19:28:56 +00:00
|
|
|
|
gtk_widget_set_parent (completion->popup_window, GTK_WIDGET (entry));
|
2013-02-03 21:32:21 +00:00
|
|
|
|
|
2012-08-31 14:47:23 +00:00
|
|
|
|
connect_completion_signals (completion);
|
|
|
|
|
}
|