PanelGadget Tabs too width on GTK3

Linux specific forum
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

PanelGadget Tabs too width on GTK3

Post by uwekel »

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
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
Fred
Administrator
Administrator
Posts: 16617
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PanelGadget Tabs too width on GTK3

Post by Fred »

I don't think it's a PB issue as we use the standard API to create and render tabs.
Oma
Enthusiast
Enthusiast
Posts: 312
Joined: Thu Jun 26, 2014 9:17 am
Location: Germany

Re: PanelGadget Tabs too width on GTK3

Post by Oma »

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: Select all

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
PureBasic 5.4-5.7, Linux: (X/L/K)Ubuntus+Mint - Windows XP (32Bit)
PureBasic Linux-API-Library & Viewer: http://www.chabba.de
Post Reply