View Issue Details

IDProjectCategoryView StatusLast Update
0037804LazarusWidgetsetpublic2020-10-05 13:39
ReporterCudaText man_ Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
OSUbuntu 20 x64 
Product Version2.1 (SVN) 
Summary0037804: gtk3: MessageBox is empty if text has HTML brackets
DescriptionDemo
https://github.com/Alexey-T/Lazarus_test_messageboxes

Run on gtk3, and paste msg text from attached file. All buttons (AskUser.... etc) show empty dlg.
TagsNo tags attached.
Fixed in Revisionr63928
LazTarget-
WidgetsetGTK 3
Attached Files

Relationships

related to 0037805 closedZeljan Rikalo qt5: MessageBox shows crap for text with HTML tags 
related to 0037803 closedJuha Manninen gtk2: MessageBox isn't shown if HTML brackets are in text 

Activities

CudaText man_

2020-09-24 00:59

reporter  

caption.zip (258 bytes)

Anton Kavalenka

2020-09-24 08:44

reporter   ~0125803

Nice feature - these dialogs show rendered HTML.

Anton Kavalenka

2020-09-24 09:01

reporter   ~0125804

Last edited: 2020-09-24 09:05

View 3 revisions

Recent updates in gtk3widgets.pas lead to calling button click handler twice
Here is the fix with some GTK3 warnings elimination.

I think, HTML output in dialogs should not be disabled.

Anton Kavalenka

2020-09-24 09:04

reporter   ~0125805

gtk3fix.diff (1,215 bytes)   
Index: lcl/interfaces/gtk3/gtk3widgets.pas
===================================================================
--- lcl/interfaces/gtk3/gtk3widgets.pas	(revision 63911)
+++ lcl/interfaces/gtk3/gtk3widgets.pas	(working copy)
@@ -1224,7 +1224,8 @@
     // GDK_BUTTON_RELEASE:
     7:
     begin
-      Result := TGtk3Widget(Data).GtkEventMouse(Widget , Event);
+      if not (csClickEvents in TGtk3Widget(Data).LCLObject.ControlStyle) then
+        Result := TGtk3Widget(Data).GtkEventMouse(Widget , Event);
     end;
 
     // GDK_KEY_PRESS
@@ -6923,7 +6924,13 @@
 
 function TGtk3Window.GetTitle: String;
 begin
-  Result:=PGtkWindow(FWidget)^.get_title();
+  if Gtk3IsGtkWindow(fWidget) then
+  Result:=PGtkWindow(fWidget)^.get_title()
+  {else
+  if Gtk3IsWIdget(fWidget) then
+  Result:='widget'}
+  else
+  Result:=''
 end;
 
 procedure TGtk3Window.SetIcon(AValue: PGdkPixBuf);
@@ -6957,7 +6964,8 @@
 
 procedure TGtk3Window.SetTitle(const AValue: String);
 begin
-  PGtkWindow(FWidget)^.set_title(PGChar(AValue));
+  if Gtk3IsGtkWindow(fWidget) then
+    PGtkWindow(FWidget)^.set_title(PGChar(AValue))
 end;
 
 function Gtk3WindowState(AWidget: PGtkWidget; AEvent: PGdkEvent; AData: gPointer): GBoolean; cdecl;
gtk3fix.diff (1,215 bytes)   

Juha Manninen

2020-09-24 11:08

developer   ~0125808

Last edited: 2020-09-24 11:12

View 2 revisions

I applied the button click handler patch in r63919. Thanks.

I also like the HTML output but it is inconsistent with other widgetsets. At least Zeljko decided to strip the tags for QT5 in the related issue.
Does any other widgetset support the tags?

CudaText man_

2020-09-24 11:09

reporter   ~0125810

>HTML output in dialogs should not be disabled.

no, it should. Otherwise cross-platform app can show some tags on win32/qt5, but fails on gtk2/gtk3. Tags can be NON STANDARD HTML.

Zeljan Rikalo

2020-09-24 17:05

developer   ~0125822

Yes, HTML should be disabled otherwise we are different around widgetsets and Delphi.

Anton Kavalenka

2020-09-24 18:03

reporter   ~0125826

Actually it is not HTML but small subset https://developer.gnome.org/pygtk/stable/pango-markup-language.html
As GTK4 moves away from Pango it may disappear.

Proposed patch has set_message_text method with is_pango_markup flag
gtk3boxes.diff (1,981 bytes)   
Index: lcl/interfaces/gtk3/gtk3boxes.pas
===================================================================
--- lcl/interfaces/gtk3/gtk3boxes.pas	(revision 63919)
+++ lcl/interfaces/gtk3/gtk3boxes.pas	(working copy)
@@ -38,6 +38,7 @@
     procedure run;
     function btn_coll_info(ndx:integer):longint;
     function btn_ptr_info(ndx:integer):longint;
