View Issue Details

IDProjectCategoryView StatusLast Update
0039010LazarusWidgetsetpublic2021-06-17 06:20
ReporterAnton Kavalenka Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product Version2.1 (SVN) 
Summary0039010: gtk3: Allow working PageControl with some tabs hidden
DescriptionCurrently two checks for amount of TGtk3Page and TTabSheet does not take in account hidden pages in TPageControl.
In such conditions amount of GTK3 pages is always less or equal to amount of TTabSheet.

The patch make working my way of multipage form constructor.
I.e. TTabSheet is allocated by docking TForm into TPageControl and then Form decides if it should be visible.

patch includes diff for 0039007
TagsNo tags attached.
Fixed in Revisionr65253
LazTarget-
WidgetsetGTK 3
Attached Files

Relationships

related to 0039007 closedJuha Manninen gtk3: Make ListView handle selection change 

Activities

Anton Kavalenka

2021-06-16 15:34

reporter  

gtk3_lv_nb.diff (3,954 bytes)   
Index: lcl/interfaces/gtk3/gtk3widgets.pas
===================================================================
--- lcl/interfaces/gtk3/gtk3widgets.pas	(revision 65248)
+++ lcl/interfaces/gtk3/gtk3widgets.pas	(working copy)
@@ -573,6 +573,7 @@
   protected
     function CreateWidget(const {%H-}Params: TCreateParams):PGtkWidget; override;
     function EatArrowKeys(const {%H-}AKey: Word): Boolean; override;
+    class function selection_changed(ctl:TGtk3ListView):gboolean;cdecl;
   public
     destructor Destroy; override;
     {interface implementation}
@@ -2596,6 +2597,7 @@
 begin
   if IsValidHandle and FOwnWidget then
   begin
