Bug in vertical ProgressBarGadget in GTK3

Linux specific forum
User avatar
Shardik
Addict
Addict
Posts: 2066
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Bug in vertical ProgressBarGadget in GTK3

Post by Shardik »

In PB 5.41 x86 and x64 with GTK 3 a vertical ProgressBarGadget is filled from left to right instead of from bottom to top or not displayed at all.

On these Linux distros and desktop environments the vertical ProgressBar is filled from left to right with GTK 3:
- Lubuntu 14.04 x86 with LXDE
- Ubuntu 14.04 x64 with Enlightenment E17
- Ubuntu 14.04 x64 with KDE
- Ubuntu 14.04 x64 with Unity

On these Linux distros and desktop environments the vertical ProgressBar is not displayed at all with GTK 3:
- Ubuntu 15.10 x86 with Unity

This bug doesn't occur with GTK 2 (subsystem "gtk2").

Code: Select all

OpenWindow(0, 100, 100, 230, 200, "Vertical ProgressBar")
ProgressBarGadget(0, WindowWidth(0) / 2 - 10, 10, 20, WindowHeight(0) - 20,
  0, 100, #PB_ProgressBar_Vertical | #PB_ProgressBar_Smooth)
AddWindowTimer(0, 0, 30)

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Timer
      If Count < 100
        Count + 1
        SetGadgetState(0, Count)
      EndIf
  EndSelect
ForEver
Last edited by Shardik on Tue Feb 23, 2016 4:47 pm, edited 3 times in total.
User avatar
bbanelli
Enthusiast
Enthusiast
Posts: 544
Joined: Tue May 28, 2013 10:51 pm
Location: Europe
Contact:

Re: Bug in vertical ProgressBarGadget in GTK3

Post by bbanelli »

On Lubuntu 15.10, both x86 and x64 version, ProgressBarGadget is not even displayed in any form. GTK2 works properly.

http://imgur.com/DohhQla
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Bug in vertical ProgressBarGadget in GTK3

Post by ts-soft »

On Ubuntu 16.04 (64), no ProgressBarGadget visible with GTK3!
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Oma
Enthusiast
Enthusiast
Posts: 312
Joined: Thu Jun 26, 2014 9:17 am
Location: Germany

Re: Bug in vertical ProgressBarGadget in GTK3

Post by Oma »

The Progressbar produces the weirdest bugs of all gtk3 problems, dependant on the themes from invisible or only a visible small line. On a few themes it works.

The orientation issue seem to be a PureBasic-flag problem with #PB_ProgressBar_Vertical
From Gtk3 - Changes that need to be done at the time of the switch (from gtk2):
GtkProgressBar orientation
In GTK+ 2.x, GtkProgressBar and GtkCellRendererProgress were using the GtkProgressBarOrientation enumeration to specify their orientation and direction. In GTK+ 3, both the widget and the cell renderer implement GtkOrientable, and have an additional 'inverted' property to determine their direction. Therefore, a call to
gtk_progress_bar_set_orientation() needs to be replaced by a pair of calls to gtk_orientable_set_orientation() and gtk_progress_bar_set_inverted(). The following values correspond: ...
An Addition of

Code: Select all

ImportC ""
	gtk_orientable_set_orientation(*orientable, orientation)
EndImport

Enumeration
	#GTK_ORIENTATION_HORIZONTAL
	#GTK_ORIENTATION_VERTICAL
EndEnumeration
;....
;gtk2 (deprecated in gtk3) ...
; gtk_progress_bar_set_orientation_(GadgetID(0), #GTK_PROGRESS_TOP_TO_BOTTOM)
;gtk3 ...
gtk_orientable_set_orientation(GadgetID(0), #GTK_ORIENTATION_VERTICAL)
;...
let it work correctly.

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
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Bug in vertical ProgressBarGadget in GTK3

Post by Fred »

Thanks for the patch, does it fix the theme issue as well ?
Oma
Enthusiast
Enthusiast
Posts: 312
Joined: Thu Jun 26, 2014 9:17 am
Location: Germany

Re: Bug in vertical ProgressBarGadget in GTK3

Post by Oma »

does it fix the theme issue as well ?
No, it only affects the correct function in vertical direction. At the moment it is a hor. Progressbar with vert. sizes on gtk3 with #PB_ProgressBar_Vertical.

And I have to correct myself.
It seems that the display problem (only line heights or widths) is more likely caused by recent distributions than of themes,
since I couldn't see gtk3 display errors in all themes on Ubuntu-Versions up to 14.x.

But at the moment i have no idea what has changed to cause this.

Best Regards

PS:
I did a another few experiments with the ProgressBar size problem.
But it's somewhat difficult to describe in English so i try my best :wink: .

In any Gtk version above 3.10 the representation of the ProgressBar has changed and behaves as follows:

- An invisible rectangle in the requested size is created.
- A horizontal ProgressBar appears at the bottom in "min-horizontal-bar-height" - height.
- A vertical ProgressBar appears at the right side of the rectangle in "min-vertical-bar-width" - width.
- The rest (top or left range) is empty
- If you manipulate the "min-horizontal-bar-height"- or "min-vertical-bar-width"-property, the ProgressBars are shown with this heights or width, but never in the allocated size as in ProgressBarGadget(,,,w,h)

This way the "min-horizontal-bar-height"- and "min-vertical-bar-width" can be manipulated to test this in gtk3 ...

Code: Select all

Procedure ProgressBarSetMinSizes(size)
	Protected   *provider= gtk_css_provider_new()
	Protected   *screen= gdk_display_get_default_screen_(gdk_display_get_default_())
	Protected.s css
	
	css= "GtkProgressBar {" + #LF$ + 
	     "-GtkProgressBar-min-horizontal-bar-height: "+ Str(size) +"px;" + #LF$ + 
	     "-GtkProgressBar-min-vertical-bar-width: "+ Str(size) +"px;" + #LF$ + 
	     "}"
	
	gtk_css_provider_load_from_data(*provider, css, -1, 0)
	gtk_style_context_add_provider_for_screen(*screen, *provider, #GTK_STYLE_PROVIDER_PRIORITY_APPLICATION)
	g_object_unref_(*provider)
EndProcedure
But I still have no idea where the actual problem could be :cry: .

Charly
PureBasic 5.4-5.7, Linux: (X/L/K)Ubuntus+Mint - Windows XP (32Bit)
PureBasic Linux-API-Library & Viewer: http://www.chabba.de
User avatar
Shardik
Addict
Addict
Posts: 2066
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Bug in vertical ProgressBarGadget in GTK3

Post by Shardik »

Thank you for your research, Charly! You seem to be right. In order to display a vertical ProgressBar with a more recent GTK version like 3.16.7 it seems to be necessary to always set the CSS style property -GtkProgressBar-min-vertical-bar-width: to the width defined in PB's ProgressBarGadget... :shock:
This is not necessary in older GTK 3 versions but it doesn't hurt... :wink:

I have therefore modified my code example from above to work correctly with PB 5.41 on these Ubuntu distributions and GTK 3 versions (subsystem "gtk2" also works):
- Ubuntu 12.04 x86 with Unity and GTK 3.4.2
- Ubuntu 14.04 x86 with Unity and GTK 3.10.8
- Ubuntu 15.10 x86 with Unity and GTK 3.16.7

Code: Select all

EnableExplicit

#ProgressBarWidth = 20

#GTK_STYLE_PROVIDER_PRIORITY_APPLICATION = 600

CompilerIf Subsystem("gtk2") = #False
  ImportC ""
    gtk_css_provider_load_from_data(*CSSProvider, CSSData.P-UTF8, Length.I,
      *Error.GError)
    gtk_css_provider_new()
    gtk_orientable_set_orientation(*Orientable, Orientation.I)
    gtk_progress_bar_set_inverted(*ProgressBar.GtkProgressBar, Inverted.I)
    gtk_style_context_add_provider_for_screen(*Screen.GdkScreen, *StyleProvider,
      Priority.I)
  EndImport

  Procedure SetProgressBarWidth(ProgressBarID.I)
    Protected CSSStyle.S = "GtkProgressBar {" + #LF$ +
      "  -GtkProgressBar-min-vertical-bar-width: " + GadgetWidth(ProgressBarID) + "px;" + #LF$ +
      "}"
    Protected Provider.I = gtk_css_provider_new()
    Protected Screen.I = gdk_display_get_default_screen_(gdk_display_get_default_())

    gtk_css_provider_load_from_data(Provider, CSSStyle, -1, 0)
    gtk_style_context_add_provider_for_screen(Screen, Provider,
      #GTK_STYLE_PROVIDER_PRIORITY_APPLICATION)
    g_object_unref_(Provider)
    ProcedureReturn
  EndProcedure ;}
CompilerEndIf

Define Count.I

OpenWindow(0, 100, 100, 230, 200, "Vertical ProgressBar")
ProgressBarGadget(0, WindowWidth(0) / 2 - #ProgressBarWidth / 2, 10,
  #ProgressBarWidth, 180, 0, 100, #PB_ProgressBar_Vertical)

CompilerIf Subsystem("gtk2") = #False
  gtk_orientable_set_orientation(GadgetID(0), #GTK_ORIENTATION_VERTICAL)
  gtk_progress_bar_set_inverted(GadgetID(0), #True)
  SetProgressBarWidth(0)
CompilerEndIf

AddWindowTimer(0, 0, 30)

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Timer
      If Count < 100
        Count + 1
        SetGadgetState(0, Count)
      EndIf
  EndSelect
ForEver
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Bug in vertical ProgressBarGadget in GTK3

Post by ts-soft »

Thanks Shardik,

works also on Ubuntu 16.04 LTS with GTK 3.18.8, 64-Bit.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

Re: Bug in vertical ProgressBarGadget in GTK3

Post by uwekel »

Fred, would you mind fixing this bug before the next LTS release?
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Bug in vertical ProgressBarGadget in GTK3

Post by Fred »

Fixed the 1 pixel bar error. For exact bar width/height, it's a GTK3 thing and I don't think we will try to workaround it as it can create more harm than good.
Post Reply