+    procedure set_message_text(const msg:string;const is_pango_markup:boolean=false);
     procedure update_widget_list(const func:TBtnListFunction);
     procedure CreateButton(const ALabel : String; const AResponse: Integer;
       const AImageHint: Integer = -1);
@@ -265,7 +266,7 @@
 
   Dialog := gtk_message_dialog_new(nil, GTK_DIALOG_MODAL, GtkDialogType, Btns, nil , []);
 
-  gtk_message_dialog_set_markup(PGtkMessageDialog(Dialog), PGChar(DialogMessage));
+  set_message_text(DialogMessage);
 
   g_signal_connect_data(Dialog, 'delete-event',
     TGCallback(@BoxClosed),
@@ -315,6 +316,26 @@
   Result:=pButtons[ndx];
 end;
 
+procedure TGtk3DialogFactory.set_message_text(const msg: string;const is_pango_markup:boolean=false);
+var
+  ma:PGtkWidget;
+  mainList,ChildList:PgList;
+begin
+  if is_pango_markup then
+    gtk_message_dialog_set_markup(PGtkMessageDialog(Dialog), PGChar(msg))
+  else
+  begin
+    ma:=PGtkMessageDialog(Dialog)^.get_message_area();
+    MainList := gtk_container_get_children(PGtkContainer(ma));
+    if Assigned(MainList) then
+    begin
+      PGtkLabel(MainList^.data)^.set_label(PGChar(msg));
+      g_list_free(MainList);
+    end;
+
+  end;
+end;
+
 procedure TGtk3DialogFactory.update_widget_list(const func:TBtnListFunction);
 var
   btn:PgtkButton;
@@ -431,7 +452,7 @@
 
   Dialog := gtk_message_dialog_new(nil, GTK_DIALOG_MODAL, GtkDialogType, Btns, nil , []);
 
-  gtk_message_dialog_set_markup(PGtkMessageDialog(Dialog), PGChar(DialogMessage));
+  set_message_text(DialogMessage);
 
   g_signal_connect_data(GPointer(Dialog), 'delete-event',
     TGCallback(@BoxClosed),
gtk3boxes.diff (1,981 bytes)   

Anton Kavalenka

2020-09-25 15:18

reporter   ~0125852

ping @Juha Manninen

Juha Manninen

2020-09-27 18:33

developer   ~0125902

Applied, thanks.

Issue History

Date Modified Username Field Change
2020-09-24 00:59 CudaText man_ New Issue
2020-09-24 00:59 CudaText man_ File Added: caption.zip
2020-09-24 08:44 Anton Kavalenka Note Added: 0125803
2020-09-24 08:44 Anton Kavalenka File Added: Здымак экрана, 2020-09-24 09-43-23.png
2020-09-24 09:01 Anton Kavalenka Note Added: 0125804
2020-09-24 09:03 Anton Kavalenka Note Edited: 0125804 View Revisions
2020-09-24 09:04 Anton Kavalenka Note Added: 0125805
2020-09-24 09:04 Anton Kavalenka File Added: gtk3fix.diff
2020-09-24 09:05 Anton Kavalenka Note Edited: 0125804 View Revisions
2020-09-24 10:47 Juha Manninen Assigned To => Juha Manninen
2020-09-24 10:47 Juha Manninen Status new => assigned
2020-09-24 11:08 Juha Manninen Note Added: 0125808
2020-09-24 11:08 Juha Manninen Relationship added related to 0037805
2020-09-24 11:09 CudaText man_ Note Added: 0125810
2020-09-24 11:12 Juha Manninen Note Edited: 0125808 View Revisions
2020-09-24 11:13 Juha Manninen Assigned To Juha Manninen =>
2020-09-24 11:13 Juha Manninen Status assigned => new
2020-09-24 11:13 Juha Manninen LazTarget => -
2020-09-24 17:05 Zeljan Rikalo Note Added: 0125822
2020-09-24 17:15 Juha Manninen Relationship added related to 0037803
2020-09-24 18:03 Anton Kavalenka Note Added: 0125826
2020-09-24 18:03 Anton Kavalenka File Added: gtk3boxes.diff
2020-09-25 15:18 Anton Kavalenka Note Added: 0125852
2020-09-27 18:23 Juha Manninen Assigned To => Juha Manninen
2020-09-27 18:23 Juha Manninen Status new => assigned
2020-09-27 18:33 Juha Manninen Status assigned => resolved
2020-09-27 18:33 Juha Manninen Resolution open => fixed
2020-09-27 18:33 Juha Manninen Fixed in Revision => r63928
2020-09-27 18:33 Juha Manninen Widgetset GTK 3 => GTK 3
2020-09-27 18:33 Juha Manninen Note Added: 0125902
2020-10-05 13:39 CudaText man_ Status resolved => closed