+    fOwnWidget:=false;
     DbgOut(#10'destroying '+Classname+' ... ');
     FWidget^.destroy_;
     DbgOut(Classname+' destroyed.'+#10);
@@ -4499,12 +4501,12 @@
   if TGtk3Widget(Data).InUpdate then
     exit;
   {page is deleted}
-  DebugLn('GtkNotebookAfterSwitchPage ');
+ { DebugLn('GtkNotebookAfterSwitchPage ');
   if TGtk3NoteBook(Data).getPagesCount < TCustomTabControl(TGtk3NoteBook(Data).LCLObject).PageCount then
   begin
     DebugLn('GtkNotebookAfterSwitchPage PageIsDeleted');
     exit;
-  end;
+  end;}
   FillChar(Mess{%H-}, SizeOf(Mess), 0);
   Mess.Msg := LM_NOTIFY;
   FillChar(NMHdr{%H-}, SizeOf(NMHdr), 0);
@@ -4550,6 +4552,7 @@
 var
   Mess: TLMNotify;
   NMHdr: tagNMHDR;
+  c1,c2:integer;
 begin
   if TGtk3Widget(Data).InUpdate then
     exit;
@@ -4557,11 +4560,13 @@
   DebugLn('GtkNotebookSwitchPage Data ',dbgHex({%H-}PtrUInt(Data)),' Realized ',dbgs(Widget^.get_realized),' pageNum=',dbgs(pageNum));
 
   {page is deleted}
-  if TGtk3NoteBook(Data).getPagesCount < TCustomTabControl(TGtk3NoteBook(Data).LCLObject).PageCount then
+ { c1:=TGtk3NoteBook(Data).getPagesCount;
+  c2:=TCustomTabControl(TGtk3NoteBook(Data).LCLObject).PageCount;
+  if c1 < c2 then
   begin
     DebugLn('GtkNotebookSwitchPage PageIsDeleted ');
     exit;
-  end;
+  end;}
 
   FillChar(Mess{%H-}, SizeOf(Mess), 0);
   Mess.Msg := LM_NOTIFY;
@@ -5845,6 +5850,7 @@
     FCentralWidget := TGtkIconView.new_with_model(TreeModel);
     PGtkIconView(FCentralWidget)^.set_text_column(1);
     PGtkIconView(FCentralWidget)^.set_pixbuf_column(2);
+    PGtkIconView(FCentralWidget)^.selection_mode:=GTK_SELECTION_SINGLE;
   end
   else
   begin
@@ -5874,11 +5880,53 @@
     gtk_tree_selection_set_select_function(PGtkTreeView(FCentralWidget)^.get_selection, TGtkTreeSelectionFunc(@Gtk3WS_ListViewItemPreSelected),
       Self, nil);
     g_signal_connect_data(PGtkTreeView(FCentralWidget)^.get_selection, 'changed', TGCallback(@Gtk3WS_ListViewItemSelected), Self, nil, 0);
+  end else
+  begin
+    g_signal_connect_data (PGtkIconView(FCentralWidget), 'selection-changed',
+                        TGCallback(@Tgtk3ListView.selection_changed), Self, nil, 0);
   end;
   // if FIsTreeView then
   //  PGtkTreeView(FCentralWidget)^.set_search_column(0);
 end;
 
+class function TGtk3ListView.selection_changed(ctl:TGtk3ListView):gboolean;cdecl;
+var
+  pl:PGList;
+  pndx:PGint;
+  i,cnt:gint;
+  lv:TListView;
+  Msg: TLMNotify;
+  NM: TNMListView;
+begin
+  pl:=PGtkIconView(ctl.FCentralWidget)^.get_selected_items();
+  if Assigned(pl) then
+  begin
+    pndx:=PGtkTreePath(pl^.data)^.get_indices_with_depth(@cnt);
+    lv:=TListView(ctl.LCLObject);
+    ctl.BeginUpdate;
+    try
+      for i:=0 to cnt-1 do
+      begin
+        FillChar(Msg{%H-}, SizeOf(Msg), 0);
+        Msg.Msg := CN_NOTIFY;
+        FillChar(NM{%H-}, SizeOf(NM), 0);
+        NM.hdr.hwndfrom := HWND(ctl);
+        NM.hdr.code := LVN_ITEMCHANGED;
+        NM.iItem := {%H-}PtrInt(pndx^);
+        NM.iSubItem := 0;
+        NM.uNewState := LVIS_SELECTED;
+        NM.uChanged := LVIF_STATE;
+        Msg.NMHdr := @NM.hdr;
+        ctl.DeliverMessage(Msg);
+        inc(pndx);
+      end;
+    finally
+      ctl.EndUpdate;
+    end;
+  end;
+
+end;
+
 function TGtk3ListView.EatArrowKeys(const AKey: Word): Boolean;
 begin
   Result := False;
gtk3_lv_nb.diff (3,954 bytes)   

Anton Kavalenka

2021-06-16 15:35

reporter   ~0131338

Juha Manninen

2021-06-16 21:52

developer   ~0131347

Applied, thanks.

Issue History

Date Modified Username Field Change
2021-06-16 15:34 Anton Kavalenka New Issue
2021-06-16 15:34 Anton Kavalenka File Added: gtk3_lv_nb.diff
2021-06-16 15:35 Anton Kavalenka Note Added: 0131338
2021-06-16 15:35 Anton Kavalenka File Added: Здымак экрана, 2021-06-16 18-34-49.png
2021-06-16 21:42 Juha Manninen Relationship added related to 0039007
2021-06-16 21:43 Juha Manninen Assigned To => Juha Manninen
2021-06-16 21:43 Juha Manninen Status new => assigned
2021-06-16 21:52 Juha Manninen Status assigned => resolved
2021-06-16 21:52 Juha Manninen Resolution open => fixed
2021-06-16 21:52 Juha Manninen Fixed in Revision => r65253
2021-06-16 21:52 Juha Manninen LazTarget => -
2021-06-16 21:52 Juha Manninen Widgetset GTK 3 => GTK 3
2021-06-16 21:52 Juha Manninen Note Added: 0131347
2021-06-17 06:20 Anton Kavalenka Status resolved => closed