View Issue Details

IDProjectCategoryView StatusLast Update
0034882PatchesWidgetsetpublic2019-02-20 10:11
ReporterAlexey Tor.Assigned ToJuha Manninen 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformUbunti 18.04 OSOS Version
Product Version2.1 (SVN)Product Build 
Target VersionFixed in Version 
Summary0034882: Gtk2 fix for ListView Columns '_' escaping
DescriptionListView columns (Columns prop items) have rendered '_' in them wrong: they make accelerator and '_' is no more visible.
The fix is attached.
Additional InformationI cannot compile gtk3 app, so pls adapt the fix for it.
TagsNo tags attached.
Fixed in Revisionr60148, r60466
LazTarget-
WidgetsetGTK 2
Attached Files
  • gtk-col.diff (698 bytes)
    Index: lcl/interfaces/gtk2/gtk2wscustomlistview.inc
    ===================================================================
    --- lcl/interfaces/gtk2/gtk2wscustomlistview.inc	(revision 60093)
    +++ lcl/interfaces/gtk2/gtk2wscustomlistview.inc	(working copy)
    @@ -991,7 +991,9 @@
     
       GtkColumn := gtk_tree_view_get_column(PGtkTreeView(Widgets^.MainView), AIndex);
       if GtkColumn <> nil then
    -    gtk_tree_view_column_set_title(GtkColumn, PChar(ACaption));
    +    gtk_tree_view_column_set_title(GtkColumn, PChar(
    +      StringReplace(ACaption, '_', '__', [rfReplaceAll]) // Must replace single '_' to double
    +      ));
     end;
     
     class procedure TGtk2WSCustomListView.ColumnSetImage(const ALV: TCustomListView;
    
    gtk-col.diff (698 bytes)
  • tst_gtk2_hotkey.zip (2,017 bytes)
  • und.diff (2,607 bytes)
    Index: lcl/interfaces/gtk2/gtk2proc.inc
    ===================================================================
    --- lcl/interfaces/gtk2/gtk2proc.inc	(revision 60442)
    +++ lcl/interfaces/gtk2/gtk2proc.inc	(working copy)
    @@ -9162,6 +9162,11 @@
       end;
     end;
     
    +function EscapeUnderscores(const Str: String): String;
    +begin
    +  Result := StringReplace(Str, '_', '__', [rfReplaceAll]);
    +end;
    +
     {-------------------------------------------------------------------------------
       function RemoveAmpersands(Src: PChar; LineLength : Longint) : PChar;
     
    Index: lcl/interfaces/gtk2/gtk2proc.pp
    ===================================================================
    --- lcl/interfaces/gtk2/gtk2proc.pp	(revision 60442)
    +++ lcl/interfaces/gtk2/gtk2proc.pp	(working copy)
    @@ -591,6 +591,7 @@
     function DeleteAmpersands(var Str: String): Longint;
     function Ampersands2Underscore(Src: PChar): PChar;
     function Ampersands2Underscore(const ASource: String): String;
    +function EscapeUnderscores(const Str: String): String;
     function RemoveAmpersands(Src: PChar; LineLength: Longint): PChar;
     function RemoveAmpersands(const ASource: String): String;
     procedure LabelFromAmpersands(var AText, APattern: String; var AAccelChar: Char);
    Index: lcl/interfaces/gtk2/gtk2wscustomlistview.inc
    ===================================================================
    --- lcl/interfaces/gtk2/gtk2wscustomlistview.inc	(revision 60442)
    +++ lcl/interfaces/gtk2/gtk2wscustomlistview.inc	(working copy)
    @@ -991,9 +991,7 @@
     
       GtkColumn := gtk_tree_view_get_column(PGtkTreeView(Widgets^.MainView), AIndex);
       if GtkColumn <> nil then
    -    gtk_tree_view_column_set_title(GtkColumn, PChar(
    -      StringReplace(ACaption, '_', '__', [rfReplaceAll]) // Must replace single '_' to double
    -      ));
    +    gtk_tree_view_column_set_title(GtkColumn, PChar(EscapeUnderscores(ACaption)));
     end;
     
     class procedure TGtk2WSCustomListView.ColumnSetImage(const ALV: TCustomListView;
    Index: lcl/interfaces/gtk2/gtk2wsstdctrls.pp
    ===================================================================
    --- lcl/interfaces/gtk2/gtk2wsstdctrls.pp	(revision 60442)
    +++ lcl/interfaces/gtk2/gtk2wsstdctrls.pp	(working copy)
    @@ -1029,7 +1029,7 @@
         P := gtk_label_get_text(PGtkLabel(PGtkBin(BoxWidget)^.child));
         B := (StrPas(P) <> AText);
         gtk_widget_show(PGtkBin(BoxWidget)^.child);
    -    gtk_button_set_label(PGtkButton(BoxWidget), PChar(Ampersands2Underscore(AText)));
    +    gtk_button_set_label(PGtkButton(BoxWidget), PChar(Ampersands2Underscore(EscapeUnderscores(AText))));
         gtk_button_set_use_underline(PGtkButton(BoxWidget), True);
         if B then
         begin
    
    und.diff (2,607 bytes)

Activities

Alexey Tor.

2019-01-16 15:22

reporter  

gtk-col.diff (698 bytes)
Index: lcl/interfaces/gtk2/gtk2wscustomlistview.inc
===================================================================
--- lcl/interfaces/gtk2/gtk2wscustomlistview.inc	(revision 60093)
+++ lcl/interfaces/gtk2/gtk2wscustomlistview.inc	(working copy)
@@ -991,7 +991,9 @@
 
   GtkColumn := gtk_tree_view_get_column(PGtkTreeView(Widgets^.MainView), AIndex);
   if GtkColumn <> nil then
-    gtk_tree_view_column_set_title(GtkColumn, PChar(ACaption));
+    gtk_tree_view_column_set_title(GtkColumn, PChar(
+      StringReplace(ACaption, '_', '__', [rfReplaceAll]) // Must replace single '_' to double
+      ));
 end;
 
 class procedure TGtk2WSCustomListView.ColumnSetImage(const ALV: TCustomListView;
gtk-col.diff (698 bytes)

Alexey Tor.

2019-01-16 15:31

reporter  

tst_gtk2_hotkey.zip (2,017 bytes)

Juha Manninen

2019-01-22 13:14

developer   ~0113579

Applied, thanks.
LCL-GTK3 has essentially only one line for the job:
  TGtk3ListView(ALV.Handle).SetColumnCaption(AIndex, AColumn, ACaption);
I did not change it.

Alexey Tor.

2019-02-17 17:43

reporter  

und.diff (2,607 bytes)
Index: lcl/interfaces/gtk2/gtk2proc.inc
===================================================================
--- lcl/interfaces/gtk2/gtk2proc.inc	(revision 60442)
+++ lcl/interfaces/gtk2/gtk2proc.inc	(working copy)
@@ -9162,6 +9162,11 @@
   end;
 end;
 
+function EscapeUnderscores(const Str: String): String;
+begin
+  Result := StringReplace(Str, '_', '__', [rfReplaceAll]);
+end;
+
 {-------------------------------------------------------------------------------
   function RemoveAmpersands(Src: PChar; LineLength : Longint) : PChar;
 
Index: lcl/interfaces/gtk2/gtk2proc.pp
===================================================================
--- lcl/interfaces/gtk2/gtk2proc.pp	(revision 60442)
+++ lcl/interfaces/gtk2/gtk2proc.pp	(working copy)
@@ -591,6 +591,7 @@
 function DeleteAmpersands(var Str: String): Longint;
 function Ampersands2Underscore(Src: PChar): PChar;
 function Ampersands2Underscore(const ASource: String): String;
+function EscapeUnderscores(const Str: String): String;
 function RemoveAmpersands(Src: PChar; LineLength: Longint): PChar;
 function RemoveAmpersands(const ASource: String): String;
 procedure LabelFromAmpersands(var AText, APattern: String; var AAccelChar: Char);
Index: lcl/interfaces/gtk2/gtk2wscustomlistview.inc
===================================================================
--- lcl/interfaces/gtk2/gtk2wscustomlistview.inc	(revision 60442)
+++ lcl/interfaces/gtk2/gtk2wscustomlistview.inc	(working copy)
@@ -991,9 +991,7 @@
 
   GtkColumn := gtk_tree_view_get_column(PGtkTreeView(Widgets^.MainView), AIndex);
   if GtkColumn <> nil then
-    gtk_tree_view_column_set_title(GtkColumn, PChar(
-      StringReplace(ACaption, '_', '__', [rfReplaceAll]) // Must replace single '_' to double
-      ));
+    gtk_tree_view_column_set_title(GtkColumn, PChar(EscapeUnderscores(ACaption)));
 end;
 
 class procedure TGtk2WSCustomListView.ColumnSetImage(const ALV: TCustomListView;
Index: lcl/interfaces/gtk2/gtk2wsstdctrls.pp
===================================================================
--- lcl/interfaces/gtk2/gtk2wsstdctrls.pp	(revision 60442)
+++ lcl/interfaces/gtk2/gtk2wsstdctrls.pp	(working copy)
@@ -1029,7 +1029,7 @@
     P := gtk_label_get_text(PGtkLabel(PGtkBin(BoxWidget)^.child));
     B := (StrPas(P) <> AText);
     gtk_widget_show(PGtkBin(BoxWidget)^.child);
-    gtk_button_set_label(PGtkButton(BoxWidget), PChar(Ampersands2Underscore(AText)));
+    gtk_button_set_label(PGtkButton(BoxWidget), PChar(Ampersands2Underscore(EscapeUnderscores(AText))));
     gtk_button_set_use_underline(PGtkButton(BoxWidget), True);
     if B then
     begin
und.diff (2,607 bytes)

Alexey Tor.

2019-02-17 17:44

reporter   ~0114222

Added the fix (und.diff) for CheckBox/RadioButton. IMO it's almost the same issue.

Alexey Tor.

2019-02-17 20:28

reporter   ~0114223

Consider to add "inline" to new func EscapeUnderscores()

Juha Manninen

2019-02-20 10:11

developer   ~0114289

Applied the new patch. Thanks.

Issue History

Date Modified Username Field Change
2019-01-16 15:22 Alexey Tor. New Issue
2019-01-16 15:22 Alexey Tor. File Added: gtk-col.diff
2019-01-16 15:31 Alexey Tor. File Added: tst_gtk2_hotkey.zip
2019-01-22 13:03 Juha Manninen Assigned To => Juha Manninen
2019-01-22 13:03 Juha Manninen Status new => assigned
2019-01-22 13:14 Juha Manninen Fixed in Revision => r60147
2019-01-22 13:14 Juha Manninen LazTarget => -
2019-01-22 13:14 Juha Manninen Note Added: 0113579
2019-01-22 13:14 Juha Manninen Status assigned => resolved
2019-01-22 13:14 Juha Manninen Resolution open => fixed
2019-02-17 17:43 Alexey Tor. File Added: und.diff
2019-02-17 17:44 Alexey Tor. Note Added: 0114222
2019-02-17 17:44 Alexey Tor. Status resolved => assigned
2019-02-17 17:44 Alexey Tor. Resolution fixed => reopened
2019-02-17 20:28 Alexey Tor. Note Added: 0114223
2019-02-20 10:11 Juha Manninen Fixed in Revision r60147 => r60148, r60466
2019-02-20 10:11 Juha Manninen Note Added: 0114289
2019-02-20 10:11 Juha Manninen Status assigned => resolved
2019-02-20 10:11 Juha Manninen Resolution reopened => fixed