gtk2/gtk/gtkeditable.c

1235 lines
38 KiB
C
Raw Normal View History

/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
2012-02-27 13:01:10 +00:00
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
/**
2021-02-25 14:53:51 +00:00
* GtkEditable:
*
2021-03-01 06:33:21 +00:00
* `GtkEditable` is an interface for text editing widgets.
*
2021-02-25 14:53:51 +00:00
* Typical examples of editable widgets are [class@Gtk.Entry] and
* [class@Gtk.SpinButton]. It contains functions for generically manipulating
* an editable widget, a large number of action signals used for key bindings,
* and several signals that an application can connect to modify the behavior
* of a widget.
*
* As an example of the latter usage, by connecting the following handler to
* [signal@Gtk.Editable::insert-text], an application can convert all entry
* into a widget into uppercase.
*
* ## Forcing entry to uppercase.
*
2021-02-25 14:53:51 +00:00
* ```c
2020-08-01 18:00:13 +00:00
* #include <ctype.h>
*
* void
* insert_text_handler (GtkEditable *editable,
* const char *text,
* int length,
* int *position,
* gpointer data)
* {
* char *result = g_utf8_strup (text, length);
*
* g_signal_handlers_block_by_func (editable,
* (gpointer) insert_text_handler, data);
* gtk_editable_insert_text (editable, result, length, position);
* g_signal_handlers_unblock_by_func (editable,
* (gpointer) insert_text_handler, data);
*
* g_signal_stop_emission_by_name (editable, "insert_text");
*
* g_free (result);
* }
2021-02-25 14:53:51 +00:00
* ```
*
* ## Implementing GtkEditable
2021-02-25 14:53:51 +00:00
*
* The most likely scenario for implementing `GtkEditable` on your own widget
* is that you will embed a `GtkText` inside a complex widget, and want to
2021-02-25 14:53:51 +00:00
* delegate the editable functionality to that text widget. `GtkEditable`
* provides some utility functions to make this easy.
*
2021-02-25 14:53:51 +00:00
* In your class_init function, call [func@Gtk.Editable.install_properties],
* passing the first available property ID:
2021-02-25 14:53:51 +00:00
*
* ```c
* static void
* my_class_init (MyClass *class)
* {
2021-02-25 14:53:51 +00:00
* ...
* g_object_class_install_properties (object_class, NUM_PROPERTIES, props);
* gtk_editable_install_properties (object_clas, NUM_PROPERTIES);
* ...
* }
2021-02-25 14:53:51 +00:00
* ```
*
2021-02-25 14:53:51 +00:00
* In your interface_init function for the `GtkEditable` interface, provide
* an implementation for the get_delegate vfunc that returns your text widget:
*
2021-02-25 14:53:51 +00:00
* ```c
* GtkEditable *
* get_editable_delegate (GtkEditable *editable)
* {
* return GTK_EDITABLE (MY_WIDGET (editable)->text_widget);
* }
*
* static void
* my_editable_init (GtkEditableInterface *iface)
* {
* iface->get_delegate = get_editable_delegate;
* }
2021-02-25 14:53:51 +00:00
* ```
*
* You don't need to provide any other vfuncs. The default implementations
2021-02-25 14:53:51 +00:00
* work by forwarding to the delegate that the GtkEditableInterface.get_delegate()
* vfunc returns.
*
* In your instance_init function, create your text widget, and then call
2021-02-25 14:53:51 +00:00
* [method@Gtk.Editable.init_delegate]:
*
2021-02-25 14:53:51 +00:00
* ```c
* static void
* my_widget_init (MyWidget *self)
* {
* ...
* self->text_widget = gtk_text_new ();
* gtk_editable_init_delegate (GTK_EDITABLE (self));
* ...
* }
2021-02-25 14:53:51 +00:00
* ```
*
* In your dispose function, call [method@Gtk.Editable.finish_delegate] before
* destroying your text widget:
*
2021-02-25 14:53:51 +00:00
* ```c
* static void
* my_widget_dispose (GObject *object)
* {
* ...
* gtk_editable_finish_delegate (GTK_EDITABLE (self));
* g_clear_pointer (&self->text_widget, gtk_widget_unparent);
* ...
* }
2021-02-25 14:53:51 +00:00
* ```
*
* Finally, use [func@Gtk.Editable.delegate_set_property] in your `set_property`
* function (and similar for `get_property`), to set the editable properties:
*
2021-02-25 14:53:51 +00:00
* ```c
* ...
* if (gtk_editable_delegate_set_property (object, prop_id, value, pspec))
* return;
*
* switch (prop_id)
* ...
2021-02-25 14:53:51 +00:00
* ```
*
* It is important to note that if you create a `GtkEditable` that uses
* a delegate, the low level [signal@Gtk.Editable::insert-text] and
* [signal@Gtk.Editable::delete-text] signals will be propagated from the
* "wrapper" editable to the delegate, but they will not be propagated from
* the delegate to the "wrapper" editable, as they would cause an infinite
* recursion. If you wish to connect to the [signal@Gtk.Editable::insert-text]
* and [signal@Gtk.Editable::delete-text] signals, you will need to connect
* to them on the delegate obtained via [method@Gtk.Editable.get_delegate].
*/
#include "config.h"
#include <string.h>
Make parent_class static. Sun Nov 5 04:24:53 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkcellrenderertextpixbuf.c: Make parent_class static. Tue Sep 19 10:54:22 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimcontext*.[ch] gtk/gtkimmulticontext.[ch] gtk/gtktextlayout.[ch] gtk/gtktextview.c gtk/gtkentry.c: Add support for positioning the cursor within the preedit string. Mon Sep 18 23:56:32 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextview.c: Check for bindings after passing events to im context filter. Mon Sep 18 11:50:51 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextlayout.c (add_preedit_attrs): Handle empty attribute lists properly. Sun Sep 17 10:08:16 2000 Owen Taylor <otaylor@redhat.com> * gtk/queryimmodules.c (main): Return non-zero exit status if errors were encountered querying any modules. Sat Sep 16 14:01:52 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtk.h: include gtkmodule.h gtkoldeditable.h, don't include gtkthemes.h. * gtk/testgtk.c gtk/testtext.c: Set environment variables to point * gtk/Makefile.am: Add new .c and .h files, build gtk-query-immodules and use it to create a gtk.immodules file for use of test programs. * gtk/gtkpreview.c: remove extra blank line. Sat Sep 16 13:21:04 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimcontextsimple.c (gtk_im_context_simple_add_table): Add the ability to add extra tables beyond the default one, and also the ability to have compose sequences that are prefixes of other compose sequences. * gtk/gtkimcontextsimple.c: Export a preedit string which consists of possible candidates for keystrokes that have been entered but not yet committed. * gtk/gtkimcontext.[ch] gtk/immulticontext.[ch] gtk/gtkimcontextsimple.[ch]: add gtk_im_context_reset() * gtk/gtkmulticontext.[ch] (gtk_im_multicontext_append_menuitems): Add a function to add input-method switching menu items to a menu. * gtk/gtkimmulticontext.[ch]: Properly handly set_client_window when switching input methods. * gtk/gtkimcontextsimple.[ch]: Change the format of the compose table to allow compose tables of different lengths / sequence. Sat Sep 16 13:05:48 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimmodule.[ch]: Support routines for loading GtkIMContext implementations dynamically at runtime. * gtk/queryimmodules.c: Program to query the available input modules and write the results into a file. * gtk/gtkrc.[ch] (gtk_rc_get_im_module_file): Add extra config options "im_module_file" (cache file for input method modules), and "im_module_path" - path to look for modules when generating cache file. This doesn't scale. Sat Sep 16 13:09:06 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkthemes.[ch] gtk/gtkmodule.[ch]: Move most of the generic code from gtkthemes into a new abstraction GtkModule which has the logic for implementing a loadable module which implements a number of GObject types. Sat Sep 16 13:07:13 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkeditable.[ch]: Convert GtkEditable from a class into an interface * gtk/gtkoldeditable.[ch]: Move the old editable implementation into here, so legacy widgets can still rely on the implemenation. GtkOldEditable exports GtkEditable. Make selection handling code use new text conversion functions (and handle UTF-8 as a side-effect). Use GtkClipboard for CLIPBOARD. * gtk/gtktext.[ch] gtk/gtkcombo.c gtk/gtkspinbutton.c: Adopt to match above changes. * gtk/gtkentry.[ch]: Implement GtkEditable directly, avoid GtkOldEditable implementation. Restructure to reduce number of places that modify state directly. Move to GtkBindingSet. Display the preedit string. Queue recomputation of PangoLayout and scroll position to improve effiency of doing complex changes naively. Add a menu with cut/copy/paste and input method selection. Thu Sep 14 22:11:05 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextlayout.[ch]: Add gtk_text_layout_set_preedit_string() to set preedit string and attributes; display preedit string by inserting string and attributes at cursor when creating the GtkTextLineDisplay. * gtk/gtktextlayout.c: Move all conversions between byte positions in PangoLayout and GtkTextIter into new functions line_display_iter_to_index/index_to_iter that properly handle the preedit string. * gtk/gtktextmark.[ch]: Restore gtk_text_mark_get_name, modify it to return const char * (eventually will end up as GCONST char *, most likely.) * gtk/gtktextview.[ch]: Handle the preedit string, call gtk_im_context_reset() as necessary, add a menu to switch input methods. * gtk/gtktextlayout.[ch]: Remove useless gtk_text_layout_get_log_attrs() function.
2000-11-12 03:43:24 +00:00
#include "gtkeditable.h"
#include "gtkentrybuffer.h"
#include "gtkmarshalers.h"
#include "gtkprivate.h"
G_DEFINE_INTERFACE (GtkEditable, gtk_editable, GTK_TYPE_WIDGET)
enum {
CHANGED,
DELETE_TEXT,
INSERT_TEXT,
N_SIGNALS
};
static GQuark quark_editable_data;
static guint signals[N_SIGNALS];
static GtkEditable *
get_delegate (GtkEditable *editable)
{
GtkEditableInterface *iface = GTK_EDITABLE_GET_IFACE (editable);
if (iface->get_delegate)
return iface->get_delegate (editable);
return NULL;
}
static void
gtk_editable_default_do_insert_text (GtkEditable *editable,
const char *text,
int length,
int *position)
{
g_signal_emit (editable, signals[INSERT_TEXT], 0, text, length, position);
}
#define warn_no_delegate(func) \
g_critical ("GtkEditable %s: default implementation called without a delegate", func);
static void
gtk_editable_default_insert_text (GtkEditable *editable,
const char *text,
int length,
int *position)
{
GtkEditable *delegate = get_delegate (editable);
if (delegate)
gtk_editable_insert_text (delegate, text, length, position);
else
warn_no_delegate ("insert_text");
}
static void
gtk_editable_default_do_delete_text (GtkEditable *editable,
int start_pos,
int end_pos)
{
g_signal_emit (editable, signals[DELETE_TEXT], 0, start_pos, end_pos);
}
static void
gtk_editable_default_delete_text (GtkEditable *editable,
int start_pos,
int end_pos)
{
GtkEditable *delegate = get_delegate (editable);
if (delegate)
gtk_editable_delete_text (delegate, start_pos, end_pos);
else
warn_no_delegate ("delete_text");
}
static const char *
gtk_editable_default_get_text (GtkEditable *editable)
{
GtkEditable *delegate = get_delegate (editable);
if (delegate)
return gtk_editable_get_text (delegate);
else
warn_no_delegate ("get_text");
return NULL;
}
static void
gtk_editable_default_set_selection_bounds (GtkEditable *editable,
int start_pos,
int end_pos)
{
GtkEditable *delegate = get_delegate (editable);
if (delegate)
gtk_editable_select_region (delegate, start_pos, end_pos);
else
warn_no_delegate ("select_region");
}
static gboolean
gtk_editable_default_get_selection_bounds (GtkEditable *editable,
int *start_pos,
int *end_pos)
{
GtkEditable *delegate = get_delegate (editable);
if (delegate)
return gtk_editable_get_selection_bounds (delegate, start_pos, end_pos);
else
warn_no_delegate ("select_region");
return FALSE;
}
static void
gtk_editable_default_init (GtkEditableInterface *iface)
{
quark_editable_data = g_quark_from_static_string ("GtkEditable-data");
iface->insert_text = gtk_editable_default_insert_text;
iface->delete_text = gtk_editable_default_delete_text;
iface->get_text = gtk_editable_default_get_text;
iface->do_insert_text = gtk_editable_default_do_insert_text;
iface->do_delete_text = gtk_editable_default_do_delete_text;
iface->get_selection_bounds = gtk_editable_default_get_selection_bounds;
iface->set_selection_bounds = gtk_editable_default_set_selection_bounds;
/**
* GtkEditable::insert-text:
* @editable: the object which received the signal
* @text: the new text to insert
* @length: the length of the new text, in bytes,
* or -1 if new_text is nul-terminated
* @position: (inout) (type int): the position, in characters,
* at which to insert the new text. this is an in-out
* parameter. After the signal emission is finished, it
* should point after the newly inserted text.
*
2021-02-25 14:53:51 +00:00
* Emitted when text is inserted into the widget by the user.
*
* The default handler for this signal will normally be responsible
* for inserting the text, so by connecting to this signal and then
* stopping the signal with g_signal_stop_emission(), it is possible
* to modify the inserted text, or prevent it from being inserted entirely.
*/
signals[INSERT_TEXT] =
g_signal_new (I_("insert-text"),
GTK_TYPE_EDITABLE,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkEditableInterface, insert_text),
NULL, NULL,
_gtk_marshal_VOID__STRING_INT_POINTER,
G_TYPE_NONE, 3,
G_TYPE_STRING,
G_TYPE_INT,
G_TYPE_POINTER);
g_signal_set_va_marshaller (signals[INSERT_TEXT],
G_TYPE_FROM_INTERFACE (iface),
_gtk_marshal_VOID__STRING_INT_POINTERv);
/**
* GtkEditable::delete-text:
* @editable: the object which received the signal
* @start_pos: the starting position
* @end_pos: the end position
2021-02-25 14:53:51 +00:00
*
* Emitted when text is deleted from the widget by the user.
*
* The default handler for this signal will normally be responsible for
* deleting the text, so by connecting to this signal and then stopping
* the signal with g_signal_stop_emission(), it is possible to modify the
* range of deleted text, or prevent it from being deleted entirely.
*
* The @start_pos and @end_pos parameters are interpreted as for
* [method@Gtk.Editable.delete_text].
*/
signals[DELETE_TEXT] =
g_signal_new (I_("delete-text"),
GTK_TYPE_EDITABLE,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkEditableInterface, delete_text),
NULL, NULL,
_gtk_marshal_VOID__INT_INT,
G_TYPE_NONE, 2,
G_TYPE_INT,
G_TYPE_INT);
g_signal_set_va_marshaller (signals[DELETE_TEXT],
G_TYPE_FROM_INTERFACE (iface),
_gtk_marshal_VOID__INT_INTv);
/**
* GtkEditable::changed:
* @editable: the object which received the signal
*
2021-02-25 14:53:51 +00:00
* Emitted at the end of a single user-visible operation on the
* contents.
*
* E.g., a paste operation that replaces the contents of the
* selection will cause only one signal emission (even though it
* is implemented by first deleting the selection, then inserting
* the new content, and may cause multiple ::notify::text signals
* to be emitted).
2021-02-25 14:53:51 +00:00
*/
signals[CHANGED] =
g_signal_new (I_("changed"),
GTK_TYPE_EDITABLE,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkEditableInterface, changed),
NULL, NULL,
NULL,
G_TYPE_NONE, 0);
2021-02-25 14:53:51 +00:00
/**
* GtkEditable:text: (attributes org.gtk.Property.get=gtk_editable_get_text org.gtk.Property.set=gtk_editable_set_text)
*
* The contents of the entry.
*/
g_object_interface_install_property (iface,
g_param_spec_string ("text", NULL, NULL,
"",
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
2021-02-25 14:53:51 +00:00
/**
* GtkEditable:cursor-position: (attributes org.gtk.Property.get=gtk_editable_get_position org.gtk.Property.set=gtk_editable_set_position)
*
* The current position of the insertion cursor in chars.
*/
g_object_interface_install_property (iface,
g_param_spec_int ("cursor-position", NULL, NULL,
0, GTK_ENTRY_BUFFER_MAX_SIZE,
0,
GTK_PARAM_READABLE));
2021-02-25 14:53:51 +00:00
/**
* GtkEditable:enable-undo: (attributes org.gtk.Property.get=gtk_editable_get_enable_undo org.gtk.Property.setg=gtk_editable_set_enable_undo)
*
* If undo/redo should be enabled for the editable.
*/
g_object_interface_install_property (iface,
g_param_spec_boolean ("enable-undo", NULL, NULL,
TRUE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
2021-02-25 14:53:51 +00:00
/**
* GtkEditable:selection-bound:
*
* The position of the opposite end of the selection from the cursor in chars.
*/
g_object_interface_install_property (iface,
g_param_spec_int ("selection-bound", NULL, NULL,
0, GTK_ENTRY_BUFFER_MAX_SIZE,
0,
GTK_PARAM_READABLE));
2021-02-25 14:53:51 +00:00
/**
* GtkEditable:editable: (attributes org.gtk.Property.get=gtk_editable_get_editable org.gtk.Property.set=gtk_editable_set_editable)
*
* Whether the entry contents can be edited.
*/
g_object_interface_install_property (iface,
g_param_spec_boolean ("editable", NULL, NULL,
TRUE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
2021-02-25 14:53:51 +00:00
/**
* GtkEditable:width-chars: (attributes org.gtk.Property.get=gtk_editable_get_width_chars org.gtk.Property.set=gtk_editable_set_width_chars)
*
* Number of characters to leave space for in the entry.
*/
g_object_interface_install_property (iface,
g_param_spec_int ("width-chars", NULL, NULL,
-1, G_MAXINT,
-1,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
2021-02-25 14:53:51 +00:00
/**
* GtkEditable:max-width-chars: (attributes org.gtk.Property.get=gtk_editable_get_max_width_chars org.gtk.Property.set=gtk_editable_set_max_width_chars)
*
* The desired maximum width of the entry, in characters.
*/
g_object_interface_install_property (iface,
g_param_spec_int ("max-width-chars", NULL, NULL,
-1, G_MAXINT,
-1,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
2021-02-25 14:53:51 +00:00
/**
* GtkEditable:xalign: (attributes org.gtk.Property.get=gtk_editable_get_alignment org.gtk.Property.set=gtk_editable_set_alignment)
*
* The horizontal alignment, from 0 (left) to 1 (right).
*
* Reversed for RTL layouts.
*/
g_object_interface_install_property (iface,
g_param_spec_float ("xalign", NULL, NULL,
0.0, 1.0,
0.0,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
}
/**
2013-10-09 18:09:35 +00:00
* gtk_editable_insert_text: (virtual do_insert_text)
2021-02-25 14:53:51 +00:00
* @editable: a `GtkEditable`
* @text: the text to insert
* @length: the length of the text in bytes, or -1
* @position: (inout): location of the position text will be inserted at
*
* Inserts @length bytes of @text into the contents of the
* widget, at position @position.
*
2021-02-25 14:53:51 +00:00
* Note that the position is in characters, not in bytes.
* The function updates @position to point after the newly
* inserted text.
*/
void
gtk_editable_insert_text (GtkEditable *editable,
const char *text,
int length,
int *position)
{
g_return_if_fail (GTK_IS_EDITABLE (editable));
Make parent_class static. Sun Nov 5 04:24:53 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkcellrenderertextpixbuf.c: Make parent_class static. Tue Sep 19 10:54:22 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimcontext*.[ch] gtk/gtkimmulticontext.[ch] gtk/gtktextlayout.[ch] gtk/gtktextview.c gtk/gtkentry.c: Add support for positioning the cursor within the preedit string. Mon Sep 18 23:56:32 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextview.c: Check for bindings after passing events to im context filter. Mon Sep 18 11:50:51 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextlayout.c (add_preedit_attrs): Handle empty attribute lists properly. Sun Sep 17 10:08:16 2000 Owen Taylor <otaylor@redhat.com> * gtk/queryimmodules.c (main): Return non-zero exit status if errors were encountered querying any modules. Sat Sep 16 14:01:52 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtk.h: include gtkmodule.h gtkoldeditable.h, don't include gtkthemes.h. * gtk/testgtk.c gtk/testtext.c: Set environment variables to point * gtk/Makefile.am: Add new .c and .h files, build gtk-query-immodules and use it to create a gtk.immodules file for use of test programs. * gtk/gtkpreview.c: remove extra blank line. Sat Sep 16 13:21:04 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimcontextsimple.c (gtk_im_context_simple_add_table): Add the ability to add extra tables beyond the default one, and also the ability to have compose sequences that are prefixes of other compose sequences. * gtk/gtkimcontextsimple.c: Export a preedit string which consists of possible candidates for keystrokes that have been entered but not yet committed. * gtk/gtkimcontext.[ch] gtk/immulticontext.[ch] gtk/gtkimcontextsimple.[ch]: add gtk_im_context_reset() * gtk/gtkmulticontext.[ch] (gtk_im_multicontext_append_menuitems): Add a function to add input-method switching menu items to a menu. * gtk/gtkimmulticontext.[ch]: Properly handly set_client_window when switching input methods. * gtk/gtkimcontextsimple.[ch]: Change the format of the compose table to allow compose tables of different lengths / sequence. Sat Sep 16 13:05:48 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimmodule.[ch]: Support routines for loading GtkIMContext implementations dynamically at runtime. * gtk/queryimmodules.c: Program to query the available input modules and write the results into a file. * gtk/gtkrc.[ch] (gtk_rc_get_im_module_file): Add extra config options "im_module_file" (cache file for input method modules), and "im_module_path" - path to look for modules when generating cache file. This doesn't scale. Sat Sep 16 13:09:06 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkthemes.[ch] gtk/gtkmodule.[ch]: Move most of the generic code from gtkthemes into a new abstraction GtkModule which has the logic for implementing a loadable module which implements a number of GObject types. Sat Sep 16 13:07:13 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkeditable.[ch]: Convert GtkEditable from a class into an interface * gtk/gtkoldeditable.[ch]: Move the old editable implementation into here, so legacy widgets can still rely on the implemenation. GtkOldEditable exports GtkEditable. Make selection handling code use new text conversion functions (and handle UTF-8 as a side-effect). Use GtkClipboard for CLIPBOARD. * gtk/gtktext.[ch] gtk/gtkcombo.c gtk/gtkspinbutton.c: Adopt to match above changes. * gtk/gtkentry.[ch]: Implement GtkEditable directly, avoid GtkOldEditable implementation. Restructure to reduce number of places that modify state directly. Move to GtkBindingSet. Display the preedit string. Queue recomputation of PangoLayout and scroll position to improve effiency of doing complex changes naively. Add a menu with cut/copy/paste and input method selection. Thu Sep 14 22:11:05 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextlayout.[ch]: Add gtk_text_layout_set_preedit_string() to set preedit string and attributes; display preedit string by inserting string and attributes at cursor when creating the GtkTextLineDisplay. * gtk/gtktextlayout.c: Move all conversions between byte positions in PangoLayout and GtkTextIter into new functions line_display_iter_to_index/index_to_iter that properly handle the preedit string. * gtk/gtktextmark.[ch]: Restore gtk_text_mark_get_name, modify it to return const char * (eventually will end up as GCONST char *, most likely.) * gtk/gtktextview.[ch]: Handle the preedit string, call gtk_im_context_reset() as necessary, add a menu to switch input methods. * gtk/gtktextlayout.[ch]: Remove useless gtk_text_layout_get_log_attrs() function.
2000-11-12 03:43:24 +00:00
g_return_if_fail (position != NULL);
if (length < 0)
length = strlen (text);
GTK_EDITABLE_GET_IFACE (editable)->do_insert_text (editable, text, length, position);
}
/**
2013-10-09 18:09:35 +00:00
* gtk_editable_delete_text: (virtual do_delete_text)
2021-02-25 14:53:51 +00:00
* @editable: a `GtkEditable`
* @start_pos: start position
* @end_pos: end position
*
2021-02-25 14:53:51 +00:00
* Deletes a sequence of characters.
*
* The characters that are deleted are those characters at positions
* from @start_pos up to, but not including @end_pos. If @end_pos is
* negative, then the characters deleted are those from @start_pos to
* the end of the text.
*
* Note that the positions are specified in characters, not bytes.
*/
void
gtk_editable_delete_text (GtkEditable *editable,
int start_pos,
int end_pos)
{
g_return_if_fail (GTK_IS_EDITABLE (editable));
GTK_EDITABLE_GET_IFACE (editable)->do_delete_text (editable, start_pos, end_pos);
}
/**
* gtk_editable_get_chars:
2021-02-25 14:53:51 +00:00
* @editable: a `GtkEditable`
* @start_pos: start of text
* @end_pos: end of text
*
2021-02-25 14:53:51 +00:00
* Retrieves a sequence of characters.
*
* The characters that are retrieved are those characters at positions
* from @start_pos up to, but not including @end_pos. If @end_pos is negative,
* then the characters retrieved are those characters from @start_pos to
* the end of the text.
*
* Note that positions are specified in characters, not bytes.
*
* Returns: (transfer full): a pointer to the contents of the widget as a
2021-02-25 14:53:51 +00:00
* string. This string is allocated by the `GtkEditable` implementation
* and should be freed by the caller.
*/
2021-02-25 14:53:51 +00:00
char *
Make parent_class static. Sun Nov 5 04:24:53 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkcellrenderertextpixbuf.c: Make parent_class static. Tue Sep 19 10:54:22 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimcontext*.[ch] gtk/gtkimmulticontext.[ch] gtk/gtktextlayout.[ch] gtk/gtktextview.c gtk/gtkentry.c: Add support for positioning the cursor within the preedit string. Mon Sep 18 23:56:32 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextview.c: Check for bindings after passing events to im context filter. Mon Sep 18 11:50:51 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextlayout.c (add_preedit_attrs): Handle empty attribute lists properly. Sun Sep 17 10:08:16 2000 Owen Taylor <otaylor@redhat.com> * gtk/queryimmodules.c (main): Return non-zero exit status if errors were encountered querying any modules. Sat Sep 16 14:01:52 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtk.h: include gtkmodule.h gtkoldeditable.h, don't include gtkthemes.h. * gtk/testgtk.c gtk/testtext.c: Set environment variables to point * gtk/Makefile.am: Add new .c and .h files, build gtk-query-immodules and use it to create a gtk.immodules file for use of test programs. * gtk/gtkpreview.c: remove extra blank line. Sat Sep 16 13:21:04 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimcontextsimple.c (gtk_im_context_simple_add_table): Add the ability to add extra tables beyond the default one, and also the ability to have compose sequences that are prefixes of other compose sequences. * gtk/gtkimcontextsimple.c: Export a preedit string which consists of possible candidates for keystrokes that have been entered but not yet committed. * gtk/gtkimcontext.[ch] gtk/immulticontext.[ch] gtk/gtkimcontextsimple.[ch]: add gtk_im_context_reset() * gtk/gtkmulticontext.[ch] (gtk_im_multicontext_append_menuitems): Add a function to add input-method switching menu items to a menu. * gtk/gtkimmulticontext.[ch]: Properly handly set_client_window when switching input methods. * gtk/gtkimcontextsimple.[ch]: Change the format of the compose table to allow compose tables of different lengths / sequence. Sat Sep 16 13:05:48 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimmodule.[ch]: Support routines for loading GtkIMContext implementations dynamically at runtime. * gtk/queryimmodules.c: Program to query the available input modules and write the results into a file. * gtk/gtkrc.[ch] (gtk_rc_get_im_module_file): Add extra config options "im_module_file" (cache file for input method modules), and "im_module_path" - path to look for modules when generating cache file. This doesn't scale. Sat Sep 16 13:09:06 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkthemes.[ch] gtk/gtkmodule.[ch]: Move most of the generic code from gtkthemes into a new abstraction GtkModule which has the logic for implementing a loadable module which implements a number of GObject types. Sat Sep 16 13:07:13 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkeditable.[ch]: Convert GtkEditable from a class into an interface * gtk/gtkoldeditable.[ch]: Move the old editable implementation into here, so legacy widgets can still rely on the implemenation. GtkOldEditable exports GtkEditable. Make selection handling code use new text conversion functions (and handle UTF-8 as a side-effect). Use GtkClipboard for CLIPBOARD. * gtk/gtktext.[ch] gtk/gtkcombo.c gtk/gtkspinbutton.c: Adopt to match above changes. * gtk/gtkentry.[ch]: Implement GtkEditable directly, avoid GtkOldEditable implementation. Restructure to reduce number of places that modify state directly. Move to GtkBindingSet. Display the preedit string. Queue recomputation of PangoLayout and scroll position to improve effiency of doing complex changes naively. Add a menu with cut/copy/paste and input method selection. Thu Sep 14 22:11:05 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextlayout.[ch]: Add gtk_text_layout_set_preedit_string() to set preedit string and attributes; display preedit string by inserting string and attributes at cursor when creating the GtkTextLineDisplay. * gtk/gtktextlayout.c: Move all conversions between byte positions in PangoLayout and GtkTextIter into new functions line_display_iter_to_index/index_to_iter that properly handle the preedit string. * gtk/gtktextmark.[ch]: Restore gtk_text_mark_get_name, modify it to return const char * (eventually will end up as GCONST char *, most likely.) * gtk/gtktextview.[ch]: Handle the preedit string, call gtk_im_context_reset() as necessary, add a menu to switch input methods. * gtk/gtktextlayout.[ch]: Remove useless gtk_text_layout_get_log_attrs() function.
2000-11-12 03:43:24 +00:00
gtk_editable_get_chars (GtkEditable *editable,
int start_pos,
int end_pos)
{
const char *text;
int length;
int start_index,end_index;
g_return_val_if_fail (GTK_IS_EDITABLE (editable), NULL);
text = GTK_EDITABLE_GET_IFACE (editable)->get_text (editable);
length = g_utf8_strlen (text, -1);
if (end_pos < 0)
end_pos = length;
start_pos = MIN (length, start_pos);
end_pos = MIN (length, end_pos);
start_index = g_utf8_offset_to_pointer (text, start_pos) - text;
end_index = g_utf8_offset_to_pointer (text, end_pos) - text;
return g_strndup (text + start_index, end_index - start_index);
}
/**
2021-02-25 14:53:51 +00:00
* gtk_editable_get_text: (attributes org.gtk.Method.get_property=text)
* @editable: a `GtkEditable`
*
* Retrieves the contents of @editable.
*
2021-02-25 14:53:51 +00:00
* The returned string is owned by GTK and must not be modified or freed.
*
2021-02-25 14:53:51 +00:00
* Returns: (transfer none): a pointer to the contents of the editable
*/
const char *
gtk_editable_get_text (GtkEditable *editable)
{
g_return_val_if_fail (GTK_IS_EDITABLE (editable), NULL);
return GTK_EDITABLE_GET_IFACE (editable)->get_text (editable);
}
/**
2021-02-25 14:53:51 +00:00
* gtk_editable_set_text: (attributes org.gtk.Method.set_property=text)
* @editable: a `GtkEditable`
* @text: the text to set
*
2021-02-25 14:53:51 +00:00
* Sets the text in the editable to the given value.
*
* This is replacing the current contents.
*/
void
gtk_editable_set_text (GtkEditable *editable,
const char *text)
{
int pos;
g_return_if_fail (GTK_IS_EDITABLE (editable));
g_object_freeze_notify (G_OBJECT (editable));
gtk_editable_delete_text (editable, 0, -1);
pos = 0;
gtk_editable_insert_text (editable, text, -1, &pos);
g_object_thaw_notify (G_OBJECT (editable));
}
/**
2021-02-25 14:53:51 +00:00
* gtk_editable_set_position: (attributes org.gtk.Method.set_property=cursor-position)
* @editable: a `GtkEditable`
* @position: the position of the cursor
*
* Sets the cursor position in the editable to the given value.
*
2021-02-25 14:53:51 +00:00
* The cursor is displayed before the character with the given (base 0)
* index in the contents of the editable. The value must be less than
* or equal to the number of characters in the editable. A value of -1
* indicates that the position should be set after the last character
* of the editable. Note that @position is in characters, not in bytes.
*/
void
gtk_editable_set_position (GtkEditable *editable,
int position)
{
g_return_if_fail (GTK_IS_EDITABLE (editable));
GTK_EDITABLE_GET_IFACE (editable)->set_selection_bounds (editable, position, position);
}
/**
2021-02-25 14:53:51 +00:00
* gtk_editable_get_position: (attributes org.gtk.Method.get_property=cursor-position)
* @editable: a `GtkEditable`
*
* Retrieves the current position of the cursor relative
* to the start of the content of the editable.
*
* Note that this position is in characters, not in bytes.
*
* Returns: the cursor position
*/
int
gtk_editable_get_position (GtkEditable *editable)
{
int start, end;
Make parent_class static. Sun Nov 5 04:24:53 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkcellrenderertextpixbuf.c: Make parent_class static. Tue Sep 19 10:54:22 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimcontext*.[ch] gtk/gtkimmulticontext.[ch] gtk/gtktextlayout.[ch] gtk/gtktextview.c gtk/gtkentry.c: Add support for positioning the cursor within the preedit string. Mon Sep 18 23:56:32 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextview.c: Check for bindings after passing events to im context filter. Mon Sep 18 11:50:51 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextlayout.c (add_preedit_attrs): Handle empty attribute lists properly. Sun Sep 17 10:08:16 2000 Owen Taylor <otaylor@redhat.com> * gtk/queryimmodules.c (main): Return non-zero exit status if errors were encountered querying any modules. Sat Sep 16 14:01:52 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtk.h: include gtkmodule.h gtkoldeditable.h, don't include gtkthemes.h. * gtk/testgtk.c gtk/testtext.c: Set environment variables to point * gtk/Makefile.am: Add new .c and .h files, build gtk-query-immodules and use it to create a gtk.immodules file for use of test programs. * gtk/gtkpreview.c: remove extra blank line. Sat Sep 16 13:21:04 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimcontextsimple.c (gtk_im_context_simple_add_table): Add the ability to add extra tables beyond the default one, and also the ability to have compose sequences that are prefixes of other compose sequences. * gtk/gtkimcontextsimple.c: Export a preedit string which consists of possible candidates for keystrokes that have been entered but not yet committed. * gtk/gtkimcontext.[ch] gtk/immulticontext.[ch] gtk/gtkimcontextsimple.[ch]: add gtk_im_context_reset() * gtk/gtkmulticontext.[ch] (gtk_im_multicontext_append_menuitems): Add a function to add input-method switching menu items to a menu. * gtk/gtkimmulticontext.[ch]: Properly handly set_client_window when switching input methods. * gtk/gtkimcontextsimple.[ch]: Change the format of the compose table to allow compose tables of different lengths / sequence. Sat Sep 16 13:05:48 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimmodule.[ch]: Support routines for loading GtkIMContext implementations dynamically at runtime. * gtk/queryimmodules.c: Program to query the available input modules and write the results into a file. * gtk/gtkrc.[ch] (gtk_rc_get_im_module_file): Add extra config options "im_module_file" (cache file for input method modules), and "im_module_path" - path to look for modules when generating cache file. This doesn't scale. Sat Sep 16 13:09:06 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkthemes.[ch] gtk/gtkmodule.[ch]: Move most of the generic code from gtkthemes into a new abstraction GtkModule which has the logic for implementing a loadable module which implements a number of GObject types. Sat Sep 16 13:07:13 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkeditable.[ch]: Convert GtkEditable from a class into an interface * gtk/gtkoldeditable.[ch]: Move the old editable implementation into here, so legacy widgets can still rely on the implemenation. GtkOldEditable exports GtkEditable. Make selection handling code use new text conversion functions (and handle UTF-8 as a side-effect). Use GtkClipboard for CLIPBOARD. * gtk/gtktext.[ch] gtk/gtkcombo.c gtk/gtkspinbutton.c: Adopt to match above changes. * gtk/gtkentry.[ch]: Implement GtkEditable directly, avoid GtkOldEditable implementation. Restructure to reduce number of places that modify state directly. Move to GtkBindingSet. Display the preedit string. Queue recomputation of PangoLayout and scroll position to improve effiency of doing complex changes naively. Add a menu with cut/copy/paste and input method selection. Thu Sep 14 22:11:05 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextlayout.[ch]: Add gtk_text_layout_set_preedit_string() to set preedit string and attributes; display preedit string by inserting string and attributes at cursor when creating the GtkTextLineDisplay. * gtk/gtktextlayout.c: Move all conversions between byte positions in PangoLayout and GtkTextIter into new functions line_display_iter_to_index/index_to_iter that properly handle the preedit string. * gtk/gtktextmark.[ch]: Restore gtk_text_mark_get_name, modify it to return const char * (eventually will end up as GCONST char *, most likely.) * gtk/gtktextview.[ch]: Handle the preedit string, call gtk_im_context_reset() as necessary, add a menu to switch input methods. * gtk/gtktextlayout.[ch]: Remove useless gtk_text_layout_get_log_attrs() function.
2000-11-12 03:43:24 +00:00
g_return_val_if_fail (GTK_IS_EDITABLE (editable), 0);
GTK_EDITABLE_GET_IFACE (editable)->get_selection_bounds (editable, &start, &end);
return end;
}
/**
* gtk_editable_get_selection_bounds:
2021-02-25 14:53:51 +00:00
* @editable: a `GtkEditable`
* @start_pos: (out) (optional): location to store the starting position
* @end_pos: (out) (optional): location to store the end position
*
* Retrieves the selection bound of the editable.
2021-02-25 14:53:51 +00:00
*
* @start_pos will be filled with the start of the selection and
* @end_pos with end. If no text was selected both will be identical
* and %FALSE will be returned.
*
* Note that positions are specified in characters, not bytes.
*
* Returns: %TRUE if there is a non-empty selection, %FALSE otherwise
*/
Make parent_class static. Sun Nov 5 04:24:53 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkcellrenderertextpixbuf.c: Make parent_class static. Tue Sep 19 10:54:22 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimcontext*.[ch] gtk/gtkimmulticontext.[ch] gtk/gtktextlayout.[ch] gtk/gtktextview.c gtk/gtkentry.c: Add support for positioning the cursor within the preedit string. Mon Sep 18 23:56:32 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextview.c: Check for bindings after passing events to im context filter. Mon Sep 18 11:50:51 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextlayout.c (add_preedit_attrs): Handle empty attribute lists properly. Sun Sep 17 10:08:16 2000 Owen Taylor <otaylor@redhat.com> * gtk/queryimmodules.c (main): Return non-zero exit status if errors were encountered querying any modules. Sat Sep 16 14:01:52 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtk.h: include gtkmodule.h gtkoldeditable.h, don't include gtkthemes.h. * gtk/testgtk.c gtk/testtext.c: Set environment variables to point * gtk/Makefile.am: Add new .c and .h files, build gtk-query-immodules and use it to create a gtk.immodules file for use of test programs. * gtk/gtkpreview.c: remove extra blank line. Sat Sep 16 13:21:04 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimcontextsimple.c (gtk_im_context_simple_add_table): Add the ability to add extra tables beyond the default one, and also the ability to have compose sequences that are prefixes of other compose sequences. * gtk/gtkimcontextsimple.c: Export a preedit string which consists of possible candidates for keystrokes that have been entered but not yet committed. * gtk/gtkimcontext.[ch] gtk/immulticontext.[ch] gtk/gtkimcontextsimple.[ch]: add gtk_im_context_reset() * gtk/gtkmulticontext.[ch] (gtk_im_multicontext_append_menuitems): Add a function to add input-method switching menu items to a menu. * gtk/gtkimmulticontext.[ch]: Properly handly set_client_window when switching input methods. * gtk/gtkimcontextsimple.[ch]: Change the format of the compose table to allow compose tables of different lengths / sequence. Sat Sep 16 13:05:48 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimmodule.[ch]: Support routines for loading GtkIMContext implementations dynamically at runtime. * gtk/queryimmodules.c: Program to query the available input modules and write the results into a file. * gtk/gtkrc.[ch] (gtk_rc_get_im_module_file): Add extra config options "im_module_file" (cache file for input method modules), and "im_module_path" - path to look for modules when generating cache file. This doesn't scale. Sat Sep 16 13:09:06 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkthemes.[ch] gtk/gtkmodule.[ch]: Move most of the generic code from gtkthemes into a new abstraction GtkModule which has the logic for implementing a loadable module which implements a number of GObject types. Sat Sep 16 13:07:13 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkeditable.[ch]: Convert GtkEditable from a class into an interface * gtk/gtkoldeditable.[ch]: Move the old editable implementation into here, so legacy widgets can still rely on the implemenation. GtkOldEditable exports GtkEditable. Make selection handling code use new text conversion functions (and handle UTF-8 as a side-effect). Use GtkClipboard for CLIPBOARD. * gtk/gtktext.[ch] gtk/gtkcombo.c gtk/gtkspinbutton.c: Adopt to match above changes. * gtk/gtkentry.[ch]: Implement GtkEditable directly, avoid GtkOldEditable implementation. Restructure to reduce number of places that modify state directly. Move to GtkBindingSet. Display the preedit string. Queue recomputation of PangoLayout and scroll position to improve effiency of doing complex changes naively. Add a menu with cut/copy/paste and input method selection. Thu Sep 14 22:11:05 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextlayout.[ch]: Add gtk_text_layout_set_preedit_string() to set preedit string and attributes; display preedit string by inserting string and attributes at cursor when creating the GtkTextLineDisplay. * gtk/gtktextlayout.c: Move all conversions between byte positions in PangoLayout and GtkTextIter into new functions line_display_iter_to_index/index_to_iter that properly handle the preedit string. * gtk/gtktextmark.[ch]: Restore gtk_text_mark_get_name, modify it to return const char * (eventually will end up as GCONST char *, most likely.) * gtk/gtktextview.[ch]: Handle the preedit string, call gtk_im_context_reset() as necessary, add a menu to switch input methods. * gtk/gtktextlayout.[ch]: Remove useless gtk_text_layout_get_log_attrs() function.
2000-11-12 03:43:24 +00:00
gboolean
gtk_editable_get_selection_bounds (GtkEditable *editable,
int *start_pos,
int *end_pos)
{
int tmp_start, tmp_end;
Make parent_class static. Sun Nov 5 04:24:53 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkcellrenderertextpixbuf.c: Make parent_class static. Tue Sep 19 10:54:22 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimcontext*.[ch] gtk/gtkimmulticontext.[ch] gtk/gtktextlayout.[ch] gtk/gtktextview.c gtk/gtkentry.c: Add support for positioning the cursor within the preedit string. Mon Sep 18 23:56:32 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextview.c: Check for bindings after passing events to im context filter. Mon Sep 18 11:50:51 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextlayout.c (add_preedit_attrs): Handle empty attribute lists properly. Sun Sep 17 10:08:16 2000 Owen Taylor <otaylor@redhat.com> * gtk/queryimmodules.c (main): Return non-zero exit status if errors were encountered querying any modules. Sat Sep 16 14:01:52 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtk.h: include gtkmodule.h gtkoldeditable.h, don't include gtkthemes.h. * gtk/testgtk.c gtk/testtext.c: Set environment variables to point * gtk/Makefile.am: Add new .c and .h files, build gtk-query-immodules and use it to create a gtk.immodules file for use of test programs. * gtk/gtkpreview.c: remove extra blank line. Sat Sep 16 13:21:04 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimcontextsimple.c (gtk_im_context_simple_add_table): Add the ability to add extra tables beyond the default one, and also the ability to have compose sequences that are prefixes of other compose sequences. * gtk/gtkimcontextsimple.c: Export a preedit string which consists of possible candidates for keystrokes that have been entered but not yet committed. * gtk/gtkimcontext.[ch] gtk/immulticontext.[ch] gtk/gtkimcontextsimple.[ch]: add gtk_im_context_reset() * gtk/gtkmulticontext.[ch] (gtk_im_multicontext_append_menuitems): Add a function to add input-method switching menu items to a menu. * gtk/gtkimmulticontext.[ch]: Properly handly set_client_window when switching input methods. * gtk/gtkimcontextsimple.[ch]: Change the format of the compose table to allow compose tables of different lengths / sequence. Sat Sep 16 13:05:48 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimmodule.[ch]: Support routines for loading GtkIMContext implementations dynamically at runtime. * gtk/queryimmodules.c: Program to query the available input modules and write the results into a file. * gtk/gtkrc.[ch] (gtk_rc_get_im_module_file): Add extra config options "im_module_file" (cache file for input method modules), and "im_module_path" - path to look for modules when generating cache file. This doesn't scale. Sat Sep 16 13:09:06 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkthemes.[ch] gtk/gtkmodule.[ch]: Move most of the generic code from gtkthemes into a new abstraction GtkModule which has the logic for implementing a loadable module which implements a number of GObject types. Sat Sep 16 13:07:13 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkeditable.[ch]: Convert GtkEditable from a class into an interface * gtk/gtkoldeditable.[ch]: Move the old editable implementation into here, so legacy widgets can still rely on the implemenation. GtkOldEditable exports GtkEditable. Make selection handling code use new text conversion functions (and handle UTF-8 as a side-effect). Use GtkClipboard for CLIPBOARD. * gtk/gtktext.[ch] gtk/gtkcombo.c gtk/gtkspinbutton.c: Adopt to match above changes. * gtk/gtkentry.[ch]: Implement GtkEditable directly, avoid GtkOldEditable implementation. Restructure to reduce number of places that modify state directly. Move to GtkBindingSet. Display the preedit string. Queue recomputation of PangoLayout and scroll position to improve effiency of doing complex changes naively. Add a menu with cut/copy/paste and input method selection. Thu Sep 14 22:11:05 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextlayout.[ch]: Add gtk_text_layout_set_preedit_string() to set preedit string and attributes; display preedit string by inserting string and attributes at cursor when creating the GtkTextLineDisplay. * gtk/gtktextlayout.c: Move all conversions between byte positions in PangoLayout and GtkTextIter into new functions line_display_iter_to_index/index_to_iter that properly handle the preedit string. * gtk/gtktextmark.[ch]: Restore gtk_text_mark_get_name, modify it to return const char * (eventually will end up as GCONST char *, most likely.) * gtk/gtktextview.[ch]: Handle the preedit string, call gtk_im_context_reset() as necessary, add a menu to switch input methods. * gtk/gtktextlayout.[ch]: Remove useless gtk_text_layout_get_log_attrs() function.
2000-11-12 03:43:24 +00:00
gboolean result;
2021-02-25 14:53:51 +00:00
Make parent_class static. Sun Nov 5 04:24:53 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkcellrenderertextpixbuf.c: Make parent_class static. Tue Sep 19 10:54:22 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimcontext*.[ch] gtk/gtkimmulticontext.[ch] gtk/gtktextlayout.[ch] gtk/gtktextview.c gtk/gtkentry.c: Add support for positioning the cursor within the preedit string. Mon Sep 18 23:56:32 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextview.c: Check for bindings after passing events to im context filter. Mon Sep 18 11:50:51 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextlayout.c (add_preedit_attrs): Handle empty attribute lists properly. Sun Sep 17 10:08:16 2000 Owen Taylor <otaylor@redhat.com> * gtk/queryimmodules.c (main): Return non-zero exit status if errors were encountered querying any modules. Sat Sep 16 14:01:52 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtk.h: include gtkmodule.h gtkoldeditable.h, don't include gtkthemes.h. * gtk/testgtk.c gtk/testtext.c: Set environment variables to point * gtk/Makefile.am: Add new .c and .h files, build gtk-query-immodules and use it to create a gtk.immodules file for use of test programs. * gtk/gtkpreview.c: remove extra blank line. Sat Sep 16 13:21:04 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimcontextsimple.c (gtk_im_context_simple_add_table): Add the ability to add extra tables beyond the default one, and also the ability to have compose sequences that are prefixes of other compose sequences. * gtk/gtkimcontextsimple.c: Export a preedit string which consists of possible candidates for keystrokes that have been entered but not yet committed. * gtk/gtkimcontext.[ch] gtk/immulticontext.[ch] gtk/gtkimcontextsimple.[ch]: add gtk_im_context_reset() * gtk/gtkmulticontext.[ch] (gtk_im_multicontext_append_menuitems): Add a function to add input-method switching menu items to a menu. * gtk/gtkimmulticontext.[ch]: Properly handly set_client_window when switching input methods. * gtk/gtkimcontextsimple.[ch]: Change the format of the compose table to allow compose tables of different lengths / sequence. Sat Sep 16 13:05:48 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimmodule.[ch]: Support routines for loading GtkIMContext implementations dynamically at runtime. * gtk/queryimmodules.c: Program to query the available input modules and write the results into a file. * gtk/gtkrc.[ch] (gtk_rc_get_im_module_file): Add extra config options "im_module_file" (cache file for input method modules), and "im_module_path" - path to look for modules when generating cache file. This doesn't scale. Sat Sep 16 13:09:06 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkthemes.[ch] gtk/gtkmodule.[ch]: Move most of the generic code from gtkthemes into a new abstraction GtkModule which has the logic for implementing a loadable module which implements a number of GObject types. Sat Sep 16 13:07:13 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkeditable.[ch]: Convert GtkEditable from a class into an interface * gtk/gtkoldeditable.[ch]: Move the old editable implementation into here, so legacy widgets can still rely on the implemenation. GtkOldEditable exports GtkEditable. Make selection handling code use new text conversion functions (and handle UTF-8 as a side-effect). Use GtkClipboard for CLIPBOARD. * gtk/gtktext.[ch] gtk/gtkcombo.c gtk/gtkspinbutton.c: Adopt to match above changes. * gtk/gtkentry.[ch]: Implement GtkEditable directly, avoid GtkOldEditable implementation. Restructure to reduce number of places that modify state directly. Move to GtkBindingSet. Display the preedit string. Queue recomputation of PangoLayout and scroll position to improve effiency of doing complex changes naively. Add a menu with cut/copy/paste and input method selection. Thu Sep 14 22:11:05 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextlayout.[ch]: Add gtk_text_layout_set_preedit_string() to set preedit string and attributes; display preedit string by inserting string and attributes at cursor when creating the GtkTextLineDisplay. * gtk/gtktextlayout.c: Move all conversions between byte positions in PangoLayout and GtkTextIter into new functions line_display_iter_to_index/index_to_iter that properly handle the preedit string. * gtk/gtktextmark.[ch]: Restore gtk_text_mark_get_name, modify it to return const char * (eventually will end up as GCONST char *, most likely.) * gtk/gtktextview.[ch]: Handle the preedit string, call gtk_im_context_reset() as necessary, add a menu to switch input methods. * gtk/gtktextlayout.[ch]: Remove useless gtk_text_layout_get_log_attrs() function.
2000-11-12 03:43:24 +00:00
g_return_val_if_fail (GTK_IS_EDITABLE (editable), FALSE);
result = GTK_EDITABLE_GET_IFACE (editable)->get_selection_bounds (editable, &tmp_start, &tmp_end);
Make parent_class static. Sun Nov 5 04:24:53 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkcellrenderertextpixbuf.c: Make parent_class static. Tue Sep 19 10:54:22 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimcontext*.[ch] gtk/gtkimmulticontext.[ch] gtk/gtktextlayout.[ch] gtk/gtktextview.c gtk/gtkentry.c: Add support for positioning the cursor within the preedit string. Mon Sep 18 23:56:32 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextview.c: Check for bindings after passing events to im context filter. Mon Sep 18 11:50:51 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextlayout.c (add_preedit_attrs): Handle empty attribute lists properly. Sun Sep 17 10:08:16 2000 Owen Taylor <otaylor@redhat.com> * gtk/queryimmodules.c (main): Return non-zero exit status if errors were encountered querying any modules. Sat Sep 16 14:01:52 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtk.h: include gtkmodule.h gtkoldeditable.h, don't include gtkthemes.h. * gtk/testgtk.c gtk/testtext.c: Set environment variables to point * gtk/Makefile.am: Add new .c and .h files, build gtk-query-immodules and use it to create a gtk.immodules file for use of test programs. * gtk/gtkpreview.c: remove extra blank line. Sat Sep 16 13:21:04 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimcontextsimple.c (gtk_im_context_simple_add_table): Add the ability to add extra tables beyond the default one, and also the ability to have compose sequences that are prefixes of other compose sequences. * gtk/gtkimcontextsimple.c: Export a preedit string which consists of possible candidates for keystrokes that have been entered but not yet committed. * gtk/gtkimcontext.[ch] gtk/immulticontext.[ch] gtk/gtkimcontextsimple.[ch]: add gtk_im_context_reset() * gtk/gtkmulticontext.[ch] (gtk_im_multicontext_append_menuitems): Add a function to add input-method switching menu items to a menu. * gtk/gtkimmulticontext.[ch]: Properly handly set_client_window when switching input methods. * gtk/gtkimcontextsimple.[ch]: Change the format of the compose table to allow compose tables of different lengths / sequence. Sat Sep 16 13:05:48 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimmodule.[ch]: Support routines for loading GtkIMContext implementations dynamically at runtime. * gtk/queryimmodules.c: Program to query the available input modules and write the results into a file. * gtk/gtkrc.[ch] (gtk_rc_get_im_module_file): Add extra config options "im_module_file" (cache file for input method modules), and "im_module_path" - path to look for modules when generating cache file. This doesn't scale. Sat Sep 16 13:09:06 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkthemes.[ch] gtk/gtkmodule.[ch]: Move most of the generic code from gtkthemes into a new abstraction GtkModule which has the logic for implementing a loadable module which implements a number of GObject types. Sat Sep 16 13:07:13 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkeditable.[ch]: Convert GtkEditable from a class into an interface * gtk/gtkoldeditable.[ch]: Move the old editable implementation into here, so legacy widgets can still rely on the implemenation. GtkOldEditable exports GtkEditable. Make selection handling code use new text conversion functions (and handle UTF-8 as a side-effect). Use GtkClipboard for CLIPBOARD. * gtk/gtktext.[ch] gtk/gtkcombo.c gtk/gtkspinbutton.c: Adopt to match above changes. * gtk/gtkentry.[ch]: Implement GtkEditable directly, avoid GtkOldEditable implementation. Restructure to reduce number of places that modify state directly. Move to GtkBindingSet. Display the preedit string. Queue recomputation of PangoLayout and scroll position to improve effiency of doing complex changes naively. Add a menu with cut/copy/paste and input method selection. Thu Sep 14 22:11:05 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextlayout.[ch]: Add gtk_text_layout_set_preedit_string() to set preedit string and attributes; display preedit string by inserting string and attributes at cursor when creating the GtkTextLineDisplay. * gtk/gtktextlayout.c: Move all conversions between byte positions in PangoLayout and GtkTextIter into new functions line_display_iter_to_index/index_to_iter that properly handle the preedit string. * gtk/gtktextmark.[ch]: Restore gtk_text_mark_get_name, modify it to return const char * (eventually will end up as GCONST char *, most likely.) * gtk/gtktextview.[ch]: Handle the preedit string, call gtk_im_context_reset() as necessary, add a menu to switch input methods. * gtk/gtktextlayout.[ch]: Remove useless gtk_text_layout_get_log_attrs() function.
2000-11-12 03:43:24 +00:00
if (start_pos)
*start_pos = MIN (tmp_start, tmp_end);
if (end_pos)
*end_pos = MAX (tmp_start, tmp_end);
Make parent_class static. Sun Nov 5 04:24:53 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkcellrenderertextpixbuf.c: Make parent_class static. Tue Sep 19 10:54:22 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimcontext*.[ch] gtk/gtkimmulticontext.[ch] gtk/gtktextlayout.[ch] gtk/gtktextview.c gtk/gtkentry.c: Add support for positioning the cursor within the preedit string. Mon Sep 18 23:56:32 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextview.c: Check for bindings after passing events to im context filter. Mon Sep 18 11:50:51 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextlayout.c (add_preedit_attrs): Handle empty attribute lists properly. Sun Sep 17 10:08:16 2000 Owen Taylor <otaylor@redhat.com> * gtk/queryimmodules.c (main): Return non-zero exit status if errors were encountered querying any modules. Sat Sep 16 14:01:52 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtk.h: include gtkmodule.h gtkoldeditable.h, don't include gtkthemes.h. * gtk/testgtk.c gtk/testtext.c: Set environment variables to point * gtk/Makefile.am: Add new .c and .h files, build gtk-query-immodules and use it to create a gtk.immodules file for use of test programs. * gtk/gtkpreview.c: remove extra blank line. Sat Sep 16 13:21:04 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimcontextsimple.c (gtk_im_context_simple_add_table): Add the ability to add extra tables beyond the default one, and also the ability to have compose sequences that are prefixes of other compose sequences. * gtk/gtkimcontextsimple.c: Export a preedit string which consists of possible candidates for keystrokes that have been entered but not yet committed. * gtk/gtkimcontext.[ch] gtk/immulticontext.[ch] gtk/gtkimcontextsimple.[ch]: add gtk_im_context_reset() * gtk/gtkmulticontext.[ch] (gtk_im_multicontext_append_menuitems): Add a function to add input-method switching menu items to a menu. * gtk/gtkimmulticontext.[ch]: Properly handly set_client_window when switching input methods. * gtk/gtkimcontextsimple.[ch]: Change the format of the compose table to allow compose tables of different lengths / sequence. Sat Sep 16 13:05:48 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimmodule.[ch]: Support routines for loading GtkIMContext implementations dynamically at runtime. * gtk/queryimmodules.c: Program to query the available input modules and write the results into a file. * gtk/gtkrc.[ch] (gtk_rc_get_im_module_file): Add extra config options "im_module_file" (cache file for input method modules), and "im_module_path" - path to look for modules when generating cache file. This doesn't scale. Sat Sep 16 13:09:06 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkthemes.[ch] gtk/gtkmodule.[ch]: Move most of the generic code from gtkthemes into a new abstraction GtkModule which has the logic for implementing a loadable module which implements a number of GObject types. Sat Sep 16 13:07:13 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkeditable.[ch]: Convert GtkEditable from a class into an interface * gtk/gtkoldeditable.[ch]: Move the old editable implementation into here, so legacy widgets can still rely on the implemenation. GtkOldEditable exports GtkEditable. Make selection handling code use new text conversion functions (and handle UTF-8 as a side-effect). Use GtkClipboard for CLIPBOARD. * gtk/gtktext.[ch] gtk/gtkcombo.c gtk/gtkspinbutton.c: Adopt to match above changes. * gtk/gtkentry.[ch]: Implement GtkEditable directly, avoid GtkOldEditable implementation. Restructure to reduce number of places that modify state directly. Move to GtkBindingSet. Display the preedit string. Queue recomputation of PangoLayout and scroll position to improve effiency of doing complex changes naively. Add a menu with cut/copy/paste and input method selection. Thu Sep 14 22:11:05 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextlayout.[ch]: Add gtk_text_layout_set_preedit_string() to set preedit string and attributes; display preedit string by inserting string and attributes at cursor when creating the GtkTextLineDisplay. * gtk/gtktextlayout.c: Move all conversions between byte positions in PangoLayout and GtkTextIter into new functions line_display_iter_to_index/index_to_iter that properly handle the preedit string. * gtk/gtktextmark.[ch]: Restore gtk_text_mark_get_name, modify it to return const char * (eventually will end up as GCONST char *, most likely.) * gtk/gtktextview.[ch]: Handle the preedit string, call gtk_im_context_reset() as necessary, add a menu to switch input methods. * gtk/gtktextlayout.[ch]: Remove useless gtk_text_layout_get_log_attrs() function.
2000-11-12 03:43:24 +00:00
return result;
}
/**
* gtk_editable_delete_selection:
2021-02-25 14:53:51 +00:00
* @editable: a `GtkEditable`
*
* Deletes the currently selected text of the editable.
2021-02-25 14:53:51 +00:00
*
2014-02-07 18:32:47 +00:00
* This call doesnt do anything if there is no selected text.
*/
void
gtk_editable_delete_selection (GtkEditable *editable)
{
int start, end;
g_return_if_fail (GTK_IS_EDITABLE (editable));
Make parent_class static. Sun Nov 5 04:24:53 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkcellrenderertextpixbuf.c: Make parent_class static. Tue Sep 19 10:54:22 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimcontext*.[ch] gtk/gtkimmulticontext.[ch] gtk/gtktextlayout.[ch] gtk/gtktextview.c gtk/gtkentry.c: Add support for positioning the cursor within the preedit string. Mon Sep 18 23:56:32 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextview.c: Check for bindings after passing events to im context filter. Mon Sep 18 11:50:51 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextlayout.c (add_preedit_attrs): Handle empty attribute lists properly. Sun Sep 17 10:08:16 2000 Owen Taylor <otaylor@redhat.com> * gtk/queryimmodules.c (main): Return non-zero exit status if errors were encountered querying any modules. Sat Sep 16 14:01:52 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtk.h: include gtkmodule.h gtkoldeditable.h, don't include gtkthemes.h. * gtk/testgtk.c gtk/testtext.c: Set environment variables to point * gtk/Makefile.am: Add new .c and .h files, build gtk-query-immodules and use it to create a gtk.immodules file for use of test programs. * gtk/gtkpreview.c: remove extra blank line. Sat Sep 16 13:21:04 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimcontextsimple.c (gtk_im_context_simple_add_table): Add the ability to add extra tables beyond the default one, and also the ability to have compose sequences that are prefixes of other compose sequences. * gtk/gtkimcontextsimple.c: Export a preedit string which consists of possible candidates for keystrokes that have been entered but not yet committed. * gtk/gtkimcontext.[ch] gtk/immulticontext.[ch] gtk/gtkimcontextsimple.[ch]: add gtk_im_context_reset() * gtk/gtkmulticontext.[ch] (gtk_im_multicontext_append_menuitems): Add a function to add input-method switching menu items to a menu. * gtk/gtkimmulticontext.[ch]: Properly handly set_client_window when switching input methods. * gtk/gtkimcontextsimple.[ch]: Change the format of the compose table to allow compose tables of different lengths / sequence. Sat Sep 16 13:05:48 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkimmodule.[ch]: Support routines for loading GtkIMContext implementations dynamically at runtime. * gtk/queryimmodules.c: Program to query the available input modules and write the results into a file. * gtk/gtkrc.[ch] (gtk_rc_get_im_module_file): Add extra config options "im_module_file" (cache file for input method modules), and "im_module_path" - path to look for modules when generating cache file. This doesn't scale. Sat Sep 16 13:09:06 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkthemes.[ch] gtk/gtkmodule.[ch]: Move most of the generic code from gtkthemes into a new abstraction GtkModule which has the logic for implementing a loadable module which implements a number of GObject types. Sat Sep 16 13:07:13 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtkeditable.[ch]: Convert GtkEditable from a class into an interface * gtk/gtkoldeditable.[ch]: Move the old editable implementation into here, so legacy widgets can still rely on the implemenation. GtkOldEditable exports GtkEditable. Make selection handling code use new text conversion functions (and handle UTF-8 as a side-effect). Use GtkClipboard for CLIPBOARD. * gtk/gtktext.[ch] gtk/gtkcombo.c gtk/gtkspinbutton.c: Adopt to match above changes. * gtk/gtkentry.[ch]: Implement GtkEditable directly, avoid GtkOldEditable implementation. Restructure to reduce number of places that modify state directly. Move to GtkBindingSet. Display the preedit string. Queue recomputation of PangoLayout and scroll position to improve effiency of doing complex changes naively. Add a menu with cut/copy/paste and input method selection. Thu Sep 14 22:11:05 2000 Owen Taylor <otaylor@redhat.com> * gtk/gtktextlayout.[ch]: Add gtk_text_layout_set_preedit_string() to set preedit string and attributes; display preedit string by inserting string and attributes at cursor when creating the GtkTextLineDisplay. * gtk/gtktextlayout.c: Move all conversions between byte positions in PangoLayout and GtkTextIter into new functions line_display_iter_to_index/index_to_iter that properly handle the preedit string. * gtk/gtktextmark.[ch]: Restore gtk_text_mark_get_name, modify it to return const char * (eventually will end up as GCONST char *, most likely.) * gtk/gtktextview.[ch]: Handle the preedit string, call gtk_im_context_reset() as necessary, add a menu to switch input methods. * gtk/gtktextlayout.[ch]: Remove useless gtk_text_layout_get_log_attrs() function.
2000-11-12 03:43:24 +00:00
if (gtk_editable_get_selection_bounds (editable, &start, &end))
gtk_editable_delete_text (editable, start, end);
}
/**
2013-10-09 18:09:35 +00:00
* gtk_editable_select_region: (virtual set_selection_bounds)
2021-02-25 14:53:51 +00:00
* @editable: a `GtkEditable`
* @start_pos: start of region
* @end_pos: end of region
*
* Selects a region of text.
2021-02-25 14:53:51 +00:00
*
* The characters that are selected are those characters at positions
* from @start_pos up to, but not including @end_pos. If @end_pos is
* negative, then the characters selected are those characters from
* @start_pos to the end of the text.
2021-02-25 14:53:51 +00:00
*
* Note that positions are specified in characters, not bytes.
*/
void
gtk_editable_select_region (GtkEditable *editable,
int start_pos,
int end_pos)
{
g_return_if_fail (GTK_IS_EDITABLE (editable));
2021-02-25 14:53:51 +00:00
GTK_EDITABLE_GET_IFACE (editable)->set_selection_bounds (editable, start_pos, end_pos);
Remove --g-fatal-warnings flag from argv. Thu Jun 18 21:13:54 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkmain.c (gtk_init): Remove --g-fatal-warnings flag from argv. Thu Jun 18 20:22:28 1998 Owen Taylor <otaylor@gtk.org> * gtk/genmarshal.pl: Modified to be more idiomatic Perl, to be more readable perl, to spit out stuff that looks more like readable C, and to pipe output through indent so output looks a lot like readable C. No functional changes. Thu Jun 18 17:43:31 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkpixmap.[ch] (gtk_pixmap_set): Clear the background if necessary when switching to a masked pixmap. (Based on a patch from Ullrich Hafner <hafner@informatik.uni-wuerzburg.de>) Thu Jun 18 16:18:10 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkeditable.[ch]: Added action signals for keyboard bindings. (move_cursor, kill_word, etc, etc, etc). removed the time argument from gtk_editable_cut/copy/paste_clipboard (source but not binary incompatible...) Instead get time from gtk_get_current_event (). * gtk/gtktext.c gtk/gtkentry.c: Support the new editable signals. Thu Jun 18 02:52:09 1998 Owen Taylor <otaylor@gtk.org> Patches from Damon Chaplin <DAChaplin@email.msn.com>: gtk/gtkfontsel.h: Fixed GtkFontSelectionClass - I forgot to change parent class to GtkNotebookClass when splitting the widget in two. Also updated some comments. gtk/gtkfontsel.c: Fixed bug when toggling 'Allow scaled bitmaps' button without a font selected. Fixed bug in set_font_name - I hadn't updated the code to search for the style in the font_style clist - it was still assuming the style row was equal to its index, but it isn't any more. Changed 'Reset' button on filter page to 'Clear Filter'. Deleted old code relating to the old 'Filter Fonts' toggle Updated some comments. Cleared 'Actual Fontname' if no font is set. gtk/testgtk.c: Fixed problem when 'OK' button is pressed - it was destroying the GtkFontSelection instead of the GtkFontSelectionDialog. Thu Jun 18 02:15:31 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkmain.c (gtk_init): Added --g-fatal-warnings flag to make all warnings fatal errors. * gtk/testthreads.c: moved <pthreads.h> include inside #ifdef USE_PTHREADS Thu Jun 18 01:37:31 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkenums.h gtk/gtkcontainer.[ch] gtk/gtkwidget.c gtk/gtkmenu.c gtk/gtkviewport.c gtk/gtkwindow.c: - Added new function gtk_container_set_resize_mode() for fine-grained control of where resize-queueing is done. - Removed GtkContainer::need_resize and GtkWindow::move_resize - Added GtkContainer::check_resize to replace need_resize. - Added function gtk_container_check_resize() to trigger queued resizes, and gtk_container_resize_children() to Figure which children need to be size-allocated. (logic moved from gtkwindow.c) - Reorganized code in gtkwindow.c - Set the resize-mode for viewports so that resizes within a viewport don't propagate out of it.
1998-06-19 01:26:24 +00:00
}
/**
2021-02-25 14:53:51 +00:00
* gtk_editable_set_editable: (attributes org.gtk.Method.set_property=editable)
* @editable: a `GtkEditable`
* @is_editable: %TRUE if the user is allowed to edit the text
* in the widget
*
2021-02-25 14:53:51 +00:00
* Determines if the user can edit the text in the editable widget.
*/
void
gtk_editable_set_editable (GtkEditable *editable,
gboolean is_editable)
{
g_return_if_fail (GTK_IS_EDITABLE (editable));
g_object_set (editable, "editable", is_editable, NULL);
Remove --g-fatal-warnings flag from argv. Thu Jun 18 21:13:54 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkmain.c (gtk_init): Remove --g-fatal-warnings flag from argv. Thu Jun 18 20:22:28 1998 Owen Taylor <otaylor@gtk.org> * gtk/genmarshal.pl: Modified to be more idiomatic Perl, to be more readable perl, to spit out stuff that looks more like readable C, and to pipe output through indent so output looks a lot like readable C. No functional changes. Thu Jun 18 17:43:31 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkpixmap.[ch] (gtk_pixmap_set): Clear the background if necessary when switching to a masked pixmap. (Based on a patch from Ullrich Hafner <hafner@informatik.uni-wuerzburg.de>) Thu Jun 18 16:18:10 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkeditable.[ch]: Added action signals for keyboard bindings. (move_cursor, kill_word, etc, etc, etc). removed the time argument from gtk_editable_cut/copy/paste_clipboard (source but not binary incompatible...) Instead get time from gtk_get_current_event (). * gtk/gtktext.c gtk/gtkentry.c: Support the new editable signals. Thu Jun 18 02:52:09 1998 Owen Taylor <otaylor@gtk.org> Patches from Damon Chaplin <DAChaplin@email.msn.com>: gtk/gtkfontsel.h: Fixed GtkFontSelectionClass - I forgot to change parent class to GtkNotebookClass when splitting the widget in two. Also updated some comments. gtk/gtkfontsel.c: Fixed bug when toggling 'Allow scaled bitmaps' button without a font selected. Fixed bug in set_font_name - I hadn't updated the code to search for the style in the font_style clist - it was still assuming the style row was equal to its index, but it isn't any more. Changed 'Reset' button on filter page to 'Clear Filter'. Deleted old code relating to the old 'Filter Fonts' toggle Updated some comments. Cleared 'Actual Fontname' if no font is set. gtk/testgtk.c: Fixed problem when 'OK' button is pressed - it was destroying the GtkFontSelection instead of the GtkFontSelectionDialog. Thu Jun 18 02:15:31 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkmain.c (gtk_init): Added --g-fatal-warnings flag to make all warnings fatal errors. * gtk/testthreads.c: moved <pthreads.h> include inside #ifdef USE_PTHREADS Thu Jun 18 01:37:31 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkenums.h gtk/gtkcontainer.[ch] gtk/gtkwidget.c gtk/gtkmenu.c gtk/gtkviewport.c gtk/gtkwindow.c: - Added new function gtk_container_set_resize_mode() for fine-grained control of where resize-queueing is done. - Removed GtkContainer::need_resize and GtkWindow::move_resize - Added GtkContainer::check_resize to replace need_resize. - Added function gtk_container_check_resize() to trigger queued resizes, and gtk_container_resize_children() to Figure which children need to be size-allocated. (logic moved from gtkwindow.c) - Reorganized code in gtkwindow.c - Set the resize-mode for viewports so that resizes within a viewport don't propagate out of it.
1998-06-19 01:26:24 +00:00
}
/**
2021-02-25 14:53:51 +00:00
* gtk_editable_get_editable: (attributes org.gtk.Method.get_property=editable)
* @editable: a `GtkEditable`
*
* Retrieves whether @editable is editable.
*
* Returns: %TRUE if @editable is editable.
*/
gboolean
gtk_editable_get_editable (GtkEditable *editable)
{
gboolean is_editable;
g_return_val_if_fail (GTK_IS_EDITABLE (editable), FALSE);
g_object_get (editable, "editable", &is_editable, NULL);
return is_editable;
}
/**
2021-02-25 14:53:51 +00:00
* gtk_editable_get_alignment: (attributes org.gtk.Method.get_property=xalign)
* @editable: a `GtkEditable`
*
2021-02-25 14:53:51 +00:00
* Gets the alignment of the editable.
*
* Returns: the alignment
2021-02-25 14:53:51 +00:00
*/
float
gtk_editable_get_alignment (GtkEditable *editable)
{
float xalign;
g_return_val_if_fail (GTK_IS_EDITABLE (editable), 0);
g_object_get (editable, "xalign", &xalign, NULL);
return xalign;
}
/**
2021-02-25 14:53:51 +00:00
* gtk_editable_set_alignment: (attributes org.gtk.Method.set_property=xalign)
* @editable: a `GtkEditable`
* @xalign: The horizontal alignment, from 0 (left) to 1 (right).
* Reversed for RTL layouts
*
* Sets the alignment for the contents of the editable.
*
* This controls the horizontal positioning of the contents when
* the displayed text is shorter than the width of the editable.
*/
Remove --g-fatal-warnings flag from argv. Thu Jun 18 21:13:54 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkmain.c (gtk_init): Remove --g-fatal-warnings flag from argv. Thu Jun 18 20:22:28 1998 Owen Taylor <otaylor@gtk.org> * gtk/genmarshal.pl: Modified to be more idiomatic Perl, to be more readable perl, to spit out stuff that looks more like readable C, and to pipe output through indent so output looks a lot like readable C. No functional changes. Thu Jun 18 17:43:31 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkpixmap.[ch] (gtk_pixmap_set): Clear the background if necessary when switching to a masked pixmap. (Based on a patch from Ullrich Hafner <hafner@informatik.uni-wuerzburg.de>) Thu Jun 18 16:18:10 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkeditable.[ch]: Added action signals for keyboard bindings. (move_cursor, kill_word, etc, etc, etc). removed the time argument from gtk_editable_cut/copy/paste_clipboard (source but not binary incompatible...) Instead get time from gtk_get_current_event (). * gtk/gtktext.c gtk/gtkentry.c: Support the new editable signals. Thu Jun 18 02:52:09 1998 Owen Taylor <otaylor@gtk.org> Patches from Damon Chaplin <DAChaplin@email.msn.com>: gtk/gtkfontsel.h: Fixed GtkFontSelectionClass - I forgot to change parent class to GtkNotebookClass when splitting the widget in two. Also updated some comments. gtk/gtkfontsel.c: Fixed bug when toggling 'Allow scaled bitmaps' button without a font selected. Fixed bug in set_font_name - I hadn't updated the code to search for the style in the font_style clist - it was still assuming the style row was equal to its index, but it isn't any more. Changed 'Reset' button on filter page to 'Clear Filter'. Deleted old code relating to the old 'Filter Fonts' toggle Updated some comments. Cleared 'Actual Fontname' if no font is set. gtk/testgtk.c: Fixed problem when 'OK' button is pressed - it was destroying the GtkFontSelection instead of the GtkFontSelectionDialog. Thu Jun 18 02:15:31 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkmain.c (gtk_init): Added --g-fatal-warnings flag to make all warnings fatal errors. * gtk/testthreads.c: moved <pthreads.h> include inside #ifdef USE_PTHREADS Thu Jun 18 01:37:31 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkenums.h gtk/gtkcontainer.[ch] gtk/gtkwidget.c gtk/gtkmenu.c gtk/gtkviewport.c gtk/gtkwindow.c: - Added new function gtk_container_set_resize_mode() for fine-grained control of where resize-queueing is done. - Removed GtkContainer::need_resize and GtkWindow::move_resize - Added GtkContainer::check_resize to replace need_resize. - Added function gtk_container_check_resize() to trigger queued resizes, and gtk_container_resize_children() to Figure which children need to be size-allocated. (logic moved from gtkwindow.c) - Reorganized code in gtkwindow.c - Set the resize-mode for viewports so that resizes within a viewport don't propagate out of it.
1998-06-19 01:26:24 +00:00
void
gtk_editable_set_alignment (GtkEditable *editable,
float xalign)
Remove --g-fatal-warnings flag from argv. Thu Jun 18 21:13:54 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkmain.c (gtk_init): Remove --g-fatal-warnings flag from argv. Thu Jun 18 20:22:28 1998 Owen Taylor <otaylor@gtk.org> * gtk/genmarshal.pl: Modified to be more idiomatic Perl, to be more readable perl, to spit out stuff that looks more like readable C, and to pipe output through indent so output looks a lot like readable C. No functional changes. Thu Jun 18 17:43:31 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkpixmap.[ch] (gtk_pixmap_set): Clear the background if necessary when switching to a masked pixmap. (Based on a patch from Ullrich Hafner <hafner@informatik.uni-wuerzburg.de>) Thu Jun 18 16:18:10 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkeditable.[ch]: Added action signals for keyboard bindings. (move_cursor, kill_word, etc, etc, etc). removed the time argument from gtk_editable_cut/copy/paste_clipboard (source but not binary incompatible...) Instead get time from gtk_get_current_event (). * gtk/gtktext.c gtk/gtkentry.c: Support the new editable signals. Thu Jun 18 02:52:09 1998 Owen Taylor <otaylor@gtk.org> Patches from Damon Chaplin <DAChaplin@email.msn.com>: gtk/gtkfontsel.h: Fixed GtkFontSelectionClass - I forgot to change parent class to GtkNotebookClass when splitting the widget in two. Also updated some comments. gtk/gtkfontsel.c: Fixed bug when toggling 'Allow scaled bitmaps' button without a font selected. Fixed bug in set_font_name - I hadn't updated the code to search for the style in the font_style clist - it was still assuming the style row was equal to its index, but it isn't any more. Changed 'Reset' button on filter page to 'Clear Filter'. Deleted old code relating to the old 'Filter Fonts' toggle Updated some comments. Cleared 'Actual Fontname' if no font is set. gtk/testgtk.c: Fixed problem when 'OK' button is pressed - it was destroying the GtkFontSelection instead of the GtkFontSelectionDialog. Thu Jun 18 02:15:31 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkmain.c (gtk_init): Added --g-fatal-warnings flag to make all warnings fatal errors. * gtk/testthreads.c: moved <pthreads.h> include inside #ifdef USE_PTHREADS Thu Jun 18 01:37:31 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkenums.h gtk/gtkcontainer.[ch] gtk/gtkwidget.c gtk/gtkmenu.c gtk/gtkviewport.c gtk/gtkwindow.c: - Added new function gtk_container_set_resize_mode() for fine-grained control of where resize-queueing is done. - Removed GtkContainer::need_resize and GtkWindow::move_resize - Added GtkContainer::check_resize to replace need_resize. - Added function gtk_container_check_resize() to trigger queued resizes, and gtk_container_resize_children() to Figure which children need to be size-allocated. (logic moved from gtkwindow.c) - Reorganized code in gtkwindow.c - Set the resize-mode for viewports so that resizes within a viewport don't propagate out of it.
1998-06-19 01:26:24 +00:00
{
g_return_if_fail (GTK_IS_EDITABLE (editable));
g_object_set (editable, "xalign", xalign, NULL);
}
/**
2021-02-25 14:53:51 +00:00
* gtk_editable_get_width_chars: (attributes org.gtk.Method.get_property=width-chars)
* @editable: a `GtkEditable`
*
2021-02-25 14:53:51 +00:00
* Gets the number of characters of space reserved
* for the contents of the editable.
*
* Returns: number of chars to request space for, or negative if unset
2021-02-25 14:53:51 +00:00
*/
int
gtk_editable_get_width_chars (GtkEditable *editable)
{
int width_chars;
g_return_val_if_fail (GTK_IS_EDITABLE (editable), 0);
g_object_get (editable, "width-chars", &width_chars, NULL);
return width_chars;
}
/**
2021-02-25 14:53:51 +00:00
* gtk_editable_set_width_chars: (attributes org.gtk.Method.set_property=width-chars)
* @editable: a `GtkEditable`
* @n_chars: width in chars
*
* Changes the size request of the editable to be about the
* right size for @n_chars characters.
2021-02-25 14:53:51 +00:00
*
* Note that it changes the size request, the size can still
* be affected by how you pack the widget into containers.
* If @n_chars is -1, the size reverts to the default size.
2021-02-25 14:53:51 +00:00
*/
void
gtk_editable_set_width_chars (GtkEditable *editable,
int n_chars)
{
g_return_if_fail (GTK_IS_EDITABLE (editable));
g_object_set (editable, "width-chars", n_chars, NULL);
Remove --g-fatal-warnings flag from argv. Thu Jun 18 21:13:54 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkmain.c (gtk_init): Remove --g-fatal-warnings flag from argv. Thu Jun 18 20:22:28 1998 Owen Taylor <otaylor@gtk.org> * gtk/genmarshal.pl: Modified to be more idiomatic Perl, to be more readable perl, to spit out stuff that looks more like readable C, and to pipe output through indent so output looks a lot like readable C. No functional changes. Thu Jun 18 17:43:31 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkpixmap.[ch] (gtk_pixmap_set): Clear the background if necessary when switching to a masked pixmap. (Based on a patch from Ullrich Hafner <hafner@informatik.uni-wuerzburg.de>) Thu Jun 18 16:18:10 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkeditable.[ch]: Added action signals for keyboard bindings. (move_cursor, kill_word, etc, etc, etc). removed the time argument from gtk_editable_cut/copy/paste_clipboard (source but not binary incompatible...) Instead get time from gtk_get_current_event (). * gtk/gtktext.c gtk/gtkentry.c: Support the new editable signals. Thu Jun 18 02:52:09 1998 Owen Taylor <otaylor@gtk.org> Patches from Damon Chaplin <DAChaplin@email.msn.com>: gtk/gtkfontsel.h: Fixed GtkFontSelectionClass - I forgot to change parent class to GtkNotebookClass when splitting the widget in two. Also updated some comments. gtk/gtkfontsel.c: Fixed bug when toggling 'Allow scaled bitmaps' button without a font selected. Fixed bug in set_font_name - I hadn't updated the code to search for the style in the font_style clist - it was still assuming the style row was equal to its index, but it isn't any more. Changed 'Reset' button on filter page to 'Clear Filter'. Deleted old code relating to the old 'Filter Fonts' toggle Updated some comments. Cleared 'Actual Fontname' if no font is set. gtk/testgtk.c: Fixed problem when 'OK' button is pressed - it was destroying the GtkFontSelection instead of the GtkFontSelectionDialog. Thu Jun 18 02:15:31 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkmain.c (gtk_init): Added --g-fatal-warnings flag to make all warnings fatal errors. * gtk/testthreads.c: moved <pthreads.h> include inside #ifdef USE_PTHREADS Thu Jun 18 01:37:31 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkenums.h gtk/gtkcontainer.[ch] gtk/gtkwidget.c gtk/gtkmenu.c gtk/gtkviewport.c gtk/gtkwindow.c: - Added new function gtk_container_set_resize_mode() for fine-grained control of where resize-queueing is done. - Removed GtkContainer::need_resize and GtkWindow::move_resize - Added GtkContainer::check_resize to replace need_resize. - Added function gtk_container_check_resize() to trigger queued resizes, and gtk_container_resize_children() to Figure which children need to be size-allocated. (logic moved from gtkwindow.c) - Reorganized code in gtkwindow.c - Set the resize-mode for viewports so that resizes within a viewport don't propagate out of it.
1998-06-19 01:26:24 +00:00
}
/**
2021-02-25 14:53:51 +00:00
* gtk_editable_get_max_width_chars: (attributes org.gtk.Method.get_property=max-width-chars)
* @editable: a `GtkEditable`
*
* Retrieves the desired maximum width of @editable, in characters.
*
* Returns: the maximum width of the entry, in characters
*/
int
gtk_editable_get_max_width_chars (GtkEditable *editable)
{
int max_width_chars;
g_return_val_if_fail (GTK_IS_EDITABLE (editable), 0);
g_object_get (editable, "max-width-chars", &max_width_chars, NULL);
return max_width_chars;
}
/**
2021-02-25 14:53:51 +00:00
* gtk_editable_set_max_width_chars: (attributes org.gtk.Method.set_property=max-width-chars)
* @editable: a `GtkEditable`
* @n_chars: the new desired maximum width, in characters
*
* Sets the desired maximum width in characters of @editable.
*/
void
gtk_editable_set_max_width_chars (GtkEditable *editable,
int n_chars)
{
g_return_if_fail (GTK_IS_EDITABLE (editable));
g_object_set (editable, "max-width-chars", n_chars, NULL);
}
/**
2021-02-25 14:53:51 +00:00
* gtk_editable_get_enable_undo: (attributes org.gtk.Method.get_property=enable-undo)
* @editable: a `GtkEditable`
*
* Gets if undo/redo actions are enabled for @editable
*
* Returns: %TRUE if undo is enabled
*/
gboolean
gtk_editable_get_enable_undo (GtkEditable *editable)
{
gboolean enable_undo;
g_return_val_if_fail (GTK_IS_EDITABLE (editable), 0);
g_object_get (editable, "enable-undo", &enable_undo, NULL);
return enable_undo;
}
/**
2021-02-25 14:53:51 +00:00
* gtk_editable_set_enable_undo: (attributes org.gtk.Method.set_property=enable-undo)
* @editable: a `GtkEditable`
* @enable_undo: if undo/redo should be enabled
*
2021-02-25 14:53:51 +00:00
* If enabled, changes to @editable will be saved for undo/redo
* actions.
*
2021-02-25 14:53:51 +00:00
* This results in an additional copy of text changes and are not
* stored in secure memory. As such, undo is forcefully disabled
* when [property@Gtk.Text:visibility] is set to %FALSE.
*/
void
gtk_editable_set_enable_undo (GtkEditable *editable,
gboolean enable_undo)
{
g_return_if_fail (GTK_IS_EDITABLE (editable));
g_object_set (editable, "enable-undo", enable_undo, NULL);
}
/**
* gtk_editable_install_properties:
2021-02-25 14:53:51 +00:00
* @object_class: a `GObjectClass`
* @first_prop: property ID to use for the first property
*
* Overrides the `GtkEditable` properties for @class.
*
* This is a helper function that should be called in class_init,
* after installing your own properties.
*
* Note that your class must have "text", "cursor-position",
* "selection-bound", "editable", "width-chars", "max-width-chars",
* "xalign" and "enable-undo" properties for this function to work.
*
* To handle the properties in your set_property and get_property
2021-02-25 14:53:51 +00:00
* functions, you can either use [func@Gtk.Editable.delegate_set_property]
* and [func@Gtk.Editable.delegate_get_property] (if you are using
* a delegate), or remember the @first_prop offset and add it to the
* values in the [enum@Gtk.EditableProperties] enumeration to get the
* property IDs for these properties.
*
* Returns: the number of properties that were installed
*/
guint
gtk_editable_install_properties (GObjectClass *object_class,
guint first_prop)
{
g_type_set_qdata (G_TYPE_FROM_CLASS (object_class),
quark_editable_data,
GUINT_TO_POINTER (first_prop));
g_object_class_override_property (object_class, first_prop + GTK_EDITABLE_PROP_TEXT, "text");
g_object_class_override_property (object_class, first_prop + GTK_EDITABLE_PROP_CURSOR_POSITION, "cursor-position");
g_object_class_override_property (object_class, first_prop + GTK_EDITABLE_PROP_SELECTION_BOUND, "selection-bound");
g_object_class_override_property (object_class, first_prop + GTK_EDITABLE_PROP_EDITABLE, "editable");
g_object_class_override_property (object_class, first_prop + GTK_EDITABLE_PROP_WIDTH_CHARS, "width-chars");
g_object_class_override_property (object_class, first_prop + GTK_EDITABLE_PROP_MAX_WIDTH_CHARS, "max-width-chars");
g_object_class_override_property (object_class, first_prop + GTK_EDITABLE_PROP_XALIGN, "xalign");
g_object_class_override_property (object_class, first_prop + GTK_EDITABLE_PROP_ENABLE_UNDO, "enable-undo");
return GTK_EDITABLE_NUM_PROPERTIES;
}
static void
delegate_changed (GtkEditable *delegate,
gpointer editable)
{
g_signal_emit (editable, signals[CHANGED], 0);
}
static void
delegate_notify (GObject *object,
GParamSpec *pspec,
gpointer data)
{
gpointer iface;
iface = g_type_interface_peek (g_type_class_peek (G_OBJECT_TYPE (object)), gtk_editable_get_type ());
if (g_object_interface_find_property (iface, pspec->name))
g_object_notify (data, pspec->name);
}
/**
* gtk_editable_get_delegate:
2021-02-25 14:53:51 +00:00
* @editable: a `GtkEditable`
*
* Gets the `GtkEditable` that @editable is delegating its
* implementation to.
*
2021-02-25 14:53:51 +00:00
* Typically, the delegate is a [class@Gtk.Text] widget.
*
2021-02-25 14:53:51 +00:00
* Returns: (nullable) (transfer none): the delegate `GtkEditable`
*/
GtkEditable *
gtk_editable_get_delegate (GtkEditable *editable)
{
return get_delegate (editable);
}
/**
* gtk_editable_init_delegate:
2021-02-25 14:53:51 +00:00
* @editable: a `GtkEditable`
*
2021-02-25 14:53:51 +00:00
* Sets up a delegate for `GtkEditable`.
*
* This is assuming that the get_delegate vfunc in the `GtkEditable`
* interface has been set up for the @editable's type.
*
* This is a helper function that should be called in instance init,
* after creating the delegate object.
*/
void
gtk_editable_init_delegate (GtkEditable *editable)
{
GtkEditable *delegate = get_delegate (editable);
g_signal_connect (delegate, "notify", G_CALLBACK (delegate_notify), editable);
g_signal_connect (delegate, "changed", G_CALLBACK (delegate_changed), editable);
}
/**
* gtk_editable_finish_delegate:
2021-02-25 14:53:51 +00:00
* @editable: a `GtkEditable`
*
2021-02-25 14:53:51 +00:00
* Undoes the setup done by [method@Gtk.Editable.init_delegate].
*
* This is a helper function that should be called from dispose,
* before removing the delegate object.
*/
void
gtk_editable_finish_delegate (GtkEditable *editable)
{
GtkEditable *delegate = get_delegate (editable);
g_signal_handlers_disconnect_by_func (delegate, delegate_notify, editable);
g_signal_handlers_disconnect_by_func (delegate, delegate_changed, editable);
}
/**
* gtk_editable_delegate_set_property:
2021-02-25 14:53:51 +00:00
* @object: a `GObject`
* @prop_id: a property ID
* @value: value to set
2021-02-25 14:53:51 +00:00
* @pspec: the `GParamSpec` for the property
*
* Sets a property on the `GtkEditable` delegate for @object.
*
2021-02-25 14:53:51 +00:00
* This is a helper function that should be called in the `set_property`
* function of your `GtkEditable` implementation, before handling your
* own properties.
*
* Returns: %TRUE if the property was found
*/
gboolean
gtk_editable_delegate_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkEditable *delegate = get_delegate (GTK_EDITABLE (object));
GType type = G_TYPE_FROM_INSTANCE (object);
guint first_prop;
do {
first_prop = GPOINTER_TO_UINT (g_type_get_qdata (type, quark_editable_data));
type = g_type_parent (type);
} while (first_prop == 0 && type != 0);
if (prop_id < first_prop)
return FALSE;
switch (prop_id - first_prop)
{
case GTK_EDITABLE_PROP_TEXT:
gtk_editable_set_text (delegate, g_value_get_string (value));
break;
case GTK_EDITABLE_PROP_EDITABLE:
gtk_editable_set_editable (delegate, g_value_get_boolean (value));
break;
case GTK_EDITABLE_PROP_WIDTH_CHARS:
gtk_editable_set_width_chars (delegate, g_value_get_int (value));
break;
case GTK_EDITABLE_PROP_MAX_WIDTH_CHARS:
gtk_editable_set_max_width_chars (delegate, g_value_get_int (value));
break;
case GTK_EDITABLE_PROP_XALIGN:
gtk_editable_set_alignment (delegate, g_value_get_float (value));
break;
case GTK_EDITABLE_PROP_ENABLE_UNDO:
gtk_editable_set_enable_undo (delegate, g_value_get_boolean (value));
break;
default:
return FALSE;
}
return TRUE;
}
/**
* gtk_editable_delegate_get_property:
2021-02-25 14:53:51 +00:00
* @object: a `GObject`
* @prop_id: a property ID
* @value: value to set
2021-02-25 14:53:51 +00:00
* @pspec: the `GParamSpec` for the property
*
2021-02-25 14:53:51 +00:00
* Gets a property of the `GtkEditable` delegate for @object.
*
* This is helper function that should be called in the `get_property`
* function of your `GtkEditable` implementation, before handling your
* own properties.
*
* Returns: %TRUE if the property was found
*/
gboolean
gtk_editable_delegate_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkEditable *delegate = get_delegate (GTK_EDITABLE (object));
int cursor_position, selection_bound;
GType type = G_TYPE_FROM_INSTANCE (object);
guint first_prop;
do {
first_prop = GPOINTER_TO_UINT (g_type_get_qdata (type, quark_editable_data));
type = g_type_parent (type);
} while (first_prop == 0 && type != 0);
if (prop_id < first_prop)
return FALSE;
switch (prop_id - first_prop)
{
case GTK_EDITABLE_PROP_TEXT:
g_value_set_string (value, gtk_editable_get_text (delegate));
break;
case GTK_EDITABLE_PROP_CURSOR_POSITION:
gtk_editable_get_selection_bounds (delegate, &cursor_position, &selection_bound);
g_value_set_int (value, cursor_position);
break;
case GTK_EDITABLE_PROP_SELECTION_BOUND:
gtk_editable_get_selection_bounds (delegate, &cursor_position, &selection_bound);
g_value_set_int (value, selection_bound);
break;
case GTK_EDITABLE_PROP_EDITABLE:
g_value_set_boolean (value, gtk_editable_get_editable (delegate));
break;
case GTK_EDITABLE_PROP_WIDTH_CHARS:
g_value_set_int (value, gtk_editable_get_width_chars (delegate));
break;
case GTK_EDITABLE_PROP_MAX_WIDTH_CHARS:
g_value_set_int (value, gtk_editable_get_max_width_chars (delegate));
break;
case GTK_EDITABLE_PROP_XALIGN:
g_value_set_float (value, gtk_editable_get_alignment (delegate));
break;
case GTK_EDITABLE_PROP_ENABLE_UNDO:
g_value_set_boolean (value, gtk_editable_get_enable_undo (delegate));
break;
default:
return FALSE;
}
return TRUE;
}
/**
* gtk_editable_delegate_get_accessible_platform_state:
* @editable: a `GtkEditable` implementation
* @state: what kind of accessible state to retrieve
*
* Retrieves the accessible platform state from the editable delegate.
*
* This is an helper function to retrieve the accessible state for
* `GtkEditable` interface implementations using a delegate pattern.
*
* You should call this function in your editable widget implementation
* of the [vfunc@Gtk.Accessible.get_platform_state] virtual function, for
* instance:
*
* ```c
* static void
* accessible_interface_init (GtkAccessibleInterface *iface)
* {
* iface->get_platform_state = your_editable_get_accessible_platform_state;
* }
*
* static gboolean
* your_editable_get_accessible_platform_state (GtkAccessible *accessible,
* GtkAccessiblePlatformState state)
* {
* return gtk_editable_delegate_get_accessible_platform_state (GTK_EDITABLE (accessible), state);
* }
* ```
*
* Since: 4.10
*/
gboolean
gtk_editable_delegate_get_accessible_platform_state (GtkEditable *editable,
GtkAccessiblePlatformState state)
{
GtkWidget *delegate = GTK_WIDGET (gtk_editable_get_delegate (editable));
switch (state)
{
case GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSABLE:
return gtk_widget_get_focusable (delegate);
case GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSED:
return gtk_widget_has_focus (delegate);
case GTK_ACCESSIBLE_PLATFORM_STATE_ACTIVE:
return FALSE;
default:
g_assert_not_reached ();
return FALSE;
}
}