2008-07-01 22:57:50 +00:00
|
|
|
|
/* GTK - The GIMP Toolkit
|
1997-11-24 22:37:52 +00:00
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1997-11-24 22:37:52 +00:00
|
|
|
|
* 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
|
1998-12-15 20:31:26 +00:00
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* Lesser General Public License for more details.
|
1997-11-24 22:37:52 +00:00
|
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* 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/>.Free
|
1997-11-24 22:37:52 +00:00
|
|
|
|
*/
|
1999-02-24 07:37:18 +00:00
|
|
|
|
|
|
|
|
|
/*
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
1999-02-24 07:37:18 +00:00
|
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
|
* files for a list of changes. These files are distributed with
|
2008-10-30 18:38:06 +00:00
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
1999-02-24 07:37:18 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
|
#include "config.h"
|
2008-10-30 18:38:06 +00:00
|
|
|
|
|
2014-01-04 01:44:21 +00:00
|
|
|
|
#include "gtklabelprivate.h"
|
2018-02-08 13:39:45 +00:00
|
|
|
|
|
2014-08-20 22:02:29 +00:00
|
|
|
|
#include "gtkbuildable.h"
|
2018-02-08 13:39:45 +00:00
|
|
|
|
#include "gtkeventcontrollermotion.h"
|
2020-08-02 15:24:27 +00:00
|
|
|
|
#include "gtkeventcontrollerfocus.h"
|
2018-02-08 13:39:45 +00:00
|
|
|
|
#include "gtkgesturedrag.h"
|
2019-05-29 17:10:46 +00:00
|
|
|
|
#include "gtkgestureclick.h"
|
2018-02-08 13:39:45 +00:00
|
|
|
|
#include "gtkgesturesingle.h"
|
2022-09-24 13:07:56 +00:00
|
|
|
|
#include <glib/gi18n-lib.h>
|
2014-08-20 22:02:29 +00:00
|
|
|
|
#include "gtkmarshalers.h"
|
2001-03-21 18:58:28 +00:00
|
|
|
|
#include "gtknotebook.h"
|
2022-10-06 02:59:51 +00:00
|
|
|
|
#include "gtkpangoprivate.h"
|
2014-08-20 22:02:29 +00:00
|
|
|
|
#include "gtkprivate.h"
|
2018-08-16 03:43:37 +00:00
|
|
|
|
#include "gtkshortcut.h"
|
|
|
|
|
#include "gtkshortcutcontroller.h"
|
|
|
|
|
#include "gtkshortcuttrigger.h"
|
2022-10-08 19:30:29 +00:00
|
|
|
|
#include "gtksnapshot.h"
|
|
|
|
|
#include "gtkrenderbackgroundprivate.h"
|
|
|
|
|
#include "gtkrenderborderprivate.h"
|
|
|
|
|
#include "gtkrenderlayoutprivate.h"
|
2022-10-06 02:59:51 +00:00
|
|
|
|
#include "gtktextutilprivate.h"
|
2009-05-11 05:23:13 +00:00
|
|
|
|
#include "gtktooltip.h"
|
2011-01-04 19:51:19 +00:00
|
|
|
|
#include "gtktypebuiltins.h"
|
2023-01-15 18:25:34 +00:00
|
|
|
|
#include "gtkurilauncher.h"
|
2014-08-20 22:02:29 +00:00
|
|
|
|
#include "gtkwidgetprivate.h"
|
2019-01-27 21:43:54 +00:00
|
|
|
|
#include "gtkpopovermenu.h"
|
|
|
|
|
#include "gtknative.h"
|
2020-12-25 17:57:48 +00:00
|
|
|
|
#include "gtkdragsourceprivate.h"
|
2020-01-06 21:00:32 +00:00
|
|
|
|
#include "gtkdragicon.h"
|
2020-02-07 17:49:45 +00:00
|
|
|
|
#include "gtkcsscolorvalueprivate.h"
|
2021-07-08 21:16:06 +00:00
|
|
|
|
#include "gtkjoinedmenuprivate.h"
|
Remove all references to offscreen flag which was no longer used.
Thu Jun 1 23:05:13 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c: Remove all references to
offscreen flag which was no longer used.
* gtk/gtkprivate.h (enum): Remove unused flags and compress.
* gtk/gtkframe.c (gtk_frame_set_label_widget): Check
for non-null label_widget->parent.
* gtk/gtkentry.c: Get rid of code to deal with PangoAttribute
which no longer was used.
* gdk/gdkpango.c (gdk_pango_context_get_info): make static.
* gdk/gdkpango.c (gdk_draw_layout[_line]): Add checks
for null arguments.
* gdk/x11/gdkgeometry-x11.c (gdk_window_scroll): add
check for destroyed windows.
Thu Jun 1 13:48:45 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimmulticontext.c: Add a finalize method and unref
the slave context there.
* gtk/gtkinvisible.[ch]: Make reference counting behavior
identical to GtkWindow.
Thu Jun 1 01:54:11 2000 Owen Taylor <otaylor@redhat.com>
* Makefile.am gdk/gdkpango.c: Copy the layout render function from
pangox to here, so we can write them independent of rendering
system, using GDK primitives.
* gdk/gdkdrawable.h gdk/gdkdraw.c gdk/gdkwindow.c
gdk/x11/gdkdrawable-x11.c: Remove draw_layout() from the vtable,
since we have a rendering-system independent implementation in
terms of draw_glyphs().
* gdk/gdkpango.c gdkdrawable.h (gdk_draw_layout_line): New
function to render a single line.
* gdk/x11/gdkpango.c: Move the guts of this file mostly
into ../gdkpango.c, which simplifies things, since we
don't have to deal with raw X gc's.
Fri May 19 04:28:16 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextlayout.[ch]: Add get_log_attrs() function to
get the logical attributes for a given GtkTextLine.
Tue May 30 16:05:39 2000 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkfont-x11.c (gdk_font_charset_for_locale): Track
g_locale_get_codeset() to g_get_codeset() change.
Tue May 30 15:03:19 2000 Owen Taylor <otaylor@redhat.com>
* gtk/testcalendar.c (calendar_font_selection_ok): Use font
descriptions.
* gtk/gtkentry.c (gtk_entry_draw_text): Center text within
the entry.
* gtk/gtkfontsel.c (gtk_font_selection_dialog_init): Start of
redoing (vastly simplifying) for Pango. Still needs quite
a bit of work. (Size selection is currently poor. List of
predefined sizes is not a good idea, since all of these
sizes won't necessarily be distinct.)
Tue May 30 13:50:19 2000 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkfont-x11.c (gdk_font_charset_for_locale): Handle
CODESET results for LANG=C.
Mon May 29 15:49:10 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrc.[ch]: Add a 'font_name' declaration to RC
which takes a stringized pango font description;
ignore the older 'font' and 'fontset' declarations.
* gtk/gtkstyle.c gtk/gtkrc.c: Fill in the style->font
field with a GdkFont derived via gdk_font_from_description(),
for compatibility. (Should we just remove it entirely?
Probably too much compatibility breakage, but people
should be migrating to the new Pango stuff as quickly
as possible.)
Mon May 29 15:47:41 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c gtk/gtkclist.c: s/pango_font_unref/g_object_unref/.
Mon May 29 15:44:46 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcalender.c: Roughly pango-ized. Really needs
redoing; there are some bugs in size allocation right
now, the semi-existant distinction between header / day
fonts was removed, but, with Pango, could actually
be made functional in a nice way.
* gtk/testcalender: Move calender from examples into this
directory as a test program. (We really need to restrcture
testgtk into a whole directory full of tests for every
widget or functionality group, separated into multiple .c
files.)
Mon May 29 15:19:56 2000 Owen Taylor <otaylor@redhat.com>
* gtk/testgtk.c (file_exists): Fix stupid typo that
was keeping RC file from being loaded.
* gtk/testgtkrc gtk/testgtkrc2: Test new pango-ized
RC file font code.
Mon May 29 14:31:27 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdkfont.h gdk/x11/gdkfont-x11.c (gdk_font_from_description):
Add function to load a GdkFont from a PangoFontDescription.
Fri May 26 17:16:40 2000 Owen Taylor <otaylor@redhat.com>
* gtk/frame.[ch] gtkaspectframe.c: Make frame widgets able
to have any widget for the label, use a GtkLabel widget
to display the text. (Based partially on a patch from
Anders Carlson.)
(Quite a bit of code reorganization - strip 90% of the
guts out of gtkaspectframe and add a single virtual
func to GtkFrameClass - compute_child_allocation.)
Fri May 26 12:00:02 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkctree.c gtk/gtkclist.[ch]: Pangoized.
(Removed clist->row_center_offset field because caching
it wasn't saving time or code, added private function
_gtk_clist_create_cell_layout()).
Wed May 24 15:59:37 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkaccellabel.c: Pangoized.
* gtk/[hv]ruler.c: Pangoized
Mon May 22 19:23:59 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkfilesel.c (gtk_file_selection_init):
Use gtk_clist_set_column_auto_resize() to remove need
need for manual column width computations.
Mon May 22 18:50:26 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktooltips.[ch]: Replace custom drawing with a GtkLabel,
ensuring Pango correctness, and considerably simplifying the
code.
* gtk/gtklabel.c gtk[hv]scale.c: 1000 => PANGO_SCALE.
* gtk/gtklabel.c (gtk_label_size_request): Fixed incorrect
getting of numbers of lines.
* gtk/gtklabel.c (gtk_label_size_request): Set the requisition
to the actual requested width of the lable, not to the wrap
width we set.
* gtk/gtktextchild.h: Remove extraneous include of gtk/gtk.h.
* gtk/gtktextbtree.c gtk/gtktextbuffer.c gtk/gtktextlayout.c
gtk/gtktextview.c gtk/gtktextview.[ch]: Fix up includes.
* gtk/gtktextview.c: Fix structure inheritance.
* gtk/gtkprogressbar.c: Pangoize.
Mon May 22 15:47:30 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.c (gtk_text_view_get_first_para_iter): Encapsulate
in a function.
* gtk/gtktextlayout.c (find_display_line_above): Fixed
bug with computing line tops.
* gtk/gtktextview.c (changed_handler): Fix < , <= confusion.
Thu May 18 18:53:31 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextdisplay.c (gtk_text_layout_draw): Fix up the x_offset
and y_offset coordinates to do what we need now. (The offset between
buffer and layout coordinates has been reintroduced, but is a
bit different than before.)
* gtk/gtktextview.[ch]: No longer inherit from GtkLayout; instead
handle the adjustments ourselves, and scroll as necessary using
the new gdk_window_scroll().
The advantage of this is that when we are incrementally revalidating,
we are essentially rearranging things around the visible portion
of the screen. With the old setup, the visible portion of the
screen was moved around in the layout, so scrolling and redrawing
to track that caused jumping of the display. Since we now
control the scrolling ourselves, we can suppress this and
only redraw when things actually change.
Thu May 18 18:47:25 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextbtree.c (redisplay_mark): We need to invalidate
the region not just redisplay it after-all, since we store the
cursors in the LineDisplay. (Ugly interactions here between
GtkLayout and GtkTextBTree here.)
* gtk/gtktextbtree.c (redisplay_region): Fixed reversed comparison.
Thu May 18 18:43:21 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.h gdk/x11/gdkgeometry-x11.c (gdk_window_scroll):
Added function to scroll contents of a window while keeping the
window constant. Works by XCopyArea or guffaw-scrolling depending
on the details of how the window is set up. (guffaw-scrolling
still needs to be filled in.)
Wed May 17 22:36:53 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextiter.c gtk/gtkmain.c: Add a debug key for the text widget,
move the debugging that was tied to a global variable
to that.
* gtk/gtkmarshal.list: Add NONE:INT,INT,INT
* gtk/gtktextbtree.[ch] gtk/gtktextlayout.c: Keep a separate
validated flag, in line data instead of setting height/width to
-1. This allows us to perform operations with partially invalid
buffer (using the old size for invalid lines) and thus to do
incremental vaidation. Keep height/width aggregates up to date
when deleting text and rebalancing the tree.
* gtk/gtktextbtree.[ch]: Add functions validate a line
(gtk_text_btree_validate_line), and to validate up
to a number of pixels (gtk_text_btree_validate).
* gtk/gtktextlayout.[ch]: Add an ::invalidated signal
that indicates that something is changed and a revalidation
pass is needed. Change ::need_repaint to ::changed, and
make it take old and new yranges instead of a rectangle.
* gtk/gtktextbtree.[ch] gtk/gtktextlayout.[ch]: Move
the line_data_destroy() function from
gtk_text_btree_add_view() to a virtual function in
GtkTextLayout
* gtk/gtktextbtree.[ch]: Remove gtk_text_btree_get_damage_range(),
since we are handling partial repaints in a different fashion
now.
* gtk/gtktextbtree.[ch]: Only repaint the changed portion
of the selection instead of queueing a repaint on the
entire widget.
* gtk/gtktextbuffer.[ch] gtk/gtktextbtree.[ch]: Move
get_selection_bounds() down to btree, make the function
in buffer a wrapper around the btree function.
* gtk/gtktextlayout.[ch]: Add functions to check if the
layout is valid and to recompute either a range of pixels
aroudn a line or a certain total number of pixels.
* gtk/gtktextlayout.[ch]: Cache a single line display;
now that we only redraw the needed portions, the hit rate
for this cache is quite high.
* gtk/gtktextview.[ch]: Keep track of the first paragraph
on the screen so that when re-laying-out the buffer, we can
keep the same place. This requires connecting to ::value_changed
on the adjustments
* gtk/gtktextview.[ch]: Add idle functions to revalidate
the buffer after we receive an ::invalidated signal.
Wed May 17 22:10:47 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtklayout.c (gtk_layout_size_allocate): Set upper
to max of allocation and layout size, not just to the
layout size.
* gtk/gtk[hv]scrollbar.c (gtk_[hv]scrollbar_calc_slider_size):
Invalidate window so it gets redrawn properly.
* gdk/gdkwindow.c (gdk_window_invalidate_rect): Allow rect == NULL
to mean the entire window.
* gdk/gdkevents.h: Move definition for GDK_PRIORITY_REDRAW
into public header.
Mon May 15 14:51:31 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextmark.c (gtk_text_mark_get_name): Add function
to get the name of a mark.
* gtk/gtktextlayout.c (gtk_text_layout_get_line_at_y): Add a function
to find the paragraph from a y position.
Thu May 11 12:57:20 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextbtree.c (gtk_text_btree_node_invalidate_upward): Valid
nodes have width/height >= 0, not > 0.
Tue May 9 21:29:06 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextlayout.[ch] gtk/gtktextdisplay.c (gtk_text_layout_get_line_display):
Add a size_only flag, so when we only need the size, we don't create
useless appearance attributes.
* gtk/gtktextview.c (gtk_text_view_ensure_layout): Remove
duplicate setting of font description.
* gtk/gtkscale.c: Use PANGO_SCALE instead of 1000
Wed Apr 26 01:53:23 2000 Owen Taylor <otaylor@redhat.com>
* gtk/Makefile.am (EXTRA_DIST): Add OLD_STAMP into
EXTRA_DIST. It does not work well when the file that
everything depends on is not in the tarball.
Wed Apr 26 00:56:14 2000 Owen Taylor <otaylor@redhat.com>
* gtk/testgtk.c: Some hacks and fixes so that it basically
works when not sitting in the GTK+ build tree.
2000-05-03 Havoc Pennington <hp@redhat.com>
* gtk/gtktextbtree.c (gtk_text_line_next_could_contain_tag):
Properly determine the ordering of the tag root and the current
line within the tree. Previous algorithm only worked if the tag
root's immediate parent was the common root of both the current
line and the tag root.
Wed Apr 26 00:43:00 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextlayout.c (set_para_values): Fix some bugs in
alignment.
* gtk/gtktextview.c (gtk_text_view_ensure_layout): Track
the widget text directional dynamically.
* gtk/gtktextview.[ch]: Added functions to get and set default
wrap mode.
Tue Apr 25 23:47:38 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextlayout.c (gtk_text_layout_get_iter_location): Fix bug
in cursor location computation.
Tue Apr 25 23:22:59 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtklayout.c (gtk_layout_set_size): Clamp hadjustment/
vadjusment values properly when layout gets smaller.
* gtk/gtktextview.c (need_repaint_handler): Areas being
passed in are far completely inaccurate, and sometimes
too small, so, for now, just queue a redraw on the
whole visible region.
2000-04-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextbtree.c (summary_destroy): new function to
destroy tag summary nodes
(gtk_text_line_next_could_contain_tag): this function was
totally broken if the line passed in wasn't below the tag
root. Fix it.
(gtk_text_btree_first_could_contain_tag): In the tag == NULL
"wildcard" case, we have to do a linear scan. Blah.
(gtk_text_btree_last_could_contain_tag): In tag == NULL case,
we have to do the linear scan
(tag_removed_cb): When a tag is removed from the tag table,
remove the GtkTextTagInfo node from the btree.
(gtk_text_btree_spew): Implement the spew function, for
our debugging pleasure.
Tue Apr 25 19:40:18 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextlayout.c (gtk_text_layout_set_buffer): Fix
a problem with referring to the wrong buffer.
* gtk/gtkentry.c: Fix focus-in/focus-out confusion.
* gtk/gtkrc.c gtk/gtkstyle.c: Moving setting default
font description to gtk_style_new() - otherwise things
don't work without a .gtkrc file.
* gtk/gtktextbuffer.c (gtk_text_buffer_new): Sink the
tags table if we create it ourself, too.
* gdk/gdktypes.h (enum): Move GDK_RELEASE_MASK, since
it was conflicting with XKB modifiers.
* gtk/gtktextview.[ch]: Add simple support for
GtkIMContext.
Mon Apr 24 19:34:18 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c (gtk_entry_move_cursor_visually): Fix problem
with deletion from last commit.
Mon Apr 24 19:29:40 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_create_pango_context): Set the language
in the context from the current locale.
* gtk/gtkentry.c (gtk_entry_size_request): Use language from the
context, not hardcoded value.
* gtk/gtkentry.c (gtk_entry_move_cursor): Make character movement visual,
not logical.
Sun Apr 23 23:39:18 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c gtk/gtktextdisplay.c: Don't handle selections as
attributes - that doesn't handle partial-glyph selection
properly. Instead use new pango_layout_line_get_x_ranges()
functionality to draw the selection.
* gtk/gtkentry.c: Simplify code since pango_layout_line_index_to_x()
now properly handles out-of-range coordinates.
* gtk/gtktextbuffer.c: Emit "mark_set" when the cursor is moved.
* gtk/gtktextiter.h gtk/gtktextiterprivate.h: Make gtk_text_iter_get_line_byte()
public.
* gtk/gtktextlayout.[ch]: Properly set the direction in the PangoContext
for paragraphs opposite to the base direction of the widget.
* gtk/gtktextlayout.[ch] gtk/gtktextdisplay.c: Fixes for alignment.
* gtk/gtktextlayout.c: Don't split segments on marks, since that
causes Arabic words to reshape as you cursor through.
* gtk/gtktextlayout.[ch] gtk/gtktextview.[ch]: Implement virtual
cursor position when moving vertically with the arrow keys and
scrolling with page-up/page-down. (Arrow keys save only the X,
scrolling saves both X and Y.)
This means you can line-up / line-down or page-up / page-down
without losing your place, and also that moving vertically
with the cursor keys keeps the same X position, not the same
character count:
* gtk/gtktextlayout.[ch] gtk/gtktextview.[ch]: Make vertical
arrow keys move by display lines, not paragraphs.
Tue Apr 18 14:16:50 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtklayout.c: Make sure that the bin window is at least
as big as the allocation. (Should we also make sure that the
bin window is big enough to completely cover widget->window?)
* gtk/gtktextview.c (gtk_text_view_get_visible_rect): Add
function to get the onscreen rectangle.
* gdk/x11/gdkwindow-x11.c (gdk_window_get_pointer): Correctly account
for offsets in window coordinates.
Sun Apr 16 16:13:27 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c (gtk_entry_get_cursor_locations): Fix index/offset
confusion.
* gtk/gtktextview.c (gtk_text_view_ensure_layout): Set the default direction
from the widget direction.
* gtk/gtktexttag.c gtk/gtktexttagprivate.h (gtk_text_tag_set_arg):
Add a "direction" attribute.
* gtk/gtktextview.c: global s/tkxt/text_view/.
* gtk/testtext.c: Added long block of text in Arabic, to test out
the direction attributes. (Some problems with the shaping system
for arabic become obvious - like the fact the cursor splits words
into unjoined pieces.)
Fri Apr 14 12:54:34 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextdisplay.c (render_layout): Add overstrike handling.
* gtk/gtktextlayout.c: Fix up alignment.
* gtk/testtext.c: Add some tests for centering, wrapping.
Fri Apr 14 09:26:22 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdrawable.h gdk/gdkdraw.c gdk/gdkwindow.c gdk/x11/gdkdrawable-x11.c:
Add a draw_glyphs() operation to the drawable vtable and gdk_draw_glyphs().
If we wrote GTK+-specific layout-render function this could just replace
the draw_layout() operation in the vtable.
* gtk/gtkentry.c: Move guts of gtk_entry_get_cursor_locations to
pango_layout_get_cursor_pos() and use that function.
* gtk/gtktextchild.[ch]: add gtk_ onto pixmap_segment_new(), since it
is a non-static symbol.
* gtk/gtktextbtree.[ch]: Replace gtk_text_btree_find_line_data_by_y()
with gtk_text_btree_find_line_by_y()
* gtk/gtktextdisplay.c: Rewrote for Pango - uses a custom layout
renderer that handles GtkTextAppearance attributes.
* gtk/gtktexttag.[ch] gtk/gtktexttagprivate.h:
- Move the values in the style that don't affect geometry into a
GtkTextAppearance structure.
- Change underline to take a PangoUnderline and "font" a string
representation of a font description
- Add a "font_desc" attribute which takes a FontDescription structure.
* gtk/gtktextlayout.[ch]:
- Get rid of the display-line list per each line. Instead, we
generate, on demand, a GtkTextLineDisplay structure which]
contains a PangoLayout * and other necesary information
(offsets, cursor locations) for displaying a paragraph.
- Get rid of the code to wrap lines, create display chunks,
etc. Instead, we just go through a paragraph and convert
it into the necessary inputs to a PangoLayout.
- Implement a new attribute type, GtkTextAttrAppearance. This
holds a GtkTextAppearance, and is used to pass colors,
stipple, etc, through from the layout to the display without
having to use lots and lots of individual attributes.
- Reimplement gtk_layout_get_iter_at_pixel() gtk_layout_get_iter_pos()
in terms of PangoLayout functions.
* gtk/gtktextview.c:
- Handle passing the necessary PangoContext to the layout
- Some fixups in painting to deal with the automatic backing store
and offsetting of GTK+-1.4
- Add a style_set handler so that the default style reacts
properly to theme changes.
* gtk/gtktext?*.[ch]: Random code-style fixes.
* gtk/testtext.c: Substitute in languages that Pango handles now for Thai
Mon Apr 10 10:33:45 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktext?*.[ch]: Check in Havoc's port of the Tk text widget,
in original form preparatory to Pango-ization and gdkimcontext-ization.
Thu Apr 6 19:25:39 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimcontext.c: Move default implementations to real_* vfuncs,
so that we can derive from gtkimcontext in language bindings properly.
Thu Apr 6 16:02:52 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimcontextsimple.[ch]: Use gdk_keyval_to_unicode to gdk_unicode_to_keyval.
Add a compose table including (almost) all the compose combinations
from X. This is 6k of static, shared data as opposed to 50k or so of dynamic
data in the XIM implementation.
* gdk/gdk.h gdk/gdkkeyuni.c gdk/win32/gdkevents-win32.c (gdk_keyval_to_unicode, gdk_unicode_to_keyval):
Moved functions to convert keyvalues from and to unicode here from
the win32 port and made them public.
Wed Apr 5 16:37:29 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkeditable.c (gtk_editable_insert_text): Allow new_text_length == -1.
Wed Apr 5 16:27:45 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimcontext.[ch]: Base class for new input context system
* gtk/gtkimmulticontext.[ch]: Proxy input context that allows
the real input context implementation to be loaded from modules
and switched on the fly.
* gtk/gtkcontextsimple.[ch]: Simple implementation of an input
context that just does direct keysymbol => unicode translation.
* gtk/gtkentry.[ch]: Start switching editing over to using
GtkInputContext. (No handling of preedit yet.)
Wed Apr 5 15:48:41 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktypeutils.h (GTK_CHECK_GET_CLASS): Fix problem with one too
many substitutions. (klass should not be subsituted.)
Wed Apr 5 00:18:14 2000 Owen Taylor <otaylor@redhat.com>
* configure.in: Add checks for Pango
* configure.in docs/Makefile.am: Add test for sgml2html
and allow 'make dist' without building html, but print out
warnings in that case. (For making snapshots)
* gdk/Makefile.am gdk/x11/Makefile.am gtk/Makefile.am:
Add Pango libraries and C flags
* gdk/gdkdraw.c gdk/gdkdrawable.h gdkwindow.c gdk/x11/gdkdrawable-x11.c:
Add function (gdk_draw_layout) to draw a pango layout.
* gdk/gdkpango.h gdk/x11/gdkpango-x11.c: New file with functions
for getting Pango contexts for GDK.
* gtk/gtkeditable.c: Get rid of dead code gtk_editable_parent_set()
* gtk/gtkentry.[ch]: Complete rewrite to use Pango, add bidirectional
editing.
* gtk/gtkentry.c: Hack in simple Hebrew input with direct
keysym => unicode translations. More languages can be added
here, but real input-method support is needed.
* docs/Changes-1.4.txt: Added note about entry behavior.
* gtk/gtkenums.h gtk/gtkwidget.[ch] testgtk.c gtkprivate.h: Add functions
to set the reading direction for a widget and the global direction.
Add test which allows toggling the global direction. Two private
flags are used to store the direction. (GTK_DIRECTION_SET + GTK_DIRECTION_LTR)
* gtk/gtkcheckbutton.c gtk/gtkframe.c gtk/gtkhbbox.c gtk/gtkhbox.c
gtk/gtkradiobutton.c gtk/gtkspinbutton.c gtk/gtktable.c
* gtk/gtk[hv]scale.c gtk/gtkscale.[ch]: Draw numbers using Pango
* gtk/gtklabel.[ch]: Moved to Pango and considerably rewritten. Line breaking,
underlining now handled by Pango.
* gtk/gtkstyle.[ch] gtk/gtkrc.[ch]: Add a PangoFontDescription
to RCStyle and Style. (Having both this and the old font name and GdkFont
is temporary.)
* gtk/gtkwidget.[ch] (gtk_widget_create_pango_{context,layout}): Added
convenience functions for creating contexts and layouts for widgets.
* gtk/testgtk.c: Enhance label tests with multilingual labels.
2000-06-02 03:14:07 +00:00
|
|
|
|
|
2018-02-08 13:39:45 +00:00
|
|
|
|
#include <math.h>
|
2022-01-02 17:22:18 +00:00
|
|
|
|
#include <stdlib.h>
|
2018-02-08 13:39:45 +00:00
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2011-04-14 21:50:45 +00:00
|
|
|
|
/**
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* GtkLabel:
|
2011-04-14 21:50:45 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* The `GtkLabel` widget displays a small amount of text.
|
|
|
|
|
*
|
|
|
|
|
* As the name implies, most labels are used to label another widget
|
|
|
|
|
* such as a [class@Button].
|
|
|
|
|
*
|
|
|
|
|
* ![An example GtkLabel](label.png)
|
2011-04-14 21:50:45 +00:00
|
|
|
|
*
|
2015-10-23 03:18:30 +00:00
|
|
|
|
* # CSS nodes
|
|
|
|
|
*
|
2021-02-28 00:47:58 +00:00
|
|
|
|
* ```
|
2015-11-15 06:00:20 +00:00
|
|
|
|
* label
|
|
|
|
|
* ├── [selection]
|
|
|
|
|
* ├── [link]
|
|
|
|
|
* ┊
|
|
|
|
|
* ╰── [link]
|
2021-02-28 00:47:58 +00:00
|
|
|
|
* ```
|
2015-11-15 06:00:20 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* `GtkLabel` has a single CSS node with the name label. A wide variety
|
2015-10-25 22:53:56 +00:00
|
|
|
|
* of style classes may be applied to labels, such as .title, .subtitle,
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* .dim-label, etc. In the `GtkShortcutsWindow`, labels are used with the
|
2016-02-25 18:23:40 +00:00
|
|
|
|
* .keycap style class.
|
2015-10-23 03:18:30 +00:00
|
|
|
|
*
|
2015-11-15 06:00:20 +00:00
|
|
|
|
* If the label has a selection, it gets a subnode with name selection.
|
|
|
|
|
*
|
|
|
|
|
* If the label has links, there is one subnode per link. These subnodes
|
|
|
|
|
* carry the link or visited state depending on whether they have been
|
2020-04-10 01:15:30 +00:00
|
|
|
|
* visited. In this case, label node also gets a .link style class.
|
2015-11-15 06:00:20 +00:00
|
|
|
|
*
|
2014-02-05 02:00:58 +00:00
|
|
|
|
* # GtkLabel as GtkBuildable
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2011-04-14 21:50:45 +00:00
|
|
|
|
* The GtkLabel implementation of the GtkBuildable interface supports a
|
2023-01-15 06:17:07 +00:00
|
|
|
|
* custom `<attributes>` element, which supports any number of `<attribute>`
|
2014-02-09 22:24:06 +00:00
|
|
|
|
* elements. The <attribute> element has attributes named “name“, “value“,
|
2021-03-02 16:09:28 +00:00
|
|
|
|
* “start“ and “end“ and allows you to specify [struct@Pango.Attribute]
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* values for this label.
|
2011-04-14 21:50:45 +00:00
|
|
|
|
*
|
2014-02-02 05:29:00 +00:00
|
|
|
|
* An example of a UI definition fragment specifying Pango attributes:
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* ```xml
|
2011-04-14 21:50:45 +00:00
|
|
|
|
* <object class="GtkLabel">
|
|
|
|
|
* <attributes>
|
|
|
|
|
* <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
|
2017-07-07 07:13:41 +00:00
|
|
|
|
* <attribute name="background" value="red" start="5" end="10"/>
|
2011-04-14 21:50:45 +00:00
|
|
|
|
* </attributes>
|
|
|
|
|
* </object>
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* ```
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2011-04-14 21:50:45 +00:00
|
|
|
|
* The start and end attributes specify the range of characters to which the
|
|
|
|
|
* Pango attribute applies. If start and end are not specified, the attribute is
|
|
|
|
|
* applied to the whole text. Note that specifying ranges does not make much
|
|
|
|
|
* sense with translatable attributes. Use markup embedded in the translatable
|
|
|
|
|
* content instead.
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2020-07-28 20:53:19 +00:00
|
|
|
|
* # Accessibility
|
|
|
|
|
*
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* `GtkLabel` uses the %GTK_ACCESSIBLE_ROLE_LABEL role.
|
2020-07-28 20:53:19 +00:00
|
|
|
|
*
|
2014-02-05 02:00:58 +00:00
|
|
|
|
* # Mnemonics
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Labels may contain “mnemonics”. Mnemonics are underlined characters in the
|
|
|
|
|
* label, used for keyboard navigation. Mnemonics are created by providing a
|
|
|
|
|
* string with an underscore before the mnemonic character, such as `"_File"`,
|
|
|
|
|
* to the functions [ctor@Gtk.Label.new_with_mnemonic] or
|
|
|
|
|
* [method@Gtk.Label.set_text_with_mnemonic].
|
2011-04-14 21:50:45 +00:00
|
|
|
|
*
|
|
|
|
|
* Mnemonics automatically activate any activatable widget the label is
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* inside, such as a [class@Gtk.Button]; if the label is not inside the
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* mnemonic’s target widget, you have to tell the label about the target
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* using [class@Gtk.Label.set_mnemonic_widget]. Here’s a simple example where
|
2011-04-14 21:50:45 +00:00
|
|
|
|
* the label is inside a button:
|
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* ```c
|
|
|
|
|
* // Pressing Alt+H will activate this button
|
|
|
|
|
* GtkWidget *button = gtk_button_new ();
|
|
|
|
|
* GtkWidget *label = gtk_label_new_with_mnemonic ("_Hello");
|
|
|
|
|
* gtk_button_set_child (GTK_BUTTON (button), label);
|
|
|
|
|
* ```
|
2011-04-14 21:50:45 +00:00
|
|
|
|
*
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* There’s a convenience function to create buttons with a mnemonic label
|
2011-04-14 21:50:45 +00:00
|
|
|
|
* already inside:
|
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* ```c
|
|
|
|
|
* // Pressing Alt+H will activate this button
|
|
|
|
|
* GtkWidget *button = gtk_button_new_with_mnemonic ("_Hello");
|
|
|
|
|
* ```
|
2011-04-14 21:50:45 +00:00
|
|
|
|
*
|
|
|
|
|
* To create a mnemonic for a widget alongside the label, such as a
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* [class@Gtk.Entry], you have to point the label at the entry with
|
|
|
|
|
* [method@Gtk.Label.set_mnemonic_widget]:
|
|
|
|
|
*
|
|
|
|
|
* ```c
|
|
|
|
|
* // Pressing Alt+H will focus the entry
|
|
|
|
|
* GtkWidget *entry = gtk_entry_new ();
|
|
|
|
|
* GtkWidget *label = gtk_label_new_with_mnemonic ("_Hello");
|
|
|
|
|
* gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
|
|
|
|
|
* ```
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-05 02:00:58 +00:00
|
|
|
|
* # Markup (styled text)
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
|
|
|
|
* To make it easy to format text in a label (changing colors,
|
2014-02-07 02:07:03 +00:00
|
|
|
|
* fonts, etc.), label text can be provided in a simple
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* markup format:
|
2011-04-14 21:50:45 +00:00
|
|
|
|
*
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* Here’s how to create a label with a small font:
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* ```c
|
|
|
|
|
* GtkWidget *label = gtk_label_new (NULL);
|
|
|
|
|
* gtk_label_set_markup (GTK_LABEL (label), "<small>Small text</small>");
|
|
|
|
|
* ```
|
2011-04-14 21:50:45 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* (See the Pango manual for complete documentation] of available
|
|
|
|
|
* tags, [func@Pango.parse_markup])
|
2011-04-14 21:50:45 +00:00
|
|
|
|
*
|
|
|
|
|
* The markup passed to gtk_label_set_markup() must be valid; for example,
|
2014-02-09 22:24:06 +00:00
|
|
|
|
* literal <, > and & characters must be escaped as <, >, and &.
|
|
|
|
|
* If you pass text obtained from the user, file, or a network to
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* [method@Gtk.Label.set_markup], you’ll want to escape it with
|
2011-04-14 21:50:45 +00:00
|
|
|
|
* g_markup_escape_text() or g_markup_printf_escaped().
|
|
|
|
|
*
|
2021-03-02 16:09:28 +00:00
|
|
|
|
* Markup strings are just a convenient way to set the [struct@Pango.AttrList]
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* on a label; [method@Gtk.Label.set_attributes] may be a simpler way to set
|
2021-03-02 16:09:28 +00:00
|
|
|
|
* attributes in some cases. Be careful though; [struct@Pango.AttrList] tends
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* to cause internationalization problems, unless you’re applying attributes
|
2011-04-14 21:50:45 +00:00
|
|
|
|
* to the entire string (i.e. unless you set the range of each attribute
|
|
|
|
|
* to [0, %G_MAXINT)). The reason is that specifying the start_index and
|
2021-03-02 16:09:28 +00:00
|
|
|
|
* end_index for a [struct@Pango.Attribute] requires knowledge of the exact
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* string being displayed, so translations will cause problems.
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2014-02-05 02:00:58 +00:00
|
|
|
|
* # Selectable labels
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Labels can be made selectable with [method@Gtk.Label.set_selectable].
|
2011-04-14 21:50:45 +00:00
|
|
|
|
* Selectable labels allow the user to copy the label contents to
|
|
|
|
|
* the clipboard. Only labels that contain useful-to-copy information
|
2014-09-08 19:23:52 +00:00
|
|
|
|
* — such as error messages — should be made selectable.
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* # Text layout
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2011-04-14 21:50:45 +00:00
|
|
|
|
* A label can contain any number of paragraphs, but will have
|
|
|
|
|
* performance problems if it contains more than a small number.
|
|
|
|
|
* Paragraphs are separated by newlines or other paragraph separators
|
|
|
|
|
* understood by Pango.
|
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Labels can automatically wrap text if you call [method@Gtk.Label.set_wrap].
|
2011-04-14 21:50:45 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* [method@Gtk.Label.set_justify] sets how the lines in a label align
|
|
|
|
|
* with one another. If you want to set how the label as a whole aligns
|
|
|
|
|
* in its available space, see the [property@Gtk.Widget:halign] and
|
|
|
|
|
* [property@Gtk.Widget:valign] properties.
|
2011-04-14 21:50:45 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* The [property@Gtk.Label:width-chars] and [property@Gtk.Label:max-width-chars]
|
|
|
|
|
* properties can be used to control the size allocation of ellipsized or
|
|
|
|
|
* wrapped labels. For ellipsizing labels, if either is specified (and less
|
2011-04-14 21:50:45 +00:00
|
|
|
|
* than the actual text size), it is used as the minimum width, and the actual
|
|
|
|
|
* text size is used as the natural width of the label. For wrapping labels,
|
|
|
|
|
* width-chars is used as the minimum width, if specified, and max-width-chars
|
|
|
|
|
* is used as the natural width. Even if max-width-chars specified, wrapping
|
|
|
|
|
* labels will be rewrapped to use all of the available width.
|
|
|
|
|
*
|
2014-02-05 02:00:58 +00:00
|
|
|
|
* # Links
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* GTK supports markup for clickable hyperlinks in addition to regular Pango
|
|
|
|
|
* markup. The markup for links is borrowed from HTML, using the `<a>` with
|
|
|
|
|
* “href“, “title“ and “class“ attributes. GTK renders links similar to the
|
|
|
|
|
* way they appear in web browsers, with colored, underlined text. The “title“
|
|
|
|
|
* attribute is displayed as a tooltip on the link. The “class“ attribute is
|
|
|
|
|
* used as style class on the CSS node for the link.
|
2011-04-14 21:50:45 +00:00
|
|
|
|
*
|
2014-02-02 05:29:00 +00:00
|
|
|
|
* An example looks like this:
|
2014-02-04 22:38:09 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* ```c
|
2020-07-24 18:40:36 +00:00
|
|
|
|
* const char *text =
|
2022-11-17 03:46:01 +00:00
|
|
|
|
* "Go to the "
|
|
|
|
|
* "<a href=\"https://www.gtk.org\" title=\"<i>Our</i> website\">"
|
2020-09-12 16:01:04 +00:00
|
|
|
|
* "GTK website</a> for more...";
|
2017-10-11 10:18:22 +00:00
|
|
|
|
* GtkWidget *label = gtk_label_new (NULL);
|
|
|
|
|
* gtk_label_set_markup (GTK_LABEL (label), text);
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* ```
|
2011-04-14 21:50:45 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* It is possible to implement custom handling for links and their tooltips
|
|
|
|
|
* with the [signal@Gtk.Label::activate-link] signal and the
|
|
|
|
|
* [method@Gtk.Label.get_current_uri] function.
|
2011-04-14 21:50:45 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2019-05-28 23:45:45 +00:00
|
|
|
|
typedef struct _GtkLabelClass GtkLabelClass;
|
|
|
|
|
typedef struct _GtkLabelSelectionInfo GtkLabelSelectionInfo;
|
|
|
|
|
|
|
|
|
|
struct _GtkLabel
|
|
|
|
|
{
|
|
|
|
|
GtkWidget parent_instance;
|
|
|
|
|
|
2010-06-24 02:36:08 +00:00
|
|
|
|
GtkLabelSelectionInfo *select_info;
|
|
|
|
|
GtkWidget *mnemonic_widget;
|
2018-08-16 03:43:37 +00:00
|
|
|
|
GtkEventController *mnemonic_controller;
|
2010-06-24 02:36:08 +00:00
|
|
|
|
|
|
|
|
|
PangoAttrList *attrs;
|
2012-01-06 04:07:36 +00:00
|
|
|
|
PangoAttrList *markup_attrs;
|
2010-06-24 02:36:08 +00:00
|
|
|
|
PangoLayout *layout;
|
2022-07-31 15:40:20 +00:00
|
|
|
|
PangoTabArray *tabs;
|
2009-12-20 08:04:52 +00:00
|
|
|
|
|
2019-01-27 21:43:54 +00:00
|
|
|
|
GtkWidget *popup_menu;
|
|
|
|
|
GMenuModel *extra_menu;
|
|
|
|
|
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *label;
|
|
|
|
|
char *text;
|
2010-06-24 02:36:08 +00:00
|
|
|
|
|
2020-07-24 20:25:56 +00:00
|
|
|
|
float xalign;
|
|
|
|
|
float yalign;
|
2011-04-12 16:34:11 +00:00
|
|
|
|
|
2011-09-04 03:59:40 +00:00
|
|
|
|
guint mnemonics_visible : 1;
|
2011-04-12 16:34:11 +00:00
|
|
|
|
guint jtype : 2;
|
|
|
|
|
guint wrap : 1;
|
|
|
|
|
guint use_underline : 1;
|
|
|
|
|
guint ellipsize : 3;
|
2018-05-11 06:28:34 +00:00
|
|
|
|
guint use_markup : 1;
|
|
|
|
|
guint wrap_mode : 3;
|
2021-12-19 18:22:31 +00:00
|
|
|
|
guint natural_wrap_mode : 3;
|
2011-04-12 16:34:11 +00:00
|
|
|
|
guint single_line_mode : 1;
|
|
|
|
|
guint in_click : 1;
|
|
|
|
|
guint track_links : 1;
|
2010-06-24 02:36:08 +00:00
|
|
|
|
|
|
|
|
|
guint mnemonic_keyval;
|
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int width_chars;
|
|
|
|
|
int max_width_chars;
|
|
|
|
|
int lines;
|
2010-06-24 02:36:08 +00:00
|
|
|
|
};
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
struct _GtkLabelClass
|
|
|
|
|
{
|
|
|
|
|
GtkWidgetClass parent_class;
|
|
|
|
|
|
|
|
|
|
void (* move_cursor) (GtkLabel *self,
|
|
|
|
|
GtkMovementStep step,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int count,
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gboolean extend_selection);
|
|
|
|
|
void (* copy_clipboard) (GtkLabel *self);
|
|
|
|
|
|
|
|
|
|
gboolean (*activate_link) (GtkLabel *self,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *uri);
|
2020-04-13 06:56:33 +00:00
|
|
|
|
};
|
|
|
|
|
|
2009-05-11 05:23:13 +00:00
|
|
|
|
/* Notes about the handling of links:
|
|
|
|
|
*
|
|
|
|
|
* Links share the GtkLabelSelectionInfo struct with selectable labels.
|
|
|
|
|
* There are some new fields for links. The links field contains the list
|
|
|
|
|
* of GtkLabelLink structs that describe the links which are embedded in
|
|
|
|
|
* the label. The active_link field points to the link under the mouse
|
2014-02-07 19:03:49 +00:00
|
|
|
|
* pointer. For keyboard navigation, the “focus” link is determined by
|
2009-05-11 05:23:13 +00:00
|
|
|
|
* finding the link which contains the selection_anchor position.
|
|
|
|
|
* The link_clicked field is used with button press and release events
|
|
|
|
|
* to ensure that pressing inside a link and releasing outside of it
|
|
|
|
|
* does not activate the link.
|
|
|
|
|
*
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* Links are rendered with the %GTK_STATE_FLAG_LINK/%GTK_STATE_FLAG_VISITED
|
2014-03-17 19:00:45 +00:00
|
|
|
|
* state flags. When the mouse pointer is over a link, the pointer is changed
|
|
|
|
|
* to indicate the link.
|
2009-05-11 05:23:13 +00:00
|
|
|
|
*
|
|
|
|
|
* Labels with links accept keyboard focus, and it is possible to move
|
|
|
|
|
* the focus between the embedded links using Tab/Shift-Tab. The focus
|
|
|
|
|
* is indicated by a focus rectangle that is drawn around the link text.
|
2016-08-31 05:46:34 +00:00
|
|
|
|
* Pressing Enter activates the focused link, and there is a suitable
|
2009-05-11 05:23:13 +00:00
|
|
|
|
* context menu for links that can be opened with the Menu key. Pressing
|
|
|
|
|
* Control-C copies the link URI to the clipboard.
|
|
|
|
|
*
|
|
|
|
|
* In selectable labels with links, link functionality is only available
|
|
|
|
|
* when the selection is empty.
|
|
|
|
|
*/
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *uri;
|
|
|
|
|
char *title; /* the title attribute, used as tooltip */
|
2015-11-15 06:00:20 +00:00
|
|
|
|
|
|
|
|
|
GtkCssNode *cssnode;
|
|
|
|
|
|
2009-05-11 05:23:13 +00:00
|
|
|
|
gboolean visited; /* get set when the link is activated; this flag
|
|
|
|
|
* gets preserved over later set_markup() calls
|
|
|
|
|
*/
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int start; /* position of the link in the PangoLayout */
|
|
|
|
|
int end;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
} GtkLabelLink;
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
2001-02-17 00:11:03 +00:00
|
|
|
|
struct _GtkLabelSelectionInfo
|
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int selection_anchor;
|
|
|
|
|
int selection_end;
|
2015-11-11 01:28:10 +00:00
|
|
|
|
GtkCssNode *selection_node;
|
2017-11-28 01:36:16 +00:00
|
|
|
|
GdkContentProvider *provider;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-04-10 13:41:56 +00:00
|
|
|
|
GtkLabelLink *links;
|
|
|
|
|
guint n_links;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
GtkLabelLink *active_link;
|
2019-01-27 21:43:54 +00:00
|
|
|
|
GtkLabelLink *context_link;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2015-11-20 15:06:10 +00:00
|
|
|
|
GtkGesture *drag_gesture;
|
2019-05-29 17:10:46 +00:00
|
|
|
|
GtkGesture *click_gesture;
|
2017-12-11 23:30:22 +00:00
|
|
|
|
GtkEventController *motion_controller;
|
2020-08-02 15:24:27 +00:00
|
|
|
|
GtkEventController *focus_controller;
|
2015-11-20 15:06:10 +00:00
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int drag_start_x;
|
|
|
|
|
int drag_start_y;
|
2004-11-12 21:52:04 +00:00
|
|
|
|
|
2009-05-11 05:23:13 +00:00
|
|
|
|
guint in_drag : 1;
|
2009-01-22 00:33:54 +00:00
|
|
|
|
guint select_words : 1;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
guint selectable : 1;
|
|
|
|
|
guint link_clicked : 1;
|
2001-02-17 00:11:03 +00:00
|
|
|
|
};
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2001-09-19 00:49:52 +00:00
|
|
|
|
enum {
|
|
|
|
|
MOVE_CURSOR,
|
|
|
|
|
COPY_CLIPBOARD,
|
2009-05-11 05:23:13 +00:00
|
|
|
|
ACTIVATE_LINK,
|
2009-05-11 06:44:12 +00:00
|
|
|
|
ACTIVATE_CURRENT_LINK,
|
2001-09-19 00:49:52 +00:00
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
2001-03-21 18:58:28 +00:00
|
|
|
|
|
1998-01-17 07:52:38 +00:00
|
|
|
|
enum {
|
2001-03-05 14:08:42 +00:00
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_LABEL,
|
|
|
|
|
PROP_ATTRIBUTES,
|
|
|
|
|
PROP_USE_MARKUP,
|
|
|
|
|
PROP_USE_UNDERLINE,
|
|
|
|
|
PROP_JUSTIFY,
|
|
|
|
|
PROP_WRAP,
|
2006-06-19 14:27:50 +00:00
|
|
|
|
PROP_WRAP_MODE,
|
2021-12-19 18:22:31 +00:00
|
|
|
|
PROP_NATURAL_WRAP_MODE,
|
2001-03-05 14:08:42 +00:00
|
|
|
|
PROP_SELECTABLE,
|
2001-03-22 13:44:00 +00:00
|
|
|
|
PROP_MNEMONIC_KEYVAL,
|
2001-10-22 21:01:47 +00:00
|
|
|
|
PROP_MNEMONIC_WIDGET,
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
PROP_ELLIPSIZE,
|
2004-11-09 05:04:41 +00:00
|
|
|
|
PROP_WIDTH_CHARS,
|
2004-11-21 16:24:01 +00:00
|
|
|
|
PROP_SINGLE_LINE_MODE,
|
2009-07-09 17:59:35 +00:00
|
|
|
|
PROP_MAX_WIDTH_CHARS,
|
2014-09-16 03:17:11 +00:00
|
|
|
|
PROP_LINES,
|
|
|
|
|
PROP_XALIGN,
|
2015-09-05 07:58:50 +00:00
|
|
|
|
PROP_YALIGN,
|
2019-01-27 21:43:54 +00:00
|
|
|
|
PROP_EXTRA_MENU,
|
2022-07-31 15:40:20 +00:00
|
|
|
|
PROP_TABS,
|
2015-09-05 07:58:50 +00:00
|
|
|
|
NUM_PROPERTIES
|
1998-01-17 07:52:38 +00:00
|
|
|
|
};
|
|
|
|
|
|
2015-09-05 07:58:50 +00:00
|
|
|
|
static GParamSpec *label_props[NUM_PROPERTIES] = { NULL, };
|
|
|
|
|
|
2001-09-19 00:49:52 +00:00
|
|
|
|
static guint signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
2015-09-12 13:14:47 +00:00
|
|
|
|
static GQuark quark_mnemonics_visible_connected;
|
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
static void gtk_label_set_markup_internal (GtkLabel *self,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
const char *str,
|
|
|
|
|
gboolean with_uline);
|
2020-04-13 06:56:33 +00:00
|
|
|
|
static void gtk_label_recalculate (GtkLabel *self);
|
|
|
|
|
static void gtk_label_do_popup (GtkLabel *self,
|
2019-01-27 21:43:54 +00:00
|
|
|
|
double x,
|
|
|
|
|
double y);
|
2020-04-13 06:56:33 +00:00
|
|
|
|
static void gtk_label_ensure_select_info (GtkLabel *self);
|
|
|
|
|
static void gtk_label_clear_select_info (GtkLabel *self);
|
|
|
|
|
static void gtk_label_clear_layout (GtkLabel *self);
|
|
|
|
|
static void gtk_label_ensure_layout (GtkLabel *self);
|
|
|
|
|
static void gtk_label_select_region_index (GtkLabel *self,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int anchor_index,
|
|
|
|
|
int end_index);
|
2017-07-25 14:18:07 +00:00
|
|
|
|
static void gtk_label_update_active_link (GtkWidget *widget,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double x,
|
|
|
|
|
double y);
|
2020-04-13 06:56:33 +00:00
|
|
|
|
static void gtk_label_setup_mnemonic (GtkLabel *self);
|
2004-11-12 21:52:04 +00:00
|
|
|
|
|
2019-08-29 13:21:20 +00:00
|
|
|
|
static void gtk_label_buildable_interface_init (GtkBuildableIface *iface);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
/* For selectable labels: */
|
2020-04-13 06:56:33 +00:00
|
|
|
|
static void gtk_label_move_cursor (GtkLabel *self,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
GtkMovementStep step,
|
|
|
|
|
int count,
|
|
|
|
|
gboolean extend_selection);
|
2019-01-27 21:43:54 +00:00
|
|
|
|
|
2008-04-11 16:56:26 +00:00
|
|
|
|
static GtkBuildableIface *buildable_parent_iface = NULL;
|
|
|
|
|
|
2016-10-02 16:19:59 +00:00
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkLabel, gtk_label, GTK_TYPE_WIDGET,
|
2014-05-13 12:45:00 +00:00
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
|
|
|
|
|
gtk_label_buildable_interface_init))
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2001-09-19 00:49:52 +00:00
|
|
|
|
static void
|
2018-08-12 14:55:43 +00:00
|
|
|
|
add_move_binding (GtkWidgetClass *widget_class,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
guint keyval,
|
|
|
|
|
guint modmask,
|
|
|
|
|
GtkMovementStep step,
|
|
|
|
|
int count)
|
2001-09-19 00:49:52 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail ((modmask & GDK_SHIFT_MASK) == 0);
|
2020-12-25 11:05:28 +00:00
|
|
|
|
|
2018-08-12 14:55:43 +00:00
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
keyval, modmask,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
"move-cursor",
|
2018-08-12 14:55:43 +00:00
|
|
|
|
"(iib)", step, count, FALSE);
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
|
|
|
|
/* Selection-extending version */
|
2018-08-12 14:55:43 +00:00
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
keyval, modmask | GDK_SHIFT_MASK,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
"move-cursor",
|
2018-08-12 14:55:43 +00:00
|
|
|
|
"(iib)", step, count, TRUE);
|
2001-09-19 00:49:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-01-08 19:02:40 +00:00
|
|
|
|
static void
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_label_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
GtkLabel *self = GTK_LABEL (object);
|
2001-03-22 13:44:00 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_LABEL:
|
|
|
|
|
gtk_label_set_label (self, g_value_get_string (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_ATTRIBUTES:
|
|
|
|
|
gtk_label_set_attributes (self, g_value_get_boxed (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_USE_MARKUP:
|
|
|
|
|
gtk_label_set_use_markup (self, g_value_get_boolean (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_USE_UNDERLINE:
|
|
|
|
|
gtk_label_set_use_underline (self, g_value_get_boolean (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_JUSTIFY:
|
|
|
|
|
gtk_label_set_justify (self, g_value_get_enum (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_WRAP:
|
|
|
|
|
gtk_label_set_wrap (self, g_value_get_boolean (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_WRAP_MODE:
|
|
|
|
|
gtk_label_set_wrap_mode (self, g_value_get_enum (value));
|
|
|
|
|
break;
|
2021-12-19 18:22:31 +00:00
|
|
|
|
case PROP_NATURAL_WRAP_MODE:
|
|
|
|
|
gtk_label_set_natural_wrap_mode (self, g_value_get_enum (value));
|
|
|
|
|
break;
|
2020-12-25 11:05:28 +00:00
|
|
|
|
case PROP_SELECTABLE:
|
|
|
|
|
gtk_label_set_selectable (self, g_value_get_boolean (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_MNEMONIC_WIDGET:
|
|
|
|
|
gtk_label_set_mnemonic_widget (self, (GtkWidget*) g_value_get_object (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_ELLIPSIZE:
|
|
|
|
|
gtk_label_set_ellipsize (self, g_value_get_enum (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_WIDTH_CHARS:
|
|
|
|
|
gtk_label_set_width_chars (self, g_value_get_int (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_SINGLE_LINE_MODE:
|
|
|
|
|
gtk_label_set_single_line_mode (self, g_value_get_boolean (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_MAX_WIDTH_CHARS:
|
|
|
|
|
gtk_label_set_max_width_chars (self, g_value_get_int (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_LINES:
|
|
|
|
|
gtk_label_set_lines (self, g_value_get_int (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_XALIGN:
|
|
|
|
|
gtk_label_set_xalign (self, g_value_get_float (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_YALIGN:
|
|
|
|
|
gtk_label_set_yalign (self, g_value_get_float (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_EXTRA_MENU:
|
|
|
|
|
gtk_label_set_extra_menu (self, g_value_get_object (value));
|
|
|
|
|
break;
|
2022-07-31 15:40:20 +00:00
|
|
|
|
case PROP_TABS:
|
|
|
|
|
gtk_label_set_tabs (self, g_value_get_boxed (value));
|
|
|
|
|
break;
|
2020-12-25 11:05:28 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-03-22 13:44:00 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
GtkLabel *self = GTK_LABEL (object);
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_LABEL:
|
|
|
|
|
g_value_set_string (value, self->label);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_ATTRIBUTES:
|
|
|
|
|
g_value_set_boxed (value, self->attrs);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_USE_MARKUP:
|
|
|
|
|
g_value_set_boolean (value, self->use_markup);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_USE_UNDERLINE:
|
|
|
|
|
g_value_set_boolean (value, self->use_underline);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_JUSTIFY:
|
|
|
|
|
g_value_set_enum (value, self->jtype);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_WRAP:
|
|
|
|
|
g_value_set_boolean (value, self->wrap);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_WRAP_MODE:
|
|
|
|
|
g_value_set_enum (value, self->wrap_mode);
|
|
|
|
|
break;
|
2021-12-19 18:22:31 +00:00
|
|
|
|
case PROP_NATURAL_WRAP_MODE:
|
|
|
|
|
g_value_set_enum (value, self->natural_wrap_mode);
|
|
|
|
|
break;
|
2020-12-25 11:05:28 +00:00
|
|
|
|
case PROP_SELECTABLE:
|
|
|
|
|
g_value_set_boolean (value, gtk_label_get_selectable (self));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_MNEMONIC_KEYVAL:
|
|
|
|
|
g_value_set_uint (value, self->mnemonic_keyval);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_MNEMONIC_WIDGET:
|
|
|
|
|
g_value_set_object (value, (GObject*) self->mnemonic_widget);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_ELLIPSIZE:
|
|
|
|
|
g_value_set_enum (value, self->ellipsize);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_WIDTH_CHARS:
|
|
|
|
|
g_value_set_int (value, gtk_label_get_width_chars (self));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_SINGLE_LINE_MODE:
|
|
|
|
|
g_value_set_boolean (value, gtk_label_get_single_line_mode (self));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_MAX_WIDTH_CHARS:
|
|
|
|
|
g_value_set_int (value, gtk_label_get_max_width_chars (self));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_LINES:
|
|
|
|
|
g_value_set_int (value, gtk_label_get_lines (self));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_XALIGN:
|
|
|
|
|
g_value_set_float (value, gtk_label_get_xalign (self));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_YALIGN:
|
|
|
|
|
g_value_set_float (value, gtk_label_get_yalign (self));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_EXTRA_MENU:
|
|
|
|
|
g_value_set_object (value, gtk_label_get_extra_menu (self));
|
|
|
|
|
break;
|
2022-07-31 15:40:20 +00:00
|
|
|
|
case PROP_TABS:
|
|
|
|
|
g_value_set_boxed (value, self->tabs);
|
|
|
|
|
break;
|
2020-12-25 11:05:28 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_init (GtkLabel *self)
|
|
|
|
|
{
|
|
|
|
|
self->width_chars = -1;
|
|
|
|
|
self->max_width_chars = -1;
|
|
|
|
|
self->label = g_strdup ("");
|
|
|
|
|
self->lines = -1;
|
2008-12-29 21:20:18 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
self->xalign = 0.5;
|
|
|
|
|
self->yalign = 0.5;
|
2009-05-11 06:44:12 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
self->jtype = GTK_JUSTIFY_LEFT;
|
|
|
|
|
self->wrap = FALSE;
|
|
|
|
|
self->wrap_mode = PANGO_WRAP_WORD;
|
2021-12-19 18:22:31 +00:00
|
|
|
|
self->natural_wrap_mode = GTK_NATURAL_WRAP_INHERIT;
|
2020-12-25 11:05:28 +00:00
|
|
|
|
self->ellipsize = PANGO_ELLIPSIZE_NONE;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
self->use_underline = FALSE;
|
|
|
|
|
self->use_markup = FALSE;
|
2015-09-05 07:58:50 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
self->mnemonic_keyval = GDK_KEY_VoidSymbol;
|
|
|
|
|
self->layout = NULL;
|
|
|
|
|
self->text = g_strdup ("");
|
|
|
|
|
self->attrs = NULL;
|
2022-07-31 15:40:20 +00:00
|
|
|
|
self->tabs = NULL;
|
2015-09-05 07:58:50 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
self->mnemonic_widget = NULL;
|
2015-09-05 07:58:50 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
self->mnemonics_visible = FALSE;
|
|
|
|
|
}
|
2015-09-05 07:58:50 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static const GtkBuildableParser pango_parser =
|
|
|
|
|
{
|
|
|
|
|
gtk_pango_attribute_start_element,
|
|
|
|
|
};
|
2001-03-05 14:08:42 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_label_buildable_custom_tag_start (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
|
|
|
|
const char *tagname,
|
|
|
|
|
GtkBuildableParser *parser,
|
|
|
|
|
gpointer *data)
|
|
|
|
|
{
|
|
|
|
|
if (buildable_parent_iface->custom_tag_start (buildable, builder, child,
|
|
|
|
|
tagname, parser, data))
|
|
|
|
|
return TRUE;
|
2014-09-16 03:17:11 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (strcmp (tagname, "attributes") == 0)
|
|
|
|
|
{
|
|
|
|
|
GtkPangoAttributeParserData *parser_data;
|
2015-09-05 07:58:50 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
parser_data = g_slice_new0 (GtkPangoAttributeParserData);
|
|
|
|
|
parser_data->builder = g_object_ref (builder);
|
|
|
|
|
parser_data->object = (GObject *) g_object_ref (buildable);
|
|
|
|
|
*parser = pango_parser;
|
|
|
|
|
*data = parser_data;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2014-06-07 20:40:31 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_buildable_custom_finished (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
|
|
|
|
const char *tagname,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GtkPangoAttributeParserData *data = user_data;
|
2015-09-05 07:58:50 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
buildable_parent_iface->custom_finished (buildable, builder, child,
|
|
|
|
|
tagname, user_data);
|
2015-09-05 07:58:50 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (strcmp (tagname, "attributes") == 0)
|
|
|
|
|
{
|
|
|
|
|
if (data->attrs)
|
|
|
|
|
{
|
|
|
|
|
gtk_label_set_attributes (GTK_LABEL (buildable), data->attrs);
|
|
|
|
|
pango_attr_list_unref (data->attrs);
|
|
|
|
|
}
|
2015-09-05 07:58:50 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_object_unref (data->object);
|
|
|
|
|
g_object_unref (data->builder);
|
|
|
|
|
g_slice_free (GtkPangoAttributeParserData, data);
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-09-05 07:58:50 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_buildable_interface_init (GtkBuildableIface *iface)
|
|
|
|
|
{
|
|
|
|
|
buildable_parent_iface = g_type_interface_peek_parent (iface);
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
iface->custom_tag_start = gtk_label_buildable_custom_tag_start;
|
|
|
|
|
iface->custom_finished = gtk_label_buildable_custom_finished;
|
|
|
|
|
}
|
2015-09-05 07:58:50 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
update_link_state (GtkLabel *self)
|
|
|
|
|
{
|
|
|
|
|
GtkStateFlags state;
|
|
|
|
|
guint i;
|
2004-11-21 16:24:01 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (!self->select_info)
|
|
|
|
|
return;
|
2009-07-09 17:59:35 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
for (i = 0; i < self->select_info->n_links; i++)
|
|
|
|
|
{
|
|
|
|
|
const GtkLabelLink *link = &self->select_info->links[i];
|
2015-09-05 07:58:50 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
state = gtk_widget_get_state_flags (GTK_WIDGET (self));
|
|
|
|
|
if (link->visited)
|
|
|
|
|
state |= GTK_STATE_FLAG_VISITED;
|
|
|
|
|
else
|
|
|
|
|
state |= GTK_STATE_FLAG_LINK;
|
|
|
|
|
if (link == self->select_info->active_link)
|
|
|
|
|
{
|
|
|
|
|
if (self->select_info->link_clicked)
|
|
|
|
|
state |= GTK_STATE_FLAG_ACTIVE;
|
|
|
|
|
else
|
|
|
|
|
state |= GTK_STATE_FLAG_PRELIGHT;
|
|
|
|
|
}
|
|
|
|
|
gtk_css_node_set_state (link->cssnode, state);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-27 21:43:54 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_update_cursor (GtkLabel *self)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *widget = GTK_WIDGET (self);
|
2015-09-05 07:58:50 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (!self->select_info)
|
|
|
|
|
return;
|
2020-03-16 02:25:09 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (gtk_widget_is_sensitive (widget))
|
|
|
|
|
{
|
|
|
|
|
if (self->select_info->active_link)
|
|
|
|
|
gtk_widget_set_cursor_from_name (widget, "pointer");
|
|
|
|
|
else if (self->select_info->selectable)
|
|
|
|
|
gtk_widget_set_cursor_from_name (widget, "text");
|
|
|
|
|
else
|
|
|
|
|
gtk_widget_set_cursor (widget, NULL);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
gtk_widget_set_cursor (widget, NULL);
|
|
|
|
|
}
|
2020-03-16 02:25:09 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_state_flags_changed (GtkWidget *widget,
|
|
|
|
|
GtkStateFlags prev_state)
|
|
|
|
|
{
|
|
|
|
|
GtkLabel *self = GTK_LABEL (widget);
|
2020-03-16 02:25:09 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (self->select_info)
|
|
|
|
|
{
|
2021-05-03 20:25:36 +00:00
|
|
|
|
GtkStateFlags state;
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (!gtk_widget_is_sensitive (widget))
|
|
|
|
|
gtk_label_select_region (self, 0, 0);
|
2015-09-05 07:58:50 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_label_update_cursor (self);
|
|
|
|
|
update_link_state (self);
|
2021-05-03 20:25:36 +00:00
|
|
|
|
|
|
|
|
|
state = gtk_widget_get_state_flags (widget) & ~GTK_STATE_FLAG_DROP_ACTIVE;
|
|
|
|
|
|
|
|
|
|
if (self->select_info->selection_node)
|
|
|
|
|
{
|
|
|
|
|
gtk_css_node_set_state (self->select_info->selection_node, state);
|
|
|
|
|
|
|
|
|
|
gtk_widget_queue_draw (widget);
|
|
|
|
|
}
|
2020-12-25 11:05:28 +00:00
|
|
|
|
}
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (GTK_WIDGET_CLASS (gtk_label_parent_class)->state_flags_changed)
|
|
|
|
|
GTK_WIDGET_CLASS (gtk_label_parent_class)->state_flags_changed (widget, prev_state);
|
|
|
|
|
}
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_update_layout_attributes (GtkLabel *self,
|
|
|
|
|
PangoAttrList *style_attrs)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *widget = GTK_WIDGET (self);
|
|
|
|
|
GtkCssStyle *style;
|
|
|
|
|
PangoAttrList *attrs;
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (self->layout == NULL)
|
|
|
|
|
{
|
|
|
|
|
pango_attr_list_unref (style_attrs);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (self->select_info && self->select_info->links)
|
|
|
|
|
{
|
|
|
|
|
guint i;
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
attrs = pango_attr_list_new ();
|
2005-12-26 07:02:51 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
for (i = 0; i < self->select_info->n_links; i++)
|
|
|
|
|
{
|
|
|
|
|
const GtkLabelLink *link = &self->select_info->links[i];
|
|
|
|
|
const GdkRGBA *link_color;
|
|
|
|
|
PangoAttrList *link_attrs;
|
|
|
|
|
PangoAttribute *attr;
|
2018-08-12 14:55:43 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
style = gtk_css_node_get_style (link->cssnode);
|
|
|
|
|
link_attrs = gtk_css_style_get_pango_attributes (style);
|
|
|
|
|
if (link_attrs)
|
|
|
|
|
{
|
|
|
|
|
GSList *attributes = pango_attr_list_get_attributes (link_attrs);
|
|
|
|
|
GSList *l;
|
|
|
|
|
for (l = attributes; l; l = l->next)
|
|
|
|
|
{
|
|
|
|
|
attr = l->data;
|
2018-08-12 14:55:43 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
attr->start_index = link->start;
|
|
|
|
|
attr->end_index = link->end;
|
|
|
|
|
pango_attr_list_insert (attrs, attr);
|
|
|
|
|
}
|
|
|
|
|
g_slist_free (attributes);
|
|
|
|
|
}
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
link_color = gtk_css_color_value_get_rgba (style->core->color);
|
|
|
|
|
attr = pango_attr_foreground_new (link_color->red * 65535,
|
|
|
|
|
link_color->green * 65535,
|
|
|
|
|
link_color->blue * 65535);
|
|
|
|
|
attr->start_index = link->start;
|
|
|
|
|
attr->end_index = link->end;
|
|
|
|
|
pango_attr_list_insert (attrs, attr);
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
pango_attr_list_unref (link_attrs);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
attrs = NULL;
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
|
|
|
|
|
if (!style_attrs)
|
|
|
|
|
style_attrs = gtk_css_style_get_pango_attributes (style);
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (style_attrs)
|
|
|
|
|
{
|
|
|
|
|
attrs = _gtk_pango_attr_list_merge (attrs, style_attrs);
|
|
|
|
|
pango_attr_list_unref (style_attrs);
|
|
|
|
|
}
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
attrs = _gtk_pango_attr_list_merge (attrs, self->markup_attrs);
|
|
|
|
|
attrs = _gtk_pango_attr_list_merge (attrs, self->attrs);
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
pango_layout_set_attributes (self->layout, attrs);
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
pango_attr_list_unref (attrs);
|
|
|
|
|
}
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_css_changed (GtkWidget *widget,
|
|
|
|
|
GtkCssStyleChange *change)
|
|
|
|
|
{
|
|
|
|
|
GtkLabel *self = GTK_LABEL (widget);
|
|
|
|
|
gboolean attrs_affected;
|
|
|
|
|
PangoAttrList *new_attrs = NULL;
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
GTK_WIDGET_CLASS (gtk_label_parent_class)->css_changed (widget, change);
|
2018-08-12 14:55:43 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT_ATTRS))
|
|
|
|
|
{
|
|
|
|
|
new_attrs = gtk_css_style_get_pango_attributes (gtk_css_style_change_get_new_style (change));
|
|
|
|
|
attrs_affected = (self->layout && pango_layout_get_attributes (self->layout)) ||
|
|
|
|
|
new_attrs;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
attrs_affected = FALSE;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (change == NULL || attrs_affected || (self->select_info && self->select_info->links))
|
|
|
|
|
{
|
|
|
|
|
gtk_label_update_layout_attributes (self, new_attrs);
|
2015-10-23 03:18:30 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (attrs_affected)
|
|
|
|
|
gtk_widget_queue_draw (widget);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-06-15 00:05:51 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static PangoDirection
|
|
|
|
|
get_cursor_direction (GtkLabel *self)
|
|
|
|
|
{
|
|
|
|
|
GSList *l;
|
2020-04-20 02:50:35 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_assert (self->select_info);
|
2020-04-20 02:50:35 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_label_ensure_layout (self);
|
2020-04-20 02:50:35 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
for (l = pango_layout_get_lines_readonly (self->layout); l; l = l->next)
|
|
|
|
|
{
|
|
|
|
|
PangoLayoutLine *line = l->data;
|
2020-04-20 02:50:35 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/* If self->select_info->selection_end is at the very end of
|
|
|
|
|
* the line, we don't know if the cursor is on this line or
|
|
|
|
|
* the next without looking ahead at the next line. (End
|
|
|
|
|
* of paragraph is different from line break.) But it's
|
|
|
|
|
* definitely in this paragraph, which is good enough
|
|
|
|
|
* to figure out the resolved direction.
|
|
|
|
|
*/
|
2022-01-23 14:09:57 +00:00
|
|
|
|
if (pango_layout_line_get_start_index (line) + pango_layout_line_get_length (line) >= self->select_info->selection_end)
|
|
|
|
|
return pango_layout_line_get_resolved_direction (line);
|
2020-12-25 11:05:28 +00:00
|
|
|
|
}
|
2020-04-20 02:50:35 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return PANGO_DIRECTION_LTR;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:20:35 +00:00
|
|
|
|
static int
|
|
|
|
|
_gtk_label_get_link_at (GtkLabel *self,
|
|
|
|
|
int pos)
|
|
|
|
|
{
|
|
|
|
|
if (self->select_info)
|
|
|
|
|
{
|
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < self->select_info->n_links; i++)
|
|
|
|
|
{
|
|
|
|
|
const GtkLabelLink *link = &self->select_info->links[i];
|
|
|
|
|
|
|
|
|
|
if (link->start <= pos && pos < link->end)
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static GtkLabelLink *
|
|
|
|
|
gtk_label_get_focus_link (GtkLabel *self,
|
|
|
|
|
int *out_index)
|
1998-01-17 07:52:38 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
GtkLabelSelectionInfo *info = self->select_info;
|
|
|
|
|
int link_index;
|
2001-05-17 16:22:06 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (!info ||
|
|
|
|
|
info->selection_anchor != info->selection_end)
|
|
|
|
|
goto nope;
|
|
|
|
|
|
|
|
|
|
link_index = _gtk_label_get_link_at (self, info->selection_anchor);
|
|
|
|
|
|
|
|
|
|
if (link_index != -1)
|
1998-01-17 07:52:38 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (out_index)
|
|
|
|
|
*out_index = link_index;
|
|
|
|
|
|
|
|
|
|
return &info->links[link_index];
|
1998-01-17 07:52:38 +00:00
|
|
|
|
}
|
2020-12-25 11:05:28 +00:00
|
|
|
|
|
|
|
|
|
nope:
|
|
|
|
|
if (out_index)
|
|
|
|
|
*out_index = -1;
|
|
|
|
|
return NULL;
|
1998-01-17 07:52:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_label_get_measuring_layout:
|
|
|
|
|
* @self: the label
|
|
|
|
|
* @existing_layout: %NULL or an existing layout already in use.
|
|
|
|
|
* @width: the width to measure with in pango units, or -1 for infinite
|
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Gets a layout that can be used for measuring sizes.
|
|
|
|
|
*
|
|
|
|
|
* The returned layout will be identical to the label’s layout except for
|
|
|
|
|
* the layout’s width, which will be set to @width. Do not modify the
|
|
|
|
|
* returned layout.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: a new reference to a pango layout
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static PangoLayout *
|
|
|
|
|
gtk_label_get_measuring_layout (GtkLabel *self,
|
|
|
|
|
PangoLayout *existing_layout,
|
|
|
|
|
int width)
|
1998-01-17 07:52:38 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
PangoLayout *copy;
|
2010-06-24 02:36:08 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (existing_layout != NULL)
|
1998-01-17 07:52:38 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (existing_layout != self->layout)
|
|
|
|
|
{
|
|
|
|
|
pango_layout_set_width (existing_layout, width);
|
|
|
|
|
return existing_layout;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_object_unref (existing_layout);
|
1998-01-17 07:52:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_label_ensure_layout (self);
|
1999-01-18 20:46:51 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (pango_layout_get_width (self->layout) == width)
|
|
|
|
|
{
|
|
|
|
|
g_object_ref (self->layout);
|
|
|
|
|
return self->layout;
|
|
|
|
|
}
|
2014-09-16 03:17:11 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/* We can use the label's own layout if we're not allocated a size yet,
|
|
|
|
|
* because we don't need it to be properly setup at that point.
|
|
|
|
|
* This way we can make use of caching upon the label's creation.
|
|
|
|
|
*/
|
|
|
|
|
if (gtk_widget_get_width (GTK_WIDGET (self)) <= 1)
|
|
|
|
|
{
|
|
|
|
|
g_object_ref (self->layout);
|
|
|
|
|
pango_layout_set_width (self->layout, width);
|
|
|
|
|
return self->layout;
|
|
|
|
|
}
|
2001-03-05 14:08:42 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/* oftentimes we want to measure a width that is far wider than the current width,
|
|
|
|
|
* even though the layout would not change if we made it wider. In that case, we
|
|
|
|
|
* can just return the current layout, because for measuring purposes, it will be
|
|
|
|
|
* identical.
|
|
|
|
|
*/
|
|
|
|
|
if (!pango_layout_is_wrapped (self->layout) &&
|
|
|
|
|
!pango_layout_is_ellipsized (self->layout))
|
|
|
|
|
{
|
|
|
|
|
PangoRectangle rect;
|
2009-07-09 17:59:35 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (width == -1)
|
|
|
|
|
return g_object_ref (self->layout);
|
2001-03-21 18:58:28 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
pango_layout_get_extents (self->layout, NULL, &rect);
|
|
|
|
|
if (rect.width <= width)
|
|
|
|
|
return g_object_ref (self->layout);
|
|
|
|
|
}
|
2009-07-09 17:59:35 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
copy = pango_layout_copy (self->layout);
|
|
|
|
|
pango_layout_set_width (copy, width);
|
|
|
|
|
return copy;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-18 23:04:25 +00:00
|
|
|
|
static int
|
2021-11-04 14:56:37 +00:00
|
|
|
|
get_char_pixels (PangoLayout *layout)
|
2021-10-18 23:04:25 +00:00
|
|
|
|
{
|
|
|
|
|
PangoContext *context;
|
|
|
|
|
PangoFontMetrics *metrics;
|
|
|
|
|
int char_width, digit_width;
|
|
|
|
|
|
|
|
|
|
context = pango_layout_get_context (layout);
|
|
|
|
|
metrics = pango_context_get_metrics (context, NULL, NULL);
|
|
|
|
|
char_width = pango_font_metrics_get_approximate_char_width (metrics);
|
|
|
|
|
digit_width = pango_font_metrics_get_approximate_digit_width (metrics);
|
|
|
|
|
pango_font_metrics_unref (metrics);
|
|
|
|
|
|
|
|
|
|
return MAX (char_width, digit_width);
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-11 16:56:26 +00:00
|
|
|
|
static void
|
2021-11-04 14:56:37 +00:00
|
|
|
|
get_default_widths (GtkLabel *self,
|
|
|
|
|
int *minimum,
|
|
|
|
|
int *natural)
|
2008-04-11 16:56:26 +00:00
|
|
|
|
{
|
2021-11-04 14:56:37 +00:00
|
|
|
|
int char_pixels;
|
2008-04-11 16:56:26 +00:00
|
|
|
|
|
2021-11-04 14:56:37 +00:00
|
|
|
|
if (self->width_chars < 0 && self->max_width_chars < 0)
|
|
|
|
|
{
|
|
|
|
|
if (minimum)
|
|
|
|
|
*minimum = -1;
|
|
|
|
|
if (natural)
|
|
|
|
|
*natural = -1;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2008-04-11 16:56:26 +00:00
|
|
|
|
|
2021-11-04 14:56:37 +00:00
|
|
|
|
gtk_label_ensure_layout (self);
|
|
|
|
|
char_pixels = get_char_pixels (self->layout);
|
2008-04-11 16:56:26 +00:00
|
|
|
|
|
2021-11-04 14:56:37 +00:00
|
|
|
|
if (minimum)
|
|
|
|
|
{
|
|
|
|
|
if (self->width_chars < 0)
|
|
|
|
|
*minimum = -1;
|
|
|
|
|
else
|
|
|
|
|
*minimum = char_pixels * self->width_chars;
|
|
|
|
|
}
|
2008-04-11 16:56:26 +00:00
|
|
|
|
|
2021-11-04 14:56:37 +00:00
|
|
|
|
if (natural)
|
|
|
|
|
{
|
|
|
|
|
if (self->max_width_chars < 0)
|
|
|
|
|
*natural = -1;
|
|
|
|
|
else
|
|
|
|
|
*natural = char_pixels * MAX (self->width_chars, self->max_width_chars);
|
|
|
|
|
}
|
2008-04-11 16:56:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
2021-11-04 14:56:37 +00:00
|
|
|
|
get_static_size (GtkLabel *self,
|
|
|
|
|
GtkOrientation orientation,
|
|
|
|
|
int *minimum,
|
|
|
|
|
int *natural,
|
|
|
|
|
int *minimum_baseline,
|
|
|
|
|
int *natural_baseline)
|
2001-03-21 18:58:28 +00:00
|
|
|
|
{
|
2021-11-06 15:17:59 +00:00
|
|
|
|
int minimum_default, natural_default;
|
2020-12-25 11:05:28 +00:00
|
|
|
|
PangoLayout *layout;
|
2001-03-21 18:58:28 +00:00
|
|
|
|
|
2021-11-06 15:17:59 +00:00
|
|
|
|
get_default_widths (self, &minimum_default, &natural_default);
|
|
|
|
|
|
2021-11-06 15:25:11 +00:00
|
|
|
|
layout = gtk_label_get_measuring_layout (self, NULL, self->ellipsize ? natural_default : -1);
|
2001-03-21 18:58:28 +00:00
|
|
|
|
|
2021-11-04 14:56:37 +00:00
|
|
|
|
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
2001-03-21 18:58:28 +00:00
|
|
|
|
{
|
2021-11-04 14:56:37 +00:00
|
|
|
|
pango_layout_get_size (layout, natural, NULL);
|
|
|
|
|
if (self->ellipsize)
|
2018-08-16 03:43:37 +00:00
|
|
|
|
{
|
2021-11-04 14:56:37 +00:00
|
|
|
|
layout = gtk_label_get_measuring_layout (self, layout, 0);
|
|
|
|
|
pango_layout_get_size (layout, minimum, NULL);
|
|
|
|
|
/* yes, Pango ellipsizes even when that needs more space */
|
|
|
|
|
*minimum = MIN (*minimum, *natural);
|
2018-08-16 03:43:37 +00:00
|
|
|
|
}
|
2021-11-04 14:56:37 +00:00
|
|
|
|
else
|
|
|
|
|
*minimum = *natural;
|
|
|
|
|
|
|
|
|
|
if (minimum_default > *minimum)
|
|
|
|
|
*minimum = minimum_default;
|
|
|
|
|
*natural = MAX (*minimum, *natural);
|
2018-08-16 03:43:37 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-11-04 14:56:37 +00:00
|
|
|
|
pango_layout_get_size (layout, NULL, minimum);
|
|
|
|
|
*minimum_baseline = pango_layout_get_baseline (layout);
|
|
|
|
|
|
|
|
|
|
*natural = *minimum;
|
|
|
|
|
*natural_baseline = *minimum_baseline;
|
2018-08-16 03:43:37 +00:00
|
|
|
|
}
|
2009-12-20 08:04:52 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_object_unref (layout);
|
2001-03-21 18:58:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-02 00:08:49 +00:00
|
|
|
|
static void
|
2021-11-04 14:56:37 +00:00
|
|
|
|
get_height_for_width (GtkLabel *self,
|
|
|
|
|
int width,
|
|
|
|
|
int *minimum_height,
|
|
|
|
|
int *natural_height,
|
|
|
|
|
int *minimum_baseline,
|
|
|
|
|
int *natural_baseline)
|
2020-12-25 11:05:28 +00:00
|
|
|
|
{
|
2021-11-04 14:56:37 +00:00
|
|
|
|
PangoLayout *layout;
|
|
|
|
|
int natural_width, text_height, baseline;
|
2019-05-02 00:08:49 +00:00
|
|
|
|
|
2021-11-04 14:56:37 +00:00
|
|
|
|
if (width < 0)
|
|
|
|
|
{
|
|
|
|
|
/* Minimum height is assuming infinite width */
|
|
|
|
|
layout = gtk_label_get_measuring_layout (self, NULL, -1);
|
|
|
|
|
pango_layout_get_size (layout, NULL, minimum_height);
|
|
|
|
|
baseline = pango_layout_get_baseline (layout);
|
|
|
|
|
*minimum_baseline = baseline;
|
|
|
|
|
|
|
|
|
|
/* Natural height is assuming natural width */
|
|
|
|
|
get_default_widths (self, NULL, &natural_width);
|
|
|
|
|
|
|
|
|
|
layout = gtk_label_get_measuring_layout (self, layout, natural_width);
|
|
|
|
|
pango_layout_get_size (layout, NULL, natural_height);
|
|
|
|
|
baseline = pango_layout_get_baseline (layout);
|
|
|
|
|
*natural_baseline = baseline;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* minimum = natural for any given width */
|
|
|
|
|
layout = gtk_label_get_measuring_layout (self, NULL, width);
|
2019-05-02 00:08:49 +00:00
|
|
|
|
|
2021-11-04 14:56:37 +00:00
|
|
|
|
pango_layout_get_size (layout, NULL, &text_height);
|
2019-05-02 00:08:49 +00:00
|
|
|
|
|
2021-11-04 14:56:37 +00:00
|
|
|
|
*minimum_height = text_height;
|
|
|
|
|
*natural_height = text_height;
|
2019-05-02 00:08:49 +00:00
|
|
|
|
|
2021-11-04 14:56:37 +00:00
|
|
|
|
baseline = pango_layout_get_baseline (layout);
|
|
|
|
|
*minimum_baseline = baseline;
|
|
|
|
|
*natural_baseline = baseline;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_object_unref (layout);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-13 13:49:39 +00:00
|
|
|
|
static int
|
|
|
|
|
my_pango_layout_get_width_for_height (PangoLayout *layout,
|
|
|
|
|
int for_height,
|
|
|
|
|
int min,
|
|
|
|
|
int max)
|
|
|
|
|
{
|
|
|
|
|
int mid, text_width, text_height;
|
|
|
|
|
|
|
|
|
|
min = PANGO_PIXELS_CEIL (min);
|
|
|
|
|
max = PANGO_PIXELS_CEIL (max);
|
|
|
|
|
|
|
|
|
|
while (min < max)
|
|
|
|
|
{
|
|
|
|
|
mid = (min + max) / 2;
|
|
|
|
|
pango_layout_set_width (layout, mid * PANGO_SCALE);
|
|
|
|
|
pango_layout_get_size (layout, &text_width, &text_height);
|
|
|
|
|
text_width = PANGO_PIXELS_CEIL (text_width);
|
|
|
|
|
if (text_width > mid)
|
2022-01-02 08:46:28 +00:00
|
|
|
|
min = text_width;
|
2021-12-13 13:49:39 +00:00
|
|
|
|
else if (text_height > for_height)
|
|
|
|
|
min = mid + 1;
|
|
|
|
|
else
|
|
|
|
|
max = mid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return min * PANGO_SCALE;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-04 14:56:37 +00:00
|
|
|
|
static void
|
|
|
|
|
get_width_for_height (GtkLabel *self,
|
|
|
|
|
int height,
|
|
|
|
|
int *minimum_width,
|
|
|
|
|
int *natural_width)
|
|
|
|
|
{
|
|
|
|
|
PangoLayout *layout;
|
|
|
|
|
int minimum_default, natural_default;
|
|
|
|
|
|
|
|
|
|
get_default_widths (self, &minimum_default, &natural_default);
|
|
|
|
|
|
|
|
|
|
if (height < 0)
|
2020-12-25 11:05:28 +00:00
|
|
|
|
{
|
2021-11-04 14:56:37 +00:00
|
|
|
|
/* Minimum width is as many line breaks as possible */
|
|
|
|
|
layout = gtk_label_get_measuring_layout (self, NULL, MAX (minimum_default, 0));
|
|
|
|
|
pango_layout_get_size (layout, minimum_width, NULL);
|
2021-11-09 16:49:40 +00:00
|
|
|
|
*minimum_width = MAX (*minimum_width, minimum_default);
|
2021-11-04 14:56:37 +00:00
|
|
|
|
|
|
|
|
|
/* Natural width is natural width - or as wide as possible */
|
|
|
|
|
layout = gtk_label_get_measuring_layout (self, layout, natural_default);
|
|
|
|
|
pango_layout_get_size (layout, natural_width, NULL);
|
|
|
|
|
*natural_width = MAX (*natural_width, *minimum_width);
|
2020-12-25 11:05:28 +00:00
|
|
|
|
}
|
2021-11-04 14:56:37 +00:00
|
|
|
|
else
|
2009-12-20 08:04:52 +00:00
|
|
|
|
{
|
2021-12-13 13:49:39 +00:00
|
|
|
|
int min, max;
|
2021-11-04 14:56:37 +00:00
|
|
|
|
|
2021-11-30 13:05:22 +00:00
|
|
|
|
/* Can't use a measuring layout here, because we need to force
|
|
|
|
|
* ellipsizing mode */
|
|
|
|
|
gtk_label_ensure_layout (self);
|
|
|
|
|
layout = pango_layout_copy (self->layout);
|
|
|
|
|
pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_NONE);
|
|
|
|
|
|
2021-11-04 14:56:37 +00:00
|
|
|
|
/* binary search for the smallest width where the height doesn't
|
|
|
|
|
* eclipse the given height */
|
|
|
|
|
min = MAX (minimum_default, 0);
|
2021-11-30 13:05:22 +00:00
|
|
|
|
|
|
|
|
|
pango_layout_set_width (layout, -1);
|
2021-11-04 14:56:37 +00:00
|
|
|
|
pango_layout_get_size (layout, &max, NULL);
|
|
|
|
|
|
2021-12-19 18:22:31 +00:00
|
|
|
|
/* first, do natural width */
|
|
|
|
|
if (self->natural_wrap_mode == GTK_NATURAL_WRAP_NONE)
|
|
|
|
|
{
|
|
|
|
|
*natural_width = max;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (self->natural_wrap_mode == GTK_NATURAL_WRAP_WORD)
|
|
|
|
|
pango_layout_set_wrap (layout, PANGO_WRAP_WORD);
|
|
|
|
|
*natural_width = my_pango_layout_get_width_for_height (layout, height, min, max);
|
|
|
|
|
}
|
2021-11-30 13:05:22 +00:00
|
|
|
|
|
2021-12-19 18:22:31 +00:00
|
|
|
|
/* then, do minimum width */
|
2021-11-30 13:05:22 +00:00
|
|
|
|
if (self->ellipsize != PANGO_ELLIPSIZE_NONE)
|
|
|
|
|
{
|
|
|
|
|
g_object_unref (layout);
|
|
|
|
|
layout = gtk_label_get_measuring_layout (self, NULL, MAX (minimum_default, 0));
|
|
|
|
|
pango_layout_get_size (layout, minimum_width, NULL);
|
|
|
|
|
*minimum_width = MAX (*minimum_width, minimum_default);
|
|
|
|
|
}
|
2021-12-19 18:22:31 +00:00
|
|
|
|
else if (self->natural_wrap_mode == GTK_NATURAL_WRAP_INHERIT)
|
2021-12-13 13:49:39 +00:00
|
|
|
|
{
|
2021-12-19 18:22:31 +00:00
|
|
|
|
*minimum_width = *natural_width;
|
2021-12-13 13:49:39 +00:00
|
|
|
|
}
|
2021-11-30 13:05:22 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2021-12-19 18:22:31 +00:00
|
|
|
|
pango_layout_set_wrap (layout, self->wrap_mode);
|
|
|
|
|
*minimum_width = my_pango_layout_get_width_for_height (layout, height, min, *natural_width);
|
2021-11-30 13:05:22 +00:00
|
|
|
|
}
|
2019-06-08 13:40:59 +00:00
|
|
|
|
}
|
2020-12-25 11:05:28 +00:00
|
|
|
|
|
2021-11-04 14:56:37 +00:00
|
|
|
|
g_object_unref (layout);
|
|
|
|
|
}
|
2020-12-25 11:05:28 +00:00
|
|
|
|
|
2002-09-30 20:02:00 +00:00
|
|
|
|
static void
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_label_measure (GtkWidget *widget,
|
|
|
|
|
GtkOrientation orientation,
|
|
|
|
|
int for_size,
|
|
|
|
|
int *minimum,
|
|
|
|
|
int *natural,
|
|
|
|
|
int *minimum_baseline,
|
|
|
|
|
int *natural_baseline)
|
2002-09-30 20:02:00 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
GtkLabel *self = GTK_LABEL (widget);
|
2002-09-30 20:02:00 +00:00
|
|
|
|
|
2021-11-04 14:56:37 +00:00
|
|
|
|
if (for_size > 0)
|
|
|
|
|
for_size *= PANGO_SCALE;
|
2020-12-25 11:05:28 +00:00
|
|
|
|
|
2021-11-04 14:56:37 +00:00
|
|
|
|
if (!self->wrap)
|
|
|
|
|
get_static_size (self, orientation, minimum, natural, minimum_baseline, natural_baseline);
|
|
|
|
|
else if (orientation == GTK_ORIENTATION_VERTICAL)
|
|
|
|
|
get_height_for_width (self, for_size, minimum, natural, minimum_baseline, natural_baseline);
|
2020-12-25 11:05:28 +00:00
|
|
|
|
else
|
2021-11-04 14:56:37 +00:00
|
|
|
|
get_width_for_height (self, for_size, minimum, natural);
|
|
|
|
|
|
|
|
|
|
*minimum = PANGO_PIXELS_CEIL (*minimum);
|
|
|
|
|
*natural = PANGO_PIXELS_CEIL (*natural);
|
|
|
|
|
if (*minimum_baseline > 0)
|
|
|
|
|
*minimum_baseline = PANGO_PIXELS_CEIL (*minimum_baseline);
|
|
|
|
|
if (*natural_baseline > 0)
|
|
|
|
|
*natural_baseline = PANGO_PIXELS_CEIL (*natural_baseline);
|
2002-09-30 20:02:00 +00:00
|
|
|
|
}
|
2001-03-21 18:58:28 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
get_layout_location (GtkLabel *self,
|
|
|
|
|
int *xp,
|
|
|
|
|
int *yp)
|
2001-03-21 18:58:28 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
GtkWidget *widget = GTK_WIDGET (self);
|
2021-01-11 18:53:25 +00:00
|
|
|
|
const int widget_width = gtk_widget_get_width (widget);
|
|
|
|
|
const int widget_height = gtk_widget_get_height (widget);
|
2020-12-25 11:05:28 +00:00
|
|
|
|
PangoRectangle logical;
|
2021-01-11 18:53:25 +00:00
|
|
|
|
float xalign;
|
|
|
|
|
int baseline;
|
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
|
|
g_assert (xp);
|
|
|
|
|
g_assert (yp);
|
2010-06-24 02:36:08 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
xalign = self->xalign;
|
2001-03-21 18:58:28 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (_gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR)
|
|
|
|
|
xalign = 1.0 - xalign;
|
2020-04-13 06:56:33 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
pango_layout_get_pixel_extents (self->layout, NULL, &logical);
|
2021-01-11 18:53:25 +00:00
|
|
|
|
x = floor ((xalign * (widget_width - logical.width)) - logical.x);
|
2001-03-21 18:58:28 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
baseline = gtk_widget_get_allocated_baseline (widget);
|
|
|
|
|
if (baseline != -1)
|
2013-03-12 19:22:18 +00:00
|
|
|
|
{
|
2021-01-11 18:53:25 +00:00
|
|
|
|
int layout_baseline = pango_layout_get_baseline (self->layout) / PANGO_SCALE;
|
|
|
|
|
/* yalign is 0 because we can't support yalign while baseline aligning */
|
|
|
|
|
y = baseline - layout_baseline;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
y = floor ((widget_height - logical.height) * self->yalign);
|
2013-03-12 19:22:18 +00:00
|
|
|
|
}
|
2010-06-24 02:36:08 +00:00
|
|
|
|
|
2021-01-11 18:53:25 +00:00
|
|
|
|
*xp = x;
|
|
|
|
|
*yp = y;
|
2001-03-05 14:08:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_size_allocate (GtkWidget *widget,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
int baseline)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
GtkLabel *self = GTK_LABEL (widget);
|
2001-02-17 00:11:03 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (self->layout)
|
|
|
|
|
{
|
|
|
|
|
if (self->ellipsize || self->wrap)
|
|
|
|
|
pango_layout_set_width (self->layout, width * PANGO_SCALE);
|
|
|
|
|
else
|
|
|
|
|
pango_layout_set_width (self->layout, -1);
|
|
|
|
|
}
|
2020-11-11 15:35:09 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (self->popup_menu)
|
|
|
|
|
gtk_popover_present (GTK_POPOVER (self->popup_menu));
|
2001-03-05 14:08:42 +00:00
|
|
|
|
}
|
2001-02-17 00:11:03 +00:00
|
|
|
|
|
2015-09-20 03:58:11 +00:00
|
|
|
|
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
#define GRAPHENE_RECT_FROM_RECT(_r) (GRAPHENE_RECT_INIT ((_r)->x, (_r)->y, (_r)->width, (_r)->height))
|
2001-03-05 14:08:42 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_snapshot (GtkWidget *widget,
|
|
|
|
|
GtkSnapshot *snapshot)
|
2001-03-05 14:08:42 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
GtkLabel *self = GTK_LABEL (widget);
|
|
|
|
|
GtkLabelSelectionInfo *info;
|
2022-10-09 03:33:21 +00:00
|
|
|
|
GtkCssStyle *style;
|
2020-12-25 11:05:28 +00:00
|
|
|
|
int lx, ly;
|
|
|
|
|
int width, height;
|
2022-10-08 19:30:29 +00:00
|
|
|
|
GtkCssBoxes boxes;
|
2006-01-11 16:13:23 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (!self->text || (*self->text == '\0'))
|
|
|
|
|
return;
|
2015-09-20 03:58:11 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_label_ensure_layout (self);
|
2015-09-20 03:58:11 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
get_layout_location (self, &lx, &ly);
|
2001-03-05 14:08:42 +00:00
|
|
|
|
|
2022-10-08 19:30:29 +00:00
|
|
|
|
gtk_css_boxes_init (&boxes, widget);
|
|
|
|
|
gtk_css_style_snapshot_layout (&boxes, snapshot, lx, ly, self->layout);
|
2008-05-29 18:09:01 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
info = self->select_info;
|
|
|
|
|
if (!info)
|
|
|
|
|
return;
|
2012-01-06 00:52:32 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
width = gtk_widget_get_width (widget);
|
|
|
|
|
height = gtk_widget_get_height (widget);
|
|
|
|
|
|
|
|
|
|
if (info->selection_anchor != info->selection_end)
|
2001-03-05 14:08:42 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
int range[2];
|
|
|
|
|
cairo_region_t *range_clip;
|
|
|
|
|
cairo_rectangle_int_t clip_rect;
|
|
|
|
|
int i;
|
2020-04-10 14:03:37 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
range[0] = MIN (info->selection_anchor, info->selection_end);
|
|
|
|
|
range[1] = MAX (info->selection_anchor, info->selection_end);
|
2001-03-05 14:08:42 +00:00
|
|
|
|
|
2022-10-09 03:33:21 +00:00
|
|
|
|
style = gtk_css_node_get_style (info->selection_node);
|
|
|
|
|
gtk_css_boxes_init_border_box (&boxes, style, 0, 0, width, height);
|
2022-10-08 19:30:29 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
range_clip = gdk_pango_layout_get_clip_region (self->layout, lx, ly, range, 1);
|
|
|
|
|
for (i = 0; i < cairo_region_num_rectangles (range_clip); i++)
|
|
|
|
|
{
|
|
|
|
|
cairo_region_get_rectangle (range_clip, i, &clip_rect);
|
|
|
|
|
|
|
|
|
|
gtk_snapshot_push_clip (snapshot, &GRAPHENE_RECT_FROM_RECT (&clip_rect));
|
2022-10-08 19:30:29 +00:00
|
|
|
|
gtk_css_style_snapshot_background (&boxes, snapshot);
|
|
|
|
|
gtk_css_style_snapshot_layout (&boxes, snapshot, lx, ly, self->layout);
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_snapshot_pop (snapshot);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cairo_region_destroy (range_clip);
|
2001-03-21 18:58:28 +00:00
|
|
|
|
}
|
2020-12-25 11:05:28 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GtkLabelLink *focus_link;
|
|
|
|
|
GtkLabelLink *active_link;
|
|
|
|
|
int range[2];
|
|
|
|
|
cairo_region_t *range_clip;
|
|
|
|
|
cairo_rectangle_int_t clip_rect;
|
|
|
|
|
int i;
|
|
|
|
|
GdkRectangle rect;
|
2001-03-05 14:08:42 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (info->selectable &&
|
|
|
|
|
gtk_widget_has_focus (widget) &&
|
|
|
|
|
gtk_widget_is_drawable (widget))
|
|
|
|
|
{
|
|
|
|
|
PangoDirection cursor_direction;
|
Added gdk_text/string_extents() - too calculate all the metrics at once of
Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() -
too calculate all the metrics at once of a string, including
things which weren't calculated before.
* gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New
MenuItem type, that when put as the first thing in a
menu, makes the menu tearoff. Currently drawn as a
dashed line.
* gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag
"hide_on_activate" to the MenuItem class structure to allow
check and radio buttons to be changed with <Space> without
hiding the menu.
* gtk/gtkaccellabel.[ch]: Added new capabilities to set
a underline_group and underline_mods for the label -
accelerators added in the underline group matching
underline_mods will be displayed as an underline character.
This doesn't work - Save As needs to be underlined
as Save _As.
* gtk/gtkitemfactory.c:
- Create a AccelGroup for each MenuShell we create.
- If an '&' appears before a character 'c' in the path,
then make 'c' an accelerator in the menu's accel group,
and if the menuitem is menubar <alt>C an accelerator
in the itemfactory's accel group.
* gtk/gtklabel.[ch]: Add support for a pattern arg -
which is a string. If an '_' appears in this string,
the corresponding position in the label is underlined.
Add gtk_label_parse_uline() convenience function which
takes a string with embedded underlines, sets the
pattern and label, and returns the accelerator keyval.
* gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget.
Instead, they create a GtkWindow and add themselves
to that. (When torn off, another new feature, they
create another GtkWindow to hold the torn off menu)
New function gtk_menu_set_tearoff_state()
* gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h:
Added action signals for keyboard navigation of menus.
* gtk/gtkmenushell.c: Key press handler which activates
bindings for navigation, and accelerators, for handling
underline accelerators. Exported functions to select
and activate menu items in a menushell.
* gtk/testgtk.c: Added a new "Item Factory" test which
tests GtkItemFactory and the new keyboard navigation
of menus.
1998-08-12 16:49:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
cursor_direction = get_cursor_direction (self);
|
2022-10-08 19:30:29 +00:00
|
|
|
|
gtk_css_style_snapshot_caret (&boxes, gtk_widget_get_display (widget),
|
|
|
|
|
snapshot,
|
|
|
|
|
lx, ly,
|
|
|
|
|
self->layout,
|
|
|
|
|
self->select_info->selection_end,
|
|
|
|
|
cursor_direction);
|
2020-12-25 11:05:28 +00:00
|
|
|
|
}
|
2020-11-13 20:35:51 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
focus_link = gtk_label_get_focus_link (self, NULL);
|
|
|
|
|
active_link = info->active_link;
|
2020-11-11 15:35:09 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (active_link)
|
|
|
|
|
{
|
|
|
|
|
range[0] = active_link->start;
|
|
|
|
|
range[1] = active_link->end;
|
2002-04-12 12:43:01 +00:00
|
|
|
|
|
2022-10-09 03:33:21 +00:00
|
|
|
|
style = gtk_css_node_get_style (active_link->cssnode);
|
|
|
|
|
gtk_css_boxes_init_border_box (&boxes, style, 0, 0, width, height);
|
2022-10-08 19:30:29 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
range_clip = gdk_pango_layout_get_clip_region (self->layout, lx, ly, range, 1);
|
|
|
|
|
for (i = 0; i < cairo_region_num_rectangles (range_clip); i++)
|
|
|
|
|
{
|
|
|
|
|
cairo_region_get_rectangle (range_clip, i, &clip_rect);
|
2002-04-12 12:43:01 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_snapshot_push_clip (snapshot, &GRAPHENE_RECT_FROM_RECT (&clip_rect));
|
2022-10-08 19:30:29 +00:00
|
|
|
|
gtk_css_style_snapshot_background (&boxes, snapshot);
|
|
|
|
|
gtk_css_style_snapshot_layout (&boxes, snapshot, lx, ly, self->layout);
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_snapshot_pop (snapshot);
|
|
|
|
|
}
|
Remove all references to offscreen flag which was no longer used.
Thu Jun 1 23:05:13 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c: Remove all references to
offscreen flag which was no longer used.
* gtk/gtkprivate.h (enum): Remove unused flags and compress.
* gtk/gtkframe.c (gtk_frame_set_label_widget): Check
for non-null label_widget->parent.
* gtk/gtkentry.c: Get rid of code to deal with PangoAttribute
which no longer was used.
* gdk/gdkpango.c (gdk_pango_context_get_info): make static.
* gdk/gdkpango.c (gdk_draw_layout[_line]): Add checks
for null arguments.
* gdk/x11/gdkgeometry-x11.c (gdk_window_scroll): add
check for destroyed windows.
Thu Jun 1 13:48:45 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimmulticontext.c: Add a finalize method and unref
the slave context there.
* gtk/gtkinvisible.[ch]: Make reference counting behavior
identical to GtkWindow.
Thu Jun 1 01:54:11 2000 Owen Taylor <otaylor@redhat.com>
* Makefile.am gdk/gdkpango.c: Copy the layout render function from
pangox to here, so we can write them independent of rendering
system, using GDK primitives.
* gdk/gdkdrawable.h gdk/gdkdraw.c gdk/gdkwindow.c
gdk/x11/gdkdrawable-x11.c: Remove draw_layout() from the vtable,
since we have a rendering-system independent implementation in
terms of draw_glyphs().
* gdk/gdkpango.c gdkdrawable.h (gdk_draw_layout_line): New
function to render a single line.
* gdk/x11/gdkpango.c: Move the guts of this file mostly
into ../gdkpango.c, which simplifies things, since we
don't have to deal with raw X gc's.
Fri May 19 04:28:16 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextlayout.[ch]: Add get_log_attrs() function to
get the logical attributes for a given GtkTextLine.
Tue May 30 16:05:39 2000 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkfont-x11.c (gdk_font_charset_for_locale): Track
g_locale_get_codeset() to g_get_codeset() change.
Tue May 30 15:03:19 2000 Owen Taylor <otaylor@redhat.com>
* gtk/testcalendar.c (calendar_font_selection_ok): Use font
descriptions.
* gtk/gtkentry.c (gtk_entry_draw_text): Center text within
the entry.
* gtk/gtkfontsel.c (gtk_font_selection_dialog_init): Start of
redoing (vastly simplifying) for Pango. Still needs quite
a bit of work. (Size selection is currently poor. List of
predefined sizes is not a good idea, since all of these
sizes won't necessarily be distinct.)
Tue May 30 13:50:19 2000 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkfont-x11.c (gdk_font_charset_for_locale): Handle
CODESET results for LANG=C.
Mon May 29 15:49:10 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrc.[ch]: Add a 'font_name' declaration to RC
which takes a stringized pango font description;
ignore the older 'font' and 'fontset' declarations.
* gtk/gtkstyle.c gtk/gtkrc.c: Fill in the style->font
field with a GdkFont derived via gdk_font_from_description(),
for compatibility. (Should we just remove it entirely?
Probably too much compatibility breakage, but people
should be migrating to the new Pango stuff as quickly
as possible.)
Mon May 29 15:47:41 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c gtk/gtkclist.c: s/pango_font_unref/g_object_unref/.
Mon May 29 15:44:46 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcalender.c: Roughly pango-ized. Really needs
redoing; there are some bugs in size allocation right
now, the semi-existant distinction between header / day
fonts was removed, but, with Pango, could actually
be made functional in a nice way.
* gtk/testcalender: Move calender from examples into this
directory as a test program. (We really need to restrcture
testgtk into a whole directory full of tests for every
widget or functionality group, separated into multiple .c
files.)
Mon May 29 15:19:56 2000 Owen Taylor <otaylor@redhat.com>
* gtk/testgtk.c (file_exists): Fix stupid typo that
was keeping RC file from being loaded.
* gtk/testgtkrc gtk/testgtkrc2: Test new pango-ized
RC file font code.
Mon May 29 14:31:27 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdkfont.h gdk/x11/gdkfont-x11.c (gdk_font_from_description):
Add function to load a GdkFont from a PangoFontDescription.
Fri May 26 17:16:40 2000 Owen Taylor <otaylor@redhat.com>
* gtk/frame.[ch] gtkaspectframe.c: Make frame widgets able
to have any widget for the label, use a GtkLabel widget
to display the text. (Based partially on a patch from
Anders Carlson.)
(Quite a bit of code reorganization - strip 90% of the
guts out of gtkaspectframe and add a single virtual
func to GtkFrameClass - compute_child_allocation.)
Fri May 26 12:00:02 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkctree.c gtk/gtkclist.[ch]: Pangoized.
(Removed clist->row_center_offset field because caching
it wasn't saving time or code, added private function
_gtk_clist_create_cell_layout()).
Wed May 24 15:59:37 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkaccellabel.c: Pangoized.
* gtk/[hv]ruler.c: Pangoized
Mon May 22 19:23:59 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkfilesel.c (gtk_file_selection_init):
Use gtk_clist_set_column_auto_resize() to remove need
need for manual column width computations.
Mon May 22 18:50:26 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktooltips.[ch]: Replace custom drawing with a GtkLabel,
ensuring Pango correctness, and considerably simplifying the
code.
* gtk/gtklabel.c gtk[hv]scale.c: 1000 => PANGO_SCALE.
* gtk/gtklabel.c (gtk_label_size_request): Fixed incorrect
getting of numbers of lines.
* gtk/gtklabel.c (gtk_label_size_request): Set the requisition
to the actual requested width of the lable, not to the wrap
width we set.
* gtk/gtktextchild.h: Remove extraneous include of gtk/gtk.h.
* gtk/gtktextbtree.c gtk/gtktextbuffer.c gtk/gtktextlayout.c
gtk/gtktextview.c gtk/gtktextview.[ch]: Fix up includes.
* gtk/gtktextview.c: Fix structure inheritance.
* gtk/gtkprogressbar.c: Pangoize.
Mon May 22 15:47:30 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.c (gtk_text_view_get_first_para_iter): Encapsulate
in a function.
* gtk/gtktextlayout.c (find_display_line_above): Fixed
bug with computing line tops.
* gtk/gtktextview.c (changed_handler): Fix < , <= confusion.
Thu May 18 18:53:31 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextdisplay.c (gtk_text_layout_draw): Fix up the x_offset
and y_offset coordinates to do what we need now. (The offset between
buffer and layout coordinates has been reintroduced, but is a
bit different than before.)
* gtk/gtktextview.[ch]: No longer inherit from GtkLayout; instead
handle the adjustments ourselves, and scroll as necessary using
the new gdk_window_scroll().
The advantage of this is that when we are incrementally revalidating,
we are essentially rearranging things around the visible portion
of the screen. With the old setup, the visible portion of the
screen was moved around in the layout, so scrolling and redrawing
to track that caused jumping of the display. Since we now
control the scrolling ourselves, we can suppress this and
only redraw when things actually change.
Thu May 18 18:47:25 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextbtree.c (redisplay_mark): We need to invalidate
the region not just redisplay it after-all, since we store the
cursors in the LineDisplay. (Ugly interactions here between
GtkLayout and GtkTextBTree here.)
* gtk/gtktextbtree.c (redisplay_region): Fixed reversed comparison.
Thu May 18 18:43:21 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.h gdk/x11/gdkgeometry-x11.c (gdk_window_scroll):
Added function to scroll contents of a window while keeping the
window constant. Works by XCopyArea or guffaw-scrolling depending
on the details of how the window is set up. (guffaw-scrolling
still needs to be filled in.)
Wed May 17 22:36:53 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextiter.c gtk/gtkmain.c: Add a debug key for the text widget,
move the debugging that was tied to a global variable
to that.
* gtk/gtkmarshal.list: Add NONE:INT,INT,INT
* gtk/gtktextbtree.[ch] gtk/gtktextlayout.c: Keep a separate
validated flag, in line data instead of setting height/width to
-1. This allows us to perform operations with partially invalid
buffer (using the old size for invalid lines) and thus to do
incremental vaidation. Keep height/width aggregates up to date
when deleting text and rebalancing the tree.
* gtk/gtktextbtree.[ch]: Add functions validate a line
(gtk_text_btree_validate_line), and to validate up
to a number of pixels (gtk_text_btree_validate).
* gtk/gtktextlayout.[ch]: Add an ::invalidated signal
that indicates that something is changed and a revalidation
pass is needed. Change ::need_repaint to ::changed, and
make it take old and new yranges instead of a rectangle.
* gtk/gtktextbtree.[ch] gtk/gtktextlayout.[ch]: Move
the line_data_destroy() function from
gtk_text_btree_add_view() to a virtual function in
GtkTextLayout
* gtk/gtktextbtree.[ch]: Remove gtk_text_btree_get_damage_range(),
since we are handling partial repaints in a different fashion
now.
* gtk/gtktextbtree.[ch]: Only repaint the changed portion
of the selection instead of queueing a repaint on the
entire widget.
* gtk/gtktextbuffer.[ch] gtk/gtktextbtree.[ch]: Move
get_selection_bounds() down to btree, make the function
in buffer a wrapper around the btree function.
* gtk/gtktextlayout.[ch]: Add functions to check if the
layout is valid and to recompute either a range of pixels
aroudn a line or a certain total number of pixels.
* gtk/gtktextlayout.[ch]: Cache a single line display;
now that we only redraw the needed portions, the hit rate
for this cache is quite high.
* gtk/gtktextview.[ch]: Keep track of the first paragraph
on the screen so that when re-laying-out the buffer, we can
keep the same place. This requires connecting to ::value_changed
on the adjustments
* gtk/gtktextview.[ch]: Add idle functions to revalidate
the buffer after we receive an ::invalidated signal.
Wed May 17 22:10:47 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtklayout.c (gtk_layout_size_allocate): Set upper
to max of allocation and layout size, not just to the
layout size.
* gtk/gtk[hv]scrollbar.c (gtk_[hv]scrollbar_calc_slider_size):
Invalidate window so it gets redrawn properly.
* gdk/gdkwindow.c (gdk_window_invalidate_rect): Allow rect == NULL
to mean the entire window.
* gdk/gdkevents.h: Move definition for GDK_PRIORITY_REDRAW
into public header.
Mon May 15 14:51:31 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextmark.c (gtk_text_mark_get_name): Add function
to get the name of a mark.
* gtk/gtktextlayout.c (gtk_text_layout_get_line_at_y): Add a function
to find the paragraph from a y position.
Thu May 11 12:57:20 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextbtree.c (gtk_text_btree_node_invalidate_upward): Valid
nodes have width/height >= 0, not > 0.
Tue May 9 21:29:06 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextlayout.[ch] gtk/gtktextdisplay.c (gtk_text_layout_get_line_display):
Add a size_only flag, so when we only need the size, we don't create
useless appearance attributes.
* gtk/gtktextview.c (gtk_text_view_ensure_layout): Remove
duplicate setting of font description.
* gtk/gtkscale.c: Use PANGO_SCALE instead of 1000
Wed Apr 26 01:53:23 2000 Owen Taylor <otaylor@redhat.com>
* gtk/Makefile.am (EXTRA_DIST): Add OLD_STAMP into
EXTRA_DIST. It does not work well when the file that
everything depends on is not in the tarball.
Wed Apr 26 00:56:14 2000 Owen Taylor <otaylor@redhat.com>
* gtk/testgtk.c: Some hacks and fixes so that it basically
works when not sitting in the GTK+ build tree.
2000-05-03 Havoc Pennington <hp@redhat.com>
* gtk/gtktextbtree.c (gtk_text_line_next_could_contain_tag):
Properly determine the ordering of the tag root and the current
line within the tree. Previous algorithm only worked if the tag
root's immediate parent was the common root of both the current
line and the tag root.
Wed Apr 26 00:43:00 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextlayout.c (set_para_values): Fix some bugs in
alignment.
* gtk/gtktextview.c (gtk_text_view_ensure_layout): Track
the widget text directional dynamically.
* gtk/gtktextview.[ch]: Added functions to get and set default
wrap mode.
Tue Apr 25 23:47:38 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextlayout.c (gtk_text_layout_get_iter_location): Fix bug
in cursor location computation.
Tue Apr 25 23:22:59 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtklayout.c (gtk_layout_set_size): Clamp hadjustment/
vadjusment values properly when layout gets smaller.
* gtk/gtktextview.c (need_repaint_handler): Areas being
passed in are far completely inaccurate, and sometimes
too small, so, for now, just queue a redraw on the
whole visible region.
2000-04-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextbtree.c (summary_destroy): new function to
destroy tag summary nodes
(gtk_text_line_next_could_contain_tag): this function was
totally broken if the line passed in wasn't below the tag
root. Fix it.
(gtk_text_btree_first_could_contain_tag): In the tag == NULL
"wildcard" case, we have to do a linear scan. Blah.
(gtk_text_btree_last_could_contain_tag): In tag == NULL case,
we have to do the linear scan
(tag_removed_cb): When a tag is removed from the tag table,
remove the GtkTextTagInfo node from the btree.
(gtk_text_btree_spew): Implement the spew function, for
our debugging pleasure.
Tue Apr 25 19:40:18 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextlayout.c (gtk_text_layout_set_buffer): Fix
a problem with referring to the wrong buffer.
* gtk/gtkentry.c: Fix focus-in/focus-out confusion.
* gtk/gtkrc.c gtk/gtkstyle.c: Moving setting default
font description to gtk_style_new() - otherwise things
don't work without a .gtkrc file.
* gtk/gtktextbuffer.c (gtk_text_buffer_new): Sink the
tags table if we create it ourself, too.
* gdk/gdktypes.h (enum): Move GDK_RELEASE_MASK, since
it was conflicting with XKB modifiers.
* gtk/gtktextview.[ch]: Add simple support for
GtkIMContext.
Mon Apr 24 19:34:18 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c (gtk_entry_move_cursor_visually): Fix problem
with deletion from last commit.
Mon Apr 24 19:29:40 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_create_pango_context): Set the language
in the context from the current locale.
* gtk/gtkentry.c (gtk_entry_size_request): Use language from the
context, not hardcoded value.
* gtk/gtkentry.c (gtk_entry_move_cursor): Make character movement visual,
not logical.
Sun Apr 23 23:39:18 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c gtk/gtktextdisplay.c: Don't handle selections as
attributes - that doesn't handle partial-glyph selection
properly. Instead use new pango_layout_line_get_x_ranges()
functionality to draw the selection.
* gtk/gtkentry.c: Simplify code since pango_layout_line_index_to_x()
now properly handles out-of-range coordinates.
* gtk/gtktextbuffer.c: Emit "mark_set" when the cursor is moved.
* gtk/gtktextiter.h gtk/gtktextiterprivate.h: Make gtk_text_iter_get_line_byte()
public.
* gtk/gtktextlayout.[ch]: Properly set the direction in the PangoContext
for paragraphs opposite to the base direction of the widget.
* gtk/gtktextlayout.[ch] gtk/gtktextdisplay.c: Fixes for alignment.
* gtk/gtktextlayout.c: Don't split segments on marks, since that
causes Arabic words to reshape as you cursor through.
* gtk/gtktextlayout.[ch] gtk/gtktextview.[ch]: Implement virtual
cursor position when moving vertically with the arrow keys and
scrolling with page-up/page-down. (Arrow keys save only the X,
scrolling saves both X and Y.)
This means you can line-up / line-down or page-up / page-down
without losing your place, and also that moving vertically
with the cursor keys keeps the same X position, not the same
character count:
* gtk/gtktextlayout.[ch] gtk/gtktextview.[ch]: Make vertical
arrow keys move by display lines, not paragraphs.
Tue Apr 18 14:16:50 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtklayout.c: Make sure that the bin window is at least
as big as the allocation. (Should we also make sure that the
bin window is big enough to completely cover widget->window?)
* gtk/gtktextview.c (gtk_text_view_get_visible_rect): Add
function to get the onscreen rectangle.
* gdk/x11/gdkwindow-x11.c (gdk_window_get_pointer): Correctly account
for offsets in window coordinates.
Sun Apr 16 16:13:27 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c (gtk_entry_get_cursor_locations): Fix index/offset
confusion.
* gtk/gtktextview.c (gtk_text_view_ensure_layout): Set the default direction
from the widget direction.
* gtk/gtktexttag.c gtk/gtktexttagprivate.h (gtk_text_tag_set_arg):
Add a "direction" attribute.
* gtk/gtktextview.c: global s/tkxt/text_view/.
* gtk/testtext.c: Added long block of text in Arabic, to test out
the direction attributes. (Some problems with the shaping system
for arabic become obvious - like the fact the cursor splits words
into unjoined pieces.)
Fri Apr 14 12:54:34 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextdisplay.c (render_layout): Add overstrike handling.
* gtk/gtktextlayout.c: Fix up alignment.
* gtk/testtext.c: Add some tests for centering, wrapping.
Fri Apr 14 09:26:22 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdrawable.h gdk/gdkdraw.c gdk/gdkwindow.c gdk/x11/gdkdrawable-x11.c:
Add a draw_glyphs() operation to the drawable vtable and gdk_draw_glyphs().
If we wrote GTK+-specific layout-render function this could just replace
the draw_layout() operation in the vtable.
* gtk/gtkentry.c: Move guts of gtk_entry_get_cursor_locations to
pango_layout_get_cursor_pos() and use that function.
* gtk/gtktextchild.[ch]: add gtk_ onto pixmap_segment_new(), since it
is a non-static symbol.
* gtk/gtktextbtree.[ch]: Replace gtk_text_btree_find_line_data_by_y()
with gtk_text_btree_find_line_by_y()
* gtk/gtktextdisplay.c: Rewrote for Pango - uses a custom layout
renderer that handles GtkTextAppearance attributes.
* gtk/gtktexttag.[ch] gtk/gtktexttagprivate.h:
- Move the values in the style that don't affect geometry into a
GtkTextAppearance structure.
- Change underline to take a PangoUnderline and "font" a string
representation of a font description
- Add a "font_desc" attribute which takes a FontDescription structure.
* gtk/gtktextlayout.[ch]:
- Get rid of the display-line list per each line. Instead, we
generate, on demand, a GtkTextLineDisplay structure which]
contains a PangoLayout * and other necesary information
(offsets, cursor locations) for displaying a paragraph.
- Get rid of the code to wrap lines, create display chunks,
etc. Instead, we just go through a paragraph and convert
it into the necessary inputs to a PangoLayout.
- Implement a new attribute type, GtkTextAttrAppearance. This
holds a GtkTextAppearance, and is used to pass colors,
stipple, etc, through from the layout to the display without
having to use lots and lots of individual attributes.
- Reimplement gtk_layout_get_iter_at_pixel() gtk_layout_get_iter_pos()
in terms of PangoLayout functions.
* gtk/gtktextview.c:
- Handle passing the necessary PangoContext to the layout
- Some fixups in painting to deal with the automatic backing store
and offsetting of GTK+-1.4
- Add a style_set handler so that the default style reacts
properly to theme changes.
* gtk/gtktext?*.[ch]: Random code-style fixes.
* gtk/testtext.c: Substitute in languages that Pango handles now for Thai
Mon Apr 10 10:33:45 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktext?*.[ch]: Check in Havoc's port of the Tk text widget,
in original form preparatory to Pango-ization and gdkimcontext-ization.
Thu Apr 6 19:25:39 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimcontext.c: Move default implementations to real_* vfuncs,
so that we can derive from gtkimcontext in language bindings properly.
Thu Apr 6 16:02:52 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimcontextsimple.[ch]: Use gdk_keyval_to_unicode to gdk_unicode_to_keyval.
Add a compose table including (almost) all the compose combinations
from X. This is 6k of static, shared data as opposed to 50k or so of dynamic
data in the XIM implementation.
* gdk/gdk.h gdk/gdkkeyuni.c gdk/win32/gdkevents-win32.c (gdk_keyval_to_unicode, gdk_unicode_to_keyval):
Moved functions to convert keyvalues from and to unicode here from
the win32 port and made them public.
Wed Apr 5 16:37:29 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkeditable.c (gtk_editable_insert_text): Allow new_text_length == -1.
Wed Apr 5 16:27:45 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimcontext.[ch]: Base class for new input context system
* gtk/gtkimmulticontext.[ch]: Proxy input context that allows
the real input context implementation to be loaded from modules
and switched on the fly.
* gtk/gtkcontextsimple.[ch]: Simple implementation of an input
context that just does direct keysymbol => unicode translation.
* gtk/gtkentry.[ch]: Start switching editing over to using
GtkInputContext. (No handling of preedit yet.)
Wed Apr 5 15:48:41 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktypeutils.h (GTK_CHECK_GET_CLASS): Fix problem with one too
many substitutions. (klass should not be subsituted.)
Wed Apr 5 00:18:14 2000 Owen Taylor <otaylor@redhat.com>
* configure.in: Add checks for Pango
* configure.in docs/Makefile.am: Add test for sgml2html
and allow 'make dist' without building html, but print out
warnings in that case. (For making snapshots)
* gdk/Makefile.am gdk/x11/Makefile.am gtk/Makefile.am:
Add Pango libraries and C flags
* gdk/gdkdraw.c gdk/gdkdrawable.h gdkwindow.c gdk/x11/gdkdrawable-x11.c:
Add function (gdk_draw_layout) to draw a pango layout.
* gdk/gdkpango.h gdk/x11/gdkpango-x11.c: New file with functions
for getting Pango contexts for GDK.
* gtk/gtkeditable.c: Get rid of dead code gtk_editable_parent_set()
* gtk/gtkentry.[ch]: Complete rewrite to use Pango, add bidirectional
editing.
* gtk/gtkentry.c: Hack in simple Hebrew input with direct
keysym => unicode translations. More languages can be added
here, but real input-method support is needed.
* docs/Changes-1.4.txt: Added note about entry behavior.
* gtk/gtkenums.h gtk/gtkwidget.[ch] testgtk.c gtkprivate.h: Add functions
to set the reading direction for a widget and the global direction.
Add test which allows toggling the global direction. Two private
flags are used to store the direction. (GTK_DIRECTION_SET + GTK_DIRECTION_LTR)
* gtk/gtkcheckbutton.c gtk/gtkframe.c gtk/gtkhbbox.c gtk/gtkhbox.c
gtk/gtkradiobutton.c gtk/gtkspinbutton.c gtk/gtktable.c
* gtk/gtk[hv]scale.c gtk/gtkscale.[ch]: Draw numbers using Pango
* gtk/gtklabel.[ch]: Moved to Pango and considerably rewritten. Line breaking,
underlining now handled by Pango.
* gtk/gtkstyle.[ch] gtk/gtkrc.[ch]: Add a PangoFontDescription
to RCStyle and Style. (Having both this and the old font name and GdkFont
is temporary.)
* gtk/gtkwidget.[ch] (gtk_widget_create_pango_{context,layout}): Added
convenience functions for creating contexts and layouts for widgets.
* gtk/testgtk.c: Enhance label tests with multilingual labels.
2000-06-02 03:14:07 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
cairo_region_destroy (range_clip);
|
|
|
|
|
}
|
2020-04-17 05:37:22 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (focus_link && gtk_widget_has_visible_focus (widget))
|
|
|
|
|
{
|
|
|
|
|
range[0] = focus_link->start;
|
|
|
|
|
range[1] = focus_link->end;
|
2012-01-05 16:06:00 +00:00
|
|
|
|
|
2022-10-09 03:33:21 +00:00
|
|
|
|
style = gtk_css_node_get_style (focus_link->cssnode);
|
2012-01-05 16:06:00 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
range_clip = gdk_pango_layout_get_clip_region (self->layout, lx, ly, range, 1);
|
|
|
|
|
cairo_region_get_extents (range_clip, &rect);
|
2008-11-06 16:36:16 +00:00
|
|
|
|
|
2022-10-09 03:33:21 +00:00
|
|
|
|
gtk_css_boxes_init_border_box (&boxes, style, rect.x, rect.y, rect.width, rect.height);
|
2022-10-08 19:30:29 +00:00
|
|
|
|
gtk_css_style_snapshot_outline (&boxes, snapshot);
|
2000-11-01 07:07:46 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
cairo_region_destroy (range_clip);
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-06-24 15:34:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static GtkSizeRequestMode
|
|
|
|
|
gtk_label_get_request_mode (GtkWidget *widget)
|
2001-06-24 15:34:48 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
GtkLabel *self = GTK_LABEL (widget);
|
2007-06-13 13:38:51 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (self->wrap)
|
|
|
|
|
return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
|
2007-06-13 13:38:51 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return GTK_SIZE_REQUEST_CONSTANT_SIZE;
|
2001-06-24 15:34:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_dispose (GObject *object)
|
2001-06-24 15:34:48 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
GtkLabel *self = GTK_LABEL (object);
|
2017-09-30 16:48:11 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_label_set_mnemonic_widget (self, NULL);
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_label_parent_class)->dispose (object);
|
2001-06-24 15:34:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_clear_links (GtkLabel *self)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
guint i;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (!self->select_info)
|
|
|
|
|
return;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
for (i = 0; i < self->select_info->n_links; i++)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
const GtkLabelLink *link = &self->select_info->links[i];
|
|
|
|
|
gtk_css_node_set_parent (link->cssnode, NULL);
|
|
|
|
|
g_free (link->uri);
|
|
|
|
|
g_free (link->title);
|
|
|
|
|
}
|
|
|
|
|
g_free (self->select_info->links);
|
|
|
|
|
self->select_info->links = NULL;
|
|
|
|
|
self->select_info->n_links = 0;
|
|
|
|
|
self->select_info->active_link = NULL;
|
|
|
|
|
gtk_widget_remove_css_class (GTK_WIDGET (self), "link");
|
|
|
|
|
}
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_finalize (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
GtkLabel *self = GTK_LABEL (object);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_free (self->label);
|
|
|
|
|
g_free (self->text);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_clear_object (&self->layout);
|
|
|
|
|
g_clear_pointer (&self->attrs, pango_attr_list_unref);
|
|
|
|
|
g_clear_pointer (&self->markup_attrs, pango_attr_list_unref);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (self->select_info)
|
|
|
|
|
g_object_unref (self->select_info->provider);
|
2020-04-10 13:41:56 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_label_clear_links (self);
|
|
|
|
|
g_free (self->select_info);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_clear_pointer (&self->popup_menu, gtk_widget_unparent);
|
|
|
|
|
g_clear_object (&self->extra_menu);
|
2020-04-10 13:41:56 +00:00
|
|
|
|
|
2022-07-31 15:40:20 +00:00
|
|
|
|
g_clear_pointer (&self->tabs, pango_tab_array_free);
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_label_parent_class)->finalize (object);
|
|
|
|
|
}
|
2015-11-15 06:00:20 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_unrealize (GtkWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
GtkLabel *self = GTK_LABEL (widget);
|
2017-01-05 21:36:14 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (self->select_info &&
|
|
|
|
|
self->select_info->provider)
|
|
|
|
|
{
|
|
|
|
|
GdkClipboard *clipboard = gtk_widget_get_primary_clipboard (widget);
|
2015-11-15 06:00:20 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (gdk_clipboard_get_content (clipboard) == self->select_info->provider)
|
|
|
|
|
gdk_clipboard_set_content (clipboard, NULL);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
GTK_WIDGET_CLASS (gtk_label_parent_class)->unrealize (widget);
|
|
|
|
|
}
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
range_is_in_ellipsis_full (GtkLabel *self,
|
|
|
|
|
int range_start,
|
|
|
|
|
int range_end,
|
|
|
|
|
int *ellipsis_start,
|
|
|
|
|
int *ellipsis_end)
|
|
|
|
|
{
|
|
|
|
|
PangoLayoutIter *iter;
|
|
|
|
|
gboolean in_ellipsis;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (!self->ellipsize)
|
|
|
|
|
return FALSE;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_label_ensure_layout (self);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (!pango_layout_is_ellipsized (self->layout))
|
|
|
|
|
return FALSE;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
iter = pango_layout_get_iter (self->layout);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
in_ellipsis = FALSE;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
do {
|
|
|
|
|
PangoLayoutRun *run;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
run = pango_layout_iter_get_run_readonly (iter);
|
|
|
|
|
if (run)
|
|
|
|
|
{
|
|
|
|
|
PangoItem *item;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
item = ((PangoGlyphItem*)run)->item;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (item->offset <= range_start && range_end <= item->offset + item->length)
|
|
|
|
|
{
|
|
|
|
|
if (item->analysis.flags & PANGO_ANALYSIS_FLAG_IS_ELLIPSIS)
|
|
|
|
|
{
|
|
|
|
|
if (ellipsis_start)
|
|
|
|
|
*ellipsis_start = item->offset;
|
|
|
|
|
if (ellipsis_end)
|
|
|
|
|
*ellipsis_end = item->offset + item->length;
|
|
|
|
|
in_ellipsis = TRUE;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if (item->offset + item->length >= range_end)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} while (pango_layout_iter_next_run (iter));
|
|
|
|
|
|
|
|
|
|
pango_layout_iter_free (iter);
|
|
|
|
|
|
|
|
|
|
return in_ellipsis;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
range_is_in_ellipsis (GtkLabel *self,
|
|
|
|
|
int range_start,
|
|
|
|
|
int range_end)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return range_is_in_ellipsis_full (self, range_start, range_end, NULL, NULL);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_label_grab_focus (GtkWidget *widget)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
GtkLabel *self = GTK_LABEL (widget);
|
|
|
|
|
gboolean select_on_focus;
|
|
|
|
|
GtkWidget *prev_focus;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (self->select_info == NULL)
|
|
|
|
|
return FALSE;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
prev_focus = gtk_root_get_focus (gtk_widget_get_root (widget));
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (!GTK_WIDGET_CLASS (gtk_label_parent_class)->grab_focus (widget))
|
|
|
|
|
return FALSE;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (self->select_info->selectable)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_object_get (gtk_widget_get_settings (widget),
|
|
|
|
|
"gtk-label-select-on-focus",
|
|
|
|
|
&select_on_focus,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
if (select_on_focus && !self->in_click &&
|
|
|
|
|
!(prev_focus && gtk_widget_is_ancestor (prev_focus, widget)))
|
|
|
|
|
gtk_label_select_region (self, 0, -1);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
2020-04-10 14:23:32 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (self->select_info->links && !self->in_click &&
|
|
|
|
|
!(prev_focus && gtk_widget_is_ancestor (prev_focus, widget)))
|
|
|
|
|
{
|
|
|
|
|
guint i;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
for (i = 0; i < self->select_info->n_links; i++)
|
|
|
|
|
{
|
|
|
|
|
const GtkLabelLink *link = &self->select_info->links[i];
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (!range_is_in_ellipsis (self, link->start, link->end))
|
|
|
|
|
{
|
|
|
|
|
self->select_info->selection_anchor = link->start;
|
|
|
|
|
self->select_info->selection_end = link->start;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
get_layout_index (GtkLabel *self,
|
|
|
|
|
int x,
|
|
|
|
|
int y,
|
|
|
|
|
int *index)
|
|
|
|
|
{
|
|
|
|
|
int trailing = 0;
|
|
|
|
|
const char *cluster;
|
|
|
|
|
const char *cluster_end;
|
|
|
|
|
gboolean inside;
|
|
|
|
|
int lx, ly;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*index = 0;
|
2020-04-10 13:41:56 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_label_ensure_layout (self);
|
|
|
|
|
get_layout_location (self, &lx, &ly);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/* Translate x/y to layout position */
|
|
|
|
|
x -= lx;
|
|
|
|
|
y -= ly;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
x *= PANGO_SCALE;
|
|
|
|
|
y *= PANGO_SCALE;
|
2020-04-10 13:41:56 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
inside = pango_layout_xy_to_index (self->layout,
|
|
|
|
|
x, y,
|
|
|
|
|
index, &trailing);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
cluster = self->text + *index;
|
|
|
|
|
cluster_end = cluster;
|
|
|
|
|
while (trailing)
|
|
|
|
|
{
|
|
|
|
|
cluster_end = g_utf8_next_char (cluster_end);
|
|
|
|
|
--trailing;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*index += (cluster_end - cluster);
|
|
|
|
|
|
|
|
|
|
return inside;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_label_query_tooltip (GtkWidget *widget,
|
|
|
|
|
int x,
|
|
|
|
|
int y,
|
|
|
|
|
gboolean keyboard_tip,
|
|
|
|
|
GtkTooltip *tooltip)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
GtkLabel *self = GTK_LABEL (widget);
|
|
|
|
|
GtkLabelSelectionInfo *info = self->select_info;
|
|
|
|
|
int index = -1;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (info && info->links)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (keyboard_tip)
|
|
|
|
|
{
|
|
|
|
|
if (info->selection_anchor == info->selection_end)
|
|
|
|
|
index = info->selection_anchor;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!get_layout_index (self, x, y, &index))
|
|
|
|
|
index = -1;
|
|
|
|
|
}
|
2020-04-10 13:41:56 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (index != -1)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
const int link_index = _gtk_label_get_link_at (self, index);
|
|
|
|
|
|
|
|
|
|
if (link_index != -1)
|
|
|
|
|
{
|
|
|
|
|
const GtkLabelLink *link = &info->links[link_index];
|
|
|
|
|
|
|
|
|
|
if (link->title)
|
|
|
|
|
{
|
|
|
|
|
gtk_tooltip_set_markup (tooltip, link->title);
|
2021-03-17 22:16:47 +00:00
|
|
|
|
return TRUE;
|
2020-12-25 11:05:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return GTK_WIDGET_CLASS (gtk_label_parent_class)->query_tooltip (widget,
|
|
|
|
|
x, y,
|
|
|
|
|
keyboard_tip,
|
|
|
|
|
tooltip);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_label_focus (GtkWidget *widget,
|
|
|
|
|
GtkDirectionType direction)
|
2020-04-12 17:54:20 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
GtkLabel *self = GTK_LABEL (widget);
|
|
|
|
|
GtkLabelSelectionInfo *info = self->select_info;
|
|
|
|
|
GtkLabelLink *focus_link;
|
2020-04-12 17:54:20 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (!gtk_widget_is_focus (widget))
|
2020-04-12 17:54:20 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_widget_grab_focus (widget);
|
|
|
|
|
if (info)
|
|
|
|
|
{
|
|
|
|
|
focus_link = gtk_label_get_focus_link (self, NULL);
|
|
|
|
|
if (focus_link && direction == GTK_DIR_TAB_BACKWARD)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
for (i = info->n_links - 1; i >= 0; i--)
|
|
|
|
|
{
|
|
|
|
|
focus_link = &info->links[i];
|
|
|
|
|
if (!range_is_in_ellipsis (self, focus_link->start, focus_link->end))
|
|
|
|
|
{
|
|
|
|
|
info->selection_anchor = focus_link->start;
|
|
|
|
|
info->selection_end = focus_link->start;
|
2022-04-14 10:14:17 +00:00
|
|
|
|
break;
|
2020-12-25 11:05:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-12 17:54:20 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2020-04-12 17:54:20 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2020-04-12 17:54:20 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (!info)
|
|
|
|
|
return FALSE;
|
2020-04-12 17:54:20 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (info->selectable)
|
|
|
|
|
{
|
|
|
|
|
int index;
|
2020-04-12 17:54:20 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (info->selection_anchor != info->selection_end)
|
|
|
|
|
goto out;
|
2020-04-12 17:54:20 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
index = info->selection_anchor;
|
2020-04-12 17:54:20 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (direction == GTK_DIR_TAB_FORWARD)
|
|
|
|
|
{
|
|
|
|
|
guint i;
|
|
|
|
|
for (i = 0; i < info->n_links; i++)
|
2020-04-12 17:54:20 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
const GtkLabelLink *link = &info->links[i];
|
2020-04-12 17:54:20 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (link->start > index)
|
|
|
|
|
{
|
|
|
|
|
if (!range_is_in_ellipsis (self, link->start, link->end))
|
|
|
|
|
{
|
|
|
|
|
gtk_label_select_region_index (self, link->start, link->start);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-12 17:54:20 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-25 11:05:28 +00:00
|
|
|
|
else if (direction == GTK_DIR_TAB_BACKWARD)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
for (i = info->n_links - 1; i >= 0; i--)
|
|
|
|
|
{
|
|
|
|
|
GtkLabelLink *link = &info->links[i];
|
2020-04-12 17:54:20 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (link->end < index)
|
|
|
|
|
{
|
|
|
|
|
if (!range_is_in_ellipsis (self, link->start, link->end))
|
|
|
|
|
{
|
|
|
|
|
gtk_label_select_region_index (self, link->start, link->start);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-12 17:54:20 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int focus_link_index;
|
|
|
|
|
int new_index = -1;
|
|
|
|
|
|
|
|
|
|
if (info->n_links == 0)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
focus_link = gtk_label_get_focus_link (self, &focus_link_index);
|
|
|
|
|
|
|
|
|
|
if (!focus_link)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
switch (direction)
|
|
|
|
|
{
|
|
|
|
|
case GTK_DIR_TAB_FORWARD:
|
|
|
|
|
if (focus_link)
|
2022-04-14 10:14:17 +00:00
|
|
|
|
new_index = focus_link_index + 1;
|
2020-12-25 11:05:28 +00:00
|
|
|
|
else
|
|
|
|
|
new_index = 0;
|
|
|
|
|
|
2022-04-14 10:14:17 +00:00
|
|
|
|
if (new_index >= info->n_links)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
while (new_index < info->n_links)
|
2020-12-25 11:05:28 +00:00
|
|
|
|
{
|
2022-04-14 10:14:17 +00:00
|
|
|
|
const GtkLabelLink *link = &info->links[new_index];
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (!range_is_in_ellipsis (self, link->start, link->end))
|
|
|
|
|
break;
|
2022-04-14 10:14:17 +00:00
|
|
|
|
|
|
|
|
|
new_index++;
|
2020-12-25 11:05:28 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GTK_DIR_TAB_BACKWARD:
|
|
|
|
|
if (focus_link)
|
2022-04-14 10:14:17 +00:00
|
|
|
|
new_index = focus_link_index - 1;
|
2020-12-25 11:05:28 +00:00
|
|
|
|
else
|
|
|
|
|
new_index = info->n_links - 1;
|
|
|
|
|
|
2022-04-14 10:14:17 +00:00
|
|
|
|
if (new_index < 0)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
while (new_index >= 0)
|
2020-12-25 11:05:28 +00:00
|
|
|
|
{
|
2022-04-14 10:14:17 +00:00
|
|
|
|
const GtkLabelLink *link = &info->links[new_index];
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (!range_is_in_ellipsis (self, link->start, link->end))
|
|
|
|
|
break;
|
2022-04-14 10:14:17 +00:00
|
|
|
|
|
|
|
|
|
new_index--;
|
2020-12-25 11:05:28 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
case GTK_DIR_UP:
|
|
|
|
|
case GTK_DIR_DOWN:
|
|
|
|
|
case GTK_DIR_LEFT:
|
|
|
|
|
case GTK_DIR_RIGHT:
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-14 10:14:17 +00:00
|
|
|
|
if (new_index != -1 && new_index < info->n_links)
|
2020-12-25 11:05:28 +00:00
|
|
|
|
{
|
|
|
|
|
focus_link = &info->links[new_index];
|
|
|
|
|
info->selection_anchor = focus_link->start;
|
|
|
|
|
info->selection_end = focus_link->start;
|
|
|
|
|
gtk_widget_queue_draw (widget);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
2020-04-12 17:54:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-03-05 14:08:42 +00:00
|
|
|
|
static void
|
2020-12-25 11:05:28 +00:00
|
|
|
|
emit_activate_link (GtkLabel *self,
|
|
|
|
|
GtkLabelLink *link)
|
2000-11-01 07:07:46 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gboolean handled;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_signal_emit (self, signals[ACTIVATE_LINK], 0, link->uri, &handled);
|
2012-04-24 20:22:22 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/* signal handler might have invalidated the layout */
|
|
|
|
|
if (!self->layout)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (handled && !link->visited &&
|
|
|
|
|
self->select_info && self->select_info->links)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
link->visited = TRUE;
|
|
|
|
|
update_link_state (self);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
2020-12-25 11:05:28 +00:00
|
|
|
|
}
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_activate_link_open (GtkWidget *widget,
|
|
|
|
|
const char *name,
|
|
|
|
|
GVariant *parameter)
|
|
|
|
|
{
|
|
|
|
|
GtkLabel *self = GTK_LABEL (widget);
|
|
|
|
|
GtkLabelLink *link = self->select_info->context_link;
|
2010-01-03 05:57:14 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (link)
|
|
|
|
|
emit_activate_link (self, link);
|
|
|
|
|
}
|
2020-04-10 14:33:12 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_activate_link_copy (GtkWidget *widget,
|
|
|
|
|
const char *name,
|
|
|
|
|
GVariant *parameter)
|
|
|
|
|
{
|
|
|
|
|
GtkLabel *self = GTK_LABEL (widget);
|
|
|
|
|
GtkLabelLink *link = self->select_info->context_link;
|
2010-01-03 05:57:14 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (link)
|
|
|
|
|
{
|
|
|
|
|
GdkClipboard *clipboard;
|
2010-01-03 05:57:14 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
clipboard = gtk_widget_get_clipboard (widget);
|
|
|
|
|
gdk_clipboard_set_text (clipboard, link->uri);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
g_print ("no link ?!\n");
|
|
|
|
|
}
|
2020-04-12 17:54:20 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_activate_clipboard_copy (GtkWidget *widget,
|
|
|
|
|
const char *name,
|
|
|
|
|
GVariant *parameter)
|
|
|
|
|
{
|
|
|
|
|
g_signal_emit_by_name (widget, "copy-clipboard");
|
|
|
|
|
}
|
2020-04-12 17:54:20 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_select_all (GtkLabel *self)
|
|
|
|
|
{
|
|
|
|
|
gtk_label_select_region_index (self, 0, strlen (self->text));
|
|
|
|
|
}
|
2012-04-24 20:22:22 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_activate_selection_select_all (GtkWidget *widget,
|
|
|
|
|
const char *name,
|
|
|
|
|
GVariant *parameter)
|
|
|
|
|
{
|
|
|
|
|
gtk_label_select_all (GTK_LABEL (widget));
|
|
|
|
|
}
|
2000-11-01 07:07:46 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_nop (GtkWidget *widget,
|
|
|
|
|
const char *name,
|
|
|
|
|
GVariant *parameter)
|
|
|
|
|
{
|
|
|
|
|
}
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_label_mnemonic_activate (GtkWidget *widget,
|
|
|
|
|
gboolean group_cycling)
|
|
|
|
|
{
|
|
|
|
|
GtkLabel *self = GTK_LABEL (widget);
|
|
|
|
|
GtkWidget *parent;
|
2000-11-01 07:07:46 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (self->mnemonic_widget)
|
|
|
|
|
return gtk_widget_mnemonic_activate (self->mnemonic_widget, group_cycling);
|
2020-04-12 17:54:20 +00:00
|
|
|
|
|
2022-05-18 11:40:40 +00:00
|
|
|
|
/* Not a label for something else, but is selectable, so set focus into
|
|
|
|
|
* the label itself.
|
|
|
|
|
*/
|
|
|
|
|
if (gtk_label_get_selectable (self) && gtk_widget_get_focusable (widget))
|
|
|
|
|
return gtk_label_grab_focus (widget);
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/* Try to find the widget to activate by traversing the
|
|
|
|
|
* widget's ancestry.
|
|
|
|
|
*/
|
|
|
|
|
parent = gtk_widget_get_parent (widget);
|
2020-04-14 09:11:08 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (GTK_IS_NOTEBOOK (parent))
|
|
|
|
|
return FALSE;
|
2000-11-01 07:07:46 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
while (parent)
|
|
|
|
|
{
|
2021-05-23 14:23:08 +00:00
|
|
|
|
if (gtk_widget_get_focusable (parent) ||
|
2020-12-25 11:05:28 +00:00
|
|
|
|
(!group_cycling && gtk_widget_can_activate (parent)) ||
|
|
|
|
|
GTK_IS_NOTEBOOK (gtk_widget_get_parent (parent)))
|
|
|
|
|
return gtk_widget_mnemonic_activate (parent, group_cycling);
|
|
|
|
|
parent = gtk_widget_get_parent (parent);
|
|
|
|
|
}
|
2020-04-12 17:54:20 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/* barf if there was nothing to activate */
|
|
|
|
|
g_warning ("Couldn't find a target for a mnemonic activation.");
|
|
|
|
|
gtk_widget_error_bell (widget);
|
2020-04-12 17:54:20 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return FALSE;
|
2000-11-01 07:07:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_popup_menu (GtkWidget *widget,
|
|
|
|
|
const char *action_name,
|
|
|
|
|
GVariant *parameters)
|
2010-06-24 02:36:08 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
GtkLabel *self = GTK_LABEL (widget);
|
|
|
|
|
|
|
|
|
|
gtk_label_do_popup (self, -1, -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_label_root (GtkWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
GtkLabel *self = GTK_LABEL (widget);
|
|
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (gtk_label_parent_class)->root (widget);
|
|
|
|
|
|
|
|
|
|
gtk_label_setup_mnemonic (self);
|
|
|
|
|
|
|
|
|
|
/* The PangoContext is replaced when the display changes, so clear the layouts */
|
|
|
|
|
gtk_label_clear_layout (GTK_LABEL (widget));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_label_unroot (GtkWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
GtkLabel *self = GTK_LABEL (widget);
|
|
|
|
|
|
|
|
|
|
gtk_label_setup_mnemonic (self);
|
|
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (gtk_label_parent_class)->unroot (widget);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gtk_label_activate_link (GtkLabel *self,
|
|
|
|
|
const char *uri)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *widget = GTK_WIDGET (self);
|
|
|
|
|
GtkWidget *toplevel = GTK_WIDGET (gtk_widget_get_root (widget));
|
2023-01-15 18:25:34 +00:00
|
|
|
|
GtkUriLauncher *launcher;
|
2020-12-25 11:05:28 +00:00
|
|
|
|
|
|
|
|
|
if (!GTK_IS_WINDOW (toplevel))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2023-01-15 18:25:34 +00:00
|
|
|
|
launcher = gtk_uri_launcher_new (uri);
|
|
|
|
|
gtk_uri_launcher_launch (launcher, GTK_WINDOW (toplevel), NULL, NULL, NULL);
|
2022-11-29 19:11:26 +00:00
|
|
|
|
g_object_unref (launcher);
|
2020-12-25 11:05:28 +00:00
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_label_activate_current_link (GtkLabel *self)
|
|
|
|
|
{
|
|
|
|
|
GtkLabelLink *link;
|
|
|
|
|
GtkWidget *widget = GTK_WIDGET (self);
|
|
|
|
|
|
|
|
|
|
link = gtk_label_get_focus_link (self, NULL);
|
|
|
|
|
|
|
|
|
|
if (link)
|
|
|
|
|
emit_activate_link (self, link);
|
|
|
|
|
else
|
|
|
|
|
gtk_widget_activate_default (widget);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_label_copy_clipboard (GtkLabel *self)
|
|
|
|
|
{
|
|
|
|
|
if (self->text && self->select_info)
|
|
|
|
|
{
|
|
|
|
|
int start, end;
|
|
|
|
|
int len;
|
|
|
|
|
GdkClipboard *clipboard;
|
|
|
|
|
|
|
|
|
|
start = MIN (self->select_info->selection_anchor,
|
|
|
|
|
self->select_info->selection_end);
|
|
|
|
|
end = MAX (self->select_info->selection_anchor,
|
|
|
|
|
self->select_info->selection_end);
|
|
|
|
|
|
|
|
|
|
len = strlen (self->text);
|
|
|
|
|
|
|
|
|
|
if (end > len)
|
|
|
|
|
end = len;
|
|
|
|
|
|
|
|
|
|
if (start > len)
|
|
|
|
|
start = len;
|
|
|
|
|
|
|
|
|
|
clipboard = gtk_widget_get_clipboard (GTK_WIDGET (self));
|
|
|
|
|
|
|
|
|
|
if (start != end)
|
|
|
|
|
{
|
|
|
|
|
char *str = g_strndup (self->text + start, end - start);
|
|
|
|
|
gdk_clipboard_set_text (clipboard, str);
|
|
|
|
|
g_free (str);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GtkLabelLink *link;
|
|
|
|
|
|
|
|
|
|
link = gtk_label_get_focus_link (self, NULL);
|
|
|
|
|
if (link)
|
|
|
|
|
gdk_clipboard_set_text (clipboard, link->uri);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_label_class_init (GtkLabelClass *class)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
|
|
|
|
|
|
|
|
|
gobject_class->set_property = gtk_label_set_property;
|
|
|
|
|
gobject_class->get_property = gtk_label_get_property;
|
|
|
|
|
gobject_class->finalize = gtk_label_finalize;
|
|
|
|
|
gobject_class->dispose = gtk_label_dispose;
|
|
|
|
|
|
|
|
|
|
widget_class->size_allocate = gtk_label_size_allocate;
|
|
|
|
|
widget_class->state_flags_changed = gtk_label_state_flags_changed;
|
|
|
|
|
widget_class->css_changed = gtk_label_css_changed;
|
|
|
|
|
widget_class->query_tooltip = gtk_label_query_tooltip;
|
|
|
|
|
widget_class->snapshot = gtk_label_snapshot;
|
|
|
|
|
widget_class->unrealize = gtk_label_unrealize;
|
|
|
|
|
widget_class->root = gtk_label_root;
|
|
|
|
|
widget_class->unroot = gtk_label_unroot;
|
|
|
|
|
widget_class->mnemonic_activate = gtk_label_mnemonic_activate;
|
|
|
|
|
widget_class->grab_focus = gtk_label_grab_focus;
|
|
|
|
|
widget_class->focus = gtk_label_focus;
|
|
|
|
|
widget_class->get_request_mode = gtk_label_get_request_mode;
|
|
|
|
|
widget_class->measure = gtk_label_measure;
|
|
|
|
|
|
|
|
|
|
class->move_cursor = gtk_label_move_cursor;
|
|
|
|
|
class->copy_clipboard = gtk_label_copy_clipboard;
|
|
|
|
|
class->activate_link = gtk_label_activate_link;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkLabel::move-cursor:
|
|
|
|
|
* @entry: the object which received the signal
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* @step: the granularity of the move, as a `GtkMovementStep`
|
2020-12-25 11:05:28 +00:00
|
|
|
|
* @count: the number of @step units to move
|
|
|
|
|
* @extend_selection: %TRUE if the move should extend the selection
|
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Gets emitted when the user initiates a cursor movement.
|
|
|
|
|
*
|
|
|
|
|
* The ::move-cursor signal is a [keybinding signal](class.SignalAction.html).
|
|
|
|
|
* If the cursor is not visible in @entry, this signal causes the viewport to
|
|
|
|
|
* be moved instead.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
|
|
|
|
* Applications should not connect to it, but may emit it with
|
|
|
|
|
* g_signal_emit_by_name() if they need to control the cursor
|
|
|
|
|
* programmatically.
|
|
|
|
|
*
|
|
|
|
|
* The default bindings for this signal come in two variants,
|
|
|
|
|
* the variant with the Shift modifier extends the selection,
|
|
|
|
|
* the variant without the Shift modifier does not.
|
|
|
|
|
* There are too many key combinations to list them all here.
|
|
|
|
|
* - Arrow keys move by individual characters/lines
|
|
|
|
|
* - Ctrl-arrow key combinations move by words/paragraphs
|
|
|
|
|
* - Home/End keys move to the ends of the buffer
|
|
|
|
|
*/
|
|
|
|
|
signals[MOVE_CURSOR] =
|
|
|
|
|
g_signal_new (I_("move-cursor"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (gobject_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
|
|
|
|
G_STRUCT_OFFSET (GtkLabelClass, move_cursor),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
_gtk_marshal_VOID__ENUM_INT_BOOLEAN,
|
|
|
|
|
G_TYPE_NONE, 3,
|
|
|
|
|
GTK_TYPE_MOVEMENT_STEP,
|
|
|
|
|
G_TYPE_INT,
|
|
|
|
|
G_TYPE_BOOLEAN);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkLabel::copy-clipboard:
|
|
|
|
|
* @self: the object which received the signal
|
|
|
|
|
*
|
2022-11-18 03:24:18 +00:00
|
|
|
|
* Gets emitted to copy the selection to the clipboard.
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*
|
|
|
|
|
* The ::copy-clipboard signal is a [keybinding signal](class.SignalAction.html).
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
|
|
|
|
* The default binding for this signal is Ctrl-c.
|
|
|
|
|
*/
|
|
|
|
|
signals[COPY_CLIPBOARD] =
|
|
|
|
|
g_signal_new (I_("copy-clipboard"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (gobject_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
|
|
|
|
G_STRUCT_OFFSET (GtkLabelClass, copy_clipboard),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkLabel::activate-current-link:
|
|
|
|
|
* @self: The label on which the signal was emitted
|
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Gets emitted when the user activates a link in the label.
|
|
|
|
|
*
|
|
|
|
|
* The ::activate-current-link is a [keybinding signal](class.SignalAction.html).
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
|
|
|
|
* Applications may also emit the signal with g_signal_emit_by_name()
|
|
|
|
|
* if they need to control activation of URIs programmatically.
|
|
|
|
|
*
|
|
|
|
|
* The default bindings for this signal are all forms of the Enter key.
|
|
|
|
|
*/
|
|
|
|
|
signals[ACTIVATE_CURRENT_LINK] =
|
|
|
|
|
g_signal_new_class_handler (I_("activate-current-link"),
|
|
|
|
|
G_TYPE_FROM_CLASS (gobject_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
|
|
|
|
G_CALLBACK (gtk_label_activate_current_link),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkLabel::activate-link:
|
|
|
|
|
* @self: The label on which the signal was emitted
|
|
|
|
|
* @uri: the URI that is activated
|
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Gets emitted to activate a URI.
|
|
|
|
|
*
|
2020-12-25 11:05:28 +00:00
|
|
|
|
* Applications may connect to it to override the default behaviour,
|
2022-11-29 19:11:26 +00:00
|
|
|
|
* which is to call [method@Gtk.FileLauncher.launch].
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the link has been activated
|
|
|
|
|
*/
|
|
|
|
|
signals[ACTIVATE_LINK] =
|
|
|
|
|
g_signal_new (I_("activate-link"),
|
|
|
|
|
G_TYPE_FROM_CLASS (gobject_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (GtkLabelClass, activate_link),
|
|
|
|
|
_gtk_boolean_handled_accumulator, NULL,
|
|
|
|
|
_gtk_marshal_BOOLEAN__STRING,
|
|
|
|
|
G_TYPE_BOOLEAN, 1, G_TYPE_STRING);
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* GtkLabel:label: (attributes org.gtk.Property.get=gtk_label_get_label org.gtk.Property.set=gtk_label_set_label)
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
|
|
|
|
* The contents of the label.
|
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* If the string contains Pango markup (see [func@Pango.parse_markup]),
|
|
|
|
|
* you will have to set the [property@Gtk.Label:use-markup] property to
|
|
|
|
|
* %TRUE in order for the label to display the markup attributes. See also
|
|
|
|
|
* [method@Gtk.Label.set_markup] for a convenience function that sets both
|
|
|
|
|
* this property and the [property@Gtk.Label:use-markup] property at the
|
|
|
|
|
* same time.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
|
|
|
|
* If the string contains underlines acting as mnemonics, you will have to
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* set the [property@Gtk.Label:use-underline] property to %TRUE in order
|
|
|
|
|
* for the label to display them.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*/
|
|
|
|
|
label_props[PROP_LABEL] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_string ("label", NULL, NULL,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
"",
|
|
|
|
|
GTK_PARAM_READWRITE);
|
|
|
|
|
|
2021-02-19 19:47:44 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* GtkLabel:attributes: (attributes org.gtk.Property.get=gtk_label_get_attributes org.gtk.Property.set=gtk_label_set_attributes)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*
|
|
|
|
|
* A list of style attributes to apply to the text of the label.
|
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
label_props[PROP_ATTRIBUTES] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_boxed ("attributes", NULL, NULL,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
PANGO_TYPE_ATTR_LIST,
|
|
|
|
|
GTK_PARAM_READWRITE);
|
|
|
|
|
|
2021-02-19 19:47:44 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* GtkLabel:use-markup: (attributes org.gtk.Property.get=gtk_label_get_use_markup org.gtk.Property.set=gtk_label_set_use_markup)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*
|
|
|
|
|
* %TRUE if the text of the label includes Pango markup.
|
|
|
|
|
*
|
|
|
|
|
* See [func@Pango.parse_markup].
|
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
label_props[PROP_USE_MARKUP] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_boolean ("use-markup", NULL, NULL,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
FALSE,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
|
|
|
|
|
2021-02-19 19:47:44 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* GtkLabel:use-underline: (attributes org.gtk.Property.get=gtk_label_get_use_underline org.gtk.Property.set=gtk_label_set_use_underline)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*
|
|
|
|
|
* %TRUE if the text of the label indicates a mnemonic with _.
|
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
label_props[PROP_USE_UNDERLINE] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_boolean ("use-underline", NULL, NULL,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
FALSE,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
|
|
|
|
|
2021-02-19 19:47:44 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* GtkLabel:justify: (attributes org.gtk.Property.get=gtk_label_get_justify org.gtk.Property.set=gtk_label_set_justify)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*
|
|
|
|
|
* The alignment of the lines in the text of the label, relative to each other.
|
|
|
|
|
*
|
|
|
|
|
* This does *not* affect the alignment of the label within its allocation.
|
|
|
|
|
* See [property@Gtk.Label:xalign] for that.
|
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
label_props[PROP_JUSTIFY] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_enum ("justify", NULL, NULL,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
GTK_TYPE_JUSTIFICATION,
|
|
|
|
|
GTK_JUSTIFY_LEFT,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* GtkLabel:xalign: (attributes org.gtk.Property.get=gtk_label_get_xalign org.gtk.Property.set=gtk_label_set_xalign)
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* The horizontal alignment of the label text inside its size allocation.
|
|
|
|
|
*
|
|
|
|
|
* Compare this to [property@Gtk.Widget:halign], which determines how the
|
|
|
|
|
* labels size allocation is positioned in the space available for the label.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*/
|
|
|
|
|
label_props[PROP_XALIGN] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_float ("xalign", NULL, NULL,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
0.0, 1.0,
|
|
|
|
|
0.5,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* GtkLabel:yalign: (attributes org.gtk.Property.get=gtk_label_get_yalign org.gtk.Property.set=gtk_label_set_yalign)
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* The vertical alignment of the label text inside its size allocation.
|
|
|
|
|
*
|
|
|
|
|
* Compare this to [property@Gtk.Widget:valign], which determines how the
|
|
|
|
|
* labels size allocation is positioned in the space available for the label.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*/
|
|
|
|
|
label_props[PROP_YALIGN] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_float ("yalign", NULL, NULL,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
0.0, 1.0,
|
|
|
|
|
0.5,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
|
|
|
|
|
2021-02-19 19:47:44 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* GtkLabel:wrap: (attributes org.gtk.Property.get=gtk_label_get_wrap org.gtk.Property.set=gtk_label_set_wrap)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*
|
|
|
|
|
* %TRUE if the label text will wrap if it gets too wide.
|
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
label_props[PROP_WRAP] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_boolean ("wrap", NULL, NULL,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
FALSE,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* GtkLabel:wrap-mode: (attributes org.gtk.Property.get=gtk_label_get_wrap_mode org.gtk.Property.set=gtk_label_set_wrap_mode)
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Controls how the line wrapping is done.
|
|
|
|
|
*
|
|
|
|
|
* This only affects the formatting if line wrapping is on (see the
|
|
|
|
|
* [property@Gtk.Label:wrap] property). The default is %PANGO_WRAP_WORD,
|
|
|
|
|
* which means wrap on word boundaries.
|
2021-12-19 18:22:31 +00:00
|
|
|
|
*
|
|
|
|
|
* For sizing behavior, also consider the [property@Gtk.Label:natural-wrap-mode]
|
|
|
|
|
* property.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*/
|
|
|
|
|
label_props[PROP_WRAP_MODE] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_enum ("wrap-mode", NULL, NULL,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
PANGO_TYPE_WRAP_MODE,
|
|
|
|
|
PANGO_WRAP_WORD,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
|
|
|
|
|
2021-12-19 18:22:31 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkLabel:natural-wrap-mode: (attributes org.gtk.Property.get=gtk_label_get_natural_wrap_mode org.gtk.Property.set=gtk_label_set_natural_wrap_mode)
|
|
|
|
|
*
|
|
|
|
|
* Select the line wrapping for the natural size request.
|
|
|
|
|
*
|
|
|
|
|
* This only affects the natural size requested. For the actual wrapping used,
|
|
|
|
|
* see the [property@Gtk.Label:wrap-mode] property.
|
|
|
|
|
*
|
|
|
|
|
* The default is %GTK_NATURAL_WRAP_INHERIT, which inherits the behavior of the
|
|
|
|
|
* [property@Gtk.Label:wrap-mode] property.
|
|
|
|
|
*
|
|
|
|
|
* Since: 4.6
|
|
|
|
|
*/
|
|
|
|
|
label_props[PROP_NATURAL_WRAP_MODE] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_enum ("natural-wrap-mode", NULL, NULL,
|
2021-12-19 18:22:31 +00:00
|
|
|
|
GTK_TYPE_NATURAL_WRAP_MODE,
|
|
|
|
|
GTK_NATURAL_WRAP_INHERIT,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
|
|
|
|
|
2021-02-19 19:47:44 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* GtkLabel:selectable: (attributes org.gtk.Property.get=gtk_label_get_selectable og.gtk.Property.set=gtk_label_set_selectable)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*
|
|
|
|
|
* Whether the label text can be selected with the mouse.
|
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
label_props[PROP_SELECTABLE] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_boolean ("selectable", NULL, NULL,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
FALSE,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
|
|
|
|
|
2021-02-19 19:47:44 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* GtkLabel:mnemonic-keyval: (attributes org.gtk.Property.get=gtk_label_get_mnemonic_keyval)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*
|
|
|
|
|
* The mnemonic accelerator key for the label.
|
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
label_props[PROP_MNEMONIC_KEYVAL] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_uint ("mnemonic-keyval", NULL, NULL,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
0, G_MAXUINT,
|
|
|
|
|
GDK_KEY_VoidSymbol,
|
|
|
|
|
GTK_PARAM_READABLE);
|
|
|
|
|
|
2021-02-19 19:47:44 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* GtkLabel:mnemonic-widget: (attributes org.gtk.Property.get=gtk_label_get_mnemonic_widget org.gtk.Property.set=gtk_label_set_mnemonic_widget)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*
|
|
|
|
|
* The widget to be activated when the labels mnemonic key is pressed.
|
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
label_props[PROP_MNEMONIC_WIDGET] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_object ("mnemonic-widget", NULL, NULL,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
GTK_TYPE_WIDGET,
|
|
|
|
|
GTK_PARAM_READWRITE);
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* GtkLabel:ellipsize: (attributes org.gtk.Property.get=gtk_label_get_ellipsize org.gtk.Property.set=gtk_label_set_ellipsize)
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
|
|
|
|
* The preferred place to ellipsize the string, if the label does
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* not have enough room to display the entire string.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
|
|
|
|
* Note that setting this property to a value other than
|
|
|
|
|
* %PANGO_ELLIPSIZE_NONE has the side-effect that the label requests
|
|
|
|
|
* only enough space to display the ellipsis "...". In particular, this
|
|
|
|
|
* means that ellipsizing labels do not work well in notebook tabs, unless
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* the [property@Gtk.NotebookPage:tab-expand] child property is set to %TRUE.
|
|
|
|
|
* Other ways to set a label's width are [method@Gtk.Widget.set_size_request]
|
|
|
|
|
* and [method@Gtk.Label.set_width_chars].
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*/
|
|
|
|
|
label_props[PROP_ELLIPSIZE] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_enum ("ellipsize", NULL, NULL,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
PANGO_TYPE_ELLIPSIZE_MODE,
|
|
|
|
|
PANGO_ELLIPSIZE_NONE,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
2020-11-13 20:35:51 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* GtkLabel:width-chars: (attributes org.gtk.Property.get=gtk_label_get_width_chars org.gtk.Property.set=gtk_label_set_width_chars)
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* The desired width of the label, in characters.
|
|
|
|
|
*
|
|
|
|
|
* If this property is set to -1, the width will be calculated automatically.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2022-01-04 15:33:00 +00:00
|
|
|
|
* See the section on [text layout](class.Label.html#text-layout) for details of how
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* [property@Gtk.Label:width-chars] and [property@Gtk.Label:max-width-chars]
|
2020-12-25 11:05:28 +00:00
|
|
|
|
* determine the width of ellipsized and wrapped labels.
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
label_props[PROP_WIDTH_CHARS] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_int ("width-chars", NULL, NULL,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
-1, G_MAXINT,
|
|
|
|
|
-1,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
2000-11-01 07:07:46 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* GtkLabel:single-line-mode: (attributes org.gtk.Property.get=gtk_label_get_single_line_mode org.gtk.Property.set=gtk_label_set_single_line_mode)
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Whether the label is in single line mode.
|
|
|
|
|
*
|
|
|
|
|
* In single line mode, the height of the label does not depend on the
|
|
|
|
|
* actual text, it is always set to ascent + descent of the font. This
|
|
|
|
|
* can be an advantage in situations where resizing the label because
|
|
|
|
|
* of text changes would be distracting, e.g. in a statusbar.
|
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
label_props[PROP_SINGLE_LINE_MODE] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_boolean ("single-line-mode", NULL, NULL,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
FALSE,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
2006-01-11 16:13:23 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* GtkLabel:max-width-chars: (attributes org.gtk.Property.get=gtk_label_set_max_width_chars org.gtk.Property.set=gtk_label_set_max_width_chars)
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* The desired maximum width of the label, in characters.
|
|
|
|
|
*
|
|
|
|
|
* If this property is set to -1, the width will be calculated automatically.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2022-01-04 15:33:00 +00:00
|
|
|
|
* See the section on [text layout](class.Label.html#text-layout) for details of how
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* [property@Gtk.Label:width-chars] and [property@Gtk.Label:max-width-chars]
|
2020-12-25 11:05:28 +00:00
|
|
|
|
* determine the width of ellipsized and wrapped labels.
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
label_props[PROP_MAX_WIDTH_CHARS] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_int ("max-width-chars", NULL, NULL,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
-1, G_MAXINT,
|
|
|
|
|
-1,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
2020-11-13 20:35:51 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* GtkLabel:lines: (attributes org.gtk.Property.get=gtk_label_get_lines org.gtk.Property.set=gtk_label_set_lines)
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
|
|
|
|
* The number of lines to which an ellipsized, wrapping label
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* should be limited.
|
|
|
|
|
*
|
|
|
|
|
* This property has no effect if the label is not wrapping or ellipsized.
|
|
|
|
|
* Set this property to -1 if you don't want to limit the number of lines.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*/
|
|
|
|
|
label_props[PROP_LINES] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_int ("lines", NULL, NULL,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
-1, G_MAXINT,
|
|
|
|
|
-1,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
2006-01-11 16:13:23 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* GtkLabel:extra-menu: (attributes org.gtk.Property.get=gtk_label_get_extra_menu org.gtk.Property.set=gtk_label_set_extra_menu)
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* A menu model whose contents will be appended to the context menu.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*/
|
|
|
|
|
label_props[PROP_EXTRA_MENU] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_object ("extra-menu", NULL, NULL,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
G_TYPE_MENU_MODEL,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
2000-11-01 07:07:46 +00:00
|
|
|
|
|
2022-07-31 15:40:20 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkLabel:tabs: (attributes org.gtk.Property.get=gtk_label_get_tabs org.gtk.Property.set=gtk_label_set_tabs)
|
|
|
|
|
*
|
|
|
|
|
* Custom tabs for this label.
|
|
|
|
|
*
|
|
|
|
|
* Since: 4.8
|
|
|
|
|
*/
|
|
|
|
|
label_props[PROP_TABS] =
|
|
|
|
|
g_param_spec_boxed ("tabs", NULL, NULL,
|
|
|
|
|
PANGO_TYPE_TAB_ARRAY,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_object_class_install_properties (gobject_class, NUM_PROPERTIES, label_props);
|
2020-11-13 20:35:51 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkLabel|menu.popup:
|
|
|
|
|
*
|
|
|
|
|
* Opens the context menu.
|
|
|
|
|
*/
|
|
|
|
|
gtk_widget_class_install_action (widget_class, "menu.popup", NULL, gtk_label_popup_menu);
|
2000-11-01 07:07:46 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/*
|
|
|
|
|
* Key bindings
|
|
|
|
|
*/
|
2006-01-11 16:13:23 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_widget_class_add_binding_action (widget_class,
|
|
|
|
|
GDK_KEY_F10, GDK_SHIFT_MASK,
|
|
|
|
|
"menu.popup",
|
|
|
|
|
NULL);
|
|
|
|
|
gtk_widget_class_add_binding_action (widget_class,
|
|
|
|
|
GDK_KEY_Menu, 0,
|
|
|
|
|
"menu.popup",
|
|
|
|
|
NULL);
|
2020-11-13 20:35:51 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/* Moving the insertion point */
|
|
|
|
|
add_move_binding (widget_class, GDK_KEY_Right, 0,
|
|
|
|
|
GTK_MOVEMENT_VISUAL_POSITIONS, 1);
|
2006-01-11 16:13:23 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
add_move_binding (widget_class, GDK_KEY_Left, 0,
|
|
|
|
|
GTK_MOVEMENT_VISUAL_POSITIONS, -1);
|
2000-11-01 07:07:46 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
add_move_binding (widget_class, GDK_KEY_KP_Right, 0,
|
|
|
|
|
GTK_MOVEMENT_VISUAL_POSITIONS, 1);
|
Remove all references to offscreen flag which was no longer used.
Thu Jun 1 23:05:13 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c: Remove all references to
offscreen flag which was no longer used.
* gtk/gtkprivate.h (enum): Remove unused flags and compress.
* gtk/gtkframe.c (gtk_frame_set_label_widget): Check
for non-null label_widget->parent.
* gtk/gtkentry.c: Get rid of code to deal with PangoAttribute
which no longer was used.
* gdk/gdkpango.c (gdk_pango_context_get_info): make static.
* gdk/gdkpango.c (gdk_draw_layout[_line]): Add checks
for null arguments.
* gdk/x11/gdkgeometry-x11.c (gdk_window_scroll): add
check for destroyed windows.
Thu Jun 1 13:48:45 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimmulticontext.c: Add a finalize method and unref
the slave context there.
* gtk/gtkinvisible.[ch]: Make reference counting behavior
identical to GtkWindow.
Thu Jun 1 01:54:11 2000 Owen Taylor <otaylor@redhat.com>
* Makefile.am gdk/gdkpango.c: Copy the layout render function from
pangox to here, so we can write them independent of rendering
system, using GDK primitives.
* gdk/gdkdrawable.h gdk/gdkdraw.c gdk/gdkwindow.c
gdk/x11/gdkdrawable-x11.c: Remove draw_layout() from the vtable,
since we have a rendering-system independent implementation in
terms of draw_glyphs().
* gdk/gdkpango.c gdkdrawable.h (gdk_draw_layout_line): New
function to render a single line.
* gdk/x11/gdkpango.c: Move the guts of this file mostly
into ../gdkpango.c, which simplifies things, since we
don't have to deal with raw X gc's.
Fri May 19 04:28:16 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextlayout.[ch]: Add get_log_attrs() function to
get the logical attributes for a given GtkTextLine.
Tue May 30 16:05:39 2000 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkfont-x11.c (gdk_font_charset_for_locale): Track
g_locale_get_codeset() to g_get_codeset() change.
Tue May 30 15:03:19 2000 Owen Taylor <otaylor@redhat.com>
* gtk/testcalendar.c (calendar_font_selection_ok): Use font
descriptions.
* gtk/gtkentry.c (gtk_entry_draw_text): Center text within
the entry.
* gtk/gtkfontsel.c (gtk_font_selection_dialog_init): Start of
redoing (vastly simplifying) for Pango. Still needs quite
a bit of work. (Size selection is currently poor. List of
predefined sizes is not a good idea, since all of these
sizes won't necessarily be distinct.)
Tue May 30 13:50:19 2000 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkfont-x11.c (gdk_font_charset_for_locale): Handle
CODESET results for LANG=C.
Mon May 29 15:49:10 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrc.[ch]: Add a 'font_name' declaration to RC
which takes a stringized pango font description;
ignore the older 'font' and 'fontset' declarations.
* gtk/gtkstyle.c gtk/gtkrc.c: Fill in the style->font
field with a GdkFont derived via gdk_font_from_description(),
for compatibility. (Should we just remove it entirely?
Probably too much compatibility breakage, but people
should be migrating to the new Pango stuff as quickly
as possible.)
Mon May 29 15:47:41 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c gtk/gtkclist.c: s/pango_font_unref/g_object_unref/.
Mon May 29 15:44:46 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcalender.c: Roughly pango-ized. Really needs
redoing; there are some bugs in size allocation right
now, the semi-existant distinction between header / day
fonts was removed, but, with Pango, could actually
be made functional in a nice way.
* gtk/testcalender: Move calender from examples into this
directory as a test program. (We really need to restrcture
testgtk into a whole directory full of tests for every
widget or functionality group, separated into multiple .c
files.)
Mon May 29 15:19:56 2000 Owen Taylor <otaylor@redhat.com>
* gtk/testgtk.c (file_exists): Fix stupid typo that
was keeping RC file from being loaded.
* gtk/testgtkrc gtk/testgtkrc2: Test new pango-ized
RC file font code.
Mon May 29 14:31:27 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdkfont.h gdk/x11/gdkfont-x11.c (gdk_font_from_description):
Add function to load a GdkFont from a PangoFontDescription.
Fri May 26 17:16:40 2000 Owen Taylor <otaylor@redhat.com>
* gtk/frame.[ch] gtkaspectframe.c: Make frame widgets able
to have any widget for the label, use a GtkLabel widget
to display the text. (Based partially on a patch from
Anders Carlson.)
(Quite a bit of code reorganization - strip 90% of the
guts out of gtkaspectframe and add a single virtual
func to GtkFrameClass - compute_child_allocation.)
Fri May 26 12:00:02 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkctree.c gtk/gtkclist.[ch]: Pangoized.
(Removed clist->row_center_offset field because caching
it wasn't saving time or code, added private function
_gtk_clist_create_cell_layout()).
Wed May 24 15:59:37 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkaccellabel.c: Pangoized.
* gtk/[hv]ruler.c: Pangoized
Mon May 22 19:23:59 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkfilesel.c (gtk_file_selection_init):
Use gtk_clist_set_column_auto_resize() to remove need
need for manual column width computations.
Mon May 22 18:50:26 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktooltips.[ch]: Replace custom drawing with a GtkLabel,
ensuring Pango correctness, and considerably simplifying the
code.
* gtk/gtklabel.c gtk[hv]scale.c: 1000 => PANGO_SCALE.
* gtk/gtklabel.c (gtk_label_size_request): Fixed incorrect
getting of numbers of lines.
* gtk/gtklabel.c (gtk_label_size_request): Set the requisition
to the actual requested width of the lable, not to the wrap
width we set.
* gtk/gtktextchild.h: Remove extraneous include of gtk/gtk.h.
* gtk/gtktextbtree.c gtk/gtktextbuffer.c gtk/gtktextlayout.c
gtk/gtktextview.c gtk/gtktextview.[ch]: Fix up includes.
* gtk/gtktextview.c: Fix structure inheritance.
* gtk/gtkprogressbar.c: Pangoize.
Mon May 22 15:47:30 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.c (gtk_text_view_get_first_para_iter): Encapsulate
in a function.
* gtk/gtktextlayout.c (find_display_line_above): Fixed
bug with computing line tops.
* gtk/gtktextview.c (changed_handler): Fix < , <= confusion.
Thu May 18 18:53:31 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextdisplay.c (gtk_text_layout_draw): Fix up the x_offset
and y_offset coordinates to do what we need now. (The offset between
buffer and layout coordinates has been reintroduced, but is a
bit different than before.)
* gtk/gtktextview.[ch]: No longer inherit from GtkLayout; instead
handle the adjustments ourselves, and scroll as necessary using
the new gdk_window_scroll().
The advantage of this is that when we are incrementally revalidating,
we are essentially rearranging things around the visible portion
of the screen. With the old setup, the visible portion of the
screen was moved around in the layout, so scrolling and redrawing
to track that caused jumping of the display. Since we now
control the scrolling ourselves, we can suppress this and
only redraw when things actually change.
Thu May 18 18:47:25 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextbtree.c (redisplay_mark): We need to invalidate
the region not just redisplay it after-all, since we store the
cursors in the LineDisplay. (Ugly interactions here between
GtkLayout and GtkTextBTree here.)
* gtk/gtktextbtree.c (redisplay_region): Fixed reversed comparison.
Thu May 18 18:43:21 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.h gdk/x11/gdkgeometry-x11.c (gdk_window_scroll):
Added function to scroll contents of a window while keeping the
window constant. Works by XCopyArea or guffaw-scrolling depending
on the details of how the window is set up. (guffaw-scrolling
still needs to be filled in.)
Wed May 17 22:36:53 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextiter.c gtk/gtkmain.c: Add a debug key for the text widget,
move the debugging that was tied to a global variable
to that.
* gtk/gtkmarshal.list: Add NONE:INT,INT,INT
* gtk/gtktextbtree.[ch] gtk/gtktextlayout.c: Keep a separate
validated flag, in line data instead of setting height/width to
-1. This allows us to perform operations with partially invalid
buffer (using the old size for invalid lines) and thus to do
incremental vaidation. Keep height/width aggregates up to date
when deleting text and rebalancing the tree.
* gtk/gtktextbtree.[ch]: Add functions validate a line
(gtk_text_btree_validate_line), and to validate up
to a number of pixels (gtk_text_btree_validate).
* gtk/gtktextlayout.[ch]: Add an ::invalidated signal
that indicates that something is changed and a revalidation
pass is needed. Change ::need_repaint to ::changed, and
make it take old and new yranges instead of a rectangle.
* gtk/gtktextbtree.[ch] gtk/gtktextlayout.[ch]: Move
the line_data_destroy() function from
gtk_text_btree_add_view() to a virtual function in
GtkTextLayout
* gtk/gtktextbtree.[ch]: Remove gtk_text_btree_get_damage_range(),
since we are handling partial repaints in a different fashion
now.
* gtk/gtktextbtree.[ch]: Only repaint the changed portion
of the selection instead of queueing a repaint on the
entire widget.
* gtk/gtktextbuffer.[ch] gtk/gtktextbtree.[ch]: Move
get_selection_bounds() down to btree, make the function
in buffer a wrapper around the btree function.
* gtk/gtktextlayout.[ch]: Add functions to check if the
layout is valid and to recompute either a range of pixels
aroudn a line or a certain total number of pixels.
* gtk/gtktextlayout.[ch]: Cache a single line display;
now that we only redraw the needed portions, the hit rate
for this cache is quite high.
* gtk/gtktextview.[ch]: Keep track of the first paragraph
on the screen so that when re-laying-out the buffer, we can
keep the same place. This requires connecting to ::value_changed
on the adjustments
* gtk/gtktextview.[ch]: Add idle functions to revalidate
the buffer after we receive an ::invalidated signal.
Wed May 17 22:10:47 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtklayout.c (gtk_layout_size_allocate): Set upper
to max of allocation and layout size, not just to the
layout size.
* gtk/gtk[hv]scrollbar.c (gtk_[hv]scrollbar_calc_slider_size):
Invalidate window so it gets redrawn properly.
* gdk/gdkwindow.c (gdk_window_invalidate_rect): Allow rect == NULL
to mean the entire window.
* gdk/gdkevents.h: Move definition for GDK_PRIORITY_REDRAW
into public header.
Mon May 15 14:51:31 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextmark.c (gtk_text_mark_get_name): Add function
to get the name of a mark.
* gtk/gtktextlayout.c (gtk_text_layout_get_line_at_y): Add a function
to find the paragraph from a y position.
Thu May 11 12:57:20 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextbtree.c (gtk_text_btree_node_invalidate_upward): Valid
nodes have width/height >= 0, not > 0.
Tue May 9 21:29:06 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextlayout.[ch] gtk/gtktextdisplay.c (gtk_text_layout_get_line_display):
Add a size_only flag, so when we only need the size, we don't create
useless appearance attributes.
* gtk/gtktextview.c (gtk_text_view_ensure_layout): Remove
duplicate setting of font description.
* gtk/gtkscale.c: Use PANGO_SCALE instead of 1000
Wed Apr 26 01:53:23 2000 Owen Taylor <otaylor@redhat.com>
* gtk/Makefile.am (EXTRA_DIST): Add OLD_STAMP into
EXTRA_DIST. It does not work well when the file that
everything depends on is not in the tarball.
Wed Apr 26 00:56:14 2000 Owen Taylor <otaylor@redhat.com>
* gtk/testgtk.c: Some hacks and fixes so that it basically
works when not sitting in the GTK+ build tree.
2000-05-03 Havoc Pennington <hp@redhat.com>
* gtk/gtktextbtree.c (gtk_text_line_next_could_contain_tag):
Properly determine the ordering of the tag root and the current
line within the tree. Previous algorithm only worked if the tag
root's immediate parent was the common root of both the current
line and the tag root.
Wed Apr 26 00:43:00 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextlayout.c (set_para_values): Fix some bugs in
alignment.
* gtk/gtktextview.c (gtk_text_view_ensure_layout): Track
the widget text directional dynamically.
* gtk/gtktextview.[ch]: Added functions to get and set default
wrap mode.
Tue Apr 25 23:47:38 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextlayout.c (gtk_text_layout_get_iter_location): Fix bug
in cursor location computation.
Tue Apr 25 23:22:59 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtklayout.c (gtk_layout_set_size): Clamp hadjustment/
vadjusment values properly when layout gets smaller.
* gtk/gtktextview.c (need_repaint_handler): Areas being
passed in are far completely inaccurate, and sometimes
too small, so, for now, just queue a redraw on the
whole visible region.
2000-04-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextbtree.c (summary_destroy): new function to
destroy tag summary nodes
(gtk_text_line_next_could_contain_tag): this function was
totally broken if the line passed in wasn't below the tag
root. Fix it.
(gtk_text_btree_first_could_contain_tag): In the tag == NULL
"wildcard" case, we have to do a linear scan. Blah.
(gtk_text_btree_last_could_contain_tag): In tag == NULL case,
we have to do the linear scan
(tag_removed_cb): When a tag is removed from the tag table,
remove the GtkTextTagInfo node from the btree.
(gtk_text_btree_spew): Implement the spew function, for
our debugging pleasure.
Tue Apr 25 19:40:18 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextlayout.c (gtk_text_layout_set_buffer): Fix
a problem with referring to the wrong buffer.
* gtk/gtkentry.c: Fix focus-in/focus-out confusion.
* gtk/gtkrc.c gtk/gtkstyle.c: Moving setting default
font description to gtk_style_new() - otherwise things
don't work without a .gtkrc file.
* gtk/gtktextbuffer.c (gtk_text_buffer_new): Sink the
tags table if we create it ourself, too.
* gdk/gdktypes.h (enum): Move GDK_RELEASE_MASK, since
it was conflicting with XKB modifiers.
* gtk/gtktextview.[ch]: Add simple support for
GtkIMContext.
Mon Apr 24 19:34:18 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c (gtk_entry_move_cursor_visually): Fix problem
with deletion from last commit.
Mon Apr 24 19:29:40 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_create_pango_context): Set the language
in the context from the current locale.
* gtk/gtkentry.c (gtk_entry_size_request): Use language from the
context, not hardcoded value.
* gtk/gtkentry.c (gtk_entry_move_cursor): Make character movement visual,
not logical.
Sun Apr 23 23:39:18 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c gtk/gtktextdisplay.c: Don't handle selections as
attributes - that doesn't handle partial-glyph selection
properly. Instead use new pango_layout_line_get_x_ranges()
functionality to draw the selection.
* gtk/gtkentry.c: Simplify code since pango_layout_line_index_to_x()
now properly handles out-of-range coordinates.
* gtk/gtktextbuffer.c: Emit "mark_set" when the cursor is moved.
* gtk/gtktextiter.h gtk/gtktextiterprivate.h: Make gtk_text_iter_get_line_byte()
public.
* gtk/gtktextlayout.[ch]: Properly set the direction in the PangoContext
for paragraphs opposite to the base direction of the widget.
* gtk/gtktextlayout.[ch] gtk/gtktextdisplay.c: Fixes for alignment.
* gtk/gtktextlayout.c: Don't split segments on marks, since that
causes Arabic words to reshape as you cursor through.
* gtk/gtktextlayout.[ch] gtk/gtktextview.[ch]: Implement virtual
cursor position when moving vertically with the arrow keys and
scrolling with page-up/page-down. (Arrow keys save only the X,
scrolling saves both X and Y.)
This means you can line-up / line-down or page-up / page-down
without losing your place, and also that moving vertically
with the cursor keys keeps the same X position, not the same
character count:
* gtk/gtktextlayout.[ch] gtk/gtktextview.[ch]: Make vertical
arrow keys move by display lines, not paragraphs.
Tue Apr 18 14:16:50 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtklayout.c: Make sure that the bin window is at least
as big as the allocation. (Should we also make sure that the
bin window is big enough to completely cover widget->window?)
* gtk/gtktextview.c (gtk_text_view_get_visible_rect): Add
function to get the onscreen rectangle.
* gdk/x11/gdkwindow-x11.c (gdk_window_get_pointer): Correctly account
for offsets in window coordinates.
Sun Apr 16 16:13:27 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c (gtk_entry_get_cursor_locations): Fix index/offset
confusion.
* gtk/gtktextview.c (gtk_text_view_ensure_layout): Set the default direction
from the widget direction.
* gtk/gtktexttag.c gtk/gtktexttagprivate.h (gtk_text_tag_set_arg):
Add a "direction" attribute.
* gtk/gtktextview.c: global s/tkxt/text_view/.
* gtk/testtext.c: Added long block of text in Arabic, to test out
the direction attributes. (Some problems with the shaping system
for arabic become obvious - like the fact the cursor splits words
into unjoined pieces.)
Fri Apr 14 12:54:34 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextdisplay.c (render_layout): Add overstrike handling.
* gtk/gtktextlayout.c: Fix up alignment.
* gtk/testtext.c: Add some tests for centering, wrapping.
Fri Apr 14 09:26:22 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdrawable.h gdk/gdkdraw.c gdk/gdkwindow.c gdk/x11/gdkdrawable-x11.c:
Add a draw_glyphs() operation to the drawable vtable and gdk_draw_glyphs().
If we wrote GTK+-specific layout-render function this could just replace
the draw_layout() operation in the vtable.
* gtk/gtkentry.c: Move guts of gtk_entry_get_cursor_locations to
pango_layout_get_cursor_pos() and use that function.
* gtk/gtktextchild.[ch]: add gtk_ onto pixmap_segment_new(), since it
is a non-static symbol.
* gtk/gtktextbtree.[ch]: Replace gtk_text_btree_find_line_data_by_y()
with gtk_text_btree_find_line_by_y()
* gtk/gtktextdisplay.c: Rewrote for Pango - uses a custom layout
renderer that handles GtkTextAppearance attributes.
* gtk/gtktexttag.[ch] gtk/gtktexttagprivate.h:
- Move the values in the style that don't affect geometry into a
GtkTextAppearance structure.
- Change underline to take a PangoUnderline and "font" a string
representation of a font description
- Add a "font_desc" attribute which takes a FontDescription structure.
* gtk/gtktextlayout.[ch]:
- Get rid of the display-line list per each line. Instead, we
generate, on demand, a GtkTextLineDisplay structure which]
contains a PangoLayout * and other necesary information
(offsets, cursor locations) for displaying a paragraph.
- Get rid of the code to wrap lines, create display chunks,
etc. Instead, we just go through a paragraph and convert
it into the necessary inputs to a PangoLayout.
- Implement a new attribute type, GtkTextAttrAppearance. This
holds a GtkTextAppearance, and is used to pass colors,
stipple, etc, through from the layout to the display without
having to use lots and lots of individual attributes.
- Reimplement gtk_layout_get_iter_at_pixel() gtk_layout_get_iter_pos()
in terms of PangoLayout functions.
* gtk/gtktextview.c:
- Handle passing the necessary PangoContext to the layout
- Some fixups in painting to deal with the automatic backing store
and offsetting of GTK+-1.4
- Add a style_set handler so that the default style reacts
properly to theme changes.
* gtk/gtktext?*.[ch]: Random code-style fixes.
* gtk/testtext.c: Substitute in languages that Pango handles now for Thai
Mon Apr 10 10:33:45 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktext?*.[ch]: Check in Havoc's port of the Tk text widget,
in original form preparatory to Pango-ization and gdkimcontext-ization.
Thu Apr 6 19:25:39 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimcontext.c: Move default implementations to real_* vfuncs,
so that we can derive from gtkimcontext in language bindings properly.
Thu Apr 6 16:02:52 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimcontextsimple.[ch]: Use gdk_keyval_to_unicode to gdk_unicode_to_keyval.
Add a compose table including (almost) all the compose combinations
from X. This is 6k of static, shared data as opposed to 50k or so of dynamic
data in the XIM implementation.
* gdk/gdk.h gdk/gdkkeyuni.c gdk/win32/gdkevents-win32.c (gdk_keyval_to_unicode, gdk_unicode_to_keyval):
Moved functions to convert keyvalues from and to unicode here from
the win32 port and made them public.
Wed Apr 5 16:37:29 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkeditable.c (gtk_editable_insert_text): Allow new_text_length == -1.
Wed Apr 5 16:27:45 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimcontext.[ch]: Base class for new input context system
* gtk/gtkimmulticontext.[ch]: Proxy input context that allows
the real input context implementation to be loaded from modules
and switched on the fly.
* gtk/gtkcontextsimple.[ch]: Simple implementation of an input
context that just does direct keysymbol => unicode translation.
* gtk/gtkentry.[ch]: Start switching editing over to using
GtkInputContext. (No handling of preedit yet.)
Wed Apr 5 15:48:41 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktypeutils.h (GTK_CHECK_GET_CLASS): Fix problem with one too
many substitutions. (klass should not be subsituted.)
Wed Apr 5 00:18:14 2000 Owen Taylor <otaylor@redhat.com>
* configure.in: Add checks for Pango
* configure.in docs/Makefile.am: Add test for sgml2html
and allow 'make dist' without building html, but print out
warnings in that case. (For making snapshots)
* gdk/Makefile.am gdk/x11/Makefile.am gtk/Makefile.am:
Add Pango libraries and C flags
* gdk/gdkdraw.c gdk/gdkdrawable.h gdkwindow.c gdk/x11/gdkdrawable-x11.c:
Add function (gdk_draw_layout) to draw a pango layout.
* gdk/gdkpango.h gdk/x11/gdkpango-x11.c: New file with functions
for getting Pango contexts for GDK.
* gtk/gtkeditable.c: Get rid of dead code gtk_editable_parent_set()
* gtk/gtkentry.[ch]: Complete rewrite to use Pango, add bidirectional
editing.
* gtk/gtkentry.c: Hack in simple Hebrew input with direct
keysym => unicode translations. More languages can be added
here, but real input-method support is needed.
* docs/Changes-1.4.txt: Added note about entry behavior.
* gtk/gtkenums.h gtk/gtkwidget.[ch] testgtk.c gtkprivate.h: Add functions
to set the reading direction for a widget and the global direction.
Add test which allows toggling the global direction. Two private
flags are used to store the direction. (GTK_DIRECTION_SET + GTK_DIRECTION_LTR)
* gtk/gtkcheckbutton.c gtk/gtkframe.c gtk/gtkhbbox.c gtk/gtkhbox.c
gtk/gtkradiobutton.c gtk/gtkspinbutton.c gtk/gtktable.c
* gtk/gtk[hv]scale.c gtk/gtkscale.[ch]: Draw numbers using Pango
* gtk/gtklabel.[ch]: Moved to Pango and considerably rewritten. Line breaking,
underlining now handled by Pango.
* gtk/gtkstyle.[ch] gtk/gtkrc.[ch]: Add a PangoFontDescription
to RCStyle and Style. (Having both this and the old font name and GdkFont
is temporary.)
* gtk/gtkwidget.[ch] (gtk_widget_create_pango_{context,layout}): Added
convenience functions for creating contexts and layouts for widgets.
* gtk/testgtk.c: Enhance label tests with multilingual labels.
2000-06-02 03:14:07 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
add_move_binding (widget_class, GDK_KEY_KP_Left, 0,
|
|
|
|
|
GTK_MOVEMENT_VISUAL_POSITIONS, -1);
|
2001-03-05 14:08:42 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
add_move_binding (widget_class, GDK_KEY_f, GDK_CONTROL_MASK,
|
|
|
|
|
GTK_MOVEMENT_LOGICAL_POSITIONS, 1);
|
2010-06-24 02:36:08 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
add_move_binding (widget_class, GDK_KEY_b, GDK_CONTROL_MASK,
|
|
|
|
|
GTK_MOVEMENT_LOGICAL_POSITIONS, -1);
|
Adapt cast macros to standard.
Fri Nov 19 10:34:41 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkgamma.h: Adapt cast macros to standard.
[ Merges from 1.2 ]
Tue Nov 16 10:15:54 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkitemfactory.c (gtk_item_factory_parse_path):
If translation does not include a '/', use entire
translation instead of crashing.
Sun Oct 31 22:21:11 1999 Tim Janik <timj@gtk.org>
* docs/gtk_tut.sgml:
s/gtk_accel_group_attach/gtk_window_add_accel_group/.
Sat Oct 30 09:09:09 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkselection.c (gtk_target_list_remove): Use
g_list_remove_link, not g_list_remove.
[ From Geert Bevin <gbevin@thunderstorms.org> ]
Sun Oct 24 07:41:40 1999 Tim Janik <timj@gtk.org>
* gtk/gtkclist.c (real_undo_selection): commented out g_print()
statement upon unselection (how the heck did that slip in?).
Sat Oct 23 03:03:08 1999 Tim Janik <timj@gtk.org>
* gtk/gtktext.c (gtk_text_freeze):
(gtk_text_thaw): undraw/draw cursor here to avoid unnecessary scrolling
in frozen state (and aparently crashes). patch provided by Anders
Melchiorsen <and@kampsax.dtu.dk>.
Sat Oct 23 02:53:20 1999 Tim Janik <timj@gtk.org>
* fix insensitive default/focus widget activation,
reported by Matt Goodall <mgg@isotek.co.uk>.
* gtk/gtkwindow.c (gtk_window_key_press_event):
(gtk_window_activate_default):
(gtk_window_activate_focus):
return handled=FALSE for actiavtion of insensitive default
widgets. return handled=TRUE for activation of insensitive
focus widgets. don't activate in either case.
Tue Oct 19 09:55:08 1999 Owen Taylor <otaylor@redhat.com>
* gtk-config.in (lib_gtk): Switch order of @x_cflags@
and $glib_cflags to match library order and in the
theory that an old version of GLib is more likely to
be in the include directory for X then vice-versa.
(Bug #2776)
Tue Oct 19 09:46:49 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrc.c (gtk_rc_init): Always use LC_CTYPE
to determine the locale for fontsets, not LC_MESSAGES;
the user may want English messages with a handling
for non-English languages. (LC_CTYPE=ru_RU LC_MESSAGES=fr_FR
will still be broken) (Bug #2891)
Tue Oct 19 20:36:42 1999 Changwoo Ryu <cwryu@adam.kaist.ac.kr>
* gtk/gtkrc.ko: Fixed the wrong number of "*"'s.
Tue Oct 19 12:15:13 1999 Changwoo Ryu <cwryu@adam.kaist.ac.kr>
* gtk/gtkrc.ko: Changed the Korean default fontset.
Fri Oct 8 02:32:47 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtklayout.c (gtk_layout_adjustment_changed): Fix bug
where when scrolling to the left or top double exposes
were done, causing major slowdowns.
Thu Oct 7 18:31:55 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrc.c (gtk_rc_init): Always normalize codeset
names to lowercase and alphanumeric, before looking
them up.
* gtk/Makefile.am: Install codeset variant gtkrc files
with normalized names.
Thu Oct 7 22:52:42 1999 Tim Janik <timj@gtk.org>
* gtk/gtkitemfactory.c (gtk_item_factory_popup_with_data): even
popup menus when the menu is already visible, but its parent
is still hidden, (happens after tornoff window got hidden).
Thu Oct 7 11:09:55 1999 Owen Taylor <otaylor@redhat.com>
* gtk/Makefile.am (install-data-local): Fix
a typo where gtkrc.vi_VN.tcvn5712 wasn't getting
deleted, causing error messages on install.
Thu Oct 7 11:03:06 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtk[hv]paned.c (gtk_{h,v}paned_draw): Redraw
the handle as well, since we now sometimes ignore
exposes on the handle while resizing.
Wed Oct 6 18:02:31 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrc.c (gtk_rc_append_default_pixmap_path): Fix stupid
extra g_free introduced in one of the last one or two
commits.
Wed Oct 6 16:38:36 1999 Owen Taylor <otaylor@redhat.com>
* gtk/Makefile.am gtk/gtkrc*: Make naming of gtkrc files
consistent, put each style that a gtkrc.* file creates
in a unique namespace, remove old files before installing.
Wed Oct 6 14:31:16 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrc.c (gtk_rc_init): Avoid leaking memory when
gtk_rc_init is called multiple times. (Yes, people who
do that have bugs in their code.)
Tue Oct 5 11:36:57 PDT 1999 Manish Singh <yosh@gimp.org>
* gtk/Makefile.am: listing gtkrc in gtkconf_DATA seems to barf.
Remove it since it's generated by the Makefile anyway
Tue Oct 5 02:43:41 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkinputcommon.h (gdk_input_device_new): Free
device->info.axes for core pointer.
Thu Sep 30 13:55:25 1999 Owen Taylor <otaylor@redhat.com>
* gtk/testgtk.c (destroy_idle_test): Rename idle to
idle_id, to deal with obsolete, broken C libraries.
Mon Sep 27 02:50:15 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkvscale.c (gtk_vscale_draw): Don't add in
allocation->x/y twice!
* gtk/gtkhscale.c: Make usage of gtk_hscale_pos_trough()
consistent with gtk_vscale_pos_trough().
Sun Sep 26 19:44:34 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcontainer.c (gtk_container_queue_resize): We may
be queueing a resize on a toplevel container between
the time we show it and when we map it. So, we need
to test GTK_WIDGET_VISIBLE() for toplevels, and only
use GTK_WIDGET_DRAWABLE() for child windows.
Thu Sep 23 16:41:03 1999 Owen Taylor <otaylor@redhat.com>
* gtk/Makefile.am (LDADDS): Add GDK_WLIBS to LDADDS
(fixes bug #2144)
Fri Sep 24 00:51:45 1999 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c (gtk_container_queue_resize): check for
container DRAWABLE (instead of VISIBLE), so we don't queue
resizes on non-toplevel containers.
Sun Sep 19 18:13:31 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkselection.[ch]: Make the data argument
const guchar *.
Sat Sep 18 21:27:40 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c: Try to behave sensibly if
the focus widget is the window itself. (Should
we allow this at all?)
Fri Sep 17 09:57:15 1999 Tim Janik <timj@gtk.org>
* gtk/gtkwidget.c (gtk_widget_set_sensitive):
* gtk/gtknotebook.c (gtk_notebook_set_scrollable):
* gtk/gtknotebook.c (gtk_notebook_set_show_border):
* gtk/gtkclist.c (gtk_notebook_set_show_border): make gboolean args
in prototypes and implementations consistent (Tomas Ogren).
* gtk/gtklayout.c (gtk_layout_remove): unset GTK_IS_OFFSCREEN flag
before the widget is unparented (reported by damon).
* gtk/gtkdnd.c: make the cursor and icon data _unsigned_ char,
since we provide unsigned data anyways.
Thu Sep 16 21:32:01 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtktooltips.c (gtk_tooltips_set_tip): Delay
the call to gtk_tooltips_layout_text() until later.
* gtk/gtktooltips.c (gtk_tooltips_draw_tips):
Call gtk_widget_ensure_style() before using the style.
Wed Sep 15 02:52:19 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_event): Added workaround
for old widgets that don't propagate draws to all
children. (Namely gnome-dock for gnome-libs <= 1.0.16)
Tue Sep 14 19:22:19 1999 Tim Janik <timj@gtk.org>
* gtk/gtkwidget.c (gtk_widget_queue_resize): don't queue the parent
for a redraw but just the widget that requested the resize.
Tue Sep 14 18:29:47 1999 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c: added new widget level method
gtk_container_set_reallocate_redraws() and a GtkContainer flag
reallocate_redraws : 1 to reflect the setting, exported this through
the argument system as a boolean ::reallocate_redraws.
* gtk/gtkwidget.c (gtk_widget_size_allocate): when queueing redraws
on the widget because the allocation changes, do so as well for
widget->parent if the parent has reallocate_redraws set to TRUE.
with that containers requesting reallocation redraws get automatically
redrawn if their children changed allocation (this unfortunately
affects also other children that didn't change allocation, but we
cannot work around that before 1.3).
Tue Sep 14 18:23:01 1999 Tim Janik <timj@gtk.org>
* gtk/gtkwidget.c (gtk_widget_idle_draw): only emit ::draw if width
_and_ height are >0 (not _or_).
* gtk/gtktable.c (gtk_table_remove): use gtk_widget_queue_resize()
instead of gtk_container_queue_resize(), which is a core gtk internal
function (must have been on crack when i queued that).
* gtk/gtkprivate.h: added new private flag GTK_FULLDRAW_PENDING, so
we can check more reliably if we want to discard expose events.
* gtk/gtkwidget.c: added setting/unsetting of the GTK_FULLDRAW_PENDING
flag.
* gtk/gtkwidget.c (gtk_widget_event): don't discard synthesized exposes,
we simply trust these events. for deciding whether to discard exposes,
check GTK_FULLDRAW_PENDING instead of RESIZE_PENDING.
Mon Sep 13 15:01:21 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_queue_clear_area): Ignore
queues of areas that are completely off screen.
* gtk/gtkwidget.c (gtk_widget_idle_draw): Fix broken
logic for handleboxes.
* gtk/gtkwidget.c (gtk_widget_queue_draw_data): Add santity
check on width/height.
Mon Sep 13 02:22:47 1999 Tim Janik <timj@gtk.org>
* gtk/Makefile.am: backed out Raja's recent VPATH build "improvements",
we are fine with using $@ the way we do (if we actually encounter
brokeness with $@ in VPATH builds because of additional path prefixes,
we need to use $(@F) actually).
Mon Sep 13 01:34:53 1999 Tim Janik <timj@gtk.org>
* gtk/gtksignal.c: renamed two variables, hopefully didn't introduce
short lived bugs, that would allow language bindings to do surgeries
to our guts.
Fri Sep 10 15:22:50 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_size_allocate): Fix typo
where comparison was being done against an uninitialized
value causing intermittant results depending on
compiler flags. Also make it clearer that we aren't
ever initializing the child as 0x0 (though this will
be caught in gtk_widget_size_allocate())
Fri Sep 10 10:06:56 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_set_transient_for): Move
gtk_window_unset_transient_for() call after we do checks
involving the old transient parent.
[ From Lance Capser <lmc@cyberhighway.net> ]
1999-09-07 Raja R Harinath <harinath@cs.umn.edu>
* gtk/Makefile.am (gtk.defs): Go back to using `touch' to create
an empty file.
Mon Sep 6 00:11:56 1999 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (gtk_ctree_is_ancestor): return FALSE if node has
no children. (Reported by: Chris Rogers <gandalf@pobox.com>)
1999-09-03 Raja R Harinath <harinath@cs.umn.edu>
* gtk/Makefile.am (gen_sources): Improve VPATH builds.
`$@' is valid only in the build dir, not after we've done
`cd $srcdir'. Also use `test -f' instead of less portable
`test -e'.
Fri Sep 3 15:59:56 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtktext.c (correct_cache_insert): Rewrite
for simplicity, and hopefully correctness.
(Fixes bug #1322, which was a segfault when
on some insertions with the properties around
the insertion set up just wrong.)
* gtk/gtktext.c (gtk_text_adjustment): When we receive
a "changed" signal, clamp the new value to the adjustment
bounds to avoid segfaulting if someone tries to change
the adjustment to a bogus value. (Bug #1795)
Thu Sep 2 16:33:59 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmain.c: Ignore unexpected destroy notifies
for children, for toplevel windows handle them
like delete_event.
* gtk/gtkplug.c: Add an unrealize handler so that
we unref plug->socket_window when we are done
with it.
Fri Sep 3 14:52:54 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtktext.c (clear_area): Fix stupid signedness
problem that was causing background to sometimes
be misaligned.
Fri Sep 3 12:26:33 1999 Owen Taylor <otaylor@redhat.com>
[ Fixes pointed out by Ettore Perazzoli <ettore@comm2000.it> ]
* gtk/gtkmenu.c (gtk_menu_position): Make
sure we never position menus with negative x, y,
since gtk_widget_set_uposition() can't handle that.
* gtk/gtkmenuitem.c (gtk_menu_item_position_menu):
Modify the positioning code a bit so that we always
put the top-left corner onscreen. (This is for
UI reasons, gtk_menu_position() now takes care of
gtk_widet_set_uposition() brokeness.)
Fri Sep 3 03:06:30 1999 Tim Janik <timj@gtk.org>
* gtk/Makefile.am: fixed up things for -jx, x > 1.
Sun Sep 5 08:48:51 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_modify_style): Ref the
RC style that is passed in. The lack of the ref
before was a bug. If people worked around this
bug, this will introduce a slight memory leak
in their code. The code should typically look like:
rc_style = gtk_rc_style_new ();
[...]
gtk_widget_modify_style (widget, rc_style);
gtk_rc_style_unref (rc_style);
* gtk/gtkwidget.c (gtk_widget_modify_style): Reset
the style if it was already set.
* gtk/gtkwidget.c (gtk_widget_set_name): Only set the
style if it was set before.
Thu Sep 2 19:02:37 1999 Owen Taylor <otaylor@redhat.com>
* gtk/testgtk.c (main): Add a check to see if we
are being run from the correct directory and
to quit nicely if we are not.
* gtk/gtkrc.c (gtk_rc_slist_remove_all): Make function
static.
Thu Sep 2 23:00:03 1999 Tim Janik <timj@gtk.org>
* gtk/gtkenums.h (GtkWindowPosition): added GTK_WIN_POS_CENTER_ALWAYS.
* gtk/gtkwindow.c:
queue resizes unconditionally (gtk_widget_queue_resize will figure
what to do if the window is not realized).
(gtk_window_move_resize): only recenter the window
for GTK_WIN_POS_CENTER_ALWAYS.
(gtk_window_compute_reposition): handle GTK_WIN_POS_CENTER_ALWAYS in
the same way as GTK_WIN_POS_CENTER.
Thu Sep 2 22:39:27 1999 Tim Janik <timj@gtk.org>
* gtk/gtkwindow.c (gtk_window_reposition): check for the last position
with (!(info->last_flags & GDK_HINT_POS)) instead of
(!info->last_flags & GDK_HINT_POS).
* gtk/gtkwindow.c (gtk_window_move_resize): constrain new_width and
new_height unconditionally, because we use these values even if
!default_size_changed && !hints_changed.
comented the (default_size_changed || hints_changed) case with
respect to resize rejects from the window manager.
* gtk/gtkwindow.c (gtk_window_move_resize): save info->last values
in the zvt condition hack, since this includes the window hints, set
the hints after the handling_resize case.
* gtk/gtkwindow.c (gtk_window_show): constrain the default size that a
window is initially shown with to the geometry.
Thu Sep 2 07:38:56 1999 Tim Janik <timj@gtk.org>
* gtk/gtkwindow.c (gtk_window_move_resize):
s/size_changed/default_size_changed/g so i know what's
really going on (frying brain on smaller flame now).
Thu Sep 2 05:47:47 1999 Tim Janik <timj@gtk.org>
* gtk/gtkwindow.c (gtk_window_move_resize): queue a new resize if
we have size_changed upon handling_resize. this is a gross
workaround for the broken zvt widget and should be removed in
1.3 again (search for FIXME).
Owen provided an accurate comment for this:
/* We could be here for two reasons
* 1) We coincidentally got a resize while handling
* another resize.
* 2) Our computation of size_changed was completely
* screwed up, probably because one of our children
* is broken. It's probably a zvt widget.
*
* For 1), we could just go ahead and ask for the
* new size right now, but doing that for 2)
* might well be fighting the user (and can even
* trigger a loop). Since we really don't want to
* do that, we requeue a resize in hopes that
* by the time it gets handled, the child has seen
* the light and is willing to go along with the
* new size. (this happens for the zvt widget, since
* the size_allocate() above will have stored the
* requisition corresponding to the new size in the
* zvt widget)
*
* This doesn't buy us anything for 1), but it shouldn't
* hurt us too badly, since it is what would have
* happened if we had gotten the configure event before
* the new size had been set.
*/
Wed Sep 1 20:46:11 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrc.c: deal properly with the fact that RC
style lists may include rc styles more than once.
* gtk/gtkrc.c (gtk_rc_append_pixmap_path): Removed
unused static function.
* gtk/gtkrc.c (gtk_rc_find_pixmap_in_path): Keep a
stack of directories of RC files currently being
parsed and implicitely add them to pixmap path.
This fixes a bug where the directory would get
appended then overwritten by pixmap_path declarations.
(bug #1462, from Peter Wainright <prw@wainpr.demon.co.uk>)
* gtk/gtkthemes.c (gtk_theme_engine_unref): Call
theme's exit function. (Patch from Peter Wainwright,
bug #1454)
* gtk/gtkradiomenuitem.c (gtk_radio_menu_item_destroy):
Add a destroy() handler to take care of removing
group for menu item. (Fixes bug #1197)
* gtk/gtkwidget.c (gtk_widget_size_request): Fixed thinko
in warning message.
Wed Sep 1 21:27:42 1999 Tim Janik <timj@gtk.org>
* gtk/gtkwindow.c (gtk_window_move_resize): don't require a server
roundtrip to figure window's width and height, since we know that
anyways from widget->allocation.
Wed Sep 1 12:37:44 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_move_resize): Compute
the hints after we request the new size.
Wed Sep 1 10:38:37 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_compute_hints): Removed
GTK_WIDGET_REALIZED() assertion - we can compute the
hints before we are realized.
* gtk/gtkwindow.c (gtk_window_move_resize): Reorder
hint changing so that we have a value of hints_changed
when we decide whether to constrain the window size.
* gtk/gtkwindow.c (gtk_window_move_resize): Spelling fix.
* gtk/gtkwindow.c (gtk_window_constrain_size): cleanups,
change back to G_MAXINT.
Wed Sep 1 06:54:59 1999 Tim Janik <timj@gtk.org>
* gtk/gtkwindow.c (gtk_window_get_geometry_info): zero initialize
new GtkWindowGeometryInfo, so fields like GdkGeometry geometry
contain uncluttered values.
(gtk_window_compute_hints): simply assert that window is realized
and that geometry_info is valid, since we rely on this anyways.
(gtk_window_constrain_size): major cleanups to the code.
if (flags & GDK_HINT_BASE_SIZE) use geometry's base width and height
for the base size, instead of the minimums. use 32767 as max width
and height (like in gtkwindow.c) instead of G_MAXINT.
Wed Sep 1 04:41:25 1999 Tim Janik <timj@gtk.org>
* cleaned up the GtkContainer.need_resize flag handling mess, we
only need to force resize requests when we were prematurely
realized, or our widget tree was modified when we were temporarily
hidden. handling these cases directly upon showing the window (i.e.
while the GdkWindow is still unmapped) avoids the need to wait for
a configure event response and therefore makes the GUI more snappier
and avoids blank windows during the roundtrip.
* gtk/gtkwidget.c:
(gtk_widget_hide):
(gtk_widget_show): don't queue resizes on toplevels, they know how
to deal with matters.
* gtk/gtkcontainer.c (gtk_container_queue_resize): set the ->need_resize
flag directly for not visible resize containers and spare us unecessary
signal emissions.
* gtk/gtkwindow.c:
(gtk_window_realize): if we need to enforce premature size allocation,
queue a container resize so we are correctly resized later on.
(gtk_window_init):
(gtk_window_size_request):
don't freak around with the ->need_resize flag,
gtk_container_queue_resize() will care about that.
(gtk_window_show):
handle initial resizing issues here, we can handle matters better in
this place, especially since we know that our GdkWindow is still
unmapped.
(gtk_window_move_resize):
don't care about ->need_resize at all.
handle size changes properly that occoured while we waited for a
configure event.
Tue Aug 31 15:58:46 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_set_uposition):
* gtk/gtkwindow.[hc] (gtk_window_reposition):
Move the hint setting code from gtk_widget_set_uposition
to here; set the hints so that we respect any previously
set geometry hints.
* gtk/gtkwindow.c (gtk_window_compute_reposition): Don't
change the window hints here or move the window here,
let that happen in gtk_window_move_resize().
Tue Aug 31 06:58:52 1999 Tim Janik <timj@gtk.org>
* gtk/gtkwidget.c (gtk_widget_event): when discarding exposes due
to already queued resizes (and therefore redraws) on a widget, check
its anchestry as well.
* gtk/gtkcontainer.c:
(gtk_container_queue_resize): clear resize widgets for resize
containers before aborting prematurely. this is especially important
for toplevels which may need imemdiate processing or their resize
handler to be queued.
(gtk_container_dequeue_resize_handler): added new internal function for
gtkwindow.c.
* gtk/gtkwindow.c (gtk_window_move_resize): if we are resizing due to a
configure event, take possible changes in window position into account
as well.
if we request a new window size, queue up a resize handler that will
last until the configure event response arrives.
combined the ->need_resize case (initial show) with the general size
(hints) changed case and added even more comments.
if !auto_shrink, only revert to the old allocation if the new size
is smaller than the current allocation.
Tue Aug 31 11:55:20 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_set_arg, gtk_window_set_policy,
gtk_window_set_geometry_hints
gtk_window_set_default_size):
When hints are set, queue a resize so that the hints will
be eventually reset on the toplevel.
* gtk/gtkwindow.c (gtk_window_show): Use
gtk_window_compute_default_size(). Clear the need_resize flag
on the initail map so that we don't unnecessarily trigger the
resize code.
* gtk/gtkwindow.c (gtk_window_move_resize): Split apart
into separate functions. Compare the hints we are setting
with what we set last time so that we can accurately
tell when we need to reset the hints.
* gtk/gtkwindow.c (gtk_window_compute_default_size): New
function to figure out the size from requisition
and default_size.
* gtk/gtkwindow.c (gtk_window_constrain_size): Function
from fvwm to constrain a size to the geometry hints.
* gtk/gtkwindow.c (gtk_window_compare_hints): New function
to compare two sets of geometry hints.
* gtk/gtkwindow.c (gtk_window_compute_hints): Renamed
from gtk_window_set_hints(), just compute the hints,
don't set them.
* gtk/gtkwindow.c (gtk_window_compute_reposition): Move
code from gtk_window_move_resize() to separate function,
rationalize a bit.
Tue Aug 31 13:05:03 1999 Owen Taylor <otaylor@redhat.com>
* gtkrc.h: Move the ref_count member out of the GtkRcStyle
structure into a new private structure.
* gtkrc.c: Split GtkRcStyle into public/private.
In the private part, add a list of pointers to the
RcStyle lists this RcStyle participates in.
* gtkrc.c: When a RcStyle is free, remove all
lists referencing it from the
realized_style_ht hash, and free those lists.
* gtk/gtkrc.c (gtk_rc_clear_styles): Don't call
gtk_rc_init(), since that adds the default styles
to the list of parsed RC files again.
* gtk/gtkrc.c: Use gtk_rc_style_find() consistently.
Thu Aug 26 14:14:42 1999 Tim Janik <timj@gtk.org>
* gtk/gtkwidget.c (gtk_widget_size_allocate): reactivated the sanity
checks that ensure that a widget's allocation is at least 1 in width
and height. (GNOME note: this doesn't affect old panel code anymore,
because GtkSocket will request width and height of at least 1 since
Fri Jul 23).
* gtk/gtkwindow.c (gtk_window_realize): if the widget hasn't been
allocated yet (happens if the user realizes the window prematurely),
size request and allocate it.
(gtk_window_size_allocate): guard against guint underflows.
Wed Aug 25 19:01:36 1999 Lars Hamann <lars@gtk.org>
* gtk/Makefile.am (gtk_built_sources): reordered stamp-gtk.defs
in gtk_built_sources, so gtk.defs gets built prior to all other
sources.
Mon Aug 23 19:11:17 1999 Tim Janik <timj@gtk.org>
* gtk/Makefile.am:
invoke indent on gtkmarshal.*.
rewrote source generation rules, use COPYING as oldest source tag for
a piggyback rule to generate all sources from (don't touch it ;).
major cleanups, strip spaces on build rules for GNU Make.
* gtk/genmarshal.pl: don't operate on hardcoded filenames but take
source and target files from commandline arguments. don't invoke indent.
Sat Aug 21 14:07:36 1999 Lars Hamann <lars@gtk.org>
* gtk/gtknotebook.c (gtk_notebook_real_switch_page): queue_resize
notebook after switch to avoid drawing problems.
(Bug#856 Reported by: Theodore Roth <troth@netmagic.net>)
(gtk_notebook_pages_allocate): don't map not visible tab_labels,
show them instead.
(Bug#1805 Reported by: Dave Cole <dave@dccs.com.au>)
Sat Aug 21 14:07:36 1999 Lars Hamann <lars@gtk.org>
* gtk/gtknotebook.c (gtk_notebook_real_switch_page): queue_resize
notebook after switch to avoid drawing problems.
(Bug#856 Reported by: Theodore Roth <troth@netmagic.net>)
(gtk_notebook_pages_allocate): don't map not visible tab_labels,
show them instead.
(Bug#1805 Reported by: Dave Cole <dave@dccs.com.au>)
Wed Aug 18 09:20:10 1999 Tim Janik <timj@gtk.org>
* gtk/gtkwindow.c:
we use window->need_resize from configure_event now, to indicate that
the gtkwindow should keep its allocation (e.g. because the user resized
the window through window manager handles). resize_count is now reliably
used to figure whether we got the allocation we requested from the
window manager.
configure events get queued as resizes now, the real stuff (size
computation and allocation) now only goes on in gtk_window_move_resize().
GtkWindow's requisition now contains its *real* requisition (like all
other widgets), *not* taking usize into account.
geometry_info->last_{width|height} is now updated from set_hints() only
so it always contains the last hints we set for the window manager.
made some event handlers return TRUE instead of FALSE.
the overall code should be much more straight forward now, and the
significant code portions are accompanied by comments now.
(gtk_window_set_hints):
removed requisition argument and made it
fetch the requisition through gtk_widget_get_child_requisition.
we also don't move the gdkwindow here anymore, gtk_window_move_resize()
does that now.
(gtk_window_show):
ensure that the widget is realized before calling
gtk_container_check_resize() (and thus gtk_window_move_resize()), also
ensure that we got properly size requested and allocated before
realization.
(gtk_window_configure_event):
ignore plain window moves, or reallocate the widget tree through the
resize queue otherwise.
(gtk_window_move_resize):
mostly rewrote this function to figure window manager hints more
reliably, coalesce window moves and resizes to reduce configure events
and do actuall size allocations.
Tue Aug 17 07:43:04 1999 Tim Janik <timj@gtk.org>
* gtk/gtkwidget.c (gtk_widget_event): discard expose events for widgets
that have a resize pending, because a redraw is already queued for them.
* gtk/gtkcontainer.c: removed ugly connect_to ::size_allocate signal
hack to clear resize_widgets.
* gtk/gtkwidget.c (gtk_widget_size_allocate): call clear_resize_widgets
for resize containers prior to size allocation. (this is also a bit
ugly, but avoids side effects for stopped emissions and is thus more
reliable).
(gtk_widget_unparent): removed disconnect call for clear_resize_widgets.
* gtk/gtktooltips.c (gtk_tooltips_paint_window): renamed this
function from gtk_tooltips_expose, as we connect to ::expose_event
*and* ::draw now.
1999-08-18 Federico Mena Quintero <federico@redhat.com>
* gtk/gtkselection.c (gtk_target_list_ref): Added missing sanity
checks.
(gtk_target_list_unref): Likewise.
* gtk/gtkthemes.c (gtk_theme_engine_unref): Likewise.
Tue Aug 17 15:47:07 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcolorsel.c (gtk_color_selection_draw_value_bar):
guard against division by zero. (Fixes bug #1339)
Tue Aug 17 10:56:49 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c (gtk_move_{forward,backward}_word):
Prevent the trivial leak of information of allowing
word motion when the entry is not visible.
Tue Aug 17 10:28:52 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkfilesel.c (gtk_file_selection_fileop_error): Propagate
modality to error dialog as well as confirmation dialogs.
(Bug #1803, reported by Rosanna Wing Sze Yuen)
Wed Aug 11 01:04:57 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtktreeitem.c (gtk_tree_item_draw_lines): Honor
tree->view_lines.
(gtk-guy-990611-3.patch: Guy Harris <guy@netapp.com>)
* gtk/Makefile.am (install-data-local): Solaris apparently
has various troubles with ln -f; use rm first instead.
(gtk-guy-990611-2.patch: Guy Harris <guy@netapp.com>)
1999-07-30 Raja R Harinath <harinath@cs.umn.edu>
* gtk/Makefile.am (stamp-m): Don't `mv' from builddir to srcdir,
use `cp' followed by `rm' (the `rm' was already there).
July 30, 1999 Elliot Lee <sopwith@redhat.com>
* configure.in: Fix autoconf warnings about cross compilation by
trying to provide sane defaults for AC_TRY_RUN.
* gtk/Makefile.am: If we refer to gtkmarshal.[ch] in $(srcdir),
put them into $(srcdir) when generated. Also add a dependency of
gtksignal.h on gtkmarshal.h for -j builds.
* gtk/gtk(dnd,style,gamma).c: Minor warning fixes.
Wed Jul 28 09:29:19 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmain.c (gtk_main_iteration_do): Added missing
GDK_THREADS_{LEAVE,ENTER} pair.
(From Paul Fisher <pnfisher@redhat.com>)
Fri Jul 23 01:00:15 1999 Tim Janik <timj@gtk.org>
* gtk/gtksocket.c (gtk_socket_size_request): asure that the requested
width and height are always >0 (owen).
Fri Jul 23 00:00:47 1999 Tim Janik <timj@gtk.org>
* gtk/gtkwidget.c (gtk_widget_size_allocate): backed out my recent
change that assured that a widget's allocated with and height are
always >1, since this breaks *buggy* panel code. unfortunately this
back-breaks the gimp's color selector.
* gtk/gtkdrawingarea.c (gtk_drawing_area_size_allocate): asure that our
allocation is always >0 in width and height, before sending the
configure event; this is a *gross* hack to get the gimp back to work.
* marked both cases with TODO-1.3
Wed Jul 21 15:47:39 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtktext.c: Don't display wrap indicators when
text is not editable and word wrap is on.
Wed Jul 21 08:21:40 1999 Tim Janik <timj@gtk.org>
* gtk/gtkitemfactory.c (gtk_item_factory_create_item): special case
option menus here as they are not derived from menu shell, assure that
the option menu has a menu we can add items to.
Tue Jul 20 23:29:48 1999 Tim Janik <timj@gtk.org>
* gtk/gtknotebook.c (gtk_notebook_page_allocate): convert allocation->
width/height to (gint) before calculations and check against < 0 to
avoid guint wraparounds.
Sun Jul 18 00:35:49 1999 Tim Janik <timj@gtk.org>
* gtk/gtkwidget.c (gtk_widget_size_allocate): ensure that the allocated
width and height is never zero. sanity check both dimensions against
32767 and issue a warning if the allocation is greater than that.
Wed Jul 7 15:03:30 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmain.c (gtk_events_pending): Unlock around call
to g_main_pending() as well.
Wed Jul 7 14:59:01 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmain.c (gtk_main_iteration): Unlock around
call to g_main_iteration() - since that will regrab
GTK+ lock to process events.
Thu Jul 1 15:01:55 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c
- Regularize with the rest of GTK+ by making widget->requisition
not reflect the set_usize()
- Always recompute geometry hints, then check if they
changed before sending them to the X server. The
previous checks for changes would fail in a number
of circumstances.
Thu Jul 1 11:55:59 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkstyle.c: Include <stdlib.h> for strcmp().
Wed Jun 30 19:26:36 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkdnd.c:
- Code cleanups
- Instantaneously update on modifier key presses
- Allow cancellation of the drag with Escape.
Tue Jun 29 17:04:09 1999 Owen Taylor <otaylor@redhat.com>
* gtk/testgtk.c (create_handle_box): Set the policy
to auto_shrink - otherwise the appearance is rather
strange when flipping between horizontal and vertical.
Mon Jun 28 09:29:52 1999 Tim Janik <timj@gtk.org>
* gtk/gtkwindow.c: add ::default_width and ::default_height arguments.
(gtk_window_set_default_size): don't change a value if it's < 0.
queue a resize.
Sun Jun 27 11:00:33 1999 Tim Janik <timj@gtk.org>
* gtk/gtktext.c (gtk_text_insert): don't segfault on NULL inserts.
Mon Jun 28 12:08:25 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkfilesel.c (cmpl_completion_fullname): Don't
add an extra "/" when concating "/" + filename.
(From Matt Grossman <mattg@oz.net>)
Mon Jun 28 10:57:12 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkctree.c (draw_cell_pixmap): Reset clip mask
for fg_gc if we set it for drawing pixmap.
Tue Jun 15 12:45:12 1999 Owen Taylor <otaylor@redhat.com>
Fixes from Peter Wainwright <prw@wainpr.demon.co.uk>
* gtk/gtkrc.c (gtk_rc_parse_engine): If rc_style->engine is
already set, call old engine's destroy function and
unref the old engine.
Thu Jun 10 17:59:38 1999 Tim Janik <timj@gtk.org>
* gtk/gtkdrawingarea.c (gtk_drawing_area_size): queue a resize.
Wed Jun 9 15:13:16 1999 Tim Janik <timj@gtk.org>
* gtk/gtkaccelgroup.h: mark certain functions as internal.
Wed Jun 9 13:48:28 1999 Tim Janik <timj@gtk.org>
* gtk/gtkpreview.c (gtk_preview_set_expand): queue a resize if the
expand behaviour changed.
* gtk/gtklabel.c (gtk_label_set_pattern):
(gtk_label_set_justify):
(gtk_label_set_line_wrap):
don't bother invoking queue_clear, the reallocation does
that for us, always free_words so the upcoming resize will
relayout the label's contents.
Wed Jun 9 12:50:48 1999 Tim Janik <timj@gtk.org>
* applied argument implementation patches from Elena Devdariani
<elena@cogent.ca>.
* gtk/gtktoolbar.c: ::orientation, ::toolbar_style, ::space_size,
::space_style, ::relief
* gtk/gtkruler.c: ::lower, ::upper, ::position, ::max_size
* gtk/gtkpreview.c: ::expand
* gtk/gtkpaned.c: ::handle_size, ::gutter_size
* gtk/gtknotebook.c: ::homogeneous
* gtk/gtklabel.c: ::wrap
* gtk/gtklist.c: ::selection_mode
* gtk/gtkhandlebox.c: ::handle_position, ::snap_edge
* gtk/gtkcurve.c: ::curve_type, ::min_x, ::max_x, ::min_y, ::max_y
* gtk/gtkcolorsel.c: ::update_policy, ::use_opacity
* gtk/gtkclist.c: ::sort_type
* gtk/gtkcheckmenuitem.c: ::active, ::show_toggle
* gtk/gtkaspectframe.c: ::xalign, ::yalign, ::ratio, ::obey_child
Tue Jun 1 23:38:38 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkstyle.c: Removed ill-thought-out part of last
comment.
Tue Jun 1 23:30:09 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkstyle.c (gtk_style_attach): Get the reference
counting right when we have to attach a new style
for a different visual. (Chi-Deok Hwang <cdhwang@sr.hei.co.kr>)
* gtk/gtkstyle.c: Documented the refcounting
peculularities of gtk_style_attach.
1999-06-01 Tim Janik <timj@dhcpd7.redhat.com>
* gtk/gtkwindow.c (gtk_window_new): added return if fail for invalid
window types.
* examples/packer/pack.c (main): use GTK_WINDOW_TOPLEVEL instead
of GTK_TOPLEVEL for creating the window.
1999-06-01 Tim Janik <timj@dhcpd7.redhat.com>
* gtk/gtkmain.c (gtk_init_check): don't segfault when --gtk-module is
the last argument (reported by Per Winkvist).
Tue May 25 13:13:12 1999 Owen Taylor <otaylor@redhat.com>
Fixes for invisible XOR lines (Frank Loemker
<floemker@TechFak.Uni-Bielefeld.DE>)
* gtk/gtkclist.c (gtk_clist_realize): Always use
a non-zero pixel for GDK_XOR.
* gtk/gtkvpaned.c gtk/gtkhpaned.c:
Use GDK_INVERT instead of GDK_XOR.
Wed May 12 21:56:40 1999 Lars Hamann <lars@gtk.org>
* gtk/gtkclist.c (adjust_adjustments): signal emit value_changed
signals if h/voffsets differ from adjustment values.
Reportet by Jerome Bolliet <bolliet@in2p3.fr>
Mon May 10 04:20:41 1999 Tim Janik <timj@gtk.org>
* gtk/gtkmenushell.c (gtk_menu_shell_activate_item): propagate
::selection-done emissions up to the topmost menu shell.
Fri May 7 10:15:14 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtknotebook.c (gtk_notebook_set_scrollable): Unset
the user data on the window before destroying it.
* gtk/gtknotebook.c (gtk_notebook_unrealize): Add an
unrealize handler to take care of destroying
notebook->panel properly.
(Bug #1198 - Morten Welinder <terra@diku.dk>)
* gtk/gtktext.c (expand_scratch_buffer): Fix reversal
of g_new and g_realloc to stop memory leak. (Actually,
we could just use g_realloc(), but I'm not 100% sure
that is portable).
(Bug #1196 - Morten Welinder <terra@diku.dk>)
Wed Apr 21 00:42:08 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkplug.h: Removed stray GtkPlugButton declaration.
* gdk/gdkfont.c (gdk_text_measure): Fix the return value
for fontsets.
* gtk/gtkbutton.c (gtkbutton_expose): Fix warning
with bin/button confusion.
Thu May 6 04:53:26 1999 Tim Janik <timj@gtk.org>
* gtk/testgtk.c: in the ItemFactory test, link radio items together,
and show how preselection of radio items is done.
Sun May 2 13:31:14 1999 Tim Janik <timj@gtk.org>
* gtk/gtktreeitem.c (gtk_tree_item_set_subtree):
* gtk/gtktree.c (gtk_tree_add) (gtk_tree_insert):
* gtk/gtktoolbar.c (gtk_toolbar_insert_element):
* gtk/gtkpaned.c (gtk_paned_pack2) (gtk_paned_pack1):
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_add):
* gtk/gtktable.c (gtk_table_attach):
* gtk/gtklist.c (gtk_list_insert_items):
* gtk/gtkmenushell.c (gtk_menu_shell_insert):
* gtk/gtknotebook.c (gtk_notebook_insert_page_menu):
* gtk/gtkpacker.c (gtk_packer_add_defaults) (gtk_packer_add):
* gtk/gtkbin.c (gtk_bin_add):
* gtk/gtkbox.c (gtk_box_pack_start) (gtk_box_pack_end):
* gtk/gtkfixed.c (gtk_fixed_put):
* gtk/gtklayout.c (gtk_layout_put):
general fixups to container_add logic. always realize child if
child->parent is realized, only map the child and queue a resize
if child and child->parent are both visible.
Fri Apr 30 09:02:28 1999 Tim Janik <timj@gtk.org>
* gtk/gtkwidget.c (gtk_widget_real_unrealize): use gtk_container_forall
instead of gtk_container_foreach to walk and unrealize children, so
composite children get also unrealized.
(gtk_widget_real_show): don't call gtk_widget_map() if we don't need to.
(gtk_widget_map): assert that the widget is visible (basic constrain).
(gtk_widget_real_map): assert that the widget is realized (basic
constrain).
Fri Apr 29 00:53:20 1999 Tim Janik <timj@gtk.org>
* gtk/gtkbindings.c (gtk_pattern_spec_init): plugged a memory leak.
Tue May 4 09:32:08 1999 Owen Taylor <otaylor@redhat.com>
* gtk/Makefile.am gtk/gtkrc.iso-8859-2: Add a gtkrc
file for iso-8859-2 locales.
* configure.in (ALL_LINGUAS): ALL_LINGUAS update.
Tue Apr 27 16:38:32 1999 Owen Taylor <otaylor@redhat.com>
* gtk/Makefile.am: Fix typo of static_sources for static_SOURCES.
(Pointed out by andy@rz.uni-karlsruhe.de and others).
Remove some suspicious and useless lines.
Tue May 4 08:44:08 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkclist.c (gtk_clist_draw, draw_rows): Use
width,height = 0, 0 to mean - here to edge of window,
instead of -1, -1, since the former is all we support.
Tue May 4 08:34:43 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmain.c (gtk_main): Correctly free list nodes
when removing from quit_functions list.
Tue Apr 27 14:17:16 1999 Tim Janik <timj@gtk.org>
* gtk/gtkpacker.c (gtk_packer_size_request): remove unused variable.
Tue Apr 27 18:23:35 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c (gtk_entry_draw_cursor_on_drawable):
When redrawing characters on non-visible entry, use appropriate
'*' character. (Bug #1130 - Jean-Marc Jacquet <jm@littleigloo.org>)
Tue Apr 27 01:31:40 1999 Lars Hamann <lars@gtk.org>
* gtk/gtkclist.c (drag_dest_cell): compute destination cell
from drag coordinates.
(gtk_clist_drag_data_received) (gtk_clist_drag_motion):
use drag_dest_cell.
* gtk/gtktree (drag_dest_cell)
(gtk_ctree_drag_data_received) (gtk_ctree_drag_motion): likewise.
(Bug #1129)
Wed Apr 21 21:26:11 1999 Tim Janik <timj@gtk.org>
* gtk/gtkitemfactory.c (gtk_item_factory_init): properly initialize
translate_* fields.
(gtk_item_factory_finalize): invoke translate_notify independant from
translate_data.
(gtk_item_factory_set_translate_func): likewise.
(gtk_item_factory_destroy): only remove ifactory pointer from those
widgets that belong to us (stupid me).
Mon Apr 19 12:05:31 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrc.c (gtk_rc_style_init): Fixed leak of
rc_style list when lookup succeeeds.
Thu Apr 15 01:11:24 1999 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (resync_selection):
* gtk/gtkclist.c (resync_selection): fixed undo_selection bug.
* gtk/gtkclist.c (gtk_clist_button_release): fixed resync_selection
bug.
Fri Apr 9 19:22:19 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcolorsel.c gtk/gtkdnd.c gtk/gtkmenuitem.c:
Add some missing GDK_THREADS_ENTER()/LEAVE around
timeouts. (Patches from Sebastian Wilhelmi <wilhelmi@ira.uka.de>)
Thu Apr 8 20:10:33 1999 Tim Janik <timj@gtk.org>
* gtk/gtkentry.c (gtk_entry_key_press): use gtk_widget_activate()
rather than emit_by_name.
* gtk/gtkeditable.c (gtk_editable_insert_text): keep a reference
on the widget across multiple signal emissions.
(gtk_editable_delete_text): same here.
(gtk_editable_class_init): set widget_class->activate_signal after
editable_signals[ACTIVATE] has been created.
Wed Apr 7 22:59:47 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkpaned.c (gtk_paned_set_position): Don't clamp
position here prematurely -- we might not have the
right ->min_position and ->max_position yet.
Tue Apr 6 16:38:51 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkselection.c gdk/gdkselection.c: (gtk_selection_request):
Add error traps so if the other end of the connection
dies, we survive.
* gtk/gtkselection.c (gtk_selection_notify): Clean
up properly when selection property retrieval fails.
* gtk/gtkselection.c (gtk_selection_request): Correctly
reject SelectionRequest notifies where the handler
returns no data.
Tue Apr 6 12:24:21 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkdnd.c (gtk_drag_dest_leave): Only unhighlight
when we've previously highlighted.
* gtk/gtkdnd.c (gtk_drag_dest_handle_event): Don't
emit two "drag_leave" signals for Motif drops.
* gtk/gtkdnd.c (gtk_drag_source_handle_event): Send
back the correct status messages when dropping from
Motif onto a proxy window that is rejecting the
drop.
Sat Mar 27 23:32:13 1999 Tim Janik <timj@gtk.org>
* gtk/gtkarg.[hc]: added functions from GLE, gtk_arg_reset() to free
the value and reset type to GTK_TYPE_INVALID, and gtk_arg_values_equal()
to compare two argument values. added gtk_arg_to_valueloc() to set a
variable from an arg through its location (pointer).
* gtk/gtkobject.[hc]: implemented gtk_object_get() in terms of
gtk_object_arg_get() and gtk_arg_to_valueloc(), floats are collected
as gfloat*, uchars are collected as guchar*, ints are collected as
gint*, etc...
Mon Mar 29 17:45:47 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkaccelgroup.c gtk/gtkgtkbindings.c:
Include <string.h> instead of <strings.h>.
* gtk/gtkstyle.c: Fix double include of gtkthemes.h
(actually, a lot more duplicate includes occur if
you trace through the sequence of #include's)
gtk-jbb-990320-0: John Bley, jbb6@acpub.duke.edu
Mon Mar 29 17:02:58 1999 Owen Taylor <otaylor@redhat.com>
Patches from Akira Higuchi <a-higuti@math.sci.hokudai.ac.jp>
gtk-a-higuti-990322-[0-3]
* configure.in: Fix confusion between GTK_LOCALE_[C]FLAGS
that was causing -DX_LOCALE not to work.
* gtk/gtkrc.c (gtk_rc_init):
X_LOCALE will never have LC_MESSAGES defined
Thu Mar 25 12:38:31 1999 Tim Janik <timj@gtk.org>
* gtk/gtkrc.c (gtk_rc_append_default_module_path): get $HOME from
g_get_home_dir() (gtk-pmc-990123-0.patch.gz).
* gtk/gtkwindow.c (gtk_window_key_press_event): feature keypad up/down/
left/right as well (gtk-michael-980726-0.patch.gz).
* gtk/gtklabel.[hc]: bunch of miscellaneous cleanups, such as s/0/NULL/
for pointer values, use gchar instead of char. fixed uline allocation
leaks, changed the allocation pattern so we use G_ALLOC_AND_FREE mem
chunks instead of G_ALLOC_ONLY.
(gtk_label_size_request): always alter requisition as passed and leave
widget->requisition alone.
(gtk_label_set_text): allow NULL strings.
(gtk_label_new): likewise.
Wed Mar 24 09:24:03 1999 Tim Janik <timj@gtk.org>
* gtk/gtkdrawingarea.[hc]: type/macro fixups.
Mon Mar 22 05:51:34 1999 Tim Janik <timj@gtk.org>
* gtk/gtkbin.c (gtk_bin_draw): only redraw children that are visible
*and* mapped (i.e. drawable).
(gtk_bin_expose): only send exposes to drawable children.
* gtk/gtkbox.c (gtk_box_draw): only redraw children that are drawable.
(gtk_box_expose): only send exposes to drawable children.
* gtk/gtkhscale.c (gtk_hscale_draw):
* gtk/gtkvscale.c (gtk_vscale_draw):
hm, this is an ugly one. we first compute the size of our trough area
here (window relative) and then check intersection with the draw_area
which is parent relative because we're a NO_WINDOW widget, so we need
to offset the trough area by allocation.x and allocation.y before the
check. (this must not be done for the background area though, since
that's already computed parent relative).
Mon Mar 22 00:41:39 1999 Lars Hamann <lars@gtk.org>
* gtk/gtkclist.c (gtk_clist_unrealize): unmap clist if neccessary,
unrealize title buttons.
Fri Mar 19 00:00:22 1999 Lars Hamann <lars@gtk.org>
* gtk/gtkclist.c (gtk_clist_column_title_passive)
(gtk_clist_column_title_active):
only connect/disconnect to GtkWidgetClass::event to block mouse events.
* gtk/gtkclist.c (vertical_timeout) (horizontal_timeout):
zero initialize event, removed superfluous gdk_window_get_pointer call
* gtk/gtklist.c (gtk_list_vertical_timeout)
(gtk_list_horizontal_timeout): removed superfluous
gdk_window_get_pointer call
Wed Mar 17 09:00:00 1999 Tim Janik <timj@gtk.org>
* plugging problems reported by "Bruce Mitchener, Jr."
<bruce@puremagic.com> due to a purify session.
* gtk/gtkstyle.c:
(gtk_style_ref):
(gtk_style_unref): assert ref_count to be > 0.
* gtk/gtkclist.c (gtk_clist_set_cell_style): { 0 } initilaize
the requisition.
(gtk_clist_set_shift): likewise.
* gtk/gtklayout.c: introduce gtk_layout_finalize() to unref the
adjustments.
* gtk/gtklist.c (gtk_list_horizontal_timeout): zero initialize the
event before sending it and set send_event to TRUE (which needs to
be done for *all* synthesized events).
(gtk_list_vertical_timeout): likewise.
* gtk/gtktipsquery.c (gtk_tips_query_destroy): plug small memory
leaks.
* gtk/gtkdrawingarea.c (gtk_drawing_area_send_configure): set send_event
to TRUE when synthesizing events.
[ *** end of merges from 1.2 *** ]
1999-11-22 21:52:50 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
add_move_binding (widget_class, GDK_KEY_Right, GDK_CONTROL_MASK,
|
|
|
|
|
GTK_MOVEMENT_WORDS, 1);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
add_move_binding (widget_class, GDK_KEY_Left, GDK_CONTROL_MASK,
|
|
|
|
|
GTK_MOVEMENT_WORDS, -1);
|
2001-06-24 15:34:48 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
add_move_binding (widget_class, GDK_KEY_KP_Right, GDK_CONTROL_MASK,
|
|
|
|
|
GTK_MOVEMENT_WORDS, 1);
|
2001-06-24 15:34:48 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
add_move_binding (widget_class, GDK_KEY_KP_Left, GDK_CONTROL_MASK,
|
|
|
|
|
GTK_MOVEMENT_WORDS, -1);
|
2010-06-24 02:36:08 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/* select all */
|
|
|
|
|
gtk_widget_class_add_binding (widget_class,
|
|
|
|
|
GDK_KEY_a, GDK_CONTROL_MASK,
|
|
|
|
|
(GtkShortcutFunc) gtk_label_select_all,
|
|
|
|
|
NULL);
|
|
|
|
|
gtk_widget_class_add_binding (widget_class,
|
|
|
|
|
GDK_KEY_slash, GDK_CONTROL_MASK,
|
|
|
|
|
(GtkShortcutFunc) gtk_label_select_all,
|
|
|
|
|
NULL);
|
2004-07-22 05:06:39 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/* unselect all */
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_a, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
|
|
|
|
|
"move-cursor",
|
|
|
|
|
"(iib)", GTK_MOVEMENT_PARAGRAPH_ENDS, 0, FALSE);
|
2015-09-05 07:58:50 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_backslash, GDK_CONTROL_MASK,
|
|
|
|
|
"move-cursor",
|
|
|
|
|
"(iib)", GTK_MOVEMENT_PARAGRAPH_ENDS, 0, FALSE);
|
|
|
|
|
|
|
|
|
|
add_move_binding (widget_class, GDK_KEY_f, GDK_ALT_MASK,
|
|
|
|
|
GTK_MOVEMENT_WORDS, 1);
|
2004-07-22 05:06:39 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
add_move_binding (widget_class, GDK_KEY_b, GDK_ALT_MASK,
|
|
|
|
|
GTK_MOVEMENT_WORDS, -1);
|
2017-09-30 16:48:11 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
add_move_binding (widget_class, GDK_KEY_Home, 0,
|
|
|
|
|
GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1);
|
2004-07-22 05:06:39 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
add_move_binding (widget_class, GDK_KEY_End, 0,
|
|
|
|
|
GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1);
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
add_move_binding (widget_class, GDK_KEY_KP_Home, 0,
|
|
|
|
|
GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1);
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
add_move_binding (widget_class, GDK_KEY_KP_End, 0,
|
|
|
|
|
GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1);
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
add_move_binding (widget_class, GDK_KEY_Home, GDK_CONTROL_MASK,
|
|
|
|
|
GTK_MOVEMENT_BUFFER_ENDS, -1);
|
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv>
Rework of GtkFileChooserButton, some cleanups. Fixes #154388,
#154390, #154390, #156272.
* docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton
below GtkFileChooser.
* docs/reference/gtk/gtk-sections.txt: Added
gtk_file_chooser_button_get_width_chars(),
gtk_file_chooser_button_set_width_chars(),
gtk_label_set_width_chars(), gtk_label_get_width_chars().
* docs/reference/gtk/gtk.types: Added
gtk_cell_renderer_combo_get_type,
gtk_cell_view_get_type,
gtk_text_iter_get_type.
* docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add
"logo-icon-name" property.
* docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for
properties
(b/c of get_type() inclusion above).
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml:
* docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars"
property,
getters/setters.
* docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added.
* gtk/gtkentrycompletion.c:
(_gtk_entry_completion_popdown): Don't show if the entry isn't
mapped.
* gtk/gtkfilechooserbutton.[c,h]: (*): About 45%
rewritten, adds "width-chars" property, icons, working save
modes, volume/Home/Desktop friendly-naming support.
* gtk/gtklabel.[c,h]:
(gtk_label_class_init), (gtk_label_init),
(gtk_label_get_property), (gtk_label_set_property),
(gtk_label_get_width_chars), (gtk_label_set_width_chars),
(gtk_label_size_request): Add "width-chars" property.
* tests/testfilechooserbutton.c: Update, use 4 different buttons
for the different ACTIONs.
* gtk/.cvsignore: Ignore gtk-update-icon-cache.
* tests/.cvsignore: Ignore testimage.
2004-10-26 04:29:56 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
add_move_binding (widget_class, GDK_KEY_End, GDK_CONTROL_MASK,
|
|
|
|
|
GTK_MOVEMENT_BUFFER_ENDS, 1);
|
2004-12-13 06:34:54 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
add_move_binding (widget_class, GDK_KEY_KP_Home, GDK_CONTROL_MASK,
|
|
|
|
|
GTK_MOVEMENT_BUFFER_ENDS, -1);
|
2004-12-13 06:34:54 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
add_move_binding (widget_class, GDK_KEY_KP_End, GDK_CONTROL_MASK,
|
|
|
|
|
GTK_MOVEMENT_BUFFER_ENDS, 1);
|
2004-12-13 06:34:54 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/* copy */
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_c, GDK_CONTROL_MASK,
|
|
|
|
|
"copy-clipboard",
|
|
|
|
|
NULL);
|
2004-12-13 06:34:54 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_Return, 0,
|
|
|
|
|
"activate-current-link",
|
|
|
|
|
NULL);
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_ISO_Enter, 0,
|
|
|
|
|
"activate-current-link",
|
|
|
|
|
NULL);
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_KP_Enter, 0,
|
|
|
|
|
"activate-current-link",
|
|
|
|
|
NULL);
|
2004-12-13 06:34:54 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_widget_class_set_css_name (widget_class, I_("label"));
|
|
|
|
|
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_LABEL);
|
2010-06-24 02:36:08 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
quark_mnemonics_visible_connected = g_quark_from_static_string ("gtk-label-mnemonics-visible-connected");
|
2010-06-24 02:36:08 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkLabel|clipboard.cut:
|
|
|
|
|
*
|
|
|
|
|
* Doesn't do anything, since text in labels can't be deleted.
|
|
|
|
|
*/
|
|
|
|
|
gtk_widget_class_install_action (widget_class, "clipboard.cut", NULL,
|
|
|
|
|
gtk_label_nop);
|
2007-01-07 00:52:26 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkLabel|clipboard.copy:
|
|
|
|
|
*
|
|
|
|
|
* Copies the text to the clipboard.
|
|
|
|
|
*/
|
|
|
|
|
gtk_widget_class_install_action (widget_class, "clipboard.copy", NULL,
|
|
|
|
|
gtk_label_activate_clipboard_copy);
|
1998-12-15 20:31:26 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkLabel|clipboard.paste:
|
|
|
|
|
*
|
|
|
|
|
* Doesn't do anything, since text in labels can't be edited.
|
|
|
|
|
*/
|
|
|
|
|
gtk_widget_class_install_action (widget_class, "clipboard.paste", NULL,
|
|
|
|
|
gtk_label_nop);
|
2017-09-30 16:48:11 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkLabel|selection.delete:
|
|
|
|
|
*
|
|
|
|
|
* Doesn't do anything, since text in labels can't be deleted.
|
|
|
|
|
*/
|
|
|
|
|
gtk_widget_class_install_action (widget_class, "selection.delete", NULL,
|
|
|
|
|
gtk_label_nop);
|
2001-06-24 15:34:48 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkLabel|selection.select-all:
|
|
|
|
|
*
|
|
|
|
|
* Selects all of the text, if the label allows selection.
|
|
|
|
|
*/
|
|
|
|
|
gtk_widget_class_install_action (widget_class, "selection.select-all", NULL,
|
|
|
|
|
gtk_label_activate_selection_select_all);
|
2010-06-24 02:36:08 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkLabel|link.open:
|
|
|
|
|
*
|
|
|
|
|
* Opens the link, when activated on a link inside the label.
|
|
|
|
|
*/
|
|
|
|
|
gtk_widget_class_install_action (widget_class, "link.open", NULL,
|
|
|
|
|
gtk_label_activate_link_open);
|
2015-09-05 07:58:50 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkLabel|link.copy:
|
|
|
|
|
*
|
|
|
|
|
* Copies the link to the clipboard, when activated on a link
|
|
|
|
|
* inside the label.
|
|
|
|
|
*/
|
|
|
|
|
gtk_widget_class_install_action (widget_class, "link.copy", NULL,
|
|
|
|
|
gtk_label_activate_link_copy);
|
2006-06-19 14:27:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-12-25 11:05:28 +00:00
|
|
|
|
* gtk_label_new:
|
|
|
|
|
* @str: (nullable): The text of the label
|
2006-06-19 14:27:50 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Creates a new label with the given text inside it.
|
2006-06-19 14:27:50 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* You can pass %NULL to get an empty label widget.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the new `GtkLabel`
|
2020-12-25 11:05:28 +00:00
|
|
|
|
**/
|
|
|
|
|
GtkWidget*
|
|
|
|
|
gtk_label_new (const char *str)
|
2006-06-19 14:27:50 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
GtkLabel *self;
|
2006-06-19 14:27:50 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
self = g_object_new (GTK_TYPE_LABEL, NULL);
|
2001-03-22 13:44:00 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (str && *str)
|
|
|
|
|
gtk_label_set_text (self, str);
|
2001-03-22 13:44:00 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return GTK_WIDGET (self);
|
2001-03-22 13:44:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_label_new_with_mnemonic:
|
|
|
|
|
* @str: (nullable): The text of the label, with an underscore in front of the
|
2021-05-18 21:05:26 +00:00
|
|
|
|
* mnemonic character
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Creates a new `GtkLabel`, containing the text in @str.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
|
|
|
|
* If characters in @str are preceded by an underscore, they are
|
|
|
|
|
* underlined. If you need a literal underscore character in a label, use
|
|
|
|
|
* '__' (two underscores). The first underlined character represents a
|
|
|
|
|
* keyboard accelerator called a mnemonic. The mnemonic key can be used
|
|
|
|
|
* to activate another widget, chosen automatically, or explicitly using
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* [method@Gtk.Label.set_mnemonic_widget].
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* If [method@Gtk.Label.set_mnemonic_widget] is not called, then the first
|
|
|
|
|
* activatable ancestor of the `GtkLabel` will be chosen as the mnemonic
|
2020-12-25 11:05:28 +00:00
|
|
|
|
* widget. For instance, if the label is inside a button or menu item,
|
|
|
|
|
* the button or menu item will automatically become the mnemonic widget
|
|
|
|
|
* and be activated by the mnemonic.
|
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Returns: the new `GtkLabel`
|
2020-12-25 11:05:28 +00:00
|
|
|
|
**/
|
|
|
|
|
GtkWidget*
|
|
|
|
|
gtk_label_new_with_mnemonic (const char *str)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
GtkLabel *self;
|
2015-11-20 15:06:10 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
self = g_object_new (GTK_TYPE_LABEL, NULL);
|
2001-03-21 18:58:28 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (str && *str)
|
|
|
|
|
gtk_label_set_text_with_mnemonic (self, str);
|
2019-01-27 21:43:54 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return GTK_WIDGET (self);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:07:08 +00:00
|
|
|
|
static void
|
|
|
|
|
_gtk_label_mnemonics_visible_apply_recursively (GtkWidget *widget,
|
|
|
|
|
gboolean visible)
|
|
|
|
|
{
|
|
|
|
|
if (GTK_IS_LABEL (widget))
|
|
|
|
|
{
|
|
|
|
|
GtkLabel *self = GTK_LABEL (widget);
|
|
|
|
|
|
|
|
|
|
if (self->mnemonics_visible != visible)
|
|
|
|
|
{
|
|
|
|
|
self->mnemonics_visible = visible;
|
|
|
|
|
gtk_label_recalculate (self);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *child;
|
|
|
|
|
|
|
|
|
|
for (child = gtk_widget_get_first_child (widget);
|
|
|
|
|
child;
|
|
|
|
|
child = gtk_widget_get_next_sibling (child))
|
|
|
|
|
{
|
|
|
|
|
if (GTK_IS_NATIVE (child))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
_gtk_label_mnemonics_visible_apply_recursively (child, visible);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
|
static void
|
2020-12-25 11:05:28 +00:00
|
|
|
|
label_mnemonics_visible_changed (GtkWidget *widget,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
gpointer data)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gboolean visible;
|
|
|
|
|
|
|
|
|
|
g_object_get (widget, "mnemonics-visible", &visible, NULL);
|
|
|
|
|
_gtk_label_mnemonics_visible_apply_recursively (widget, visible);
|
2001-02-17 00:11:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_setup_mnemonic (GtkLabel *self)
|
2011-03-29 00:27:26 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
GtkWidget *widget = GTK_WIDGET (self);
|
|
|
|
|
GtkShortcut *shortcut;
|
|
|
|
|
GtkNative *native;
|
|
|
|
|
gboolean connected;
|
|
|
|
|
gboolean mnemonics_visible;
|
2011-03-29 00:27:26 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (self->mnemonic_keyval == GDK_KEY_VoidSymbol)
|
2011-03-29 00:27:26 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (self->mnemonic_controller)
|
2011-03-29 00:27:26 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_widget_remove_controller (widget, self->mnemonic_controller);
|
|
|
|
|
self->mnemonic_controller = NULL;
|
2011-03-29 00:27:26 +00:00
|
|
|
|
}
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2011-03-29 00:27:26 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (self->mnemonic_controller == NULL)
|
|
|
|
|
{
|
|
|
|
|
self->mnemonic_controller = gtk_shortcut_controller_new ();
|
|
|
|
|
gtk_event_controller_set_propagation_phase (self->mnemonic_controller, GTK_PHASE_CAPTURE);
|
|
|
|
|
gtk_shortcut_controller_set_scope (GTK_SHORTCUT_CONTROLLER (self->mnemonic_controller), GTK_SHORTCUT_SCOPE_MANAGED);
|
|
|
|
|
shortcut = gtk_shortcut_new (gtk_mnemonic_trigger_new (self->mnemonic_keyval),
|
|
|
|
|
g_object_ref (gtk_mnemonic_action_get ()));
|
|
|
|
|
gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (self->mnemonic_controller), shortcut);
|
|
|
|
|
gtk_widget_add_controller (GTK_WIDGET (self), self->mnemonic_controller);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
shortcut = g_list_model_get_item (G_LIST_MODEL (self->mnemonic_controller), 0);
|
|
|
|
|
gtk_shortcut_set_trigger (shortcut, gtk_mnemonic_trigger_new (self->mnemonic_keyval));
|
|
|
|
|
g_object_unref (shortcut);
|
2011-03-29 00:27:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/* Connect to notify::mnemonics-visible of the root */
|
|
|
|
|
native = gtk_widget_get_native (GTK_WIDGET (self));
|
|
|
|
|
if (!GTK_IS_WINDOW (native) && !GTK_IS_POPOVER (native))
|
|
|
|
|
return;
|
2011-03-29 00:27:26 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/* always set up this widgets initial value */
|
|
|
|
|
g_object_get (native, "mnemonics-visible", &mnemonics_visible, NULL);
|
|
|
|
|
self->mnemonics_visible = mnemonics_visible;
|
|
|
|
|
|
|
|
|
|
connected = GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (native),
|
|
|
|
|
quark_mnemonics_visible_connected));
|
|
|
|
|
|
|
|
|
|
if (!connected)
|
2011-03-29 00:27:26 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_signal_connect (native,
|
|
|
|
|
"notify::mnemonics-visible",
|
|
|
|
|
G_CALLBACK (label_mnemonics_visible_changed),
|
|
|
|
|
self);
|
|
|
|
|
g_object_set_qdata (G_OBJECT (native),
|
|
|
|
|
quark_mnemonics_visible_connected,
|
|
|
|
|
GINT_TO_POINTER (1));
|
2011-03-29 00:27:26 +00:00
|
|
|
|
}
|
2020-12-25 11:05:28 +00:00
|
|
|
|
}
|
2011-03-29 00:27:26 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
label_mnemonic_widget_weak_notify (gpointer data,
|
|
|
|
|
GObject *where_the_object_was)
|
|
|
|
|
{
|
|
|
|
|
GtkLabel *self = data;
|
2011-03-29 01:16:34 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
self->mnemonic_widget = NULL;
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), label_props[PROP_MNEMONIC_WIDGET]);
|
2011-03-29 00:27:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_set_mnemonic_widget: (attributes org.gtk.Method.set_property=mnemonic-widget)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* @widget: (nullable): the target `GtkWidget`, or %NULL to unset
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Associate the label with its mnemonic target.
|
|
|
|
|
*
|
2020-12-25 11:05:28 +00:00
|
|
|
|
* If the label has been set so that it has a mnemonic key (using
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* i.e. [method@Gtk.Label.set_markup_with_mnemonic],
|
|
|
|
|
* [method@Gtk.Label.set_text_with_mnemonic],
|
|
|
|
|
* [ctor@Gtk.Label.new_with_mnemonic]
|
|
|
|
|
* or the [property@Gtk.Label:use_underline] property) the label can be
|
|
|
|
|
* associated with a widget that is the target of the mnemonic. When the
|
|
|
|
|
* label is inside a widget (like a [class@Gtk.Button] or a
|
|
|
|
|
* [class@Gtk.Notebook] tab) it is automatically associated with the correct
|
|
|
|
|
* widget, but sometimes (i.e. when the target is a [class@Gtk.Entry] next to
|
|
|
|
|
* the label) you need to set it explicitly using this function.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
|
|
|
|
* The target widget will be accelerated by emitting the
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* [signal@GtkWidget::mnemonic-activate] signal on it. The default handler for
|
2020-12-25 11:05:28 +00:00
|
|
|
|
* this signal will activate the widget if there are no mnemonic collisions
|
|
|
|
|
* and toggle focus between the colliding widgets otherwise.
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_label_set_mnemonic_widget (GtkLabel *self,
|
|
|
|
|
GtkWidget *widget)
|
2014-02-05 02:17:48 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
2014-02-05 02:17:48 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (widget)
|
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
|
|
|
|
|
|
|
|
|
if (self->mnemonic_widget)
|
2020-04-17 15:08:04 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_widget_remove_mnemonic_label (self->mnemonic_widget, GTK_WIDGET (self));
|
|
|
|
|
g_object_weak_unref (G_OBJECT (self->mnemonic_widget),
|
|
|
|
|
label_mnemonic_widget_weak_notify,
|
|
|
|
|
self);
|
2020-04-17 15:08:04 +00:00
|
|
|
|
}
|
2020-12-25 11:05:28 +00:00
|
|
|
|
self->mnemonic_widget = widget;
|
|
|
|
|
if (self->mnemonic_widget)
|
2014-02-05 02:17:48 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_object_weak_ref (G_OBJECT (self->mnemonic_widget),
|
|
|
|
|
label_mnemonic_widget_weak_notify,
|
|
|
|
|
self);
|
|
|
|
|
gtk_widget_add_mnemonic_label (self->mnemonic_widget, GTK_WIDGET (self));
|
|
|
|
|
}
|
2017-01-06 00:48:51 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), label_props[PROP_MNEMONIC_WIDGET]);
|
|
|
|
|
}
|
2020-04-12 07:07:57 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_get_mnemonic_widget: (attributes org.gtk.Method.get_property=mnemonic-widget)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
|
|
|
|
* Retrieves the target of the mnemonic (keyboard shortcut) of this
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* label.
|
|
|
|
|
*
|
|
|
|
|
* See [method@Gtk.Label.set_mnemonic_widget].
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: (nullable) (transfer none): the target of the label’s mnemonic,
|
2021-05-18 21:05:26 +00:00
|
|
|
|
* or %NULL if none has been set and the default algorithm will be used.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
**/
|
|
|
|
|
GtkWidget *
|
|
|
|
|
gtk_label_get_mnemonic_widget (GtkLabel *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_LABEL (self), NULL);
|
2020-04-12 07:07:57 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return self->mnemonic_widget;
|
|
|
|
|
}
|
2014-02-05 02:17:48 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_get_mnemonic_keyval: (attributes org.gtk.Method.get_property=mnemonic-keyval)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
|
|
|
|
*
|
|
|
|
|
* Return the mnemonic accelerator.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
|
|
|
|
* If the label has been set so that it has a mnemonic key this function
|
|
|
|
|
* returns the keyval used for the mnemonic accelerator. If there is no
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* mnemonic set up it returns `GDK_KEY_VoidSymbol`.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Returns: GDK keyval usable for accelerators, or `GDK_KEY_VoidSymbol`
|
2020-12-25 11:05:28 +00:00
|
|
|
|
**/
|
|
|
|
|
guint
|
|
|
|
|
gtk_label_get_mnemonic_keyval (GtkLabel *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_LABEL (self), GDK_KEY_VoidSymbol);
|
2020-04-14 08:53:48 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return self->mnemonic_keyval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_label_set_text_internal (GtkLabel *self,
|
|
|
|
|
char *str)
|
|
|
|
|
{
|
|
|
|
|
if (g_strcmp0 (self->text, str) == 0)
|
2020-04-12 07:22:38 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_free (str);
|
|
|
|
|
return;
|
2020-04-12 07:22:38 +00:00
|
|
|
|
}
|
2015-07-04 17:56:40 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_free (self->text);
|
|
|
|
|
self->text = str;
|
2014-02-05 02:17:48 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_accessible_update_property (GTK_ACCESSIBLE (self),
|
|
|
|
|
GTK_ACCESSIBLE_PROPERTY_LABEL, self->text,
|
|
|
|
|
-1);
|
2014-02-05 02:17:48 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_label_select_region_index (self, 0, 0);
|
2014-02-05 02:17:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_label_set_label_internal (GtkLabel *self,
|
|
|
|
|
const char *str)
|
2001-02-17 00:11:03 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (g_strcmp0 (str, self->label) == 0)
|
|
|
|
|
return FALSE;
|
2001-02-17 00:11:03 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_free (self->label);
|
|
|
|
|
self->label = g_strdup (str ? str : "");
|
2004-11-21 16:24:01 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), label_props[PROP_LABEL]);
|
2000-07-02 22:30:54 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_label_set_use_markup_internal (GtkLabel *self,
|
|
|
|
|
gboolean val)
|
|
|
|
|
{
|
|
|
|
|
if (self->use_markup != val)
|
2018-02-28 14:27:48 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
self->use_markup = val;
|
Remove all references to offscreen flag which was no longer used.
Thu Jun 1 23:05:13 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c: Remove all references to
offscreen flag which was no longer used.
* gtk/gtkprivate.h (enum): Remove unused flags and compress.
* gtk/gtkframe.c (gtk_frame_set_label_widget): Check
for non-null label_widget->parent.
* gtk/gtkentry.c: Get rid of code to deal with PangoAttribute
which no longer was used.
* gdk/gdkpango.c (gdk_pango_context_get_info): make static.
* gdk/gdkpango.c (gdk_draw_layout[_line]): Add checks
for null arguments.
* gdk/x11/gdkgeometry-x11.c (gdk_window_scroll): add
check for destroyed windows.
Thu Jun 1 13:48:45 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimmulticontext.c: Add a finalize method and unref
the slave context there.
* gtk/gtkinvisible.[ch]: Make reference counting behavior
identical to GtkWindow.
Thu Jun 1 01:54:11 2000 Owen Taylor <otaylor@redhat.com>
* Makefile.am gdk/gdkpango.c: Copy the layout render function from
pangox to here, so we can write them independent of rendering
system, using GDK primitives.
* gdk/gdkdrawable.h gdk/gdkdraw.c gdk/gdkwindow.c
gdk/x11/gdkdrawable-x11.c: Remove draw_layout() from the vtable,
since we have a rendering-system independent implementation in
terms of draw_glyphs().
* gdk/gdkpango.c gdkdrawable.h (gdk_draw_layout_line): New
function to render a single line.
* gdk/x11/gdkpango.c: Move the guts of this file mostly
into ../gdkpango.c, which simplifies things, since we
don't have to deal with raw X gc's.
Fri May 19 04:28:16 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextlayout.[ch]: Add get_log_attrs() function to
get the logical attributes for a given GtkTextLine.
Tue May 30 16:05:39 2000 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkfont-x11.c (gdk_font_charset_for_locale): Track
g_locale_get_codeset() to g_get_codeset() change.
Tue May 30 15:03:19 2000 Owen Taylor <otaylor@redhat.com>
* gtk/testcalendar.c (calendar_font_selection_ok): Use font
descriptions.
* gtk/gtkentry.c (gtk_entry_draw_text): Center text within
the entry.
* gtk/gtkfontsel.c (gtk_font_selection_dialog_init): Start of
redoing (vastly simplifying) for Pango. Still needs quite
a bit of work. (Size selection is currently poor. List of
predefined sizes is not a good idea, since all of these
sizes won't necessarily be distinct.)
Tue May 30 13:50:19 2000 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkfont-x11.c (gdk_font_charset_for_locale): Handle
CODESET results for LANG=C.
Mon May 29 15:49:10 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrc.[ch]: Add a 'font_name' declaration to RC
which takes a stringized pango font description;
ignore the older 'font' and 'fontset' declarations.
* gtk/gtkstyle.c gtk/gtkrc.c: Fill in the style->font
field with a GdkFont derived via gdk_font_from_description(),
for compatibility. (Should we just remove it entirely?
Probably too much compatibility breakage, but people
should be migrating to the new Pango stuff as quickly
as possible.)
Mon May 29 15:47:41 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c gtk/gtkclist.c: s/pango_font_unref/g_object_unref/.
Mon May 29 15:44:46 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcalender.c: Roughly pango-ized. Really needs
redoing; there are some bugs in size allocation right
now, the semi-existant distinction between header / day
fonts was removed, but, with Pango, could actually
be made functional in a nice way.
* gtk/testcalender: Move calender from examples into this
directory as a test program. (We really need to restrcture
testgtk into a whole directory full of tests for every
widget or functionality group, separated into multiple .c
files.)
Mon May 29 15:19:56 2000 Owen Taylor <otaylor@redhat.com>
* gtk/testgtk.c (file_exists): Fix stupid typo that
was keeping RC file from being loaded.
* gtk/testgtkrc gtk/testgtkrc2: Test new pango-ized
RC file font code.
Mon May 29 14:31:27 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdkfont.h gdk/x11/gdkfont-x11.c (gdk_font_from_description):
Add function to load a GdkFont from a PangoFontDescription.
Fri May 26 17:16:40 2000 Owen Taylor <otaylor@redhat.com>
* gtk/frame.[ch] gtkaspectframe.c: Make frame widgets able
to have any widget for the label, use a GtkLabel widget
to display the text. (Based partially on a patch from
Anders Carlson.)
(Quite a bit of code reorganization - strip 90% of the
guts out of gtkaspectframe and add a single virtual
func to GtkFrameClass - compute_child_allocation.)
Fri May 26 12:00:02 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkctree.c gtk/gtkclist.[ch]: Pangoized.
(Removed clist->row_center_offset field because caching
it wasn't saving time or code, added private function
_gtk_clist_create_cell_layout()).
Wed May 24 15:59:37 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkaccellabel.c: Pangoized.
* gtk/[hv]ruler.c: Pangoized
Mon May 22 19:23:59 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkfilesel.c (gtk_file_selection_init):
Use gtk_clist_set_column_auto_resize() to remove need
need for manual column width computations.
Mon May 22 18:50:26 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktooltips.[ch]: Replace custom drawing with a GtkLabel,
ensuring Pango correctness, and considerably simplifying the
code.
* gtk/gtklabel.c gtk[hv]scale.c: 1000 => PANGO_SCALE.
* gtk/gtklabel.c (gtk_label_size_request): Fixed incorrect
getting of numbers of lines.
* gtk/gtklabel.c (gtk_label_size_request): Set the requisition
to the actual requested width of the lable, not to the wrap
width we set.
* gtk/gtktextchild.h: Remove extraneous include of gtk/gtk.h.
* gtk/gtktextbtree.c gtk/gtktextbuffer.c gtk/gtktextlayout.c
gtk/gtktextview.c gtk/gtktextview.[ch]: Fix up includes.
* gtk/gtktextview.c: Fix structure inheritance.
* gtk/gtkprogressbar.c: Pangoize.
Mon May 22 15:47:30 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.c (gtk_text_view_get_first_para_iter): Encapsulate
in a function.
* gtk/gtktextlayout.c (find_display_line_above): Fixed
bug with computing line tops.
* gtk/gtktextview.c (changed_handler): Fix < , <= confusion.
Thu May 18 18:53:31 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextdisplay.c (gtk_text_layout_draw): Fix up the x_offset
and y_offset coordinates to do what we need now. (The offset between
buffer and layout coordinates has been reintroduced, but is a
bit different than before.)
* gtk/gtktextview.[ch]: No longer inherit from GtkLayout; instead
handle the adjustments ourselves, and scroll as necessary using
the new gdk_window_scroll().
The advantage of this is that when we are incrementally revalidating,
we are essentially rearranging things around the visible portion
of the screen. With the old setup, the visible portion of the
screen was moved around in the layout, so scrolling and redrawing
to track that caused jumping of the display. Since we now
control the scrolling ourselves, we can suppress this and
only redraw when things actually change.
Thu May 18 18:47:25 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextbtree.c (redisplay_mark): We need to invalidate
the region not just redisplay it after-all, since we store the
cursors in the LineDisplay. (Ugly interactions here between
GtkLayout and GtkTextBTree here.)
* gtk/gtktextbtree.c (redisplay_region): Fixed reversed comparison.
Thu May 18 18:43:21 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.h gdk/x11/gdkgeometry-x11.c (gdk_window_scroll):
Added function to scroll contents of a window while keeping the
window constant. Works by XCopyArea or guffaw-scrolling depending
on the details of how the window is set up. (guffaw-scrolling
still needs to be filled in.)
Wed May 17 22:36:53 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextiter.c gtk/gtkmain.c: Add a debug key for the text widget,
move the debugging that was tied to a global variable
to that.
* gtk/gtkmarshal.list: Add NONE:INT,INT,INT
* gtk/gtktextbtree.[ch] gtk/gtktextlayout.c: Keep a separate
validated flag, in line data instead of setting height/width to
-1. This allows us to perform operations with partially invalid
buffer (using the old size for invalid lines) and thus to do
incremental vaidation. Keep height/width aggregates up to date
when deleting text and rebalancing the tree.
* gtk/gtktextbtree.[ch]: Add functions validate a line
(gtk_text_btree_validate_line), and to validate up
to a number of pixels (gtk_text_btree_validate).
* gtk/gtktextlayout.[ch]: Add an ::invalidated signal
that indicates that something is changed and a revalidation
pass is needed. Change ::need_repaint to ::changed, and
make it take old and new yranges instead of a rectangle.
* gtk/gtktextbtree.[ch] gtk/gtktextlayout.[ch]: Move
the line_data_destroy() function from
gtk_text_btree_add_view() to a virtual function in
GtkTextLayout
* gtk/gtktextbtree.[ch]: Remove gtk_text_btree_get_damage_range(),
since we are handling partial repaints in a different fashion
now.
* gtk/gtktextbtree.[ch]: Only repaint the changed portion
of the selection instead of queueing a repaint on the
entire widget.
* gtk/gtktextbuffer.[ch] gtk/gtktextbtree.[ch]: Move
get_selection_bounds() down to btree, make the function
in buffer a wrapper around the btree function.
* gtk/gtktextlayout.[ch]: Add functions to check if the
layout is valid and to recompute either a range of pixels
aroudn a line or a certain total number of pixels.
* gtk/gtktextlayout.[ch]: Cache a single line display;
now that we only redraw the needed portions, the hit rate
for this cache is quite high.
* gtk/gtktextview.[ch]: Keep track of the first paragraph
on the screen so that when re-laying-out the buffer, we can
keep the same place. This requires connecting to ::value_changed
on the adjustments
* gtk/gtktextview.[ch]: Add idle functions to revalidate
the buffer after we receive an ::invalidated signal.
Wed May 17 22:10:47 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtklayout.c (gtk_layout_size_allocate): Set upper
to max of allocation and layout size, not just to the
layout size.
* gtk/gtk[hv]scrollbar.c (gtk_[hv]scrollbar_calc_slider_size):
Invalidate window so it gets redrawn properly.
* gdk/gdkwindow.c (gdk_window_invalidate_rect): Allow rect == NULL
to mean the entire window.
* gdk/gdkevents.h: Move definition for GDK_PRIORITY_REDRAW
into public header.
Mon May 15 14:51:31 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextmark.c (gtk_text_mark_get_name): Add function
to get the name of a mark.
* gtk/gtktextlayout.c (gtk_text_layout_get_line_at_y): Add a function
to find the paragraph from a y position.
Thu May 11 12:57:20 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextbtree.c (gtk_text_btree_node_invalidate_upward): Valid
nodes have width/height >= 0, not > 0.
Tue May 9 21:29:06 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextlayout.[ch] gtk/gtktextdisplay.c (gtk_text_layout_get_line_display):
Add a size_only flag, so when we only need the size, we don't create
useless appearance attributes.
* gtk/gtktextview.c (gtk_text_view_ensure_layout): Remove
duplicate setting of font description.
* gtk/gtkscale.c: Use PANGO_SCALE instead of 1000
Wed Apr 26 01:53:23 2000 Owen Taylor <otaylor@redhat.com>
* gtk/Makefile.am (EXTRA_DIST): Add OLD_STAMP into
EXTRA_DIST. It does not work well when the file that
everything depends on is not in the tarball.
Wed Apr 26 00:56:14 2000 Owen Taylor <otaylor@redhat.com>
* gtk/testgtk.c: Some hacks and fixes so that it basically
works when not sitting in the GTK+ build tree.
2000-05-03 Havoc Pennington <hp@redhat.com>
* gtk/gtktextbtree.c (gtk_text_line_next_could_contain_tag):
Properly determine the ordering of the tag root and the current
line within the tree. Previous algorithm only worked if the tag
root's immediate parent was the common root of both the current
line and the tag root.
Wed Apr 26 00:43:00 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextlayout.c (set_para_values): Fix some bugs in
alignment.
* gtk/gtktextview.c (gtk_text_view_ensure_layout): Track
the widget text directional dynamically.
* gtk/gtktextview.[ch]: Added functions to get and set default
wrap mode.
Tue Apr 25 23:47:38 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextlayout.c (gtk_text_layout_get_iter_location): Fix bug
in cursor location computation.
Tue Apr 25 23:22:59 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtklayout.c (gtk_layout_set_size): Clamp hadjustment/
vadjusment values properly when layout gets smaller.
* gtk/gtktextview.c (need_repaint_handler): Areas being
passed in are far completely inaccurate, and sometimes
too small, so, for now, just queue a redraw on the
whole visible region.
2000-04-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextbtree.c (summary_destroy): new function to
destroy tag summary nodes
(gtk_text_line_next_could_contain_tag): this function was
totally broken if the line passed in wasn't below the tag
root. Fix it.
(gtk_text_btree_first_could_contain_tag): In the tag == NULL
"wildcard" case, we have to do a linear scan. Blah.
(gtk_text_btree_last_could_contain_tag): In tag == NULL case,
we have to do the linear scan
(tag_removed_cb): When a tag is removed from the tag table,
remove the GtkTextTagInfo node from the btree.
(gtk_text_btree_spew): Implement the spew function, for
our debugging pleasure.
Tue Apr 25 19:40:18 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextlayout.c (gtk_text_layout_set_buffer): Fix
a problem with referring to the wrong buffer.
* gtk/gtkentry.c: Fix focus-in/focus-out confusion.
* gtk/gtkrc.c gtk/gtkstyle.c: Moving setting default
font description to gtk_style_new() - otherwise things
don't work without a .gtkrc file.
* gtk/gtktextbuffer.c (gtk_text_buffer_new): Sink the
tags table if we create it ourself, too.
* gdk/gdktypes.h (enum): Move GDK_RELEASE_MASK, since
it was conflicting with XKB modifiers.
* gtk/gtktextview.[ch]: Add simple support for
GtkIMContext.
Mon Apr 24 19:34:18 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c (gtk_entry_move_cursor_visually): Fix problem
with deletion from last commit.
Mon Apr 24 19:29:40 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_create_pango_context): Set the language
in the context from the current locale.
* gtk/gtkentry.c (gtk_entry_size_request): Use language from the
context, not hardcoded value.
* gtk/gtkentry.c (gtk_entry_move_cursor): Make character movement visual,
not logical.
Sun Apr 23 23:39:18 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c gtk/gtktextdisplay.c: Don't handle selections as
attributes - that doesn't handle partial-glyph selection
properly. Instead use new pango_layout_line_get_x_ranges()
functionality to draw the selection.
* gtk/gtkentry.c: Simplify code since pango_layout_line_index_to_x()
now properly handles out-of-range coordinates.
* gtk/gtktextbuffer.c: Emit "mark_set" when the cursor is moved.
* gtk/gtktextiter.h gtk/gtktextiterprivate.h: Make gtk_text_iter_get_line_byte()
public.
* gtk/gtktextlayout.[ch]: Properly set the direction in the PangoContext
for paragraphs opposite to the base direction of the widget.
* gtk/gtktextlayout.[ch] gtk/gtktextdisplay.c: Fixes for alignment.
* gtk/gtktextlayout.c: Don't split segments on marks, since that
causes Arabic words to reshape as you cursor through.
* gtk/gtktextlayout.[ch] gtk/gtktextview.[ch]: Implement virtual
cursor position when moving vertically with the arrow keys and
scrolling with page-up/page-down. (Arrow keys save only the X,
scrolling saves both X and Y.)
This means you can line-up / line-down or page-up / page-down
without losing your place, and also that moving vertically
with the cursor keys keeps the same X position, not the same
character count:
* gtk/gtktextlayout.[ch] gtk/gtktextview.[ch]: Make vertical
arrow keys move by display lines, not paragraphs.
Tue Apr 18 14:16:50 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtklayout.c: Make sure that the bin window is at least
as big as the allocation. (Should we also make sure that the
bin window is big enough to completely cover widget->window?)
* gtk/gtktextview.c (gtk_text_view_get_visible_rect): Add
function to get the onscreen rectangle.
* gdk/x11/gdkwindow-x11.c (gdk_window_get_pointer): Correctly account
for offsets in window coordinates.
Sun Apr 16 16:13:27 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c (gtk_entry_get_cursor_locations): Fix index/offset
confusion.
* gtk/gtktextview.c (gtk_text_view_ensure_layout): Set the default direction
from the widget direction.
* gtk/gtktexttag.c gtk/gtktexttagprivate.h (gtk_text_tag_set_arg):
Add a "direction" attribute.
* gtk/gtktextview.c: global s/tkxt/text_view/.
* gtk/testtext.c: Added long block of text in Arabic, to test out
the direction attributes. (Some problems with the shaping system
for arabic become obvious - like the fact the cursor splits words
into unjoined pieces.)
Fri Apr 14 12:54:34 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextdisplay.c (render_layout): Add overstrike handling.
* gtk/gtktextlayout.c: Fix up alignment.
* gtk/testtext.c: Add some tests for centering, wrapping.
Fri Apr 14 09:26:22 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdrawable.h gdk/gdkdraw.c gdk/gdkwindow.c gdk/x11/gdkdrawable-x11.c:
Add a draw_glyphs() operation to the drawable vtable and gdk_draw_glyphs().
If we wrote GTK+-specific layout-render function this could just replace
the draw_layout() operation in the vtable.
* gtk/gtkentry.c: Move guts of gtk_entry_get_cursor_locations to
pango_layout_get_cursor_pos() and use that function.
* gtk/gtktextchild.[ch]: add gtk_ onto pixmap_segment_new(), since it
is a non-static symbol.
* gtk/gtktextbtree.[ch]: Replace gtk_text_btree_find_line_data_by_y()
with gtk_text_btree_find_line_by_y()
* gtk/gtktextdisplay.c: Rewrote for Pango - uses a custom layout
renderer that handles GtkTextAppearance attributes.
* gtk/gtktexttag.[ch] gtk/gtktexttagprivate.h:
- Move the values in the style that don't affect geometry into a
GtkTextAppearance structure.
- Change underline to take a PangoUnderline and "font" a string
representation of a font description
- Add a "font_desc" attribute which takes a FontDescription structure.
* gtk/gtktextlayout.[ch]:
- Get rid of the display-line list per each line. Instead, we
generate, on demand, a GtkTextLineDisplay structure which]
contains a PangoLayout * and other necesary information
(offsets, cursor locations) for displaying a paragraph.
- Get rid of the code to wrap lines, create display chunks,
etc. Instead, we just go through a paragraph and convert
it into the necessary inputs to a PangoLayout.
- Implement a new attribute type, GtkTextAttrAppearance. This
holds a GtkTextAppearance, and is used to pass colors,
stipple, etc, through from the layout to the display without
having to use lots and lots of individual attributes.
- Reimplement gtk_layout_get_iter_at_pixel() gtk_layout_get_iter_pos()
in terms of PangoLayout functions.
* gtk/gtktextview.c:
- Handle passing the necessary PangoContext to the layout
- Some fixups in painting to deal with the automatic backing store
and offsetting of GTK+-1.4
- Add a style_set handler so that the default style reacts
properly to theme changes.
* gtk/gtktext?*.[ch]: Random code-style fixes.
* gtk/testtext.c: Substitute in languages that Pango handles now for Thai
Mon Apr 10 10:33:45 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktext?*.[ch]: Check in Havoc's port of the Tk text widget,
in original form preparatory to Pango-ization and gdkimcontext-ization.
Thu Apr 6 19:25:39 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimcontext.c: Move default implementations to real_* vfuncs,
so that we can derive from gtkimcontext in language bindings properly.
Thu Apr 6 16:02:52 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimcontextsimple.[ch]: Use gdk_keyval_to_unicode to gdk_unicode_to_keyval.
Add a compose table including (almost) all the compose combinations
from X. This is 6k of static, shared data as opposed to 50k or so of dynamic
data in the XIM implementation.
* gdk/gdk.h gdk/gdkkeyuni.c gdk/win32/gdkevents-win32.c (gdk_keyval_to_unicode, gdk_unicode_to_keyval):
Moved functions to convert keyvalues from and to unicode here from
the win32 port and made them public.
Wed Apr 5 16:37:29 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkeditable.c (gtk_editable_insert_text): Allow new_text_length == -1.
Wed Apr 5 16:27:45 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimcontext.[ch]: Base class for new input context system
* gtk/gtkimmulticontext.[ch]: Proxy input context that allows
the real input context implementation to be loaded from modules
and switched on the fly.
* gtk/gtkcontextsimple.[ch]: Simple implementation of an input
context that just does direct keysymbol => unicode translation.
* gtk/gtkentry.[ch]: Start switching editing over to using
GtkInputContext. (No handling of preedit yet.)
Wed Apr 5 15:48:41 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktypeutils.h (GTK_CHECK_GET_CLASS): Fix problem with one too
many substitutions. (klass should not be subsituted.)
Wed Apr 5 00:18:14 2000 Owen Taylor <otaylor@redhat.com>
* configure.in: Add checks for Pango
* configure.in docs/Makefile.am: Add test for sgml2html
and allow 'make dist' without building html, but print out
warnings in that case. (For making snapshots)
* gdk/Makefile.am gdk/x11/Makefile.am gtk/Makefile.am:
Add Pango libraries and C flags
* gdk/gdkdraw.c gdk/gdkdrawable.h gdkwindow.c gdk/x11/gdkdrawable-x11.c:
Add function (gdk_draw_layout) to draw a pango layout.
* gdk/gdkpango.h gdk/x11/gdkpango-x11.c: New file with functions
for getting Pango contexts for GDK.
* gtk/gtkeditable.c: Get rid of dead code gtk_editable_parent_set()
* gtk/gtkentry.[ch]: Complete rewrite to use Pango, add bidirectional
editing.
* gtk/gtkentry.c: Hack in simple Hebrew input with direct
keysym => unicode translations. More languages can be added
here, but real input-method support is needed.
* docs/Changes-1.4.txt: Added note about entry behavior.
* gtk/gtkenums.h gtk/gtkwidget.[ch] testgtk.c gtkprivate.h: Add functions
to set the reading direction for a widget and the global direction.
Add test which allows toggling the global direction. Two private
flags are used to store the direction. (GTK_DIRECTION_SET + GTK_DIRECTION_LTR)
* gtk/gtkcheckbutton.c gtk/gtkframe.c gtk/gtkhbbox.c gtk/gtkhbox.c
gtk/gtkradiobutton.c gtk/gtkspinbutton.c gtk/gtktable.c
* gtk/gtk[hv]scale.c gtk/gtkscale.[ch]: Draw numbers using Pango
* gtk/gtklabel.[ch]: Moved to Pango and considerably rewritten. Line breaking,
underlining now handled by Pango.
* gtk/gtkstyle.[ch] gtk/gtkrc.[ch]: Add a PangoFontDescription
to RCStyle and Style. (Having both this and the old font name and GdkFont
is temporary.)
* gtk/gtkwidget.[ch] (gtk_widget_create_pango_{context,layout}): Added
convenience functions for creating contexts and layouts for widgets.
* gtk/testgtk.c: Enhance label tests with multilingual labels.
2000-06-02 03:14:07 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), label_props[PROP_USE_MARKUP]);
|
Remove all references to offscreen flag which was no longer used.
Thu Jun 1 23:05:13 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c: Remove all references to
offscreen flag which was no longer used.
* gtk/gtkprivate.h (enum): Remove unused flags and compress.
* gtk/gtkframe.c (gtk_frame_set_label_widget): Check
for non-null label_widget->parent.
* gtk/gtkentry.c: Get rid of code to deal with PangoAttribute
which no longer was used.
* gdk/gdkpango.c (gdk_pango_context_get_info): make static.
* gdk/gdkpango.c (gdk_draw_layout[_line]): Add checks
for null arguments.
* gdk/x11/gdkgeometry-x11.c (gdk_window_scroll): add
check for destroyed windows.
Thu Jun 1 13:48:45 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimmulticontext.c: Add a finalize method and unref
the slave context there.
* gtk/gtkinvisible.[ch]: Make reference counting behavior
identical to GtkWindow.
Thu Jun 1 01:54:11 2000 Owen Taylor <otaylor@redhat.com>
* Makefile.am gdk/gdkpango.c: Copy the layout render function from
pangox to here, so we can write them independent of rendering
system, using GDK primitives.
* gdk/gdkdrawable.h gdk/gdkdraw.c gdk/gdkwindow.c
gdk/x11/gdkdrawable-x11.c: Remove draw_layout() from the vtable,
since we have a rendering-system independent implementation in
terms of draw_glyphs().
* gdk/gdkpango.c gdkdrawable.h (gdk_draw_layout_line): New
function to render a single line.
* gdk/x11/gdkpango.c: Move the guts of this file mostly
into ../gdkpango.c, which simplifies things, since we
don't have to deal with raw X gc's.
Fri May 19 04:28:16 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextlayout.[ch]: Add get_log_attrs() function to
get the logical attributes for a given GtkTextLine.
Tue May 30 16:05:39 2000 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkfont-x11.c (gdk_font_charset_for_locale): Track
g_locale_get_codeset() to g_get_codeset() change.
Tue May 30 15:03:19 2000 Owen Taylor <otaylor@redhat.com>
* gtk/testcalendar.c (calendar_font_selection_ok): Use font
descriptions.
* gtk/gtkentry.c (gtk_entry_draw_text): Center text within
the entry.
* gtk/gtkfontsel.c (gtk_font_selection_dialog_init): Start of
redoing (vastly simplifying) for Pango. Still needs quite
a bit of work. (Size selection is currently poor. List of
predefined sizes is not a good idea, since all of these
sizes won't necessarily be distinct.)
Tue May 30 13:50:19 2000 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkfont-x11.c (gdk_font_charset_for_locale): Handle
CODESET results for LANG=C.
Mon May 29 15:49:10 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrc.[ch]: Add a 'font_name' declaration to RC
which takes a stringized pango font description;
ignore the older 'font' and 'fontset' declarations.
* gtk/gtkstyle.c gtk/gtkrc.c: Fill in the style->font
field with a GdkFont derived via gdk_font_from_description(),
for compatibility. (Should we just remove it entirely?
Probably too much compatibility breakage, but people
should be migrating to the new Pango stuff as quickly
as possible.)
Mon May 29 15:47:41 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c gtk/gtkclist.c: s/pango_font_unref/g_object_unref/.
Mon May 29 15:44:46 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcalender.c: Roughly pango-ized. Really needs
redoing; there are some bugs in size allocation right
now, the semi-existant distinction between header / day
fonts was removed, but, with Pango, could actually
be made functional in a nice way.
* gtk/testcalender: Move calender from examples into this
directory as a test program. (We really need to restrcture
testgtk into a whole directory full of tests for every
widget or functionality group, separated into multiple .c
files.)
Mon May 29 15:19:56 2000 Owen Taylor <otaylor@redhat.com>
* gtk/testgtk.c (file_exists): Fix stupid typo that
was keeping RC file from being loaded.
* gtk/testgtkrc gtk/testgtkrc2: Test new pango-ized
RC file font code.
Mon May 29 14:31:27 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdkfont.h gdk/x11/gdkfont-x11.c (gdk_font_from_description):
Add function to load a GdkFont from a PangoFontDescription.
Fri May 26 17:16:40 2000 Owen Taylor <otaylor@redhat.com>
* gtk/frame.[ch] gtkaspectframe.c: Make frame widgets able
to have any widget for the label, use a GtkLabel widget
to display the text. (Based partially on a patch from
Anders Carlson.)
(Quite a bit of code reorganization - strip 90% of the
guts out of gtkaspectframe and add a single virtual
func to GtkFrameClass - compute_child_allocation.)
Fri May 26 12:00:02 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkctree.c gtk/gtkclist.[ch]: Pangoized.
(Removed clist->row_center_offset field because caching
it wasn't saving time or code, added private function
_gtk_clist_create_cell_layout()).
Wed May 24 15:59:37 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkaccellabel.c: Pangoized.
* gtk/[hv]ruler.c: Pangoized
Mon May 22 19:23:59 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkfilesel.c (gtk_file_selection_init):
Use gtk_clist_set_column_auto_resize() to remove need
need for manual column width computations.
Mon May 22 18:50:26 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktooltips.[ch]: Replace custom drawing with a GtkLabel,
ensuring Pango correctness, and considerably simplifying the
code.
* gtk/gtklabel.c gtk[hv]scale.c: 1000 => PANGO_SCALE.
* gtk/gtklabel.c (gtk_label_size_request): Fixed incorrect
getting of numbers of lines.
* gtk/gtklabel.c (gtk_label_size_request): Set the requisition
to the actual requested width of the lable, not to the wrap
width we set.
* gtk/gtktextchild.h: Remove extraneous include of gtk/gtk.h.
* gtk/gtktextbtree.c gtk/gtktextbuffer.c gtk/gtktextlayout.c
gtk/gtktextview.c gtk/gtktextview.[ch]: Fix up includes.
* gtk/gtktextview.c: Fix structure inheritance.
* gtk/gtkprogressbar.c: Pangoize.
Mon May 22 15:47:30 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.c (gtk_text_view_get_first_para_iter): Encapsulate
in a function.
* gtk/gtktextlayout.c (find_display_line_above): Fixed
bug with computing line tops.
* gtk/gtktextview.c (changed_handler): Fix < , <= confusion.
Thu May 18 18:53:31 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextdisplay.c (gtk_text_layout_draw): Fix up the x_offset
and y_offset coordinates to do what we need now. (The offset between
buffer and layout coordinates has been reintroduced, but is a
bit different than before.)
* gtk/gtktextview.[ch]: No longer inherit from GtkLayout; instead
handle the adjustments ourselves, and scroll as necessary using
the new gdk_window_scroll().
The advantage of this is that when we are incrementally revalidating,
we are essentially rearranging things around the visible portion
of the screen. With the old setup, the visible portion of the
screen was moved around in the layout, so scrolling and redrawing
to track that caused jumping of the display. Since we now
control the scrolling ourselves, we can suppress this and
only redraw when things actually change.
Thu May 18 18:47:25 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextbtree.c (redisplay_mark): We need to invalidate
the region not just redisplay it after-all, since we store the
cursors in the LineDisplay. (Ugly interactions here between
GtkLayout and GtkTextBTree here.)
* gtk/gtktextbtree.c (redisplay_region): Fixed reversed comparison.
Thu May 18 18:43:21 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.h gdk/x11/gdkgeometry-x11.c (gdk_window_scroll):
Added function to scroll contents of a window while keeping the
window constant. Works by XCopyArea or guffaw-scrolling depending
on the details of how the window is set up. (guffaw-scrolling
still needs to be filled in.)
Wed May 17 22:36:53 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextiter.c gtk/gtkmain.c: Add a debug key for the text widget,
move the debugging that was tied to a global variable
to that.
* gtk/gtkmarshal.list: Add NONE:INT,INT,INT
* gtk/gtktextbtree.[ch] gtk/gtktextlayout.c: Keep a separate
validated flag, in line data instead of setting height/width to
-1. This allows us to perform operations with partially invalid
buffer (using the old size for invalid lines) and thus to do
incremental vaidation. Keep height/width aggregates up to date
when deleting text and rebalancing the tree.
* gtk/gtktextbtree.[ch]: Add functions validate a line
(gtk_text_btree_validate_line), and to validate up
to a number of pixels (gtk_text_btree_validate).
* gtk/gtktextlayout.[ch]: Add an ::invalidated signal
that indicates that something is changed and a revalidation
pass is needed. Change ::need_repaint to ::changed, and
make it take old and new yranges instead of a rectangle.
* gtk/gtktextbtree.[ch] gtk/gtktextlayout.[ch]: Move
the line_data_destroy() function from
gtk_text_btree_add_view() to a virtual function in
GtkTextLayout
* gtk/gtktextbtree.[ch]: Remove gtk_text_btree_get_damage_range(),
since we are handling partial repaints in a different fashion
now.
* gtk/gtktextbtree.[ch]: Only repaint the changed portion
of the selection instead of queueing a repaint on the
entire widget.
* gtk/gtktextbuffer.[ch] gtk/gtktextbtree.[ch]: Move
get_selection_bounds() down to btree, make the function
in buffer a wrapper around the btree function.
* gtk/gtktextlayout.[ch]: Add functions to check if the
layout is valid and to recompute either a range of pixels
aroudn a line or a certain total number of pixels.
* gtk/gtktextlayout.[ch]: Cache a single line display;
now that we only redraw the needed portions, the hit rate
for this cache is quite high.
* gtk/gtktextview.[ch]: Keep track of the first paragraph
on the screen so that when re-laying-out the buffer, we can
keep the same place. This requires connecting to ::value_changed
on the adjustments
* gtk/gtktextview.[ch]: Add idle functions to revalidate
the buffer after we receive an ::invalidated signal.
Wed May 17 22:10:47 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtklayout.c (gtk_layout_size_allocate): Set upper
to max of allocation and layout size, not just to the
layout size.
* gtk/gtk[hv]scrollbar.c (gtk_[hv]scrollbar_calc_slider_size):
Invalidate window so it gets redrawn properly.
* gdk/gdkwindow.c (gdk_window_invalidate_rect): Allow rect == NULL
to mean the entire window.
* gdk/gdkevents.h: Move definition for GDK_PRIORITY_REDRAW
into public header.
Mon May 15 14:51:31 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextmark.c (gtk_text_mark_get_name): Add function
to get the name of a mark.
* gtk/gtktextlayout.c (gtk_text_layout_get_line_at_y): Add a function
to find the paragraph from a y position.
Thu May 11 12:57:20 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextbtree.c (gtk_text_btree_node_invalidate_upward): Valid
nodes have width/height >= 0, not > 0.
Tue May 9 21:29:06 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextlayout.[ch] gtk/gtktextdisplay.c (gtk_text_layout_get_line_display):
Add a size_only flag, so when we only need the size, we don't create
useless appearance attributes.
* gtk/gtktextview.c (gtk_text_view_ensure_layout): Remove
duplicate setting of font description.
* gtk/gtkscale.c: Use PANGO_SCALE instead of 1000
Wed Apr 26 01:53:23 2000 Owen Taylor <otaylor@redhat.com>
* gtk/Makefile.am (EXTRA_DIST): Add OLD_STAMP into
EXTRA_DIST. It does not work well when the file that
everything depends on is not in the tarball.
Wed Apr 26 00:56:14 2000 Owen Taylor <otaylor@redhat.com>
* gtk/testgtk.c: Some hacks and fixes so that it basically
works when not sitting in the GTK+ build tree.
2000-05-03 Havoc Pennington <hp@redhat.com>
* gtk/gtktextbtree.c (gtk_text_line_next_could_contain_tag):
Properly determine the ordering of the tag root and the current
line within the tree. Previous algorithm only worked if the tag
root's immediate parent was the common root of both the current
line and the tag root.
Wed Apr 26 00:43:00 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextlayout.c (set_para_values): Fix some bugs in
alignment.
* gtk/gtktextview.c (gtk_text_view_ensure_layout): Track
the widget text directional dynamically.
* gtk/gtktextview.[ch]: Added functions to get and set default
wrap mode.
Tue Apr 25 23:47:38 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextlayout.c (gtk_text_layout_get_iter_location): Fix bug
in cursor location computation.
Tue Apr 25 23:22:59 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtklayout.c (gtk_layout_set_size): Clamp hadjustment/
vadjusment values properly when layout gets smaller.
* gtk/gtktextview.c (need_repaint_handler): Areas being
passed in are far completely inaccurate, and sometimes
too small, so, for now, just queue a redraw on the
whole visible region.
2000-04-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextbtree.c (summary_destroy): new function to
destroy tag summary nodes
(gtk_text_line_next_could_contain_tag): this function was
totally broken if the line passed in wasn't below the tag
root. Fix it.
(gtk_text_btree_first_could_contain_tag): In the tag == NULL
"wildcard" case, we have to do a linear scan. Blah.
(gtk_text_btree_last_could_contain_tag): In tag == NULL case,
we have to do the linear scan
(tag_removed_cb): When a tag is removed from the tag table,
remove the GtkTextTagInfo node from the btree.
(gtk_text_btree_spew): Implement the spew function, for
our debugging pleasure.
Tue Apr 25 19:40:18 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextlayout.c (gtk_text_layout_set_buffer): Fix
a problem with referring to the wrong buffer.
* gtk/gtkentry.c: Fix focus-in/focus-out confusion.
* gtk/gtkrc.c gtk/gtkstyle.c: Moving setting default
font description to gtk_style_new() - otherwise things
don't work without a .gtkrc file.
* gtk/gtktextbuffer.c (gtk_text_buffer_new): Sink the
tags table if we create it ourself, too.
* gdk/gdktypes.h (enum): Move GDK_RELEASE_MASK, since
it was conflicting with XKB modifiers.
* gtk/gtktextview.[ch]: Add simple support for
GtkIMContext.
Mon Apr 24 19:34:18 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c (gtk_entry_move_cursor_visually): Fix problem
with deletion from last commit.
Mon Apr 24 19:29:40 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_create_pango_context): Set the language
in the context from the current locale.
* gtk/gtkentry.c (gtk_entry_size_request): Use language from the
context, not hardcoded value.
* gtk/gtkentry.c (gtk_entry_move_cursor): Make character movement visual,
not logical.
Sun Apr 23 23:39:18 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c gtk/gtktextdisplay.c: Don't handle selections as
attributes - that doesn't handle partial-glyph selection
properly. Instead use new pango_layout_line_get_x_ranges()
functionality to draw the selection.
* gtk/gtkentry.c: Simplify code since pango_layout_line_index_to_x()
now properly handles out-of-range coordinates.
* gtk/gtktextbuffer.c: Emit "mark_set" when the cursor is moved.
* gtk/gtktextiter.h gtk/gtktextiterprivate.h: Make gtk_text_iter_get_line_byte()
public.
* gtk/gtktextlayout.[ch]: Properly set the direction in the PangoContext
for paragraphs opposite to the base direction of the widget.
* gtk/gtktextlayout.[ch] gtk/gtktextdisplay.c: Fixes for alignment.
* gtk/gtktextlayout.c: Don't split segments on marks, since that
causes Arabic words to reshape as you cursor through.
* gtk/gtktextlayout.[ch] gtk/gtktextview.[ch]: Implement virtual
cursor position when moving vertically with the arrow keys and
scrolling with page-up/page-down. (Arrow keys save only the X,
scrolling saves both X and Y.)
This means you can line-up / line-down or page-up / page-down
without losing your place, and also that moving vertically
with the cursor keys keeps the same X position, not the same
character count:
* gtk/gtktextlayout.[ch] gtk/gtktextview.[ch]: Make vertical
arrow keys move by display lines, not paragraphs.
Tue Apr 18 14:16:50 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtklayout.c: Make sure that the bin window is at least
as big as the allocation. (Should we also make sure that the
bin window is big enough to completely cover widget->window?)
* gtk/gtktextview.c (gtk_text_view_get_visible_rect): Add
function to get the onscreen rectangle.
* gdk/x11/gdkwindow-x11.c (gdk_window_get_pointer): Correctly account
for offsets in window coordinates.
Sun Apr 16 16:13:27 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c (gtk_entry_get_cursor_locations): Fix index/offset
confusion.
* gtk/gtktextview.c (gtk_text_view_ensure_layout): Set the default direction
from the widget direction.
* gtk/gtktexttag.c gtk/gtktexttagprivate.h (gtk_text_tag_set_arg):
Add a "direction" attribute.
* gtk/gtktextview.c: global s/tkxt/text_view/.
* gtk/testtext.c: Added long block of text in Arabic, to test out
the direction attributes. (Some problems with the shaping system
for arabic become obvious - like the fact the cursor splits words
into unjoined pieces.)
Fri Apr 14 12:54:34 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextdisplay.c (render_layout): Add overstrike handling.
* gtk/gtktextlayout.c: Fix up alignment.
* gtk/testtext.c: Add some tests for centering, wrapping.
Fri Apr 14 09:26:22 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdrawable.h gdk/gdkdraw.c gdk/gdkwindow.c gdk/x11/gdkdrawable-x11.c:
Add a draw_glyphs() operation to the drawable vtable and gdk_draw_glyphs().
If we wrote GTK+-specific layout-render function this could just replace
the draw_layout() operation in the vtable.
* gtk/gtkentry.c: Move guts of gtk_entry_get_cursor_locations to
pango_layout_get_cursor_pos() and use that function.
* gtk/gtktextchild.[ch]: add gtk_ onto pixmap_segment_new(), since it
is a non-static symbol.
* gtk/gtktextbtree.[ch]: Replace gtk_text_btree_find_line_data_by_y()
with gtk_text_btree_find_line_by_y()
* gtk/gtktextdisplay.c: Rewrote for Pango - uses a custom layout
renderer that handles GtkTextAppearance attributes.
* gtk/gtktexttag.[ch] gtk/gtktexttagprivate.h:
- Move the values in the style that don't affect geometry into a
GtkTextAppearance structure.
- Change underline to take a PangoUnderline and "font" a string
representation of a font description
- Add a "font_desc" attribute which takes a FontDescription structure.
* gtk/gtktextlayout.[ch]:
- Get rid of the display-line list per each line. Instead, we
generate, on demand, a GtkTextLineDisplay structure which]
contains a PangoLayout * and other necesary information
(offsets, cursor locations) for displaying a paragraph.
- Get rid of the code to wrap lines, create display chunks,
etc. Instead, we just go through a paragraph and convert
it into the necessary inputs to a PangoLayout.
- Implement a new attribute type, GtkTextAttrAppearance. This
holds a GtkTextAppearance, and is used to pass colors,
stipple, etc, through from the layout to the display without
having to use lots and lots of individual attributes.
- Reimplement gtk_layout_get_iter_at_pixel() gtk_layout_get_iter_pos()
in terms of PangoLayout functions.
* gtk/gtktextview.c:
- Handle passing the necessary PangoContext to the layout
- Some fixups in painting to deal with the automatic backing store
and offsetting of GTK+-1.4
- Add a style_set handler so that the default style reacts
properly to theme changes.
* gtk/gtktext?*.[ch]: Random code-style fixes.
* gtk/testtext.c: Substitute in languages that Pango handles now for Thai
Mon Apr 10 10:33:45 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktext?*.[ch]: Check in Havoc's port of the Tk text widget,
in original form preparatory to Pango-ization and gdkimcontext-ization.
Thu Apr 6 19:25:39 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimcontext.c: Move default implementations to real_* vfuncs,
so that we can derive from gtkimcontext in language bindings properly.
Thu Apr 6 16:02:52 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimcontextsimple.[ch]: Use gdk_keyval_to_unicode to gdk_unicode_to_keyval.
Add a compose table including (almost) all the compose combinations
from X. This is 6k of static, shared data as opposed to 50k or so of dynamic
data in the XIM implementation.
* gdk/gdk.h gdk/gdkkeyuni.c gdk/win32/gdkevents-win32.c (gdk_keyval_to_unicode, gdk_unicode_to_keyval):
Moved functions to convert keyvalues from and to unicode here from
the win32 port and made them public.
Wed Apr 5 16:37:29 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkeditable.c (gtk_editable_insert_text): Allow new_text_length == -1.
Wed Apr 5 16:27:45 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkimcontext.[ch]: Base class for new input context system
* gtk/gtkimmulticontext.[ch]: Proxy input context that allows
the real input context implementation to be loaded from modules
and switched on the fly.
* gtk/gtkcontextsimple.[ch]: Simple implementation of an input
context that just does direct keysymbol => unicode translation.
* gtk/gtkentry.[ch]: Start switching editing over to using
GtkInputContext. (No handling of preedit yet.)
Wed Apr 5 15:48:41 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktypeutils.h (GTK_CHECK_GET_CLASS): Fix problem with one too
many substitutions. (klass should not be subsituted.)
Wed Apr 5 00:18:14 2000 Owen Taylor <otaylor@redhat.com>
* configure.in: Add checks for Pango
* configure.in docs/Makefile.am: Add test for sgml2html
and allow 'make dist' without building html, but print out
warnings in that case. (For making snapshots)
* gdk/Makefile.am gdk/x11/Makefile.am gtk/Makefile.am:
Add Pango libraries and C flags
* gdk/gdkdraw.c gdk/gdkdrawable.h gdkwindow.c gdk/x11/gdkdrawable-x11.c:
Add function (gdk_draw_layout) to draw a pango layout.
* gdk/gdkpango.h gdk/x11/gdkpango-x11.c: New file with functions
for getting Pango contexts for GDK.
* gtk/gtkeditable.c: Get rid of dead code gtk_editable_parent_set()
* gtk/gtkentry.[ch]: Complete rewrite to use Pango, add bidirectional
editing.
* gtk/gtkentry.c: Hack in simple Hebrew input with direct
keysym => unicode translations. More languages can be added
here, but real input-method support is needed.
* docs/Changes-1.4.txt: Added note about entry behavior.
* gtk/gtkenums.h gtk/gtkwidget.[ch] testgtk.c gtkprivate.h: Add functions
to set the reading direction for a widget and the global direction.
Add test which allows toggling the global direction. Two private
flags are used to store the direction. (GTK_DIRECTION_SET + GTK_DIRECTION_LTR)
* gtk/gtkcheckbutton.c gtk/gtkframe.c gtk/gtkhbbox.c gtk/gtkhbox.c
gtk/gtkradiobutton.c gtk/gtkspinbutton.c gtk/gtktable.c
* gtk/gtk[hv]scale.c gtk/gtkscale.[ch]: Draw numbers using Pango
* gtk/gtklabel.[ch]: Moved to Pango and considerably rewritten. Line breaking,
underlining now handled by Pango.
* gtk/gtkstyle.[ch] gtk/gtkrc.[ch]: Add a PangoFontDescription
to RCStyle and Style. (Having both this and the old font name and GdkFont
is temporary.)
* gtk/gtkwidget.[ch] (gtk_widget_create_pango_{context,layout}): Added
convenience functions for creating contexts and layouts for widgets.
* gtk/testgtk.c: Enhance label tests with multilingual labels.
2000-06-02 03:14:07 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
2001-02-17 00:11:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_label_set_use_underline_internal (GtkLabel *self,
|
|
|
|
|
gboolean val)
|
2010-04-21 05:32:55 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (self->use_underline != val)
|
|
|
|
|
{
|
|
|
|
|
self->use_underline = val;
|
2010-04-21 05:32:55 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), label_props[PROP_USE_UNDERLINE]);
|
2010-04-28 04:48:15 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2008-02-07 16:59:42 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2013-03-05 14:14:17 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/* Calculates text, attrs and mnemonic_keyval from
|
|
|
|
|
* label, use_underline and use_markup
|
|
|
|
|
*/
|
2010-04-18 02:54:29 +00:00
|
|
|
|
static void
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_label_recalculate (GtkLabel *self)
|
2010-04-18 02:54:29 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
guint keyval = self->mnemonic_keyval;
|
2010-04-18 02:54:29 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_label_clear_links (self);
|
|
|
|
|
gtk_label_clear_layout (self);
|
|
|
|
|
gtk_label_clear_select_info (self);
|
2010-04-18 02:54:29 +00:00
|
|
|
|
|
2021-06-15 17:06:10 +00:00
|
|
|
|
if (self->use_markup)
|
|
|
|
|
{
|
|
|
|
|
gtk_label_set_markup_internal (self, self->label, self->use_underline);
|
|
|
|
|
}
|
|
|
|
|
else if (self->use_underline)
|
|
|
|
|
{
|
|
|
|
|
char *text;
|
|
|
|
|
|
|
|
|
|
text = g_markup_escape_text (self->label, -1);
|
|
|
|
|
gtk_label_set_markup_internal (self, text, TRUE);
|
|
|
|
|
g_free (text);
|
|
|
|
|
}
|
2020-12-25 11:05:28 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
g_clear_pointer (&self->markup_attrs, pango_attr_list_unref);
|
2010-04-18 02:54:29 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_label_set_text_internal (self, g_strdup (self->label));
|
|
|
|
|
}
|
2010-04-18 02:54:29 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (!self->use_underline)
|
|
|
|
|
self->mnemonic_keyval = GDK_KEY_VoidSymbol;
|
2013-03-05 14:14:17 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (keyval != self->mnemonic_keyval)
|
|
|
|
|
{
|
|
|
|
|
gtk_label_setup_mnemonic (self);
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), label_props[PROP_MNEMONIC_KEYVAL]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (self));
|
2010-04-18 02:54:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_label_set_text:
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2020-12-25 11:05:28 +00:00
|
|
|
|
* @str: The text you want to set
|
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Sets the text within the `GtkLabel` widget.
|
|
|
|
|
*
|
|
|
|
|
* It overwrites any text that was there before.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* This function will clear any previously set mnemonic accelerators,
|
2022-11-26 18:32:27 +00:00
|
|
|
|
* and set the [property@Gtk.Label:use-underline] property to %FALSE as
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* a side effect.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* This function will set the [property@Gtk.Label:use-markup] property
|
|
|
|
|
* to %FALSE as a side effect.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* See also: [method@Gtk.Label.set_markup]
|
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_label_set_text (GtkLabel *self,
|
|
|
|
|
const char *str)
|
2011-04-09 20:19:51 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gboolean changed;
|
2011-04-09 20:19:51 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
2011-04-09 20:19:51 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_object_freeze_notify (G_OBJECT (self));
|
2011-03-29 13:05:27 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
changed = gtk_label_set_label_internal (self, str);
|
|
|
|
|
changed = gtk_label_set_use_markup_internal (self, FALSE) || changed;
|
|
|
|
|
changed = gtk_label_set_use_underline_internal (self, FALSE) || changed;
|
2011-03-29 13:05:27 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (changed)
|
|
|
|
|
gtk_label_recalculate (self);
|
2011-03-29 13:12:30 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_object_thaw_notify (G_OBJECT (self));
|
|
|
|
|
}
|
2017-06-11 14:35:06 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_set_attributes: (attributes org.gtk.Method.set_property=attributes)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2021-05-21 00:45:06 +00:00
|
|
|
|
* @attrs: (nullable): a [struct@Pango.AttrList]
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*
|
|
|
|
|
* Apply attributes to the label text.
|
|
|
|
|
*
|
|
|
|
|
* The attributes set with this function will be applied and merged with
|
|
|
|
|
* any other attributes previously effected by way of the
|
|
|
|
|
* [property@Gtk.Label:use-underline] or [property@Gtk.Label:use-markup]
|
|
|
|
|
* properties. While it is not recommended to mix markup strings with
|
|
|
|
|
* manually set attributes, if you must; know that the attributes will
|
|
|
|
|
* be applied to the label after the markup string is parsed.
|
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_label_set_attributes (GtkLabel *self,
|
|
|
|
|
PangoAttrList *attrs)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
2011-03-29 13:05:27 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (!attrs && !self->attrs)
|
|
|
|
|
return;
|
2011-04-22 00:51:52 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (attrs)
|
|
|
|
|
pango_attr_list_ref (attrs);
|
2011-04-22 00:51:52 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (self->attrs)
|
|
|
|
|
pango_attr_list_unref (self->attrs);
|
|
|
|
|
self->attrs = attrs;
|
2017-06-11 14:35:06 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), label_props[PROP_ATTRIBUTES]);
|
2017-06-11 14:35:06 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_label_clear_layout (self);
|
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (self));
|
|
|
|
|
}
|
2017-04-25 13:45:37 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_get_attributes: (attributes org.gtk.Method.get_property=attributes)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
|
|
|
|
*
|
2022-11-26 11:54:47 +00:00
|
|
|
|
* Gets the label's attribute list.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-03-02 16:09:28 +00:00
|
|
|
|
* This is the [struct@Pango.AttrList] that was set on the label using
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* [method@Gtk.Label.set_attributes], if any. This function does not
|
|
|
|
|
* reflect attributes that come from the labels markup (see
|
|
|
|
|
* [method@Gtk.Label.set_markup]). If you want to get the effective
|
|
|
|
|
* attributes for the label, use
|
|
|
|
|
* `pango_layout_get_attribute (gtk_label_get_layout (self))`.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-05-21 00:45:06 +00:00
|
|
|
|
* Returns: (nullable) (transfer none): the attribute list
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
PangoAttrList *
|
|
|
|
|
gtk_label_get_attributes (GtkLabel *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_LABEL (self), NULL);
|
2011-04-17 22:30:17 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return self->attrs;
|
2011-03-29 13:05:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_set_label: (attributes org.gtk.Method.set_property=label)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2020-12-25 11:05:28 +00:00
|
|
|
|
* @str: the new text to set for the label
|
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Sets the text of the label.
|
|
|
|
|
*
|
|
|
|
|
* The label is interpreted as including embedded underlines and/or Pango
|
|
|
|
|
* markup depending on the values of the [property@Gtk.Label:use-underline]
|
|
|
|
|
* and [property@Gtk.Label:use-markup] properties.
|
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_label_set_label (GtkLabel *self,
|
|
|
|
|
const char *str)
|
2009-12-02 08:48:42 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
2004-07-22 05:06:39 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_object_freeze_notify (G_OBJECT (self));
|
2010-04-11 02:30:42 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (gtk_label_set_label_internal (self, str))
|
|
|
|
|
gtk_label_recalculate (self);
|
2004-11-21 16:24:01 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_object_thaw_notify (G_OBJECT (self));
|
|
|
|
|
}
|
2016-01-28 10:04:48 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_get_label: (attributes org.gtk.Method.get_property=label)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Fetches the text from a label.
|
|
|
|
|
*
|
|
|
|
|
* The returned text includes any embedded underlines indicating
|
|
|
|
|
* mnemonics and Pango markup. (See [method@Gtk.Label.get_text]).
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: the text of the label widget. This string is
|
|
|
|
|
* owned by the widget and must not be modified or freed.
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
const char *
|
|
|
|
|
gtk_label_get_label (GtkLabel *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_LABEL (self), NULL);
|
2016-05-03 20:04:58 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return self->label;
|
2015-12-03 19:22:50 +00:00
|
|
|
|
}
|
2010-04-28 04:48:15 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
GtkLabel *label;
|
|
|
|
|
GArray *links;
|
|
|
|
|
GString *new_str;
|
|
|
|
|
gsize text_len;
|
2021-03-03 03:30:11 +00:00
|
|
|
|
gboolean strip_ulines;
|
|
|
|
|
GString *text_data;
|
2021-05-06 02:53:52 +00:00
|
|
|
|
gunichar accel_key;
|
2020-12-25 11:05:28 +00:00
|
|
|
|
} UriParserData;
|
|
|
|
|
|
2021-03-03 03:30:11 +00:00
|
|
|
|
static char *
|
2021-05-06 02:53:52 +00:00
|
|
|
|
strip_ulines (const char *text,
|
|
|
|
|
guint *accel_key)
|
2021-03-03 03:30:11 +00:00
|
|
|
|
{
|
|
|
|
|
char *new_text;
|
|
|
|
|
const char *p;
|
|
|
|
|
char *q;
|
|
|
|
|
gboolean after_uline = FALSE;
|
|
|
|
|
|
|
|
|
|
new_text = malloc (strlen (text) + 1);
|
|
|
|
|
|
|
|
|
|
q = new_text;
|
|
|
|
|
for (p = text; *p; p++)
|
|
|
|
|
{
|
|
|
|
|
if (*p == '_' && !after_uline)
|
|
|
|
|
{
|
|
|
|
|
after_uline = TRUE;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*q = *p;
|
2021-08-02 02:14:12 +00:00
|
|
|
|
if (after_uline && *p != '_' && *accel_key == 0)
|
2021-05-06 02:53:52 +00:00
|
|
|
|
*accel_key = g_utf8_get_char (p);
|
|
|
|
|
|
2021-03-03 03:30:11 +00:00
|
|
|
|
q++;
|
|
|
|
|
after_uline = FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (after_uline)
|
|
|
|
|
{
|
|
|
|
|
*q = '_';
|
|
|
|
|
q++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*q = '\0';
|
|
|
|
|
|
|
|
|
|
return new_text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
finish_text (UriParserData *pdata)
|
|
|
|
|
{
|
|
|
|
|
if (pdata->text_data->len > 0)
|
|
|
|
|
{
|
|
|
|
|
char *text;
|
|
|
|
|
gsize text_len;
|
|
|
|
|
char *newtext;
|
|
|
|
|
|
|
|
|
|
if (pdata->strip_ulines && strchr (pdata->text_data->str, '_'))
|
|
|
|
|
{
|
2021-05-06 02:53:52 +00:00
|
|
|
|
text = strip_ulines (pdata->text_data->str, &pdata->accel_key);
|
2021-03-03 03:30:11 +00:00
|
|
|
|
text_len = strlen (text);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
text = pdata->text_data->str;
|
|
|
|
|
text_len = pdata->text_data->len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
newtext = g_markup_escape_text (text, text_len);
|
|
|
|
|
g_string_append (pdata->new_str, newtext);
|
|
|
|
|
pdata->text_len += text_len;
|
|
|
|
|
g_free (newtext);
|
|
|
|
|
|
|
|
|
|
if (text != pdata->text_data->str)
|
|
|
|
|
g_free (text);
|
|
|
|
|
|
|
|
|
|
g_string_set_size (pdata->text_data, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-03 19:22:50 +00:00
|
|
|
|
static void
|
2020-12-25 11:05:28 +00:00
|
|
|
|
start_element_handler (GMarkupParseContext *context,
|
|
|
|
|
const char *element_name,
|
|
|
|
|
const char **attribute_names,
|
|
|
|
|
const char **attribute_values,
|
|
|
|
|
gpointer user_data,
|
|
|
|
|
GError **error)
|
2015-12-03 19:22:50 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
UriParserData *pdata = user_data;
|
|
|
|
|
GtkLabel *self = pdata->label;
|
2015-12-03 19:22:50 +00:00
|
|
|
|
|
2021-03-03 03:30:11 +00:00
|
|
|
|
finish_text (pdata);
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (strcmp (element_name, "a") == 0)
|
2015-12-03 19:22:50 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
GtkLabelLink link;
|
|
|
|
|
const char *uri = NULL;
|
|
|
|
|
const char *title = NULL;
|
|
|
|
|
const char *class = NULL;
|
|
|
|
|
gboolean visited = FALSE;
|
|
|
|
|
int line_number;
|
|
|
|
|
int char_number;
|
|
|
|
|
int i;
|
|
|
|
|
GtkCssNode *widget_node;
|
|
|
|
|
GtkStateFlags state;
|
2013-03-05 14:14:17 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_markup_parse_context_get_position (context, &line_number, &char_number);
|
2010-04-13 02:21:46 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
for (i = 0; attribute_names[i] != NULL; i++)
|
|
|
|
|
{
|
|
|
|
|
const char *attr = attribute_names[i];
|
2014-07-10 16:30:21 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (strcmp (attr, "href") == 0)
|
|
|
|
|
uri = attribute_values[i];
|
|
|
|
|
else if (strcmp (attr, "title") == 0)
|
|
|
|
|
title = attribute_values[i];
|
|
|
|
|
else if (strcmp (attr, "class") == 0)
|
|
|
|
|
class = attribute_values[i];
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
|
|
|
|
|
"Attribute '%s' is not allowed on the <a> tag "
|
|
|
|
|
"on line %d char %d",
|
|
|
|
|
attr, line_number, char_number);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-09-16 03:17:11 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (uri == NULL)
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_INVALID_CONTENT,
|
|
|
|
|
"Attribute 'href' was missing on the <a> tag "
|
|
|
|
|
"on line %d char %d",
|
|
|
|
|
line_number, char_number);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-07-10 16:30:21 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
visited = FALSE;
|
|
|
|
|
if (self->select_info)
|
|
|
|
|
{
|
|
|
|
|
for (i = 0; i < self->select_info->n_links; i++)
|
|
|
|
|
{
|
|
|
|
|
const GtkLabelLink *l = &self->select_info->links[i];
|
|
|
|
|
|
|
|
|
|
if (strcmp (uri, l->uri) == 0)
|
|
|
|
|
{
|
|
|
|
|
visited = l->visited;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-07-10 16:30:21 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (!pdata->links)
|
|
|
|
|
pdata->links = g_array_new (FALSE, TRUE, sizeof (GtkLabelLink));
|
2014-07-10 16:30:21 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
link.uri = g_strdup (uri);
|
|
|
|
|
link.title = g_strdup (title);
|
2017-05-04 14:14:47 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
widget_node = gtk_widget_get_css_node (GTK_WIDGET (pdata->label));
|
|
|
|
|
link.cssnode = gtk_css_node_new ();
|
|
|
|
|
gtk_css_node_set_name (link.cssnode, g_quark_from_static_string ("link"));
|
|
|
|
|
gtk_css_node_set_parent (link.cssnode, widget_node);
|
|
|
|
|
if (class)
|
|
|
|
|
gtk_css_node_add_class (link.cssnode, g_quark_from_string (class));
|
2014-07-10 16:30:21 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
state = gtk_css_node_get_state (widget_node);
|
|
|
|
|
if (visited)
|
|
|
|
|
state |= GTK_STATE_FLAG_VISITED;
|
|
|
|
|
else
|
|
|
|
|
state |= GTK_STATE_FLAG_LINK;
|
|
|
|
|
gtk_css_node_set_state (link.cssnode, state);
|
|
|
|
|
g_object_unref (link.cssnode);
|
2014-07-10 16:30:21 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
link.visited = visited;
|
|
|
|
|
link.start = pdata->text_len;
|
|
|
|
|
g_array_append_val (pdata->links, link);
|
2014-07-10 16:30:21 +00:00
|
|
|
|
}
|
2020-12-25 11:05:28 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int i;
|
2014-07-10 16:30:21 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_string_append_c (pdata->new_str, '<');
|
|
|
|
|
g_string_append (pdata->new_str, element_name);
|
2014-07-10 16:30:21 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
for (i = 0; attribute_names[i] != NULL; i++)
|
|
|
|
|
{
|
|
|
|
|
const char *attr = attribute_names[i];
|
|
|
|
|
const char *value = attribute_values[i];
|
|
|
|
|
char *newvalue;
|
2014-07-10 16:30:21 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
newvalue = g_markup_escape_text (value, -1);
|
2014-07-10 16:30:21 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_string_append_c (pdata->new_str, ' ');
|
|
|
|
|
g_string_append (pdata->new_str, attr);
|
|
|
|
|
g_string_append (pdata->new_str, "=\"");
|
|
|
|
|
g_string_append (pdata->new_str, newvalue);
|
|
|
|
|
g_string_append_c (pdata->new_str, '\"');
|
2001-12-03 22:11:40 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_free (newvalue);
|
|
|
|
|
}
|
|
|
|
|
g_string_append_c (pdata->new_str, '>');
|
2018-01-17 11:36:37 +00:00
|
|
|
|
}
|
1998-12-15 20:31:26 +00:00
|
|
|
|
}
|
1999-01-12 15:12:14 +00:00
|
|
|
|
|
2001-06-01 19:26:01 +00:00
|
|
|
|
static void
|
2020-12-25 11:05:28 +00:00
|
|
|
|
end_element_handler (GMarkupParseContext *context,
|
|
|
|
|
const char *element_name,
|
|
|
|
|
gpointer user_data,
|
|
|
|
|
GError **error)
|
2001-06-01 19:26:01 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
UriParserData *pdata = user_data;
|
2001-06-01 19:26:01 +00:00
|
|
|
|
|
2021-03-03 03:30:11 +00:00
|
|
|
|
finish_text (pdata);
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (!strcmp (element_name, "a"))
|
2006-12-31 00:36:03 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
GtkLabelLink *link = &g_array_index (pdata->links, GtkLabelLink, pdata->links->len - 1);
|
|
|
|
|
link->end = pdata->text_len;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
2019-09-26 03:36:19 +00:00
|
|
|
|
else
|
2020-12-25 11:05:28 +00:00
|
|
|
|
{
|
|
|
|
|
g_string_append (pdata->new_str, "</");
|
|
|
|
|
g_string_append (pdata->new_str, element_name);
|
|
|
|
|
g_string_append_c (pdata->new_str, '>');
|
|
|
|
|
}
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-11-15 06:00:20 +00:00
|
|
|
|
static void
|
2020-12-25 11:05:28 +00:00
|
|
|
|
text_handler (GMarkupParseContext *context,
|
|
|
|
|
const char *text,
|
|
|
|
|
gsize text_len,
|
|
|
|
|
gpointer user_data,
|
|
|
|
|
GError **error)
|
2015-11-15 06:00:20 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
UriParserData *pdata = user_data;
|
2015-11-15 06:00:20 +00:00
|
|
|
|
|
2021-03-03 03:30:11 +00:00
|
|
|
|
g_string_append_len (pdata->text_data, text, text_len);
|
2020-12-25 11:05:28 +00:00
|
|
|
|
}
|
2015-11-15 06:00:20 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static const GMarkupParser markup_parser =
|
|
|
|
|
{
|
|
|
|
|
start_element_handler,
|
|
|
|
|
end_element_handler,
|
|
|
|
|
text_handler,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL
|
|
|
|
|
};
|
2015-11-15 06:00:20 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
xml_isspace (char c)
|
|
|
|
|
{
|
|
|
|
|
return (c == ' ' || c == '\t' || c == '\n' || c == '\r');
|
2015-11-15 06:00:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
parse_uri_markup (GtkLabel *self,
|
|
|
|
|
const char *str,
|
2021-03-03 03:30:11 +00:00
|
|
|
|
gboolean strip_ulines,
|
2021-05-06 02:53:52 +00:00
|
|
|
|
gunichar *accel_key,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
char **new_str,
|
2021-03-03 03:30:11 +00:00
|
|
|
|
GtkLabelLink **links,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
guint *out_n_links,
|
|
|
|
|
GError **error)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
GMarkupParseContext *context;
|
|
|
|
|
const char *p, *end;
|
|
|
|
|
gsize length;
|
|
|
|
|
UriParserData pdata;
|
2011-03-24 16:44:03 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
length = strlen (str);
|
|
|
|
|
p = str;
|
|
|
|
|
end = str + length;
|
2001-06-01 19:26:01 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
pdata.label = self;
|
|
|
|
|
pdata.links = NULL;
|
|
|
|
|
pdata.new_str = g_string_sized_new (length);
|
|
|
|
|
pdata.text_len = 0;
|
2021-03-03 03:30:11 +00:00
|
|
|
|
pdata.strip_ulines = strip_ulines;
|
|
|
|
|
pdata.text_data = g_string_new ("");
|
2021-05-06 02:53:52 +00:00
|
|
|
|
pdata.accel_key = 0;
|
2001-06-01 19:26:01 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
while (p != end && xml_isspace (*p))
|
|
|
|
|
p++;
|
2014-02-05 12:36:33 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
context = g_markup_parse_context_new (&markup_parser, 0, &pdata, NULL);
|
2015-07-04 17:56:40 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (end - p >= 8 && strncmp (p, "<markup>", 8) == 0)
|
2020-04-14 08:53:48 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (!g_markup_parse_context_parse (context, str, length, error))
|
|
|
|
|
goto failed;
|
2020-04-14 08:53:48 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2020-04-14 13:22:52 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (!g_markup_parse_context_parse (context, "<markup>", 8, error))
|
|
|
|
|
goto failed;
|
2020-04-14 13:22:52 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (!g_markup_parse_context_parse (context, str, length, error))
|
|
|
|
|
goto failed;
|
|
|
|
|
|
|
|
|
|
if (!g_markup_parse_context_parse (context, "</markup>", 9, error))
|
|
|
|
|
goto failed;
|
2020-04-14 13:22:52 +00:00
|
|
|
|
}
|
2014-02-05 12:36:33 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (!g_markup_parse_context_end_parse (context, error))
|
|
|
|
|
goto failed;
|
2004-03-01 18:10:40 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_markup_parse_context_free (context);
|
2004-03-01 18:10:40 +00:00
|
|
|
|
|
2021-03-03 03:30:11 +00:00
|
|
|
|
g_string_free (pdata.text_data, TRUE);
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*new_str = g_string_free (pdata.new_str, FALSE);
|
2004-03-01 18:10:40 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (pdata.links)
|
2004-03-01 18:10:40 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*out_n_links = pdata.links->len;
|
|
|
|
|
*links = (GtkLabelLink *)g_array_free (pdata.links, FALSE);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*links = NULL;
|
2004-03-01 18:10:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-06 02:53:52 +00:00
|
|
|
|
if (accel_key)
|
|
|
|
|
*accel_key = pdata.accel_key;
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return TRUE;
|
2004-03-01 18:10:40 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
failed:
|
|
|
|
|
g_markup_parse_context_free (context);
|
|
|
|
|
g_string_free (pdata.new_str, TRUE);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (pdata.links)
|
|
|
|
|
g_array_free (pdata.links, TRUE);
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_ensure_has_tooltip (GtkLabel *self)
|
|
|
|
|
{
|
|
|
|
|
guint i;
|
2022-04-13 16:56:29 +00:00
|
|
|
|
gboolean has_tooltip = gtk_widget_get_has_tooltip(GTK_WIDGET(self));
|
|
|
|
|
|
|
|
|
|
if (has_tooltip) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
for (i = 0; i < self->select_info->n_links; i++)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
const GtkLabelLink *link = &self->select_info->links[i];
|
2020-04-10 13:41:56 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (link->title)
|
|
|
|
|
{
|
|
|
|
|
has_tooltip = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_widget_set_has_tooltip (GTK_WIDGET (self), has_tooltip);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2017-05-03 08:19:17 +00:00
|
|
|
|
static void
|
2021-03-03 03:30:11 +00:00
|
|
|
|
gtk_label_set_markup_internal (GtkLabel *self,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
const char *str,
|
2021-03-03 03:30:11 +00:00
|
|
|
|
gboolean with_uline)
|
2020-12-25 11:05:28 +00:00
|
|
|
|
{
|
|
|
|
|
char *text = NULL;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
PangoAttrList *attrs = NULL;
|
|
|
|
|
char *str_for_display = NULL;
|
|
|
|
|
GtkLabelLink *links = NULL;
|
|
|
|
|
guint n_links = 0;
|
2021-05-06 02:53:52 +00:00
|
|
|
|
gunichar accel_keyval = 0;
|
2021-03-03 03:30:11 +00:00
|
|
|
|
gboolean do_mnemonics;
|
|
|
|
|
|
|
|
|
|
do_mnemonics = self->mnemonics_visible &&
|
|
|
|
|
gtk_widget_is_sensitive (GTK_WIDGET (self)) &&
|
|
|
|
|
(!self->mnemonic_widget || gtk_widget_is_sensitive (self->mnemonic_widget));
|
|
|
|
|
|
|
|
|
|
if (!parse_uri_markup (self, str,
|
|
|
|
|
with_uline && !do_mnemonics,
|
2021-05-06 02:53:52 +00:00
|
|
|
|
&accel_keyval,
|
2021-03-03 03:30:11 +00:00
|
|
|
|
&str_for_display,
|
|
|
|
|
&links, &n_links,
|
|
|
|
|
&error))
|
2020-12-25 11:05:28 +00:00
|
|
|
|
goto error_set;
|
|
|
|
|
|
|
|
|
|
if (links)
|
2020-12-21 11:26:22 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_label_ensure_select_info (self);
|
|
|
|
|
self->select_info->links = g_steal_pointer (&links);
|
|
|
|
|
self->select_info->n_links = n_links;
|
|
|
|
|
gtk_label_ensure_has_tooltip (self);
|
|
|
|
|
gtk_widget_add_css_class (GTK_WIDGET (self), "link");
|
|
|
|
|
}
|
2020-12-21 11:26:22 +00:00
|
|
|
|
|
2021-03-03 03:30:11 +00:00
|
|
|
|
if (!pango_parse_markup (str_for_display, -1,
|
|
|
|
|
with_uline && do_mnemonics ? '_' : 0,
|
|
|
|
|
&attrs, &text,
|
|
|
|
|
with_uline && do_mnemonics ? &accel_keyval : NULL,
|
|
|
|
|
&error))
|
|
|
|
|
goto error_set;
|
2020-12-21 11:26:22 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_free (str_for_display);
|
2001-02-17 00:11:03 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (text)
|
|
|
|
|
gtk_label_set_text_internal (self, text);
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_clear_pointer (&self->markup_attrs, pango_attr_list_unref);
|
|
|
|
|
self->markup_attrs = attrs;
|
2017-09-01 19:32:48 +00:00
|
|
|
|
|
2021-03-03 03:30:11 +00:00
|
|
|
|
self->mnemonic_keyval = accel_keyval;
|
2010-07-21 12:23:22 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return;
|
2017-09-01 19:32:48 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
error_set:
|
|
|
|
|
g_warning ("Failed to set text '%s' from markup due to error parsing markup: %s",
|
|
|
|
|
str, error->message);
|
|
|
|
|
g_error_free (error);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_label_set_markup:
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
|
|
|
|
* @str: a markup string
|
|
|
|
|
*
|
|
|
|
|
* Sets the labels text and attributes from markup.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* The string must be marked up with Pango markup
|
|
|
|
|
* (see [func@Pango.parse_markup]).
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* If the @str is external data, you may need to escape it
|
|
|
|
|
* with g_markup_escape_text() or g_markup_printf_escaped():
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* ```c
|
2020-12-25 11:05:28 +00:00
|
|
|
|
* GtkWidget *self = gtk_label_new (NULL);
|
|
|
|
|
* const char *str = "...";
|
|
|
|
|
* const char *format = "<span style=\"italic\">\%s</span>";
|
|
|
|
|
* char *markup;
|
|
|
|
|
*
|
|
|
|
|
* markup = g_markup_printf_escaped (format, str);
|
|
|
|
|
* gtk_label_set_markup (GTK_LABEL (self), markup);
|
|
|
|
|
* g_free (markup);
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* ```
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* This function will set the [property@Gtk.Label:use-markup] property
|
|
|
|
|
* to %TRUE as a side effect.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* If you set the label contents using the [property@Gtk.Label:label]
|
|
|
|
|
* property you should also ensure that you set the
|
|
|
|
|
* [property@Gtk.Label:use-markup] property accordingly.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* See also: [method@Gtk.Label.set_text]
|
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_label_set_markup (GtkLabel *self,
|
|
|
|
|
const char *str)
|
|
|
|
|
{
|
|
|
|
|
gboolean changed;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
2020-04-10 01:15:30 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_object_freeze_notify (G_OBJECT (self));
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
changed = gtk_label_set_label_internal (self, str);
|
|
|
|
|
changed = gtk_label_set_use_markup_internal (self, TRUE) || changed;
|
|
|
|
|
changed = gtk_label_set_use_underline_internal (self, FALSE) || changed;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (changed)
|
|
|
|
|
gtk_label_recalculate (self);
|
2020-04-10 01:15:30 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_object_thaw_notify (G_OBJECT (self));
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
1999-01-12 15:12:14 +00:00
|
|
|
|
|
2001-03-21 18:58:28 +00:00
|
|
|
|
/**
|
2020-12-25 11:05:28 +00:00
|
|
|
|
* gtk_label_set_markup_with_mnemonic:
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
|
|
|
|
* @str: a markup string
|
|
|
|
|
*
|
|
|
|
|
* Sets the labels text, attributes and mnemonic from markup.
|
2020-11-13 20:35:51 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Parses @str which is marked up with Pango markup (see [func@Pango.parse_markup]),
|
2020-12-25 11:05:28 +00:00
|
|
|
|
* setting the label’s text and attribute list based on the parse results.
|
2001-03-21 18:58:28 +00:00
|
|
|
|
* If characters in @str are preceded by an underscore, they are underlined
|
|
|
|
|
* indicating that they represent a keyboard accelerator called a mnemonic.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2020-11-13 20:35:51 +00:00
|
|
|
|
* The mnemonic key can be used to activate another widget, chosen
|
2021-05-27 00:18:23 +00:00
|
|
|
|
* automatically, or explicitly using [method@Gtk.Label.set_mnemonic_widget].
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*/
|
2001-03-21 18:58:28 +00:00
|
|
|
|
void
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_label_set_markup_with_mnemonic (GtkLabel *self,
|
|
|
|
|
const char *str)
|
2001-03-21 18:58:28 +00:00
|
|
|
|
{
|
2020-11-13 20:35:51 +00:00
|
|
|
|
gboolean changed;
|
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
2001-03-21 18:58:28 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_object_freeze_notify (G_OBJECT (self));
|
2002-04-12 12:43:01 +00:00
|
|
|
|
|
2020-11-13 20:35:51 +00:00
|
|
|
|
changed = gtk_label_set_label_internal (self, str);
|
2020-12-25 11:05:28 +00:00
|
|
|
|
changed = gtk_label_set_use_markup_internal (self, TRUE) || changed;
|
2020-11-13 20:35:51 +00:00
|
|
|
|
changed = gtk_label_set_use_underline_internal (self, TRUE) || changed;
|
|
|
|
|
|
|
|
|
|
if (changed)
|
2020-11-11 15:35:09 +00:00
|
|
|
|
gtk_label_recalculate (self);
|
2001-03-21 18:58:28 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_object_thaw_notify (G_OBJECT (self));
|
Added gdk_text/string_extents() - too calculate all the metrics at once of
Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() -
too calculate all the metrics at once of a string, including
things which weren't calculated before.
* gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New
MenuItem type, that when put as the first thing in a
menu, makes the menu tearoff. Currently drawn as a
dashed line.
* gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag
"hide_on_activate" to the MenuItem class structure to allow
check and radio buttons to be changed with <Space> without
hiding the menu.
* gtk/gtkaccellabel.[ch]: Added new capabilities to set
a underline_group and underline_mods for the label -
accelerators added in the underline group matching
underline_mods will be displayed as an underline character.
This doesn't work - Save As needs to be underlined
as Save _As.
* gtk/gtkitemfactory.c:
- Create a AccelGroup for each MenuShell we create.
- If an '&' appears before a character 'c' in the path,
then make 'c' an accelerator in the menu's accel group,
and if the menuitem is menubar <alt>C an accelerator
in the itemfactory's accel group.
* gtk/gtklabel.[ch]: Add support for a pattern arg -
which is a string. If an '_' appears in this string,
the corresponding position in the label is underlined.
Add gtk_label_parse_uline() convenience function which
takes a string with embedded underlines, sets the
pattern and label, and returns the accelerator keyval.
* gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget.
Instead, they create a GtkWindow and add themselves
to that. (When torn off, another new feature, they
create another GtkWindow to hold the torn off menu)
New function gtk_menu_set_tearoff_state()
* gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h:
Added action signals for keyboard navigation of menus.
* gtk/gtkmenushell.c: Key press handler which activates
bindings for navigation, and accelerators, for handling
underline accelerators. Exported functions to select
and activate menu items in a menushell.
* gtk/testgtk.c: Added a new "Item Factory" test which
tests GtkItemFactory and the new keyboard navigation
of menus.
1998-08-12 16:49:13 +00:00
|
|
|
|
}
|
2001-02-17 00:11:03 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_label_get_text:
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Fetches the text from a label.
|
|
|
|
|
*
|
|
|
|
|
* The returned text is as it appears on screen. This does not include
|
|
|
|
|
* any embedded underlines indicating mnemonics or Pango markup. (See
|
|
|
|
|
* [method@Gtk.Label.get_label])
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: the text in the label widget. This is the internal
|
|
|
|
|
* string used by the label, and must not be modified.
|
|
|
|
|
**/
|
|
|
|
|
const char *
|
|
|
|
|
gtk_label_get_text (GtkLabel *self)
|
2017-12-27 04:32:49 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_LABEL (self), NULL);
|
2017-12-27 04:32:49 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return self->text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_set_justify: (attributes org.gtk.Method.set_property=justify)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
|
|
|
|
* @jtype: a `GtkJustification`
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
|
|
|
|
* Sets the alignment of the lines in the text of the label relative to
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* each other.
|
|
|
|
|
*
|
|
|
|
|
* %GTK_JUSTIFY_LEFT is the default value when the widget is first created
|
|
|
|
|
* with [ctor@Gtk.Label.new]. If you instead want to set the alignment of
|
|
|
|
|
* the label as a whole, use [method@Gtk.Widget.set_halign] instead.
|
|
|
|
|
* [method@Gtk.Label.set_justify] has no effect on labels containing
|
|
|
|
|
* only a single line.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_label_set_justify (GtkLabel *self,
|
|
|
|
|
GtkJustification jtype)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
|
|
|
|
g_return_if_fail (jtype >= GTK_JUSTIFY_LEFT && jtype <= GTK_JUSTIFY_FILL);
|
|
|
|
|
|
|
|
|
|
if ((GtkJustification) self->jtype != jtype)
|
2020-06-27 09:38:25 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
self->jtype = jtype;
|
2020-06-27 09:38:25 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/* No real need to be this drastic, but easier than duplicating the code */
|
|
|
|
|
gtk_label_clear_layout (self);
|
|
|
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), label_props[PROP_JUSTIFY]);
|
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (self));
|
2020-06-27 09:38:25 +00:00
|
|
|
|
}
|
2020-12-25 11:05:28 +00:00
|
|
|
|
}
|
2017-12-27 04:32:49 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_get_justify: (attributes org.gtk.Method.get_property=justify)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Returns the justification of the label.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* See [method@Gtk.Label.set_justify].
|
|
|
|
|
*
|
|
|
|
|
* Returns: `GtkJustification`
|
2020-12-25 11:05:28 +00:00
|
|
|
|
**/
|
|
|
|
|
GtkJustification
|
|
|
|
|
gtk_label_get_justify (GtkLabel *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_LABEL (self), 0);
|
|
|
|
|
|
|
|
|
|
return self->jtype;
|
2017-12-27 04:32:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_set_ellipsize: (attributes org.gtk.Method.set_property=ellipsize)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
|
|
|
|
* @mode: a `PangoEllipsizeMode`
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Sets the mode used to ellipsizei the text.
|
|
|
|
|
*
|
|
|
|
|
* The text will be ellipsized if there is not enough space
|
|
|
|
|
* to render the entire string.
|
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_label_set_ellipsize (GtkLabel *self,
|
|
|
|
|
PangoEllipsizeMode mode)
|
2001-02-17 00:11:03 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
|
|
|
|
g_return_if_fail (mode >= PANGO_ELLIPSIZE_NONE && mode <= PANGO_ELLIPSIZE_END);
|
2001-02-17 00:11:03 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if ((PangoEllipsizeMode) self->ellipsize != mode)
|
|
|
|
|
{
|
|
|
|
|
self->ellipsize = mode;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/* No real need to be this drastic, but easier than duplicating the code */
|
|
|
|
|
gtk_label_clear_layout (self);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), label_props[PROP_ELLIPSIZE]);
|
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (self));
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-02-17 00:11:03 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_get_ellipsize: (attributes org.gtk.Method.get_property=ellipsize)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Returns the ellipsizing position of the label.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* See [method@Gtk.Label.set_ellipsize].
|
|
|
|
|
*
|
|
|
|
|
* Returns: `PangoEllipsizeMode`
|
2021-11-15 15:33:56 +00:00
|
|
|
|
**/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
PangoEllipsizeMode
|
|
|
|
|
gtk_label_get_ellipsize (GtkLabel *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_LABEL (self), PANGO_ELLIPSIZE_NONE);
|
2001-02-17 00:11:03 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return self->ellipsize;
|
|
|
|
|
}
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_set_width_chars: (attributes org.gtk.Method.set_property=width-chars)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2020-12-25 11:05:28 +00:00
|
|
|
|
* @n_chars: the new desired width, in characters.
|
|
|
|
|
*
|
|
|
|
|
* Sets the desired width in characters of @label to @n_chars.
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_label_set_width_chars (GtkLabel *self,
|
|
|
|
|
int n_chars)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
|
|
|
|
|
|
|
|
|
if (self->width_chars != n_chars)
|
2009-10-09 05:08:54 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
self->width_chars = n_chars;
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), label_props[PROP_WIDTH_CHARS]);
|
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (self));
|
2001-02-17 00:11:03 +00:00
|
|
|
|
}
|
2020-12-25 11:05:28 +00:00
|
|
|
|
}
|
2001-02-17 00:11:03 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_get_width_chars: (attributes org.gtk.Method.get_property=width-chars)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
|
|
|
|
*
|
|
|
|
|
* Retrieves the desired width of @label, in characters.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* See [method@Gtk.Label.set_width_chars].
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: the width of the label in characters.
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
int
|
|
|
|
|
gtk_label_get_width_chars (GtkLabel *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_LABEL (self), -1);
|
|
|
|
|
|
|
|
|
|
return self->width_chars;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_set_max_width_chars: (attributes org.gtk.Method.set_property=max-width-chars)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2020-12-25 11:05:28 +00:00
|
|
|
|
* @n_chars: the new desired maximum width, in characters.
|
|
|
|
|
*
|
|
|
|
|
* Sets the desired maximum width in characters of @label to @n_chars.
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_label_set_max_width_chars (GtkLabel *self,
|
|
|
|
|
int n_chars)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
|
|
|
|
|
|
|
|
|
if (self->max_width_chars != n_chars)
|
|
|
|
|
{
|
|
|
|
|
self->max_width_chars = n_chars;
|
|
|
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), label_props[PROP_MAX_WIDTH_CHARS]);
|
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (self));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_get_max_width_chars: (attributes org.gtk.Method.get_property=max-width-chars)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Retrieves the desired maximum width of @label, in characters.
|
|
|
|
|
*
|
|
|
|
|
* See [method@Gtk.Label.set_width_chars].
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: the maximum width of the label in characters.
|
|
|
|
|
**/
|
|
|
|
|
int
|
|
|
|
|
gtk_label_get_max_width_chars (GtkLabel *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_LABEL (self), -1);
|
2009-10-09 05:08:54 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return self->max_width_chars;
|
2001-02-17 00:11:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_set_wrap: (attributes org.gtk.Method.set_property=wrap)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2020-12-25 11:05:28 +00:00
|
|
|
|
* @wrap: the setting
|
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Toggles line wrapping within the `GtkLabel` widget.
|
|
|
|
|
*
|
|
|
|
|
* %TRUE makes it break lines if text exceeds the widget’s size.
|
|
|
|
|
* %FALSE lets the text get cut off by the edge of the widget if
|
|
|
|
|
* it exceeds the widget size.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
|
|
|
|
* Note that setting line wrapping to %TRUE does not make the label
|
|
|
|
|
* wrap at its parent container’s width, because GTK widgets
|
|
|
|
|
* conceptually can’t make their requisition depend on the parent
|
|
|
|
|
* container’s size. For a label that wraps at a specific position,
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* set the label’s width using [method@Gtk.Widget.set_size_request].
|
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_label_set_wrap (GtkLabel *self,
|
|
|
|
|
gboolean wrap)
|
2014-09-04 00:49:44 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
2014-09-04 00:49:44 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
wrap = wrap != FALSE;
|
2014-09-04 00:49:44 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (self->wrap != wrap)
|
|
|
|
|
{
|
|
|
|
|
self->wrap = wrap;
|
2014-09-04 00:49:44 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_label_clear_layout (self);
|
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (self));
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), label_props[PROP_WRAP]);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-09-04 00:49:44 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_get_wrap: (attributes org.gtk.Method.get_property=wrap)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns whether lines in the label are automatically wrapped.
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*
|
|
|
|
|
* See [method@Gtk.Label.set_wrap].
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the lines of the label are automatically wrapped.
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_label_get_wrap (GtkLabel *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_LABEL (self), FALSE);
|
2014-09-04 00:49:44 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return self->wrap;
|
|
|
|
|
}
|
2014-09-04 00:49:44 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_set_wrap_mode: (attributes org.gtk.Method.set_property=wrap-mode)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2020-12-25 11:05:28 +00:00
|
|
|
|
* @wrap_mode: the line wrapping mode
|
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Controls how line wrapping is done.
|
|
|
|
|
*
|
|
|
|
|
* This only affects the label if line wrapping is on. (See
|
|
|
|
|
* [method@Gtk.Label.set_wrap]) The default is %PANGO_WRAP_WORD
|
|
|
|
|
* which means wrap on word boundaries.
|
2021-12-19 18:22:31 +00:00
|
|
|
|
*
|
|
|
|
|
* For sizing behavior, also consider the [property@Gtk.Label:natural-wrap-mode]
|
|
|
|
|
* property.
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_label_set_wrap_mode (GtkLabel *self,
|
|
|
|
|
PangoWrapMode wrap_mode)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
2014-09-04 00:49:44 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (self->wrap_mode != wrap_mode)
|
|
|
|
|
{
|
|
|
|
|
self->wrap_mode = wrap_mode;
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), label_props[PROP_WRAP_MODE]);
|
2014-09-04 00:49:44 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (self));
|
|
|
|
|
}
|
2014-09-04 00:49:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_get_wrap_mode: (attributes org.gtk.Method.get_property=wrap-mode)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Returns line wrap mode used by the label.
|
|
|
|
|
*
|
|
|
|
|
* See [method@Gtk.Label.set_wrap_mode].
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-12-13 17:23:32 +00:00
|
|
|
|
* Returns: the line wrap mode
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*/
|
|
|
|
|
PangoWrapMode
|
|
|
|
|
gtk_label_get_wrap_mode (GtkLabel *self)
|
2014-09-04 01:39:34 +00:00
|
|
|
|
{
|
2021-12-13 17:23:32 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_LABEL (self), PANGO_WRAP_WORD);
|
2020-12-25 11:05:28 +00:00
|
|
|
|
|
|
|
|
|
return self->wrap_mode;
|
2014-09-04 01:39:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-19 18:22:31 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_label_set_natural_wrap_mode: (attributes org.gtk.Method.set_property=natural-wrap-mode)
|
|
|
|
|
* @self: a `GtkLabel`
|
|
|
|
|
* @wrap_mode: the line wrapping mode
|
|
|
|
|
*
|
|
|
|
|
* Select the line wrapping for the natural size request.
|
|
|
|
|
*
|
|
|
|
|
* This only affects the natural size requested, for the actual wrapping used,
|
|
|
|
|
* see the [property@Gtk.Label:wrap-mode] property.
|
|
|
|
|
*
|
|
|
|
|
* Since: 4.6
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_label_set_natural_wrap_mode (GtkLabel *self,
|
|
|
|
|
GtkNaturalWrapMode wrap_mode)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
|
|
|
|
|
|
|
|
|
if (self->natural_wrap_mode != wrap_mode)
|
|
|
|
|
{
|
|
|
|
|
self->natural_wrap_mode = wrap_mode;
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), label_props[PROP_NATURAL_WRAP_MODE]);
|
|
|
|
|
|
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (self));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_label_get_natural_wrap_mode: (attributes org.gtk.Method.get_property=natural-wrap-mode)
|
|
|
|
|
* @self: a `GtkLabel`
|
|
|
|
|
*
|
|
|
|
|
* Returns line wrap mode used by the label.
|
|
|
|
|
*
|
|
|
|
|
* See [method@Gtk.Label.set_natural_wrap_mode].
|
|
|
|
|
*
|
|
|
|
|
* Returns: the natural line wrap mode
|
|
|
|
|
*
|
|
|
|
|
* Since: 4.6
|
|
|
|
|
*/
|
|
|
|
|
GtkNaturalWrapMode
|
|
|
|
|
gtk_label_get_natural_wrap_mode (GtkLabel *self)
|
|
|
|
|
{
|
2021-12-22 16:38:05 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_LABEL (self), GTK_NATURAL_WRAP_INHERIT);
|
2021-12-19 18:22:31 +00:00
|
|
|
|
|
|
|
|
|
return self->natural_wrap_mode;
|
|
|
|
|
}
|
|
|
|
|
|
2001-09-19 00:49:52 +00:00
|
|
|
|
static void
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_label_clear_layout (GtkLabel *self)
|
2001-09-19 00:49:52 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_clear_object (&self->layout);
|
2001-09-19 00:49:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_ensure_layout (GtkLabel *self)
|
2005-12-26 07:02:51 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
PangoAlignment align;
|
|
|
|
|
gboolean rtl;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (self->layout)
|
|
|
|
|
return;
|
2005-12-26 07:02:51 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
rtl = _gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_RTL;
|
|
|
|
|
self->layout = gtk_widget_create_pango_layout (GTK_WIDGET (self), self->text);
|
2020-08-02 02:01:52 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_label_update_layout_attributes (self, NULL);
|
2005-12-26 07:02:51 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
switch (self->jtype)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
case GTK_JUSTIFY_LEFT:
|
|
|
|
|
align = rtl ? PANGO_ALIGN_RIGHT : PANGO_ALIGN_LEFT;
|
|
|
|
|
break;
|
|
|
|
|
case GTK_JUSTIFY_RIGHT:
|
|
|
|
|
align = rtl ? PANGO_ALIGN_LEFT : PANGO_ALIGN_RIGHT;
|
|
|
|
|
break;
|
|
|
|
|
case GTK_JUSTIFY_CENTER:
|
|
|
|
|
align = PANGO_ALIGN_CENTER;
|
|
|
|
|
break;
|
|
|
|
|
case GTK_JUSTIFY_FILL:
|
|
|
|
|
align = rtl ? PANGO_ALIGN_RIGHT : PANGO_ALIGN_LEFT;
|
|
|
|
|
pango_layout_set_justify (self->layout, TRUE);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached();
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
2020-04-10 13:41:56 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
pango_layout_set_alignment (self->layout, align);
|
|
|
|
|
pango_layout_set_ellipsize (self->layout, self->ellipsize);
|
|
|
|
|
pango_layout_set_wrap (self->layout, self->wrap_mode);
|
|
|
|
|
pango_layout_set_single_paragraph_mode (self->layout, self->single_line_mode);
|
|
|
|
|
if (self->lines > 0)
|
|
|
|
|
pango_layout_set_height (self->layout, - self->lines);
|
2019-10-15 13:34:16 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (self->ellipsize || self->wrap)
|
|
|
|
|
pango_layout_set_width (self->layout, gtk_widget_get_width (GTK_WIDGET (self)) * PANGO_SCALE);
|
2022-07-31 15:40:20 +00:00
|
|
|
|
|
|
|
|
|
pango_layout_set_tabs (self->layout, self->tabs);
|
2005-12-26 07:02:51 +00:00
|
|
|
|
}
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_label_set_text_with_mnemonic:
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2020-12-25 11:05:28 +00:00
|
|
|
|
* @str: a string
|
|
|
|
|
*
|
|
|
|
|
* Sets the label’s text from the string @str.
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*
|
2020-12-25 11:05:28 +00:00
|
|
|
|
* If characters in @str are preceded by an underscore, they are underlined
|
|
|
|
|
* indicating that they represent a keyboard accelerator called a mnemonic.
|
|
|
|
|
* The mnemonic key can be used to activate another widget, chosen
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* automatically, or explicitly using [method@Gtk.Label.set_mnemonic_widget].
|
|
|
|
|
*/
|
2020-12-25 11:05:28 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_label_set_text_with_mnemonic (GtkLabel *self,
|
|
|
|
|
const char *str)
|
|
|
|
|
{
|
|
|
|
|
gboolean changed;
|
2017-02-08 14:40:06 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
|
|
|
|
g_return_if_fail (str != NULL);
|
2001-02-17 00:11:03 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_object_freeze_notify (G_OBJECT (self));
|
2009-01-22 00:33:54 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
changed = gtk_label_set_label_internal (self, str);
|
|
|
|
|
changed = gtk_label_set_use_markup_internal (self, FALSE) || changed;
|
|
|
|
|
changed = gtk_label_set_use_underline_internal (self, TRUE) || changed;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (changed)
|
|
|
|
|
gtk_label_recalculate (self);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
g_object_thaw_notify (G_OBJECT (self));
|
|
|
|
|
}
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static int
|
|
|
|
|
gtk_label_move_forward_word (GtkLabel *self,
|
|
|
|
|
int start)
|
|
|
|
|
{
|
|
|
|
|
int new_pos = g_utf8_pointer_to_offset (self->text, self->text + start);
|
|
|
|
|
int length;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
length = g_utf8_strlen (self->text, -1);
|
|
|
|
|
if (new_pos < length)
|
|
|
|
|
{
|
|
|
|
|
const PangoLogAttr *log_attrs;
|
|
|
|
|
int n_attrs;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_label_ensure_layout (self);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
log_attrs = pango_layout_get_log_attrs_readonly (self->layout, &n_attrs);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/* Find the next word end */
|
|
|
|
|
new_pos++;
|
|
|
|
|
while (new_pos < n_attrs && !log_attrs[new_pos].is_word_end)
|
|
|
|
|
new_pos++;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
2020-04-10 13:41:56 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return g_utf8_offset_to_pointer (self->text, new_pos) - self->text;
|
|
|
|
|
}
|
2020-04-30 08:03:11 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static int
|
|
|
|
|
gtk_label_move_backward_word (GtkLabel *self,
|
|
|
|
|
int start)
|
|
|
|
|
{
|
|
|
|
|
int new_pos = g_utf8_pointer_to_offset (self->text, self->text + start);
|
2020-04-10 13:41:56 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
if (new_pos > 0)
|
|
|
|
|
{
|
|
|
|
|
const PangoLogAttr *log_attrs;
|
|
|
|
|
int n_attrs;
|
2020-04-30 08:03:11 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
gtk_label_ensure_layout (self);
|
2020-04-10 13:41:56 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
log_attrs = pango_layout_get_log_attrs_readonly (self->layout, &n_attrs);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
new_pos -= 1;
|
2020-04-10 13:41:56 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
/* Find the previous word beginning */
|
|
|
|
|
while (new_pos > 0 && !log_attrs[new_pos].is_word_start)
|
|
|
|
|
new_pos--;
|
|
|
|
|
}
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return g_utf8_offset_to_pointer (self->text, new_pos) - self->text;
|
|
|
|
|
}
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_select_word (GtkLabel *self)
|
|
|
|
|
{
|
|
|
|
|
int min, max;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
int start_index = gtk_label_move_backward_word (self, self->select_info->selection_end);
|
|
|
|
|
int end_index = gtk_label_move_forward_word (self, self->select_info->selection_end);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
min = MIN (self->select_info->selection_anchor,
|
|
|
|
|
self->select_info->selection_end);
|
|
|
|
|
max = MAX (self->select_info->selection_anchor,
|
|
|
|
|
self->select_info->selection_end);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
min = MIN (min, start_index);
|
|
|
|
|
max = MAX (max, end_index);
|
|
|
|
|
|
|
|
|
|
gtk_label_select_region_index (self, min, max);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-05 13:36:15 +00:00
|
|
|
|
static void
|
2019-05-29 17:10:46 +00:00
|
|
|
|
gtk_label_click_gesture_pressed (GtkGestureClick *gesture,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int n_press,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double widget_x,
|
|
|
|
|
double widget_y,
|
2020-04-13 06:56:33 +00:00
|
|
|
|
GtkLabel *self)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
GtkLabelSelectionInfo *info = self->select_info;
|
|
|
|
|
GtkWidget *widget = GTK_WIDGET (self);
|
2014-06-05 13:36:15 +00:00
|
|
|
|
GdkEventSequence *sequence;
|
2020-02-16 16:09:02 +00:00
|
|
|
|
GdkEvent *event;
|
2014-06-05 13:36:15 +00:00
|
|
|
|
guint button;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2014-06-05 13:36:15 +00:00
|
|
|
|
button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
|
|
|
|
|
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
|
|
|
|
|
event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
|
2017-07-25 14:18:07 +00:00
|
|
|
|
gtk_label_update_active_link (widget, widget_x, widget_y);
|
2014-06-05 13:36:15 +00:00
|
|
|
|
|
|
|
|
|
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
|
|
|
|
if (info->active_link)
|
2001-02-17 00:11:03 +00:00
|
|
|
|
{
|
2014-06-05 13:36:15 +00:00
|
|
|
|
if (gdk_event_triggers_context_menu (event))
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2019-09-29 07:31:45 +00:00
|
|
|
|
info->link_clicked = TRUE;
|
2020-04-13 06:56:33 +00:00
|
|
|
|
update_link_state (self);
|
|
|
|
|
gtk_label_do_popup (self, widget_x, widget_y);
|
2014-06-05 13:36:15 +00:00
|
|
|
|
return;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
2014-06-05 13:36:15 +00:00
|
|
|
|
else if (button == GDK_BUTTON_PRIMARY)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2019-09-29 07:31:45 +00:00
|
|
|
|
info->link_clicked = TRUE;
|
2020-04-13 06:56:33 +00:00
|
|
|
|
update_link_state (self);
|
2011-09-18 22:32:52 +00:00
|
|
|
|
gtk_widget_queue_draw (widget);
|
2013-03-21 17:39:06 +00:00
|
|
|
|
if (!info->selectable)
|
2014-06-05 13:36:15 +00:00
|
|
|
|
return;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!info->selectable)
|
2014-06-05 13:36:15 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_DENIED);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
|
|
|
|
info->in_drag = FALSE;
|
|
|
|
|
info->select_words = FALSE;
|
|
|
|
|
|
2016-04-18 18:48:53 +00:00
|
|
|
|
if (gdk_event_triggers_context_menu (event))
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_do_popup (self, widget_x, widget_y);
|
2014-06-05 13:36:15 +00:00
|
|
|
|
else if (button == GDK_BUTTON_PRIMARY)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2010-03-01 03:21:41 +00:00
|
|
|
|
if (!gtk_widget_has_focus (widget))
|
2011-06-01 05:08:13 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
self->in_click = TRUE;
|
2011-06-01 05:08:13 +00:00
|
|
|
|
gtk_widget_grab_focus (widget);
|
2020-04-13 06:56:33 +00:00
|
|
|
|
self->in_click = FALSE;
|
2011-06-01 05:08:13 +00:00
|
|
|
|
}
|
2001-02-17 00:11:03 +00:00
|
|
|
|
|
2014-06-05 13:36:15 +00:00
|
|
|
|
if (n_press == 3)
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_select_region_index (self, 0, strlen (self->text));
|
2014-06-05 13:36:15 +00:00
|
|
|
|
else if (n_press == 2)
|
2011-06-01 05:08:13 +00:00
|
|
|
|
{
|
2009-05-11 05:23:13 +00:00
|
|
|
|
info->select_words = TRUE;
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_select_word (self);
|
2011-06-01 05:08:13 +00:00
|
|
|
|
}
|
2001-02-17 00:11:03 +00:00
|
|
|
|
}
|
2014-12-26 22:04:37 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_DENIED);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2014-06-05 13:36:15 +00:00
|
|
|
|
if (n_press >= 3)
|
|
|
|
|
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
|
2001-02-17 00:11:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-05 13:36:15 +00:00
|
|
|
|
static void
|
2019-05-29 17:10:46 +00:00
|
|
|
|
gtk_label_click_gesture_released (GtkGestureClick *gesture,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int n_press,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double x,
|
|
|
|
|
double y,
|
2020-04-13 06:56:33 +00:00
|
|
|
|
GtkLabel *self)
|
2001-02-17 00:11:03 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
GtkLabelSelectionInfo *info = self->select_info;
|
2014-06-05 13:36:15 +00:00
|
|
|
|
GdkEventSequence *sequence;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int index;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
|
|
|
|
if (info == NULL)
|
2014-06-05 13:36:15 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
|
|
|
|
|
|
|
|
|
|
if (!gtk_gesture_handles_sequence (GTK_GESTURE (gesture), sequence))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (n_press != 1)
|
|
|
|
|
return;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
|
|
|
|
if (info->in_drag)
|
2004-11-12 21:52:04 +00:00
|
|
|
|
{
|
2022-10-19 20:21:36 +00:00
|
|
|
|
info->in_drag = FALSE;
|
2020-04-13 06:56:33 +00:00
|
|
|
|
get_layout_index (self, x, y, &index);
|
|
|
|
|
gtk_label_select_region_index (self, index, index);
|
2004-11-12 21:52:04 +00:00
|
|
|
|
}
|
2014-06-05 13:36:15 +00:00
|
|
|
|
else if (info->active_link &&
|
|
|
|
|
info->selection_anchor == info->selection_end &&
|
|
|
|
|
info->link_clicked)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
emit_activate_link (self, info->active_link);
|
2019-09-29 07:31:45 +00:00
|
|
|
|
info->link_clicked = FALSE;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
2001-02-17 00:11:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-31 02:43:22 +00:00
|
|
|
|
static GdkPaintable *
|
2020-04-13 06:56:33 +00:00
|
|
|
|
get_selection_paintable (GtkLabel *self)
|
2005-07-11 17:51:54 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if ((self->select_info->selection_anchor !=
|
|
|
|
|
self->select_info->selection_end) &&
|
|
|
|
|
self->text)
|
2005-07-11 17:51:54 +00:00
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int start, end;
|
|
|
|
|
int len;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
start = MIN (self->select_info->selection_anchor,
|
|
|
|
|
self->select_info->selection_end);
|
|
|
|
|
end = MAX (self->select_info->selection_anchor,
|
|
|
|
|
self->select_info->selection_end);
|
2010-06-24 02:36:08 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
len = strlen (self->text);
|
2010-06-24 02:36:08 +00:00
|
|
|
|
|
2005-07-11 17:51:54 +00:00
|
|
|
|
if (end > len)
|
|
|
|
|
end = len;
|
2011-02-03 03:05:26 +00:00
|
|
|
|
|
2005-07-11 17:51:54 +00:00
|
|
|
|
if (start > len)
|
|
|
|
|
start = len;
|
2011-02-03 03:05:26 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
return gtk_text_util_create_drag_icon (GTK_WIDGET (self), self->text + start, end - start);
|
2005-07-11 17:51:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-31 02:43:22 +00:00
|
|
|
|
return NULL;
|
2005-07-11 17:51:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-05 13:36:15 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_drag_gesture_begin (GtkGestureDrag *gesture,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double start_x,
|
|
|
|
|
double start_y,
|
2020-04-13 06:56:33 +00:00
|
|
|
|
GtkLabel *self)
|
2001-02-17 00:11:03 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
GtkLabelSelectionInfo *info = self->select_info;
|
2014-06-05 13:36:15 +00:00
|
|
|
|
GdkModifierType state_mask;
|
|
|
|
|
GdkEventSequence *sequence;
|
2020-02-16 16:09:02 +00:00
|
|
|
|
GdkEvent *event;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int min, max, index;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2015-12-23 00:51:30 +00:00
|
|
|
|
if (!info || !info->selectable)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2014-06-05 13:36:15 +00:00
|
|
|
|
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_DENIED);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
get_layout_index (self, start_x, start_y, &index);
|
2014-06-05 13:36:15 +00:00
|
|
|
|
min = MIN (info->selection_anchor, info->selection_end);
|
|
|
|
|
max = MAX (info->selection_anchor, info->selection_end);
|
|
|
|
|
|
|
|
|
|
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
|
|
|
|
|
event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
|
2020-02-18 03:11:56 +00:00
|
|
|
|
state_mask = gdk_event_get_modifier_state (event);
|
2014-06-05 13:36:15 +00:00
|
|
|
|
|
|
|
|
|
if ((info->selection_anchor != info->selection_end) &&
|
2022-10-19 20:21:36 +00:00
|
|
|
|
((state_mask & GDK_SHIFT_MASK) != 0))
|
2014-06-05 13:36:15 +00:00
|
|
|
|
{
|
|
|
|
|
if (index > min && index < max)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2014-06-05 13:36:15 +00:00
|
|
|
|
/* truncate selection, but keep it as big as possible */
|
|
|
|
|
if (index - min > max - index)
|
|
|
|
|
max = index;
|
|
|
|
|
else
|
|
|
|
|
min = index;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* extend (same as motion) */
|
|
|
|
|
min = MIN (min, index);
|
|
|
|
|
max = MAX (max, index);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-05 13:36:15 +00:00
|
|
|
|
/* ensure the anchor is opposite index */
|
|
|
|
|
if (index == min)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int tmp = min;
|
2014-06-05 13:36:15 +00:00
|
|
|
|
min = max;
|
|
|
|
|
max = tmp;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
2014-06-05 13:36:15 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_select_region_index (self, min, max);
|
2014-06-05 13:36:15 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (min < max && min <= index && index <= max)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2022-10-19 20:21:36 +00:00
|
|
|
|
if (!info->select_words)
|
|
|
|
|
info->in_drag = TRUE;
|
2014-06-05 13:36:15 +00:00
|
|
|
|
info->drag_start_x = start_x;
|
|
|
|
|
info->drag_start_y = start_y;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
2014-06-05 13:36:15 +00:00
|
|
|
|
else
|
|
|
|
|
/* start a replacement */
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_select_region_index (self, index, index);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
2014-06-05 13:36:15 +00:00
|
|
|
|
}
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2014-06-05 13:36:15 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_drag_gesture_update (GtkGestureDrag *gesture,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double offset_x,
|
|
|
|
|
double offset_y,
|
2020-04-13 06:56:33 +00:00
|
|
|
|
GtkLabel *self)
|
2014-06-05 13:36:15 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
GtkLabelSelectionInfo *info = self->select_info;
|
|
|
|
|
GtkWidget *widget = GTK_WIDGET (self);
|
2014-06-05 13:36:15 +00:00
|
|
|
|
GdkEventSequence *sequence;
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double x, y;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int index;
|
2001-02-17 00:11:03 +00:00
|
|
|
|
|
2014-06-05 13:36:15 +00:00
|
|
|
|
if (info == NULL || !info->selectable)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
|
|
|
|
|
gtk_gesture_get_point (GTK_GESTURE (gesture), sequence, &x, &y);
|
2001-02-17 00:11:03 +00:00
|
|
|
|
|
2009-05-11 05:23:13 +00:00
|
|
|
|
if (info->in_drag)
|
2004-11-12 21:52:04 +00:00
|
|
|
|
{
|
2020-12-25 17:57:48 +00:00
|
|
|
|
if (gtk_drag_check_threshold_double (widget, info->drag_start_x, info->drag_start_y, x, y))
|
2020-12-25 11:05:28 +00:00
|
|
|
|
{
|
2020-01-06 21:00:32 +00:00
|
|
|
|
GdkDrag *drag;
|
|
|
|
|
GdkSurface *surface;
|
2019-12-31 02:43:22 +00:00
|
|
|
|
GdkDevice *device;
|
|
|
|
|
|
2020-01-06 21:00:32 +00:00
|
|
|
|
surface = gtk_native_get_surface (gtk_widget_get_native (widget));
|
2019-12-31 02:43:22 +00:00
|
|
|
|
device = gtk_gesture_get_device (GTK_GESTURE (gesture));
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-01-06 21:00:32 +00:00
|
|
|
|
drag = gdk_drag_begin (surface,
|
|
|
|
|
device,
|
|
|
|
|
info->provider,
|
|
|
|
|
GDK_ACTION_COPY,
|
|
|
|
|
info->drag_start_x,
|
|
|
|
|
info->drag_start_y);
|
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_drag_icon_set_from_paintable (drag, get_selection_paintable (self), 0, 0);
|
2020-01-06 21:00:32 +00:00
|
|
|
|
|
|
|
|
|
g_object_unref (drag);
|
2020-12-25 11:05:28 +00:00
|
|
|
|
info->in_drag = FALSE;
|
|
|
|
|
}
|
2004-11-12 21:52:04 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
get_layout_index (self, x, y, &index);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2014-06-05 13:36:15 +00:00
|
|
|
|
if (index != info->selection_anchor)
|
|
|
|
|
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
|
|
|
|
|
|
2009-05-11 05:23:13 +00:00
|
|
|
|
if (info->select_words)
|
2009-01-22 00:33:54 +00:00
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int min, max;
|
|
|
|
|
int old_min, old_max;
|
|
|
|
|
int anchor, end;
|
2009-01-22 00:33:54 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
min = gtk_label_move_backward_word (self, index);
|
|
|
|
|
max = gtk_label_move_forward_word (self, index);
|
2009-01-22 00:33:54 +00:00
|
|
|
|
|
2009-05-11 05:23:13 +00:00
|
|
|
|
anchor = info->selection_anchor;
|
|
|
|
|
end = info->selection_end;
|
2009-01-22 00:33:54 +00:00
|
|
|
|
|
|
|
|
|
old_min = MIN (anchor, end);
|
|
|
|
|
old_max = MAX (anchor, end);
|
|
|
|
|
|
|
|
|
|
if (min < old_min)
|
|
|
|
|
{
|
|
|
|
|
anchor = min;
|
|
|
|
|
end = old_max;
|
|
|
|
|
}
|
|
|
|
|
else if (old_max < max)
|
|
|
|
|
{
|
|
|
|
|
anchor = max;
|
|
|
|
|
end = old_min;
|
|
|
|
|
}
|
|
|
|
|
else if (anchor == old_min)
|
|
|
|
|
{
|
|
|
|
|
if (anchor != min)
|
|
|
|
|
anchor = max;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (anchor != max)
|
|
|
|
|
anchor = min;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_select_region_index (self, anchor, end);
|
2009-01-22 00:33:54 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_select_region_index (self, info->selection_anchor, index);
|
2004-11-12 21:52:04 +00:00
|
|
|
|
}
|
2014-06-05 13:36:15 +00:00
|
|
|
|
}
|
2001-02-17 00:11:03 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_update_actions (GtkLabel *self)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *widget = GTK_WIDGET (self);
|
|
|
|
|
gboolean has_selection;
|
|
|
|
|
GtkLabelLink *link;
|
|
|
|
|
|
|
|
|
|
if (self->select_info)
|
|
|
|
|
{
|
|
|
|
|
has_selection = self->select_info->selection_anchor != self->select_info->selection_end;
|
|
|
|
|
link = self->select_info->active_link;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
has_selection = FALSE;
|
|
|
|
|
link = gtk_label_get_focus_link (self, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_widget_action_set_enabled (widget, "clipboard.cut", FALSE);
|
|
|
|
|
gtk_widget_action_set_enabled (widget, "clipboard.copy", has_selection);
|
|
|
|
|
gtk_widget_action_set_enabled (widget, "clipboard.paste", FALSE);
|
|
|
|
|
gtk_widget_action_set_enabled (widget, "selection.select-all",
|
|
|
|
|
gtk_label_get_selectable (self));
|
|
|
|
|
gtk_widget_action_set_enabled (widget, "selection.delete", FALSE);
|
|
|
|
|
gtk_widget_action_set_enabled (widget, "link.open", !has_selection && link);
|
|
|
|
|
gtk_widget_action_set_enabled (widget, "link.copy", !has_selection && link);
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-25 14:18:07 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_update_active_link (GtkWidget *widget,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double x,
|
|
|
|
|
double y)
|
2014-06-05 13:36:15 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
GtkLabel *self = GTK_LABEL (widget);
|
|
|
|
|
GtkLabelSelectionInfo *info = self->select_info;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int index;
|
2014-06-05 13:36:15 +00:00
|
|
|
|
|
|
|
|
|
if (info == NULL)
|
2017-07-25 14:18:07 +00:00
|
|
|
|
return;
|
2014-06-05 13:36:15 +00:00
|
|
|
|
|
|
|
|
|
if (info->links && !info->in_drag)
|
|
|
|
|
{
|
|
|
|
|
GtkLabelLink *link;
|
|
|
|
|
gboolean found = FALSE;
|
|
|
|
|
|
|
|
|
|
if (info->selection_anchor == info->selection_end)
|
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (get_layout_index (self, x, y, &index))
|
2014-06-05 13:36:15 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
const int link_index = _gtk_label_get_link_at (self, index);
|
2020-04-10 13:41:56 +00:00
|
|
|
|
|
|
|
|
|
if (link_index != -1)
|
2014-06-05 13:36:15 +00:00
|
|
|
|
{
|
2020-04-10 13:41:56 +00:00
|
|
|
|
link = &info->links[link_index];
|
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (!range_is_in_ellipsis (self, link->start, link->end))
|
2020-04-10 13:41:56 +00:00
|
|
|
|
found = TRUE;
|
2014-06-05 13:36:15 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (found)
|
|
|
|
|
{
|
|
|
|
|
if (info->active_link != link)
|
|
|
|
|
{
|
2019-09-29 07:31:45 +00:00
|
|
|
|
info->link_clicked = FALSE;
|
2014-06-05 13:36:15 +00:00
|
|
|
|
info->active_link = link;
|
2020-04-13 06:56:33 +00:00
|
|
|
|
update_link_state (self);
|
|
|
|
|
gtk_label_update_cursor (self);
|
2014-06-05 13:36:15 +00:00
|
|
|
|
gtk_widget_queue_draw (widget);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (info->active_link != NULL)
|
|
|
|
|
{
|
2019-09-29 07:31:45 +00:00
|
|
|
|
info->link_clicked = FALSE;
|
2014-06-05 13:36:15 +00:00
|
|
|
|
info->active_link = NULL;
|
2020-04-13 06:56:33 +00:00
|
|
|
|
update_link_state (self);
|
|
|
|
|
gtk_label_update_cursor (self);
|
2014-06-05 13:36:15 +00:00
|
|
|
|
gtk_widget_queue_draw (widget);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-06-15 00:05:51 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_update_actions (self);
|
2014-06-05 13:36:15 +00:00
|
|
|
|
}
|
2017-07-25 14:18:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-11 23:30:22 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_label_motion (GtkEventControllerMotion *controller,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
gpointer data)
|
2017-07-25 14:18:07 +00:00
|
|
|
|
{
|
2017-12-11 23:30:22 +00:00
|
|
|
|
gtk_label_update_active_link (GTK_WIDGET (data), x, y);
|
2001-02-17 00:11:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-11 23:30:22 +00:00
|
|
|
|
static void
|
2020-02-20 03:04:28 +00:00
|
|
|
|
gtk_label_leave (GtkEventControllerMotion *controller,
|
|
|
|
|
gpointer data)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
GtkLabel *self = GTK_LABEL (data);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self->select_info)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
self->select_info->active_link = NULL;
|
|
|
|
|
gtk_label_update_cursor (self);
|
|
|
|
|
gtk_widget_queue_draw (GTK_WIDGET (self));
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-28 01:36:16 +00:00
|
|
|
|
#define GTK_TYPE_LABEL_CONTENT (gtk_label_content_get_type ())
|
|
|
|
|
#define GTK_LABEL_CONTENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_LABEL_CONTENT, GtkLabelContent))
|
|
|
|
|
#define GTK_IS_LABEL_CONTENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_LABEL_CONTENT))
|
|
|
|
|
#define GTK_LABEL_CONTENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_LABEL_CONTENT, GtkLabelContentClass))
|
|
|
|
|
#define GTK_IS_LABEL_CONTENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_LABEL_CONTENT))
|
|
|
|
|
#define GTK_LABEL_CONTENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_LABEL_CONTENT, GtkLabelContentClass))
|
|
|
|
|
|
|
|
|
|
typedef struct _GtkLabelContent GtkLabelContent;
|
|
|
|
|
typedef struct _GtkLabelContentClass GtkLabelContentClass;
|
|
|
|
|
|
|
|
|
|
struct _GtkLabelContent
|
|
|
|
|
{
|
|
|
|
|
GdkContentProvider parent;
|
|
|
|
|
|
|
|
|
|
GtkLabel *label;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct _GtkLabelContentClass
|
|
|
|
|
{
|
|
|
|
|
GdkContentProviderClass parent_class;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GType gtk_label_content_get_type (void) G_GNUC_CONST;
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GtkLabelContent, gtk_label_content, GDK_TYPE_CONTENT_PROVIDER)
|
|
|
|
|
|
|
|
|
|
static GdkContentFormats *
|
|
|
|
|
gtk_label_content_ref_formats (GdkContentProvider *provider)
|
|
|
|
|
{
|
|
|
|
|
GtkLabelContent *content = GTK_LABEL_CONTENT (provider);
|
|
|
|
|
|
|
|
|
|
if (content->label)
|
|
|
|
|
return gdk_content_formats_new_for_gtype (G_TYPE_STRING);
|
|
|
|
|
else
|
|
|
|
|
return gdk_content_formats_new (NULL, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gtk_label_content_get_value (GdkContentProvider *provider,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
GtkLabelContent *content = GTK_LABEL_CONTENT (provider);
|
|
|
|
|
|
|
|
|
|
if (G_VALUE_HOLDS (value, G_TYPE_STRING) &&
|
|
|
|
|
content->label != NULL)
|
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
GtkLabel *self = content->label;
|
2017-11-28 01:36:16 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self->select_info &&
|
|
|
|
|
(self->select_info->selection_anchor !=
|
|
|
|
|
self->select_info->selection_end) &&
|
|
|
|
|
self->text)
|
2017-11-28 01:36:16 +00:00
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int start, end;
|
|
|
|
|
int len;
|
2017-11-28 01:36:16 +00:00
|
|
|
|
char *str;
|
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
start = MIN (self->select_info->selection_anchor,
|
|
|
|
|
self->select_info->selection_end);
|
|
|
|
|
end = MAX (self->select_info->selection_anchor,
|
|
|
|
|
self->select_info->selection_end);
|
2017-11-28 01:36:16 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
len = strlen (self->text);
|
2017-11-28 01:36:16 +00:00
|
|
|
|
|
|
|
|
|
if (end > len)
|
|
|
|
|
end = len;
|
|
|
|
|
|
|
|
|
|
if (start > len)
|
|
|
|
|
start = len;
|
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
str = g_strndup (self->text + start, end - start);
|
2017-11-28 01:36:16 +00:00
|
|
|
|
g_value_take_string (value, str);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return GDK_CONTENT_PROVIDER_CLASS (gtk_label_content_parent_class)->get_value (provider, value, error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_label_content_detach (GdkContentProvider *provider,
|
|
|
|
|
GdkClipboard *clipboard)
|
|
|
|
|
{
|
|
|
|
|
GtkLabelContent *content = GTK_LABEL_CONTENT (provider);
|
2020-04-13 06:56:33 +00:00
|
|
|
|
GtkLabel *self = content->label;
|
2017-11-28 01:36:16 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self == NULL || self->select_info == NULL)
|
2017-11-28 01:36:16 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
self->select_info->selection_anchor = self->select_info->selection_end;
|
2017-11-28 01:36:16 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_widget_queue_draw (GTK_WIDGET (self));
|
2017-11-28 01:36:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_label_content_class_init (GtkLabelContentClass *class)
|
|
|
|
|
{
|
|
|
|
|
GdkContentProviderClass *provider_class = GDK_CONTENT_PROVIDER_CLASS (class);
|
|
|
|
|
|
|
|
|
|
provider_class->ref_formats = gtk_label_content_ref_formats;
|
|
|
|
|
provider_class->get_value = gtk_label_content_get_value;
|
|
|
|
|
provider_class->detach_clipboard = gtk_label_content_detach;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_label_content_init (GtkLabelContent *content)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-02 15:24:27 +00:00
|
|
|
|
static void
|
|
|
|
|
focus_change (GtkEventControllerFocus *controller,
|
|
|
|
|
GtkLabel *self)
|
|
|
|
|
{
|
|
|
|
|
gtk_widget_queue_draw (GTK_WIDGET (self));
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-11 05:23:13 +00:00
|
|
|
|
static void
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_ensure_select_info (GtkLabel *self)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self->select_info == NULL)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
self->select_info = g_new0 (GtkLabelSelectionInfo, 1);
|
|
|
|
|
|
2020-05-05 18:57:21 +00:00
|
|
|
|
gtk_widget_set_focusable (GTK_WIDGET (self), TRUE);
|
2020-04-13 06:56:33 +00:00
|
|
|
|
|
|
|
|
|
self->select_info->drag_gesture = gtk_gesture_drag_new ();
|
|
|
|
|
g_signal_connect (self->select_info->drag_gesture, "drag-begin",
|
|
|
|
|
G_CALLBACK (gtk_label_drag_gesture_begin), self);
|
|
|
|
|
g_signal_connect (self->select_info->drag_gesture, "drag-update",
|
|
|
|
|
G_CALLBACK (gtk_label_drag_gesture_update), self);
|
|
|
|
|
gtk_gesture_single_set_exclusive (GTK_GESTURE_SINGLE (self->select_info->drag_gesture), TRUE);
|
|
|
|
|
gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (self->select_info->drag_gesture));
|
|
|
|
|
|
|
|
|
|
self->select_info->click_gesture = gtk_gesture_click_new ();
|
|
|
|
|
g_signal_connect (self->select_info->click_gesture, "pressed",
|
|
|
|
|
G_CALLBACK (gtk_label_click_gesture_pressed), self);
|
|
|
|
|
g_signal_connect (self->select_info->click_gesture, "released",
|
|
|
|
|
G_CALLBACK (gtk_label_click_gesture_released), self);
|
|
|
|
|
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (self->select_info->click_gesture), 0);
|
|
|
|
|
gtk_gesture_single_set_exclusive (GTK_GESTURE_SINGLE (self->select_info->click_gesture), TRUE);
|
|
|
|
|
gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (self->select_info->click_gesture));
|
|
|
|
|
|
|
|
|
|
self->select_info->motion_controller = gtk_event_controller_motion_new ();
|
|
|
|
|
g_signal_connect (self->select_info->motion_controller, "motion",
|
|
|
|
|
G_CALLBACK (gtk_label_motion), self);
|
|
|
|
|
g_signal_connect (self->select_info->motion_controller, "leave",
|
|
|
|
|
G_CALLBACK (gtk_label_leave), self);
|
|
|
|
|
gtk_widget_add_controller (GTK_WIDGET (self), self->select_info->motion_controller);
|
|
|
|
|
|
2020-08-02 15:24:27 +00:00
|
|
|
|
self->select_info->focus_controller = gtk_event_controller_focus_new ();
|
|
|
|
|
g_signal_connect (self->select_info->focus_controller, "enter",
|
|
|
|
|
G_CALLBACK (focus_change), self);
|
|
|
|
|
g_signal_connect (self->select_info->focus_controller, "leave",
|
|
|
|
|
G_CALLBACK (focus_change), self);
|
|
|
|
|
gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (self->select_info->focus_controller));
|
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
self->select_info->provider = g_object_new (GTK_TYPE_LABEL_CONTENT, NULL);
|
|
|
|
|
GTK_LABEL_CONTENT (self->select_info->provider)->label = self;
|
|
|
|
|
|
|
|
|
|
gtk_label_update_cursor (self);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_clear_select_info (GtkLabel *self)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self->select_info == NULL)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (!self->select_info->selectable && !self->select_info->links)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_widget_remove_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (self->select_info->drag_gesture));
|
|
|
|
|
gtk_widget_remove_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (self->select_info->click_gesture));
|
|
|
|
|
gtk_widget_remove_controller (GTK_WIDGET (self), self->select_info->motion_controller);
|
2020-08-02 15:24:27 +00:00
|
|
|
|
gtk_widget_remove_controller (GTK_WIDGET (self), self->select_info->focus_controller);
|
2020-04-13 06:56:33 +00:00
|
|
|
|
GTK_LABEL_CONTENT (self->select_info->provider)->label = NULL;
|
|
|
|
|
g_object_unref (self->select_info->provider);
|
2015-11-20 15:06:10 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_free (self->select_info);
|
|
|
|
|
self->select_info = NULL;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_widget_set_cursor (GTK_WIDGET (self), NULL);
|
2017-04-02 11:33:12 +00:00
|
|
|
|
|
2020-05-05 18:57:21 +00:00
|
|
|
|
gtk_widget_set_focusable (GTK_WIDGET (self), FALSE);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-15 18:25:42 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_set_selectable: (attributes org.gtk.Method.set_property=selectable)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2001-06-15 18:25:42 +00:00
|
|
|
|
* @setting: %TRUE to allow selecting text in the label
|
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Makes text in the label selectable.
|
|
|
|
|
*
|
|
|
|
|
* Selectable labels allow the user to select text from the label,
|
|
|
|
|
* for copy-and-paste.
|
|
|
|
|
*/
|
2001-02-17 00:11:03 +00:00
|
|
|
|
void
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_set_selectable (GtkLabel *self,
|
2001-02-17 00:11:03 +00:00
|
|
|
|
gboolean setting)
|
|
|
|
|
{
|
2001-02-20 15:36:28 +00:00
|
|
|
|
gboolean old_setting;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2001-02-17 00:11:03 +00:00
|
|
|
|
setting = setting != FALSE;
|
2020-04-13 06:56:33 +00:00
|
|
|
|
old_setting = self->select_info && self->select_info->selectable;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2001-02-17 00:11:03 +00:00
|
|
|
|
if (setting)
|
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_ensure_select_info (self);
|
|
|
|
|
self->select_info->selectable = TRUE;
|
|
|
|
|
gtk_label_update_cursor (self);
|
2001-02-17 00:11:03 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-05-11 05:23:13 +00:00
|
|
|
|
if (old_setting)
|
2001-02-17 00:11:03 +00:00
|
|
|
|
{
|
2001-06-01 19:26:01 +00:00
|
|
|
|
/* unselect, to give up the selection */
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_select_region (self, 0, 0);
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
self->select_info->selectable = FALSE;
|
|
|
|
|
gtk_label_clear_select_info (self);
|
2001-02-17 00:11:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2001-02-20 15:36:28 +00:00
|
|
|
|
if (setting != old_setting)
|
2001-03-05 14:08:42 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_object_freeze_notify (G_OBJECT (self));
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), label_props[PROP_SELECTABLE]);
|
|
|
|
|
g_object_thaw_notify (G_OBJECT (self));
|
|
|
|
|
gtk_widget_queue_draw (GTK_WIDGET (self));
|
2001-03-05 14:08:42 +00:00
|
|
|
|
}
|
2001-02-17 00:11:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-06-15 18:25:42 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_get_selectable: (attributes org.gtk.Method.get_property=selectable)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Returns whether the label is selectable.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE if the user can copy text from the label
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*/
|
2001-02-17 00:11:03 +00:00
|
|
|
|
gboolean
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_get_selectable (GtkLabel *self)
|
2001-02-17 00:11:03 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_LABEL (self), FALSE);
|
2001-02-17 00:11:03 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
return self->select_info && self->select_info->selectable;
|
2001-02-17 00:11:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_select_region_index (GtkLabel *self,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int anchor_index,
|
|
|
|
|
int end_index)
|
2001-02-17 00:11:03 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
2010-06-24 02:36:08 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self->select_info && self->select_info->selectable)
|
2001-02-17 00:11:03 +00:00
|
|
|
|
{
|
2017-11-28 01:36:16 +00:00
|
|
|
|
GdkClipboard *clipboard;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int s, e;
|
2014-09-04 02:18:49 +00:00
|
|
|
|
|
|
|
|
|
/* Ensure that we treat an ellipsized region like a single
|
|
|
|
|
* character with respect to selection.
|
|
|
|
|
*/
|
|
|
|
|
if (anchor_index < end_index)
|
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (range_is_in_ellipsis_full (self, anchor_index, anchor_index + 1, &s, &e))
|
2014-09-04 02:18:49 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self->select_info->selection_anchor == s)
|
2014-09-04 02:18:49 +00:00
|
|
|
|
anchor_index = e;
|
|
|
|
|
else
|
|
|
|
|
anchor_index = s;
|
|
|
|
|
}
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (range_is_in_ellipsis_full (self, end_index - 1, end_index, &s, &e))
|
2014-09-04 02:18:49 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self->select_info->selection_end == e)
|
2014-09-04 02:18:49 +00:00
|
|
|
|
end_index = s;
|
|
|
|
|
else
|
|
|
|
|
end_index = e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (end_index < anchor_index)
|
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (range_is_in_ellipsis_full (self, end_index, end_index + 1, &s, &e))
|
2014-09-04 02:18:49 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self->select_info->selection_end == s)
|
2014-09-04 02:18:49 +00:00
|
|
|
|
end_index = e;
|
|
|
|
|
else
|
|
|
|
|
end_index = s;
|
|
|
|
|
}
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (range_is_in_ellipsis_full (self, anchor_index - 1, anchor_index, &s, &e))
|
2014-09-04 02:18:49 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self->select_info->selection_anchor == e)
|
2014-09-04 02:18:49 +00:00
|
|
|
|
anchor_index = s;
|
|
|
|
|
else
|
|
|
|
|
anchor_index = e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (range_is_in_ellipsis_full (self, anchor_index, anchor_index, &s, &e))
|
2014-09-04 02:18:49 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self->select_info->selection_anchor == s)
|
2014-09-04 02:18:49 +00:00
|
|
|
|
anchor_index = e;
|
2020-04-13 06:56:33 +00:00
|
|
|
|
else if (self->select_info->selection_anchor == e)
|
2014-09-04 02:18:49 +00:00
|
|
|
|
anchor_index = s;
|
|
|
|
|
else if (anchor_index - s < e - anchor_index)
|
|
|
|
|
anchor_index = s;
|
|
|
|
|
else
|
|
|
|
|
anchor_index = e;
|
|
|
|
|
end_index = anchor_index;
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-02-17 00:11:03 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self->select_info->selection_anchor == anchor_index &&
|
|
|
|
|
self->select_info->selection_end == end_index)
|
2011-06-25 01:18:07 +00:00
|
|
|
|
return;
|
2001-11-02 17:18:01 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_object_freeze_notify (G_OBJECT (self));
|
2011-06-26 02:42:17 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
self->select_info->selection_anchor = anchor_index;
|
|
|
|
|
self->select_info->selection_end = end_index;
|
2001-02-17 00:11:03 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
clipboard = gtk_widget_get_primary_clipboard (GTK_WIDGET (self));
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2001-06-01 19:26:01 +00:00
|
|
|
|
if (anchor_index != end_index)
|
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gdk_content_provider_content_changed (self->select_info->provider);
|
|
|
|
|
gdk_clipboard_set_content (clipboard, self->select_info->provider);
|
2015-11-11 01:28:10 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (!self->select_info->selection_node)
|
2015-11-11 01:28:10 +00:00
|
|
|
|
{
|
|
|
|
|
GtkCssNode *widget_node;
|
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
widget_node = gtk_widget_get_css_node (GTK_WIDGET (self));
|
|
|
|
|
self->select_info->selection_node = gtk_css_node_new ();
|
|
|
|
|
gtk_css_node_set_name (self->select_info->selection_node, g_quark_from_static_string ("selection"));
|
|
|
|
|
gtk_css_node_set_parent (self->select_info->selection_node, widget_node);
|
|
|
|
|
gtk_css_node_set_state (self->select_info->selection_node, gtk_css_node_get_state (widget_node));
|
|
|
|
|
g_object_unref (self->select_info->selection_node);
|
2015-11-11 01:28:10 +00:00
|
|
|
|
}
|
2001-06-01 19:26:01 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (gdk_clipboard_get_content (clipboard) == self->select_info->provider)
|
2017-11-28 01:36:16 +00:00
|
|
|
|
gdk_clipboard_set_content (clipboard, NULL);
|
2015-11-11 01:28:10 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self->select_info->selection_node)
|
2015-11-11 01:28:10 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_css_node_set_parent (self->select_info->selection_node, NULL);
|
|
|
|
|
self->select_info->selection_node = NULL;
|
2015-11-11 01:28:10 +00:00
|
|
|
|
}
|
2001-06-01 19:26:01 +00:00
|
|
|
|
}
|
2001-02-17 00:11:03 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_update_actions (self);
|
2019-06-15 00:05:51 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_widget_queue_draw (GTK_WIDGET (self));
|
2001-10-22 21:01:47 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_object_thaw_notify (G_OBJECT (self));
|
2001-02-17 00:11:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-01 19:26:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_label_select_region:
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2001-06-01 19:26:01 +00:00
|
|
|
|
* @start_offset: start offset (in characters not bytes)
|
|
|
|
|
* @end_offset: end offset (in characters not bytes)
|
|
|
|
|
*
|
|
|
|
|
* Selects a range of characters in the label, if the label is selectable.
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*
|
|
|
|
|
* See [method@Gtk.Label.set_selectable]. If the label is not selectable,
|
2001-06-01 19:26:01 +00:00
|
|
|
|
* this function has no effect. If @start_offset or
|
|
|
|
|
* @end_offset are -1, then the end of the label will be substituted.
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*/
|
2001-02-17 00:11:03 +00:00
|
|
|
|
void
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_select_region (GtkLabel *self,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int start_offset,
|
|
|
|
|
int end_offset)
|
2001-02-17 00:11:03 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
2010-06-24 02:36:08 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self->text && self->select_info)
|
2001-02-17 00:11:03 +00:00
|
|
|
|
{
|
|
|
|
|
if (start_offset < 0)
|
2020-04-13 06:56:33 +00:00
|
|
|
|
start_offset = g_utf8_strlen (self->text, -1);
|
2020-12-25 11:05:28 +00:00
|
|
|
|
|
2001-02-17 00:11:03 +00:00
|
|
|
|
if (end_offset < 0)
|
2020-04-13 06:56:33 +00:00
|
|
|
|
end_offset = g_utf8_strlen (self->text, -1);
|
2020-12-25 11:05:28 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_select_region_index (self,
|
|
|
|
|
g_utf8_offset_to_pointer (self->text, start_offset) - self->text,
|
|
|
|
|
g_utf8_offset_to_pointer (self->text, end_offset) - self->text);
|
2001-02-17 00:11:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-01 19:26:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_label_get_selection_bounds:
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2021-11-15 15:33:56 +00:00
|
|
|
|
* @start: (out) (optional): return location for start of selection, as a character offset
|
|
|
|
|
* @end: (out) (optional): return location for end of selection, as a character offset
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Gets the selected range of characters in the label.
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE if selection is non-empty
|
2001-06-01 19:26:01 +00:00
|
|
|
|
**/
|
|
|
|
|
gboolean
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_get_selection_bounds (GtkLabel *self,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int *start,
|
|
|
|
|
int *end)
|
2001-06-01 19:26:01 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_LABEL (self), FALSE);
|
2001-06-01 19:26:01 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self->select_info == NULL)
|
2001-06-01 19:26:01 +00:00
|
|
|
|
{
|
|
|
|
|
/* not a selectable label */
|
|
|
|
|
if (start)
|
|
|
|
|
*start = 0;
|
|
|
|
|
if (end)
|
|
|
|
|
*end = 0;
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int start_index, end_index;
|
|
|
|
|
int start_offset, end_offset;
|
|
|
|
|
int len;
|
2020-12-25 11:05:28 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
start_index = MIN (self->select_info->selection_anchor,
|
|
|
|
|
self->select_info->selection_end);
|
|
|
|
|
end_index = MAX (self->select_info->selection_anchor,
|
|
|
|
|
self->select_info->selection_end);
|
2001-06-01 19:26:01 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
len = strlen (self->text);
|
2001-06-01 19:26:01 +00:00
|
|
|
|
|
|
|
|
|
if (end_index > len)
|
|
|
|
|
end_index = len;
|
|
|
|
|
|
|
|
|
|
if (start_index > len)
|
|
|
|
|
start_index = len;
|
2020-12-25 11:05:28 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
start_offset = g_utf8_strlen (self->text, start_index);
|
|
|
|
|
end_offset = g_utf8_strlen (self->text, end_index);
|
2001-06-01 19:26:01 +00:00
|
|
|
|
|
|
|
|
|
if (start_offset > end_offset)
|
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int tmp = start_offset;
|
2001-06-01 19:26:01 +00:00
|
|
|
|
start_offset = end_offset;
|
|
|
|
|
end_offset = tmp;
|
|
|
|
|
}
|
2020-12-25 11:05:28 +00:00
|
|
|
|
|
2001-06-01 19:26:01 +00:00
|
|
|
|
if (start)
|
|
|
|
|
*start = start_offset;
|
|
|
|
|
|
|
|
|
|
if (end)
|
|
|
|
|
*end = end_offset;
|
|
|
|
|
|
|
|
|
|
return start_offset != end_offset;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-09 00:12:00 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_label_get_layout:
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2020-12-25 11:05:28 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Gets the `PangoLayout` used to display the label.
|
|
|
|
|
*
|
|
|
|
|
* The layout is useful to e.g. convert text positions to pixel
|
|
|
|
|
* positions, in combination with [method@Gtk.Label.get_layout_offsets].
|
2010-12-02 10:34:41 +00:00
|
|
|
|
* The returned layout is owned by the @label so need not be
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* freed by the caller. The @label is free to recreate its layout
|
|
|
|
|
* at any time, so it should be considered read-only.
|
2009-12-10 10:23:40 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Returns: (transfer none): the [class@Pango.Layout] for this label
|
|
|
|
|
*/
|
2001-06-09 00:12:00 +00:00
|
|
|
|
PangoLayout*
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_get_layout (GtkLabel *self)
|
2001-06-09 00:12:00 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_LABEL (self), NULL);
|
2010-06-24 02:36:08 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_ensure_layout (self);
|
2001-06-09 00:12:00 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
return self->layout;
|
2001-06-09 00:12:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-03-07 21:10:44 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_label_get_layout_offsets:
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2021-05-21 00:45:06 +00:00
|
|
|
|
* @x: (out) (optional): location to store X offset of layout
|
|
|
|
|
* @y: (out) (optional): location to store Y offset of layout
|
2001-03-07 21:10:44 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Obtains the coordinates where the label will draw its `PangoLayout`.
|
|
|
|
|
*
|
|
|
|
|
* The coordinates are useful to convert mouse events into coordinates
|
|
|
|
|
* inside the [class@Pango.Layout], e.g. to take some action if some part
|
|
|
|
|
* of the label is clicked. Remember when using the [class@Pango.Layout]
|
|
|
|
|
* functions you need to convert to and from pixels using PANGO_PIXELS()
|
2021-05-25 12:31:49 +00:00
|
|
|
|
* or [const@Pango.SCALE].
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*/
|
2001-03-07 21:10:44 +00:00
|
|
|
|
void
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_get_layout_offsets (GtkLabel *self,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int *x,
|
|
|
|
|
int *y)
|
2001-03-07 21:10:44 +00:00
|
|
|
|
{
|
2021-01-11 18:53:25 +00:00
|
|
|
|
int local_x, local_y;
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
2008-06-29 17:17:09 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_ensure_layout (self);
|
2021-01-11 18:53:25 +00:00
|
|
|
|
get_layout_location (self, &local_x, &local_y);
|
|
|
|
|
|
|
|
|
|
if (x)
|
|
|
|
|
*x = local_x;
|
2008-06-29 17:17:09 +00:00
|
|
|
|
|
2021-01-11 18:53:25 +00:00
|
|
|
|
if (y)
|
|
|
|
|
*y = local_y;
|
2001-03-07 21:10:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-06-24 15:34:48 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_set_use_markup: (attributes org.gtk.Method.set_property=use-markup)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* @setting: %TRUE if the label’s text should be parsed for markup.
|
2001-06-24 15:34:48 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Sets whether the text of the label contains markup.
|
|
|
|
|
*
|
|
|
|
|
* See [method@Gtk.Label.set_markup].
|
|
|
|
|
*/
|
2001-06-24 15:34:48 +00:00
|
|
|
|
void
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_set_use_markup (GtkLabel *self,
|
2020-11-11 15:35:09 +00:00
|
|
|
|
gboolean setting)
|
2001-06-24 15:34:48 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
2001-06-24 15:34:48 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_object_freeze_notify (G_OBJECT (self));
|
2011-06-23 21:56:03 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (gtk_label_set_use_markup_internal (self, !!setting))
|
|
|
|
|
gtk_label_recalculate (self);
|
2011-06-23 21:56:03 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_object_thaw_notify (G_OBJECT (self));
|
2001-06-24 15:34:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_get_use_markup: (attributes org.gtk.Method.get_property=use-markup)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2001-06-24 15:34:48 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Returns whether the label’s text is interpreted as Pango markup.
|
|
|
|
|
*
|
|
|
|
|
* See [method@Gtk.Label.set_use_markup].
|
2001-06-24 15:34:48 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE if the label’s text will be parsed for markup.
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*/
|
2001-06-24 15:34:48 +00:00
|
|
|
|
gboolean
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_get_use_markup (GtkLabel *self)
|
2001-06-24 15:34:48 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_LABEL (self), FALSE);
|
2010-06-24 02:36:08 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
return self->use_markup;
|
2001-06-24 15:34:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_set_use_underline: (attributes org.gtk.Method.set_property=use-underline)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2001-06-24 15:34:48 +00:00
|
|
|
|
* @setting: %TRUE if underlines in the text indicate mnemonics
|
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Sets whether underlines in the text indicate mnemonics.
|
2001-06-24 15:34:48 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_set_use_underline (GtkLabel *self,
|
2020-11-11 15:35:09 +00:00
|
|
|
|
gboolean setting)
|
2001-06-24 15:34:48 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
2001-06-24 15:34:48 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_object_freeze_notify (G_OBJECT (self));
|
2011-06-23 21:56:03 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (gtk_label_set_use_underline_internal (self, !!setting))
|
|
|
|
|
gtk_label_recalculate (self);
|
2011-06-23 21:56:03 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_object_thaw_notify (G_OBJECT (self));
|
2001-06-24 15:34:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_get_use_underline: (attributes org.gtk.Method.get_property=use-underline)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
|
|
|
|
*
|
|
|
|
|
* Returns whether an embedded underlines in the label indicate mnemonics.
|
2001-06-24 15:34:48 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* See [method@Gtk.Label.set_use_underline].
|
2001-06-24 15:34:48 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE whether an embedded underline in the label indicates
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* the mnemonic accelerator keys.
|
|
|
|
|
*/
|
2001-06-24 15:34:48 +00:00
|
|
|
|
gboolean
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_get_use_underline (GtkLabel *self)
|
2001-06-24 15:34:48 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_LABEL (self), FALSE);
|
2010-06-24 02:36:08 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
return self->use_underline;
|
2001-06-24 15:34:48 +00:00
|
|
|
|
}
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2004-11-09 05:04:41 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_set_single_line_mode: (attributes org.gtk.Method.set_property=single-line-mode)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2004-11-09 05:04:41 +00:00
|
|
|
|
* @single_line_mode: %TRUE if the label should be in single line mode
|
|
|
|
|
*
|
|
|
|
|
* Sets whether the label is in single line mode.
|
|
|
|
|
*/
|
|
|
|
|
void
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_set_single_line_mode (GtkLabel *self,
|
2004-11-09 05:04:41 +00:00
|
|
|
|
gboolean single_line_mode)
|
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
2004-11-09 05:04:41 +00:00
|
|
|
|
|
|
|
|
|
single_line_mode = single_line_mode != FALSE;
|
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self->single_line_mode != single_line_mode)
|
2004-11-09 05:04:41 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
self->single_line_mode = single_line_mode;
|
2004-11-09 05:04:41 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_clear_layout (self);
|
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (self));
|
2004-11-09 05:04:41 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), label_props[PROP_SINGLE_LINE_MODE]);
|
2004-11-09 05:04:41 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_get_single_line_mode: (attributes org.gtk.Method.get_property=single-line-mode)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2004-11-09 05:04:41 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns whether the label is in single line mode.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE when the label is in single line mode.
|
2004-11-09 05:04:41 +00:00
|
|
|
|
**/
|
|
|
|
|
gboolean
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_get_single_line_mode (GtkLabel *self)
|
2004-11-09 05:04:41 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_LABEL (self), FALSE);
|
2004-11-09 05:04:41 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
return self->single_line_mode;
|
2004-11-09 05:04:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-02-19 19:47:44 +00:00
|
|
|
|
/* Compute the X position for an offset that corresponds to the more important
|
2001-09-19 00:49:52 +00:00
|
|
|
|
* cursor position for that offset. We use this when trying to guess to which
|
|
|
|
|
* end of the selection we should go to when the user hits the left or
|
|
|
|
|
* right arrow key.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
2020-04-13 06:56:33 +00:00
|
|
|
|
get_better_cursor (GtkLabel *self,
|
2020-05-15 01:27:45 +00:00
|
|
|
|
int index,
|
|
|
|
|
int *x,
|
|
|
|
|
int *y)
|
2001-09-19 00:49:52 +00:00
|
|
|
|
{
|
2020-05-15 01:27:45 +00:00
|
|
|
|
GdkSeat *seat;
|
|
|
|
|
GdkDevice *keyboard;
|
|
|
|
|
PangoDirection keymap_direction;
|
|
|
|
|
PangoDirection cursor_direction;
|
2001-09-19 00:49:52 +00:00
|
|
|
|
gboolean split_cursor;
|
|
|
|
|
PangoRectangle strong_pos, weak_pos;
|
2020-05-15 01:27:45 +00:00
|
|
|
|
|
|
|
|
|
seat = gdk_display_get_default_seat (gtk_widget_get_display (GTK_WIDGET (self)));
|
|
|
|
|
if (seat)
|
|
|
|
|
keyboard = gdk_seat_get_keyboard (seat);
|
|
|
|
|
else
|
|
|
|
|
keyboard = NULL;
|
|
|
|
|
if (keyboard)
|
|
|
|
|
keymap_direction = gdk_device_get_direction (keyboard);
|
|
|
|
|
else
|
|
|
|
|
keymap_direction = PANGO_DIRECTION_LTR;
|
|
|
|
|
|
|
|
|
|
cursor_direction = get_cursor_direction (self);
|
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_object_get (gtk_widget_get_settings (GTK_WIDGET (self)),
|
2020-05-15 01:27:45 +00:00
|
|
|
|
"gtk-split-cursor", &split_cursor,
|
|
|
|
|
NULL);
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_ensure_layout (self);
|
2020-05-15 01:27:45 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
pango_layout_get_cursor_pos (self->layout, index,
|
2020-05-15 01:27:45 +00:00
|
|
|
|
&strong_pos, &weak_pos);
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
|
|
|
|
if (split_cursor)
|
|
|
|
|
{
|
|
|
|
|
*x = strong_pos.x / PANGO_SCALE;
|
|
|
|
|
*y = strong_pos.y / PANGO_SCALE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2004-03-01 18:10:40 +00:00
|
|
|
|
if (keymap_direction == cursor_direction)
|
2020-05-15 01:27:45 +00:00
|
|
|
|
{
|
|
|
|
|
*x = strong_pos.x / PANGO_SCALE;
|
|
|
|
|
*y = strong_pos.y / PANGO_SCALE;
|
|
|
|
|
}
|
2001-09-19 00:49:52 +00:00
|
|
|
|
else
|
2020-05-15 01:27:45 +00:00
|
|
|
|
{
|
|
|
|
|
*x = weak_pos.x / PANGO_SCALE;
|
|
|
|
|
*y = weak_pos.y / PANGO_SCALE;
|
|
|
|
|
}
|
2001-09-19 00:49:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
|
static int
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_move_logically (GtkLabel *self,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
int start,
|
|
|
|
|
int count)
|
2001-09-19 00:49:52 +00:00
|
|
|
|
{
|
2020-12-25 11:05:28 +00:00
|
|
|
|
int offset = g_utf8_pointer_to_offset (self->text, self->text + start);
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self->text)
|
2001-09-19 00:49:52 +00:00
|
|
|
|
{
|
2019-01-20 08:22:55 +00:00
|
|
|
|
const PangoLogAttr *log_attrs;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int n_attrs;
|
|
|
|
|
int length;
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_ensure_layout (self);
|
2019-01-20 08:22:55 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
length = g_utf8_strlen (self->text, -1);
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
log_attrs = pango_layout_get_log_attrs_readonly (self->layout, &n_attrs);
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
|
|
|
|
while (count > 0 && offset < length)
|
2020-12-25 11:05:28 +00:00
|
|
|
|
{
|
|
|
|
|
do
|
|
|
|
|
offset++;
|
|
|
|
|
while (offset < length && !log_attrs[offset].is_cursor_position);
|
|
|
|
|
|
|
|
|
|
count--;
|
|
|
|
|
}
|
2001-09-19 00:49:52 +00:00
|
|
|
|
while (count < 0 && offset > 0)
|
2020-12-25 11:05:28 +00:00
|
|
|
|
{
|
|
|
|
|
do
|
|
|
|
|
offset--;
|
|
|
|
|
while (offset > 0 && !log_attrs[offset].is_cursor_position);
|
|
|
|
|
|
|
|
|
|
count++;
|
|
|
|
|
}
|
2001-09-19 00:49:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
return g_utf8_offset_to_pointer (self->text, offset) - self->text;
|
2001-09-19 00:49:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
|
static int
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_move_visually (GtkLabel *self,
|
2020-12-25 11:05:28 +00:00
|
|
|
|
int start,
|
|
|
|
|
int count)
|
2001-09-19 00:49:52 +00:00
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int index;
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
|
|
|
|
index = start;
|
2020-12-25 11:05:28 +00:00
|
|
|
|
|
2001-09-19 00:49:52 +00:00
|
|
|
|
while (count != 0)
|
|
|
|
|
{
|
|
|
|
|
int new_index, new_trailing;
|
|
|
|
|
gboolean split_cursor;
|
|
|
|
|
gboolean strong;
|
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_ensure_layout (self);
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_object_get (gtk_widget_get_settings (GTK_WIDGET (self)),
|
2020-12-25 11:05:28 +00:00
|
|
|
|
"gtk-split-cursor", &split_cursor,
|
|
|
|
|
NULL);
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
|
|
|
|
if (split_cursor)
|
2020-05-15 01:27:45 +00:00
|
|
|
|
strong = TRUE;
|
2001-09-19 00:49:52 +00:00
|
|
|
|
else
|
2020-05-15 01:27:45 +00:00
|
|
|
|
{
|
|
|
|
|
GdkSeat *seat;
|
|
|
|
|
GdkDevice *keyboard;
|
|
|
|
|
PangoDirection keymap_direction;
|
|
|
|
|
|
|
|
|
|
seat = gdk_display_get_default_seat (gtk_widget_get_display (GTK_WIDGET (self)));
|
|
|
|
|
if (seat)
|
|
|
|
|
keyboard = gdk_seat_get_keyboard (seat);
|
|
|
|
|
else
|
|
|
|
|
keyboard = NULL;
|
|
|
|
|
if (keyboard)
|
|
|
|
|
keymap_direction = gdk_device_get_direction (keyboard);
|
|
|
|
|
else
|
|
|
|
|
keymap_direction = PANGO_DIRECTION_LTR;
|
|
|
|
|
|
|
|
|
|
strong = keymap_direction == get_cursor_direction (self);
|
|
|
|
|
}
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
|
|
|
|
if (count > 0)
|
2020-12-25 11:05:28 +00:00
|
|
|
|
{
|
|
|
|
|
pango_layout_move_cursor_visually (self->layout, strong, index, 0, 1, &new_index, &new_trailing);
|
|
|
|
|
count--;
|
|
|
|
|
}
|
2001-09-19 00:49:52 +00:00
|
|
|
|
else
|
2020-12-25 11:05:28 +00:00
|
|
|
|
{
|
|
|
|
|
pango_layout_move_cursor_visually (self->layout, strong, index, 0, -1, &new_index, &new_trailing);
|
|
|
|
|
count++;
|
|
|
|
|
}
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
|
|
|
|
if (new_index < 0 || new_index == G_MAXINT)
|
2020-12-25 11:05:28 +00:00
|
|
|
|
break;
|
2010-06-24 02:36:08 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
index = new_index;
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
while (new_trailing--)
|
|
|
|
|
index = g_utf8_next_char (self->text + new_index) - self->text;
|
2001-09-19 00:49:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
return index;
|
2001-09-19 00:49:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_move_cursor (GtkLabel *self,
|
2011-06-01 05:08:13 +00:00
|
|
|
|
GtkMovementStep step,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int count,
|
2011-06-01 05:08:13 +00:00
|
|
|
|
gboolean extend_selection)
|
2001-09-19 00:49:52 +00:00
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int old_pos;
|
|
|
|
|
int new_pos;
|
2010-06-24 02:36:08 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self->select_info == NULL)
|
2001-09-19 00:49:52 +00:00
|
|
|
|
return;
|
2006-11-16 12:56:30 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
old_pos = new_pos = self->select_info->selection_end;
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self->select_info->selection_end != self->select_info->selection_anchor &&
|
2001-09-19 00:49:52 +00:00
|
|
|
|
!extend_selection)
|
|
|
|
|
{
|
|
|
|
|
/* If we have a current selection and aren't extending it, move to the
|
|
|
|
|
* start/or end of the selection as appropriate
|
|
|
|
|
*/
|
|
|
|
|
switch (step)
|
2011-06-01 05:08:13 +00:00
|
|
|
|
{
|
|
|
|
|
case GTK_MOVEMENT_VISUAL_POSITIONS:
|
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int end_x, end_y;
|
|
|
|
|
int anchor_x, anchor_y;
|
2011-06-01 05:08:13 +00:00
|
|
|
|
gboolean end_is_left;
|
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
get_better_cursor (self, self->select_info->selection_end, &end_x, &end_y);
|
|
|
|
|
get_better_cursor (self, self->select_info->selection_anchor, &anchor_x, &anchor_y);
|
2011-06-01 05:08:13 +00:00
|
|
|
|
|
|
|
|
|
end_is_left = (end_y < anchor_y) || (end_y == anchor_y && end_x < anchor_x);
|
|
|
|
|
|
|
|
|
|
if (count < 0)
|
2020-04-13 06:56:33 +00:00
|
|
|
|
new_pos = end_is_left ? self->select_info->selection_end : self->select_info->selection_anchor;
|
2011-06-01 05:08:13 +00:00
|
|
|
|
else
|
2020-04-13 06:56:33 +00:00
|
|
|
|
new_pos = !end_is_left ? self->select_info->selection_end : self->select_info->selection_anchor;
|
2011-06-01 05:08:13 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case GTK_MOVEMENT_LOGICAL_POSITIONS:
|
|
|
|
|
case GTK_MOVEMENT_WORDS:
|
|
|
|
|
if (count < 0)
|
2020-04-13 06:56:33 +00:00
|
|
|
|
new_pos = MIN (self->select_info->selection_end, self->select_info->selection_anchor);
|
2011-06-01 05:08:13 +00:00
|
|
|
|
else
|
2020-04-13 06:56:33 +00:00
|
|
|
|
new_pos = MAX (self->select_info->selection_end, self->select_info->selection_anchor);
|
2011-06-01 05:08:13 +00:00
|
|
|
|
break;
|
|
|
|
|
case GTK_MOVEMENT_DISPLAY_LINE_ENDS:
|
|
|
|
|
case GTK_MOVEMENT_PARAGRAPH_ENDS:
|
|
|
|
|
case GTK_MOVEMENT_BUFFER_ENDS:
|
|
|
|
|
/* FIXME: Can do better here */
|
2020-04-13 06:56:33 +00:00
|
|
|
|
new_pos = count < 0 ? 0 : strlen (self->text);
|
2011-06-01 05:08:13 +00:00
|
|
|
|
break;
|
|
|
|
|
case GTK_MOVEMENT_DISPLAY_LINES:
|
|
|
|
|
case GTK_MOVEMENT_PARAGRAPHS:
|
|
|
|
|
case GTK_MOVEMENT_PAGES:
|
|
|
|
|
case GTK_MOVEMENT_HORIZONTAL_PAGES:
|
2017-10-06 19:19:42 +00:00
|
|
|
|
default:
|
2011-06-01 05:08:13 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2001-09-19 00:49:52 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
switch (step)
|
2011-06-01 05:08:13 +00:00
|
|
|
|
{
|
|
|
|
|
case GTK_MOVEMENT_LOGICAL_POSITIONS:
|
2020-04-13 06:56:33 +00:00
|
|
|
|
new_pos = gtk_label_move_logically (self, new_pos, count);
|
2011-06-01 05:08:13 +00:00
|
|
|
|
break;
|
|
|
|
|
case GTK_MOVEMENT_VISUAL_POSITIONS:
|
2020-04-13 06:56:33 +00:00
|
|
|
|
new_pos = gtk_label_move_visually (self, new_pos, count);
|
2006-11-16 12:56:30 +00:00
|
|
|
|
if (new_pos == old_pos)
|
|
|
|
|
{
|
|
|
|
|
if (!extend_selection)
|
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (!gtk_widget_keynav_failed (GTK_WIDGET (self),
|
2006-11-16 12:56:30 +00:00
|
|
|
|
count > 0 ?
|
|
|
|
|
GTK_DIR_RIGHT : GTK_DIR_LEFT))
|
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
GtkRoot *root = gtk_widget_get_root (GTK_WIDGET (self));
|
2006-11-16 12:56:30 +00:00
|
|
|
|
|
2019-03-17 23:41:26 +00:00
|
|
|
|
if (root)
|
|
|
|
|
gtk_widget_child_focus (GTK_WIDGET (root), count > 0 ? GTK_DIR_RIGHT : GTK_DIR_LEFT);
|
2006-11-16 12:56:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_widget_error_bell (GTK_WIDGET (self));
|
2006-11-16 12:56:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-01 05:08:13 +00:00
|
|
|
|
break;
|
|
|
|
|
case GTK_MOVEMENT_WORDS:
|
|
|
|
|
while (count > 0)
|
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
new_pos = gtk_label_move_forward_word (self, new_pos);
|
2011-06-01 05:08:13 +00:00
|
|
|
|
count--;
|
|
|
|
|
}
|
|
|
|
|
while (count < 0)
|
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
new_pos = gtk_label_move_backward_word (self, new_pos);
|
2011-06-01 05:08:13 +00:00
|
|
|
|
count++;
|
|
|
|
|
}
|
2006-11-16 12:56:30 +00:00
|
|
|
|
if (new_pos == old_pos)
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_widget_error_bell (GTK_WIDGET (self));
|
2011-06-01 05:08:13 +00:00
|
|
|
|
break;
|
|
|
|
|
case GTK_MOVEMENT_DISPLAY_LINE_ENDS:
|
|
|
|
|
case GTK_MOVEMENT_PARAGRAPH_ENDS:
|
|
|
|
|
case GTK_MOVEMENT_BUFFER_ENDS:
|
|
|
|
|
/* FIXME: Can do better here */
|
2020-04-13 06:56:33 +00:00
|
|
|
|
new_pos = count < 0 ? 0 : strlen (self->text);
|
2006-11-16 12:56:30 +00:00
|
|
|
|
if (new_pos == old_pos)
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_widget_error_bell (GTK_WIDGET (self));
|
2011-06-01 05:08:13 +00:00
|
|
|
|
break;
|
|
|
|
|
case GTK_MOVEMENT_DISPLAY_LINES:
|
|
|
|
|
case GTK_MOVEMENT_PARAGRAPHS:
|
|
|
|
|
case GTK_MOVEMENT_PAGES:
|
|
|
|
|
case GTK_MOVEMENT_HORIZONTAL_PAGES:
|
2017-10-06 19:19:42 +00:00
|
|
|
|
default:
|
2011-06-01 05:08:13 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2001-09-19 00:49:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (extend_selection)
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_select_region_index (self,
|
|
|
|
|
self->select_info->selection_anchor,
|
2011-06-01 05:08:13 +00:00
|
|
|
|
new_pos);
|
2001-09-19 00:49:52 +00:00
|
|
|
|
else
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_select_region_index (self, new_pos, new_pos);
|
2001-09-19 00:49:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-27 21:43:54 +00:00
|
|
|
|
static GMenuModel *
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_get_menu_model (GtkLabel *self)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2021-07-08 21:16:06 +00:00
|
|
|
|
GtkJoinedMenu *joined;
|
2019-01-27 21:43:54 +00:00
|
|
|
|
GMenu *menu, *section;
|
|
|
|
|
GMenuItem *item;
|
|
|
|
|
|
2021-07-08 21:16:06 +00:00
|
|
|
|
joined = gtk_joined_menu_new ();
|
2019-01-27 21:43:54 +00:00
|
|
|
|
menu = g_menu_new ();
|
|
|
|
|
|
|
|
|
|
section = g_menu_new ();
|
2019-06-15 00:05:51 +00:00
|
|
|
|
g_menu_append (section, _("Cu_t"), "clipboard.cut");
|
|
|
|
|
g_menu_append (section, _("_Copy"), "clipboard.copy");
|
|
|
|
|
g_menu_append (section, _("_Paste"), "clipboard.paste");
|
|
|
|
|
g_menu_append (section, _("_Delete"), "selection.delete");
|
2019-01-27 21:43:54 +00:00
|
|
|
|
g_menu_append_section (menu, NULL, G_MENU_MODEL (section));
|
|
|
|
|
g_object_unref (section);
|
|
|
|
|
|
|
|
|
|
section = g_menu_new ();
|
2019-06-15 00:05:51 +00:00
|
|
|
|
g_menu_append (section, _("Select _All"), "selection.select-all");
|
2019-01-27 21:43:54 +00:00
|
|
|
|
g_menu_append_section (menu, NULL, G_MENU_MODEL (section));
|
|
|
|
|
g_object_unref (section);
|
|
|
|
|
|
|
|
|
|
section = g_menu_new ();
|
2019-06-15 00:05:51 +00:00
|
|
|
|
item = g_menu_item_new (_("_Open Link"), "link.open");
|
2019-01-27 21:43:54 +00:00
|
|
|
|
g_menu_item_set_attribute (item, "hidden-when", "s", "action-disabled");
|
|
|
|
|
g_menu_append_item (section, item);
|
|
|
|
|
g_object_unref (item);
|
2019-06-15 00:05:51 +00:00
|
|
|
|
item = g_menu_item_new (_("Copy _Link Address"), "link.copy");
|
2019-01-27 21:43:54 +00:00
|
|
|
|
g_menu_item_set_attribute (item, "hidden-when", "s", "action-disabled");
|
|
|
|
|
g_menu_append_item (section, item);
|
|
|
|
|
g_object_unref (item);
|
|
|
|
|
g_menu_append_section (menu, NULL, G_MENU_MODEL (section));
|
|
|
|
|
g_object_unref (section);
|
|
|
|
|
|
2021-07-08 21:16:06 +00:00
|
|
|
|
gtk_joined_menu_append_menu (joined, G_MENU_MODEL (menu));
|
|
|
|
|
g_object_unref (menu);
|
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self->extra_menu)
|
2021-07-08 21:16:06 +00:00
|
|
|
|
gtk_joined_menu_append_menu (joined, self->extra_menu);
|
2019-01-27 21:43:54 +00:00
|
|
|
|
|
2021-07-08 21:16:06 +00:00
|
|
|
|
return G_MENU_MODEL (joined);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
|
|
|
|
static void
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_do_popup (GtkLabel *self,
|
2019-01-27 21:43:54 +00:00
|
|
|
|
double x,
|
|
|
|
|
double y)
|
2001-09-19 00:49:52 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (!self->select_info)
|
2019-06-15 00:05:51 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self->select_info->link_clicked)
|
|
|
|
|
self->select_info->context_link = self->select_info->active_link;
|
2019-06-15 00:05:51 +00:00
|
|
|
|
else
|
2020-04-13 06:56:33 +00:00
|
|
|
|
self->select_info->context_link = gtk_label_get_focus_link (self, NULL);
|
2019-06-15 00:05:51 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_update_actions (self);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (!self->popup_menu)
|
2019-01-27 21:43:54 +00:00
|
|
|
|
{
|
|
|
|
|
GMenuModel *model;
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
model = gtk_label_get_menu_model (self);
|
|
|
|
|
self->popup_menu = gtk_popover_menu_new_from_model (model);
|
|
|
|
|
gtk_widget_set_parent (self->popup_menu, GTK_WIDGET (self));
|
|
|
|
|
gtk_popover_set_position (GTK_POPOVER (self->popup_menu), GTK_POS_BOTTOM);
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_popover_set_has_arrow (GTK_POPOVER (self->popup_menu), FALSE);
|
|
|
|
|
gtk_widget_set_halign (self->popup_menu, GTK_ALIGN_START);
|
2001-09-19 00:49:52 +00:00
|
|
|
|
|
2019-01-27 21:43:54 +00:00
|
|
|
|
g_object_unref (model);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-27 21:43:54 +00:00
|
|
|
|
if (x != -1 && y != -1)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2019-01-27 21:43:54 +00:00
|
|
|
|
GdkRectangle rect = { x, y, 1, 1 };
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_popover_set_pointing_to (GTK_POPOVER (self->popup_menu), &rect);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_popover_set_pointing_to (GTK_POPOVER (self->popup_menu), NULL);
|
2019-01-27 21:43:54 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_popover_popup (GTK_POPOVER (self->popup_menu));
|
2019-01-27 21:43:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-05-11 05:23:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_label_get_current_uri:
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2009-05-11 05:23:13 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns the URI for the currently active link in the label.
|
2021-02-19 19:47:44 +00:00
|
|
|
|
*
|
2009-05-11 05:23:13 +00:00
|
|
|
|
* The active link is the one under the mouse pointer or, in a
|
|
|
|
|
* selectable label, the link in which the text cursor is currently
|
|
|
|
|
* positioned.
|
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* This function is intended for use in a [signal@Gtk.Label::activate-link]
|
|
|
|
|
* handler or for use in a [signal@Gtk.Widget::query-tooltip] handler.
|
2009-05-11 05:23:13 +00:00
|
|
|
|
*
|
2021-05-21 00:45:06 +00:00
|
|
|
|
* Returns: (nullable): the currently active URI
|
2009-05-11 05:23:13 +00:00
|
|
|
|
*/
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_get_current_uri (GtkLabel *self)
|
2009-05-11 05:23:13 +00:00
|
|
|
|
{
|
2020-04-14 07:20:00 +00:00
|
|
|
|
const GtkLabelLink *link;
|
2010-06-24 02:36:08 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_LABEL (self), NULL);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
2020-04-14 07:20:00 +00:00
|
|
|
|
if (!self->select_info)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
if (self->select_info->link_clicked)
|
|
|
|
|
link = self->select_info->active_link;
|
|
|
|
|
else
|
|
|
|
|
link = gtk_label_get_focus_link (self, NULL);
|
2009-05-11 05:23:13 +00:00
|
|
|
|
|
|
|
|
|
if (link)
|
|
|
|
|
return link->uri;
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int
|
2020-04-13 06:56:33 +00:00
|
|
|
|
_gtk_label_get_cursor_position (GtkLabel *self)
|
2011-06-24 03:30:57 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self->select_info && self->select_info->selectable)
|
|
|
|
|
return g_utf8_pointer_to_offset (self->text,
|
|
|
|
|
self->text + self->select_info->selection_end);
|
2011-06-24 03:30:57 +00:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int
|
2020-04-13 06:56:33 +00:00
|
|
|
|
_gtk_label_get_selection_bound (GtkLabel *self)
|
2011-06-24 03:30:57 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self->select_info && self->select_info->selectable)
|
|
|
|
|
return g_utf8_pointer_to_offset (self->text,
|
|
|
|
|
self->text + self->select_info->selection_anchor);
|
2011-06-24 03:30:57 +00:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2013-08-23 00:29:22 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_set_lines: (attributes org.gtk.Method.set_property=lines)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2013-08-23 00:29:22 +00:00
|
|
|
|
* @lines: the desired number of lines, or -1
|
|
|
|
|
*
|
|
|
|
|
* Sets the number of lines to which an ellipsized, wrapping label
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* should be limited.
|
|
|
|
|
*
|
|
|
|
|
* This has no effect if the label is not wrapping or ellipsized.
|
|
|
|
|
* Set this to -1 if you don’t want to limit the number of lines.
|
2013-08-23 00:29:22 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_set_lines (GtkLabel *self,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int lines)
|
2013-08-23 00:29:22 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
2013-08-23 00:29:22 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self->lines != lines)
|
2013-08-23 00:29:22 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
self->lines = lines;
|
|
|
|
|
gtk_label_clear_layout (self);
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), label_props[PROP_LINES]);
|
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (self));
|
2013-08-23 00:29:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_get_lines: (attributes org.gtk.Method.get_property=lines)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2013-08-23 00:29:22 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets the number of lines to which an ellipsized, wrapping
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* label should be limited.
|
|
|
|
|
*
|
|
|
|
|
* See [method@Gtk.Label.set_lines].
|
2013-08-23 00:29:22 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: The number of lines
|
|
|
|
|
*/
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_get_lines (GtkLabel *self)
|
2013-08-23 00:29:22 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_LABEL (self), -1);
|
2013-08-23 00:29:22 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
return self->lines;
|
2013-08-23 00:29:22 +00:00
|
|
|
|
}
|
2014-01-04 02:00:44 +00:00
|
|
|
|
|
2014-09-16 03:17:11 +00:00
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_set_xalign: (attributes org.gtk.Method.set_property=xalign)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2014-09-16 03:17:11 +00:00
|
|
|
|
* @xalign: the new xalign value, between 0 and 1
|
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Sets the `xalign` of the label.
|
|
|
|
|
*
|
|
|
|
|
* See the [property@Gtk.Label:xalign] property.
|
2014-09-16 03:17:11 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_set_xalign (GtkLabel *self,
|
2020-07-24 20:25:56 +00:00
|
|
|
|
float xalign)
|
2014-09-16 03:17:11 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
2017-09-30 16:48:11 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
xalign = CLAMP (xalign, 0.0, 1.0);
|
2014-09-16 03:17:11 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self->xalign == xalign)
|
2014-09-16 03:17:11 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
self->xalign = xalign;
|
2014-09-16 03:17:11 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_widget_queue_draw (GTK_WIDGET (self));
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), label_props[PROP_XALIGN]);
|
2014-09-16 03:17:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_get_xalign: (attributes org.gtk.Method.get_property=xalign)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2014-09-16 03:17:11 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Gets the `xalign` of the label.
|
|
|
|
|
*
|
|
|
|
|
* See the [property@Gtk.Label:xalign] property.
|
2014-09-16 03:17:11 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: the xalign property
|
|
|
|
|
*/
|
2020-07-24 20:25:56 +00:00
|
|
|
|
float
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_get_xalign (GtkLabel *self)
|
2014-09-16 03:17:11 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_LABEL (self), 0.5);
|
2014-09-16 03:17:11 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
return self->xalign;
|
2014-09-16 03:17:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_set_yalign: (attributes org.gtk.Method.get_property=yalign)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2015-03-14 01:40:27 +00:00
|
|
|
|
* @yalign: the new yalign value, between 0 and 1
|
2014-09-16 03:17:11 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Sets the `yalign` of the label.
|
|
|
|
|
*
|
|
|
|
|
* See the [property@Gtk.Label:yalign] property.
|
2014-09-16 03:17:11 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_set_yalign (GtkLabel *self,
|
2020-07-24 20:25:56 +00:00
|
|
|
|
float yalign)
|
2014-09-16 03:17:11 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
2014-09-16 03:17:11 +00:00
|
|
|
|
|
2020-12-25 11:05:28 +00:00
|
|
|
|
yalign = CLAMP (yalign, 0.0, 1.0);
|
2014-09-16 03:17:11 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (self->yalign == yalign)
|
2014-09-16 03:17:11 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
self->yalign = yalign;
|
2014-09-16 03:17:11 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_widget_queue_draw (GTK_WIDGET (self));
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), label_props[PROP_YALIGN]);
|
2014-09-16 03:17:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_get_yalign: (attributes org.gtk.Method.set_property=yalign)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2014-09-16 03:17:11 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* Gets the `yalign` of the label.
|
|
|
|
|
*
|
|
|
|
|
* See the [property@Gtk.Label:yalign] property.
|
2014-09-16 03:17:11 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: the yalign property
|
|
|
|
|
*/
|
2020-07-24 20:25:56 +00:00
|
|
|
|
float
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_get_yalign (GtkLabel *self)
|
2014-09-16 03:17:11 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_LABEL (self), 0.5);
|
2017-09-30 16:48:11 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
return self->yalign;
|
2014-09-16 03:17:11 +00:00
|
|
|
|
}
|
2019-01-27 21:43:54 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_set_extra_menu: (attributes org.gtk.Method.set_property=extra-menu)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
2021-05-19 11:24:34 +00:00
|
|
|
|
* @model: (nullable): a `GMenuModel`
|
2019-01-27 21:43:54 +00:00
|
|
|
|
*
|
|
|
|
|
* Sets a menu model to add when constructing
|
|
|
|
|
* the context menu for @label.
|
|
|
|
|
*/
|
|
|
|
|
void
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_set_extra_menu (GtkLabel *self,
|
2019-01-27 21:43:54 +00:00
|
|
|
|
GMenuModel *model)
|
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
2019-01-27 21:43:54 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
if (g_set_object (&self->extra_menu, model))
|
2019-01-27 21:43:54 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_clear_pointer (&self->popup_menu, gtk_widget_unparent);
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), label_props[PROP_EXTRA_MENU]);
|
2019-01-27 21:43:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-24 03:44:25 +00:00
|
|
|
|
* gtk_label_get_extra_menu: (attributes org.gtk.Method.get_property=extra-menu)
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* @self: a `GtkLabel`
|
|
|
|
|
*
|
|
|
|
|
* Gets the extra menu model of @label.
|
2019-01-27 21:43:54 +00:00
|
|
|
|
*
|
2021-02-19 19:47:44 +00:00
|
|
|
|
* See [method@Gtk.Label.set_extra_menu].
|
2019-01-27 21:43:54 +00:00
|
|
|
|
*
|
2020-11-21 15:33:40 +00:00
|
|
|
|
* Returns: (transfer none) (nullable): the menu model
|
2019-01-27 21:43:54 +00:00
|
|
|
|
*/
|
|
|
|
|
GMenuModel *
|
2020-04-13 06:56:33 +00:00
|
|
|
|
gtk_label_get_extra_menu (GtkLabel *self)
|
2019-01-27 21:43:54 +00:00
|
|
|
|
{
|
2020-04-13 06:56:33 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_LABEL (self), NULL);
|
2019-01-27 21:43:54 +00:00
|
|
|
|
|
2020-04-13 06:56:33 +00:00
|
|
|
|
return self->extra_menu;
|
2019-01-27 21:43:54 +00:00
|
|
|
|
}
|
2022-07-31 15:40:20 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_label_set_tabs: (attributes org.gtk.Method.set_property=tabs)
|
|
|
|
|
* @self: a `GtkLabel`
|
|
|
|
|
* @tabs: (nullable): tabs as a `PangoTabArray`
|
|
|
|
|
*
|
|
|
|
|
* Sets the default tab stops for paragraphs in @self.
|
|
|
|
|
*
|
|
|
|
|
* Since: 4.8
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_label_set_tabs (GtkLabel *self,
|
|
|
|
|
PangoTabArray *tabs)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_LABEL (self));
|
|
|
|
|
|
|
|
|
|
if (self->tabs == tabs)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (self->tabs)
|
|
|
|
|
pango_tab_array_free (self->tabs);
|
|
|
|
|
self->tabs = pango_tab_array_copy (tabs);
|
|
|
|
|
|
|
|
|
|
gtk_label_clear_layout (self);
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), label_props[PROP_TABS]);
|
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (self));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_label_get_tabs: (attributes org.gtk.Method.get_property=tabs)
|
|
|
|
|
* @self: a `GtkLabel`
|
|
|
|
|
*
|
|
|
|
|
* Gets the tabs for @self.
|
|
|
|
|
*
|
|
|
|
|
* The returned array will be %NULL if “standard” (8-space) tabs are used.
|
|
|
|
|
* Free the return value with [method@Pango.TabArray.free].
|
|
|
|
|
*
|
|
|
|
|
* Returns: (nullable) (transfer full): copy of default tab array,
|
|
|
|
|
* or %NULL if standard tabs are used; must be freed with
|
|
|
|
|
* [method@Pango.TabArray.free].
|
|
|
|
|
*
|
|
|
|
|
* Since: 4.8
|
|
|
|
|
*/
|
|
|
|
|
PangoTabArray *
|
|
|
|
|
gtk_label_get_tabs (GtkLabel *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_LABEL (self), NULL);
|
|
|
|
|
|
|
|
|
|
return self->tabs ? pango_tab_array_copy (self->tabs) : NULL;
|
|
|
|
|
}
|