Frustrated With Linux

Linux specific forum
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Frustrated With Linux

Post 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
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
User avatar
Erlend
Enthusiast
Enthusiast
Posts: 102
Joined: Mon Apr 19, 2004 8:22 pm
Location: NORWAY

Re: Frustrated With Linux

Post by Erlend »

Purebasic has quite a few quirks with gtk3 sizing.
Have you tried compiling with gtk2?
Bitblazer
Enthusiast
Enthusiast
Posts: 733
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: Frustrated With Linux

Post by Bitblazer »

Two possible further options are trying with 5.71 Beta 3 or try to use the QT subsystem.
webpage - discord chat links -> purebasic GPT4All
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Frustrated With Linux

Post by collectordave »

Thanks for the replies.

How do I compile with GTK 2?

CD
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Frustrated With Linux

Post by mk-soft »

Compiler option subsystem "gtk2"
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Oma
Enthusiast
Enthusiast
Posts: 312
Joined: Thu Jun 26, 2014 9:17 am
Location: Germany

Re: Frustrated With Linux

Post 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
PureBasic 5.4-5.7, Linux: (X/L/K)Ubuntus+Mint - Windows XP (32Bit)
PureBasic Linux-API-Library & Viewer: http://www.chabba.de
Justin
Addict
Addict
Posts: 829
Joined: Sat Apr 26, 2003 2:49 pm

Re: Frustrated With Linux

Post by Justin »

Post Reply