Page 1 of 1

Bug in vertical ProgressBarGadget in GTK3

Posted: Sun Feb 21, 2016 10:33 pm
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

Re: Bug in vertical ProgressBarGadget in GTK3

Posted: Sun Feb 21, 2016 11:14 pm
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

Re: Bug in vertical ProgressBarGadget in GTK3

Posted: Mon Feb 22, 2016 7:05 am
by ts-soft
On Ubuntu 16.04 (64), no ProgressBarGadget visible with GTK3!

Re: Bug in vertical ProgressBarGadget in GTK3

Posted: Mon Feb 22, 2016 6:02 pm
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

Re: Bug in vertical ProgressBarGadget in GTK3

Posted: Mon Feb 22, 2016 6:19 pm
by Fred
Thanks for the patch, does it fix the theme issue as well ?

Re: Bug in vertical ProgressBarGadget in GTK3

Posted: Tue Feb 23, 2016 6:25 am
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

Re: Bug in vertical ProgressBarGadget in GTK3

Posted: Mon Feb 29, 2016 4:19 pm
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

Re: Bug in vertical ProgressBarGadget in GTK3

Posted: Mon Feb 29, 2016 4:30 pm
by ts-soft
Thanks Shardik,

works also on Ubuntu 16.04 LTS with GTK 3.18.8, 64-Bit.

Re: Bug in vertical ProgressBarGadget in GTK3

Posted: Mon Feb 29, 2016 6:00 pm
by uwekel
Fred, would you mind fixing this bug before the next LTS release?

Re: Bug in vertical ProgressBarGadget in GTK3

Posted: Tue Mar 01, 2016 9:49 am
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.