From 206227dbc57c287b6ec5408582098cb646682b1a Mon Sep 17 00:00:00 2001 From: Blady <blady.net@orange.fr> Date: Mon, 27 Sep 2021 21:36:19 +0200 Subject: [PATCH] Fix issues or add improvements in testgtk. --- .gitignore | 1 + testgtk/create_canvas.adb | 2 ++ testgtk/create_canvas_view_animate.adb | 2 ++ testgtk/create_canvas_view_composite.adb | 2 ++ testgtk/create_canvas_view_edit.adb | 2 ++ testgtk/create_canvas_view_events.adb | 2 ++ testgtk/create_canvas_view_items.adb | 2 ++ testgtk/create_canvas_view_links.adb | 2 ++ testgtk/create_canvas_view_minimap.adb | 2 ++ testgtk/create_canvas_view_routes.adb | 2 ++ testgtk/create_canvas_view_rtrees.adb | 2 ++ testgtk/create_clipboard.adb | 30 ++++++++++++++++++++---- testgtk/create_cursors.adb | 5 ++-- testgtk/create_mdi.adb | 2 ++ testgtk/create_range.adb | 5 +++- testgtk/create_revealer.adb | 1 - testgtk/create_splittable.adb | 2 ++ testgtk/create_tooltips.adb | 4 ++-- testgtk/css_accordion.css | 14 +++++------ 19 files changed, 67 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 86745f383..54b0c4390 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,4 @@ docs/gtkada_ug/gtkada_ug.html docs/gtkada_ug/gtkada_ug.info docs/gtkada_ug/gtkada_ug.ps docs/gtkada_ug/gtkada_ug.txt +testgtk/task_project/obj diff --git a/testgtk/create_canvas.adb b/testgtk/create_canvas.adb index d287ed35d..3faa1df9a 100644 --- a/testgtk/create_canvas.adb +++ b/testgtk/create_canvas.adb @@ -791,6 +791,8 @@ package body Create_Canvas is Success : Boolean; begin + Gtk.Frame.Set_Label (Frame, "Canvas (obsolescent)"); + Last_Item := Items_List'First; Last_Link := 1; diff --git a/testgtk/create_canvas_view_animate.adb b/testgtk/create_canvas_view_animate.adb index eca2c367c..f8f0e65fc 100644 --- a/testgtk/create_canvas_view_animate.adb +++ b/testgtk/create_canvas_view_animate.adb @@ -111,6 +111,8 @@ package body Create_Canvas_View_Animate is Scrolled : Gtk_Scrolled_Window; Label : Gtk_Label; begin + Gtk.Frame.Set_Label (Frame, "Canvas View (animation)"); + Gtk_New (Model); Gtkada.Canvas_View.Initialize (Canvas); diff --git a/testgtk/create_canvas_view_composite.adb b/testgtk/create_canvas_view_composite.adb index 5713883b4..ef9cd3ec4 100644 --- a/testgtk/create_canvas_view_composite.adb +++ b/testgtk/create_canvas_view_composite.adb @@ -280,6 +280,8 @@ package body Create_Canvas_View_Composite is end Do_Example; begin + Gtk.Frame.Set_Label (Frame, "Canvas View (composite)"); + Red := Gtk_New (Stroke => Black_RGBA, Fill => Create_Rgba_Pattern ((1.0, 0.0, 0.0, 0.6))); diff --git a/testgtk/create_canvas_view_edit.adb b/testgtk/create_canvas_view_edit.adb index 6a43743d6..cf16b4924 100644 --- a/testgtk/create_canvas_view_edit.adb +++ b/testgtk/create_canvas_view_edit.adb @@ -64,6 +64,8 @@ package body Create_Canvas_View_Edit is Rect : Rect_Item; White, Font : Drawing_Style; begin + Gtk.Frame.Set_Label (Frame, "Canvas View (editing)"); + Font := Gtk_New (Stroke => Null_RGBA, Font => (Name => From_String ("sans 10"), diff --git a/testgtk/create_canvas_view_events.adb b/testgtk/create_canvas_view_events.adb index 125911812..45bc4a794 100644 --- a/testgtk/create_canvas_view_events.adb +++ b/testgtk/create_canvas_view_events.adb @@ -179,6 +179,8 @@ package body Create_Canvas_View_Events is L : Gdouble; begin + Gtk.Frame.Set_Label (Frame, "Canvas View (events)"); + Gtk_New (Model); Model.Set_Selection_Mode (Selection_Multiple); diff --git a/testgtk/create_canvas_view_items.adb b/testgtk/create_canvas_view_items.adb index b44c37979..66a6a6ed0 100644 --- a/testgtk/create_canvas_view_items.adb +++ b/testgtk/create_canvas_view_items.adb @@ -329,6 +329,8 @@ package body Create_Canvas_View_Items is Rect1, Rect2 : Rect_Item; begin + Gtk.Frame.Set_Label (Frame, "Canvas View (items)"); + Font := Gtk_New (Stroke => Null_RGBA, Font => (Name => From_String ("sans 10"), diff --git a/testgtk/create_canvas_view_links.adb b/testgtk/create_canvas_view_links.adb index f29660da0..8a18695b3 100644 --- a/testgtk/create_canvas_view_links.adb +++ b/testgtk/create_canvas_view_links.adb @@ -355,6 +355,8 @@ package body Create_Canvas_View_Links is Text : Text_Item; Y : Gdouble; begin + Gtk.Frame.Set_Label (Frame, "Canvas View (links)"); + Gtk_New (Model); Black := Gtk_New; diff --git a/testgtk/create_canvas_view_minimap.adb b/testgtk/create_canvas_view_minimap.adb index f437a2c22..73143d766 100644 --- a/testgtk/create_canvas_view_minimap.adb +++ b/testgtk/create_canvas_view_minimap.adb @@ -68,6 +68,8 @@ package body Create_Canvas_View_Minimap is L : Gdouble; begin + Gtk.Frame.Set_Label (Frame, "Canvas View (minimap)"); + Gtk_New (Model); Canvas := new Canvas_View_Record; diff --git a/testgtk/create_canvas_view_routes.adb b/testgtk/create_canvas_view_routes.adb index 76d7ab2a4..751fc6cd7 100644 --- a/testgtk/create_canvas_view_routes.adb +++ b/testgtk/create_canvas_view_routes.adb @@ -171,6 +171,8 @@ package body Create_Canvas_View_Routes is Items : array (Pos'Range) of Demo_Item; begin + Gtk.Frame.Set_Label (Frame, "Canvas View (routes)"); + Layout := Frame.Create_Pango_Layout; Layout.Set_Font_Description (From_String ("sans 8px")); diff --git a/testgtk/create_canvas_view_rtrees.adb b/testgtk/create_canvas_view_rtrees.adb index 583df9554..def666cab 100644 --- a/testgtk/create_canvas_view_rtrees.adb +++ b/testgtk/create_canvas_view_rtrees.adb @@ -87,6 +87,8 @@ package body Create_Canvas_View_Rtrees is Link_Style : Drawing_Style; begin + Gtk.Frame.Set_Label (Frame, "Canvas View (large)"); + Gtk_New (Model); Model.Set_Selection_Mode (Selection_Single); diff --git a/testgtk/create_clipboard.adb b/testgtk/create_clipboard.adb index a503cb9a0..eae4f45c1 100644 --- a/testgtk/create_clipboard.adb +++ b/testgtk/create_clipboard.adb @@ -21,7 +21,9 @@ -- -- ------------------------------------------------------------------------------ +with System; with Glib; use Glib; +with Glib.Unicode; use Glib.Unicode; with Gdk.Pixbuf; use Gdk.Pixbuf; with Gdk.Property; use Gdk.Property; with Gdk.Types; use Gdk.Types; @@ -165,6 +167,9 @@ package body Create_Clipboard is declare Format : constant String := Get_String (Model, Iter, 0); + Valid : Boolean; + Invalid_Pos : Natural; + use type System.Address; begin Data := Wait_For_Contents (Clipboard, Atom_Intern (Format)); @@ -196,10 +201,27 @@ package body Create_Clipboard is & ASCII.LF); if As_String then - Insert - (Contents, - First, - "As_String=" & Get_Data_As_String (Data)); + if Data.Get_Data /= System.Null_Address then + UTF8_Validate (Str => Get_Data_As_String (Data), + Valid => Valid, + Invalid_Pos => Invalid_Pos); + if Valid then + Insert + (Contents, + First, + "As_String=" & Get_Data_As_String (Data)); + else + Insert + (Contents, + First, + "Non valid UTF8 string"); + end if; + else + Insert + (Contents, + First, + "Null data"); + end if; end if; Free (Data); diff --git a/testgtk/create_cursors.adb b/testgtk/create_cursors.adb index 5dc2b4b33..1eef50d09 100644 --- a/testgtk/create_cursors.adb +++ b/testgtk/create_cursors.adb @@ -129,9 +129,10 @@ package body Create_Cursors is -- The cursor change is asynchronous: if you plan to do a blocking -- operation right after setting this, it is useful to call - -- Process_All_Updates in order for impacted windows to have the new + -- Process_Updates in order for impacted windows to have the new -- cursor. - Process_All_Updates; + Process_Updates (Self => Window, + Update_Children => False); -- Note: the cursor pixmap is copied to the server, which keeps it as -- long at it needs. On the client side, it is possible to delete the diff --git a/testgtk/create_mdi.adb b/testgtk/create_mdi.adb index 72f5c1622..6b3c70216 100644 --- a/testgtk/create_mdi.adb +++ b/testgtk/create_mdi.adb @@ -371,6 +371,7 @@ package body Create_MDI is procedure Run (Frame : access Gtk.Frame.Gtk_Frame_Record'Class) is begin + Gtk.Frame.Set_Label (Frame, "MDI"); Setup (Frame, Independent => False); end Run; @@ -381,6 +382,7 @@ package body Create_MDI is procedure Run_Independent (Frame : access Gtk.Frame.Gtk_Frame_Record'Class) is begin + Gtk.Frame.Set_Label (Frame, "MDI (independent perspectives)"); Setup (Frame, Independent => True); end Run_Independent; end Create_MDI; diff --git a/testgtk/create_range.adb b/testgtk/create_range.adb index 238c31dff..8f9a77d48 100644 --- a/testgtk/create_range.adb +++ b/testgtk/create_range.adb @@ -34,6 +34,8 @@ with Gtk.Volume_Button; use Gtk.Volume_Button; package body Create_Range is + Zero_String : aliased String := (1 => ASCII.NUL); + ---------- -- Help -- ---------- @@ -107,7 +109,8 @@ package body Create_Range is Pack_Start (Box3, Label, False, False, 0); Gtk_New (Scale_Button, Icon_Size_Button, 0.0, 100.0, 2.0, - Icons => (1 .. 0 => null)); + -- Icons => (1 .. 0 => null)); -- it seems to be a GTK issue in gtkscalebutton.c:988 + Icons => (1 => Zero_String'Access)); Pack_Start (Box3, Scale_Button, False, False, 0); Gtk_New (Label, "Volume button:"); diff --git a/testgtk/create_revealer.adb b/testgtk/create_revealer.adb index a57d15a58..31e9edd2f 100644 --- a/testgtk/create_revealer.adb +++ b/testgtk/create_revealer.adb @@ -77,7 +77,6 @@ package body Create_Revealer is Gtk_New (Button, "None"); Box.Attach (Button, 0, 0, 1, 1); Gtk_New (Revealer); - Revealer.Set_Halign (Align_Start); Revealer.Set_Valign (Align_Start); Gtk_New (Ent); Ent.Set_Text ("00000"); diff --git a/testgtk/create_splittable.adb b/testgtk/create_splittable.adb index fff5f583e..347bd3ad7 100644 --- a/testgtk/create_splittable.adb +++ b/testgtk/create_splittable.adb @@ -215,6 +215,8 @@ package body Create_Splittable is Box : Gtk_Box; Toggle : Gtk_Toggle_Button; begin + Gtk.Frame.Set_Label (Frame, "Multi Paned"); + Gtk_New_Vbox (Box, Homogeneous => False); Add (Frame, Box); diff --git a/testgtk/create_tooltips.adb b/testgtk/create_tooltips.adb index 0ec167b1d..d74775b01 100644 --- a/testgtk/create_tooltips.adb +++ b/testgtk/create_tooltips.adb @@ -81,7 +81,7 @@ package body Create_Tooltips is is pragma Unreferenced (X, Y, Keyboard_Tip, Tooltip); Window : constant Gtk_Window := Gtk_Window (Check.Get_Tooltip_Window); - Color : constant Gdk_RGBA := (0.0, 0.0, 1.0, 0.5); + Color : constant Gdk_RGBA := (0.25, 0.65, 1.0, 1.0); begin Window.Override_Background_Color (Gtk_State_Flag_Normal, Color); return True; @@ -131,7 +131,7 @@ package body Create_Tooltips is Gtk_New (Label, "A selectable label"); Box1.Pack_Start (Label, False, False, 0); Label.Set_Selectable (True); - Label.Set_Tooltip_Text ("<b>Another</b> Label tooltip"); + Label.Set_Tooltip_Markup ("<b>Another</b> Label tooltip"); -- Another one, with a custom tooltip window diff --git a/testgtk/css_accordion.css b/testgtk/css_accordion.css index a2761e57c..a1b56ba61 100644 --- a/testgtk/css_accordion.css +++ b/testgtk/css_accordion.css @@ -7,7 +7,7 @@ font-variant: inherit; font-weight: inherit; text-shadow: inherit; - icon-shadow: inherit; + -gtk-icon-shadow: inherit; box-shadow: initial; margin-top: initial; margin-left: initial; @@ -51,19 +51,19 @@ transition-duration: initial; transition-timing-function: initial; transition-delay: initial; - engine: initial; - gtk-key-bindings: initial; - -GtkWidget-focus-line-width: 0; - -GtkWidget-focus-padding: 0; - -GtkNotebook-initial-gap: 0; + -gtk-key-bindings: initial; + + + + } * { transition-property: color, background-color, border-color, background-image, padding, border-width; transition-duration: 0.2s; - font: Cantarell 20px; + font: 20px Cantarell; } GtkWindow {