Page 1 of 1

Frustrated With Linux

Posted: Fri Aug 09, 2019 6:50 am
by collectordave
Reported problem with combo gadgets on linux in another post but after yet another email from a frustrated Linux user of my application thought I would see what the problem is.

Wrote a little code to see what is happening:-

Code: Select all

Global Window_0

Global Combo_0, btnMag1, ListView_0, btnMag2, btnShort, btnLong,txtShort

Enumeration FormFont
  #Font_Window_0_0
EndEnumeration

LoadFont(#Font_Window_0_0,"Sans", 16)




Define Event.i,iLoop.i





  Window_0 = OpenWindow(#PB_Any, 0, 0, 600, 400, "", #PB_Window_SystemMenu)
  btnMag2 = ButtonGadget(#PB_Any, 330, 10, 110, 25, "Magic 2")
  btnMag1 = ButtonGadget(#PB_Any, 210, 10, 110, 20, "Magic 1")
  
  Combo_0 = ComboBoxGadget(#PB_Any, 10, 10, 160, 30)

  ListView_0 = ListViewGadget(#PB_Any, 10, 60, 160, 150)
  
  btnShort = ButtonGadget(#PB_Any, 10, 230, 90, 30, "Short")
  btnLong = ButtonGadget(#PB_Any, 130, 230, 90, 30, "Long")
  btnFont = ButtonGadget(#PB_Any, 250, 230, 90, 30, "Font")
  txtShort = TextGadget(#PB_Any, 210, 140, 120, 20, "Short")
  txtImportant = TextGadget(#PB_Any, 270, 140, 60, 20, "Important")
  
   
  
  
  
  Repeat
    
    Event = WaitWindowEvent()
  
  

  Select event
    Case #PB_Event_CloseWindow
      End

    Case #PB_Event_Menu
      Select EventMenu()
      EndSelect

    Case #PB_Event_Gadget
      Select EventGadget()
          
        Case btnFont
          
          SetGadgetFont(btnMag1, FontID(#Font_Window_0_0))
          SetGadgetFont(txtShort, FontID(#Font_Window_0_0))
          
        Case btnMag1
          
          Debug "Magic 1"
          
          
        Case btnMag2
          
          Debug "Magic 2"
          
        Case btnShort
          
          ClearGadgetItems(Combo_0)
          ClearGadgetItems(ListView_0)
          
          For iLoop = 0 To 20
          
          AddGadgetItem(Combo_0,-1,"Item " + Str(iLoop))
          AddGadgetItem(ListView_0,-1,"Item " + Str(iLoop))
        Next
        
        SetGadgetText(btnMag1,"Magic 1")
        SetGadgetText(txtShort,"Short")
        
      Case btnLong  
        
               ClearGadgetItems(Combo_0)
          ClearGadgetItems(ListView_0)   
        
        
        For iLoop = 0 To 20
          
          AddGadgetItem(Combo_0,-1,"Item " + Str(iLoop) + " A much Longer String To Check It Out. The Quick Brown Fox Jumps Over The Lazy Dog.")
          AddGadgetItem(ListView_0,-1,"Item " + Str(iLoop) + " A much Longer String To Check It Out")
        Next
        
        SetGadgetText(btnMag1,"Just Checking it out")
        SetGadgetText(txtShort,"Checking How text Gadgets React")
          
      EndSelect
  EndSelect
  
  ForEver
Seems to be more of a mess than I first thought!

I have resolved the Linux user problem by taking my linux applications off line, no more emails from 'Frustrated'.

Is there anyway around this auto resizeing? Or do I just give up on writing applications for Linux?

CD

Re: Frustrated With Linux

Posted: Fri Aug 09, 2019 9:59 pm
by Erlend
Purebasic has quite a few quirks with gtk3 sizing.
Have you tried compiling with gtk2?

Re: Frustrated With Linux

Posted: Fri Aug 09, 2019 10:21 pm
by Bitblazer
Two possible further options are trying with 5.71 Beta 3 or try to use the QT subsystem.

Re: Frustrated With Linux

Posted: Sat Aug 10, 2019 6:24 am
by collectordave
Thanks for the replies.

How do I compile with GTK 2?

CD

Re: Frustrated With Linux

Posted: Sat Aug 10, 2019 10:30 am
by mk-soft
Compiler option subsystem "gtk2"

Re: Frustrated With Linux

Posted: Sat Aug 10, 2019 5:27 pm
by Oma
Attention: Not very well tested. This means that the method is not bulletproof.

The ComboBox is unfortunately the worst gadget in Gtk3.
The only method I found to eliminate the dynamic width is to set the editable flag and block the effect of this flag via API.

My Linux-Api-Lib code for the issue can be found here:
http://www.chabba.de/Linux/ComboBoxGadg ... nd_Gtk3.pb

Here your example in revised form for Gtk3 ...

Code: Select all

; Addit **********
ImportC ""
	gtk_widget_set_can_focus(*widget.GtkWidget, can_focus)
EndImport
; **********

Global Window_0

Global Combo_0, btnMag1, ListView_0, btnMag2, btnShort, btnLong,txtShort

Enumeration FormFont
  #Font_Window_0_0
EndEnumeration

LoadFont(#Font_Window_0_0,"Sans", 16)

; Addit **********
Procedure ComboBoxGadget_Gtk3Tweak(Gadget)
	CompilerIf #PB_Compiler_OS = #PB_OS_Linux
		If GadgetType(Gadget) = #PB_GadgetType_ComboBox
			Protected *entry.GtkEntry = gtk_bin_get_child_(GadgetID(Gadget))
			
			If *entry
				If PeekS(gtk_widget_get_name_(*entry), -1, #PB_UTF8) = "GtkEntry"
					gtk_editable_set_editable_(*entry, #False)
					gtk_widget_set_can_focus(*entry, #False)
				EndIf
			EndIf
		EndIf
	CompilerEndIf
EndProcedure
; **********

Define Event.i,iLoop.i





  Window_0 = OpenWindow(#PB_Any, 0, 0, 600, 400, "", #PB_Window_SystemMenu)
  btnMag2 = ButtonGadget(#PB_Any, 330, 10, 110, 25, "Magic 2")
  btnMag1 = ButtonGadget(#PB_Any, 210, 10, 110, 20, "Magic 1")
 
  Combo_0 = ComboBoxGadget(#PB_Any, 10, 10, 160, 30, #PB_ComboBox_Editable);         FLAG ADDED !!!!

  ListView_0 = ListViewGadget(#PB_Any, 10, 60, 160, 150)
 
  btnShort = ButtonGadget(#PB_Any, 10, 230, 90, 30, "Short")
  btnLong = ButtonGadget(#PB_Any, 130, 230, 90, 30, "Long")
  btnFont = ButtonGadget(#PB_Any, 250, 230, 90, 30, "Font")
  txtShort = TextGadget(#PB_Any, 210, 140, 120, 20, "Short")
  txtImportant = TextGadget(#PB_Any, 270, 140, 60, 20, "Important")
 
  ; **********
  ComboBoxGadget_Gtk3Tweak(Combo_0);                                                 FLAG effect eliminated
  ; **********
 
 
  Repeat
   
    Event = WaitWindowEvent()
 
 

  Select event
    Case #PB_Event_CloseWindow
      End

    Case #PB_Event_Menu
      Select EventMenu()
      EndSelect

    Case #PB_Event_Gadget
      Select EventGadget()
         
        Case btnFont
         
          SetGadgetFont(btnMag1, FontID(#Font_Window_0_0))
          SetGadgetFont(txtShort, FontID(#Font_Window_0_0))
         
        Case btnMag1
         
          Debug "Magic 1"
         
         
        Case btnMag2
         
          Debug "Magic 2"
         
        Case btnShort
         
          ClearGadgetItems(Combo_0)
          ClearGadgetItems(ListView_0)
         
          For iLoop = 0 To 20
         
          AddGadgetItem(Combo_0,-1,"Item " + Str(iLoop))
          AddGadgetItem(ListView_0,-1,"Item " + Str(iLoop))
        Next
       
        SetGadgetText(btnMag1,"Magic 1")
        SetGadgetText(txtShort,"Short")
       
      Case btnLong 
       
               ClearGadgetItems(Combo_0)
          ClearGadgetItems(ListView_0)   
       
       
        For iLoop = 0 To 20
         
          AddGadgetItem(Combo_0,-1,"Item " + Str(iLoop) + " A much Longer String To Check It Out. The Quick Brown Fox Jumps Over The Lazy Dog.")
          AddGadgetItem(ListView_0,-1,"Item " + Str(iLoop) + " A much Longer String To Check It Out")
        Next
       
        SetGadgetText(btnMag1,"Just Checking it out")
        SetGadgetText(txtShort,"Checking How text Gadgets React")
         
      EndSelect
  EndSelect
 
  ForEver
However, if your content varies so much I would also choose Gtk2, or Qt.

Regards, Charly

Re: Frustrated With Linux

Posted: Wed Aug 14, 2019 4:52 pm
by Justin