PureBasic Forum
http://forums.purebasic.com/english/

PanelGadget Tabs too width on GTK3
http://forums.purebasic.com/english/viewtopic.php?f=15&t=66100
Page 1 of 1

Author:  uwekel [ Thu Jul 07, 2016 4:36 pm ]
Post subject:  PanelGadget Tabs too width on GTK3

Hi,

the width of the PanelGadget tabs is too large. It seems that there is left space for a probably displayed icon. It just occurs with GTK3, GTK2 instead looks as expected. I know that this depends on the used theme, but the GTK3 theme is standard and if i create a similar widget with Glade Interface Designer, the space left of the text is exactly the same as on the right.

GTK3:
Image

GTK2:
Image

Regards
Uwe

Author:  Fred [ Fri Nov 03, 2017 10:16 am ]
Post subject:  Re: PanelGadget Tabs too width on GTK3

I don't think it's a PB issue as we use the standard API to create and render tabs.

Author:  Oma [ Fri Nov 03, 2017 2:37 pm ]
Post subject:  Re: PanelGadget Tabs too width on GTK3

Hello, Fred,
under gtk3 an image placeholder (invisible image) is indeed placed on the left side of the tabs. I don't know if this is done by PureBasic or the API.
I think this workaround shows the problem (you can set the Image size to' 0' or delete the image) then the text is centered.
Code:
ImportC ""
   gtk_image_set_pixel_size(*image.GtkImage, pixel_size)
EndImport

; Object constants
#Win_Main= 0

#Panel1  = 0

Global.i gEvent, gQuit
Global.i gI


Procedure PanelTab_RemoveImgSpacer(Gadget)
   Protected   *notebook.GtkNotebook= GadgetID(Gadget)
   Protected   *Widget.GtkWidget, *gHBox.GtkHBox
   Protected   *gList.GList
   Protected.i I, O
   Protected.i Tabs= gtk_notebook_get_n_pages_(GadgetID(Gadget))
   
   For I= 0 To Tabs- 1
      *Widget= gtk_notebook_get_nth_page_(*notebook, I);               panel widget
      *gHBox= gtk_notebook_get_tab_label_(*notebook, *Widget);         hbox from tab for panel
      If *gHBox
         *gList= gtk_container_get_children_(*gHBox)
         For O= 1 To g_list_length_(*gList)
            If PeekS(gtk_widget_get_name_(g_list_nth_data_(*gList, O-1)), -1, #PB_UTF8) = "GtkImage"
            ;set size to '0' ...
               ;gtk_image_set_pixel_size(g_list_nth_data_(*gList, O-1), 0)
            ;OR remove image ...
               gtk_container_remove_(*gHBox, g_list_nth_data_(*gList, O-1)); replace placeholder image
            EndIf
         Next O
         g_list_free_(*gList)
      EndIf
   Next I
EndProcedure

If OpenWindow(#Win_Main, 300, 200, 400, 310, "PanelGadget: gtk3 empty-tab-image fix", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   PanelGadget(#Panel1, 0, 30, 400, 270)
   For gI= 0 To 3
      AddGadgetItem(#Panel1, -1, " Tab "+Str(gI))
      TextGadget(#PB_Any, 5, 5, 200, 20, "Panel " + Str(gI))
   Next gI
   
   ;comment out the next line to see default behaviour ...
   PanelTab_RemoveImgSpacer(#Panel1)
   
   Repeat
      gEvent= WaitWindowEvent()
      
      Select gEvent
         Case #PB_Event_CloseWindow
            gQuit= #True
      EndSelect
      
   Until gQuit
   
EndIf
Regards, Charly

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/