Linux PB 5.40 Linux Mint 17.2 x64 GDK-Error

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

Re: Linux PB 5.40 Linux Mint 17.2 x64 GDK-Error

Post by Shardik »

The following example works equally well with Gtk2 and Gtk3 in displaying a background image in a window (tested on Ubuntu 14.04 x64 and KDE with PB 5.31 and PB 5.40 in ASCII and Unicode mode):

Code: Select all

EnableExplicit

InitNetwork()
UseJPEGImageDecoder()

Procedure.I GetContainer(WindowID.I, ContainerName.S)
  Protected Child.I
  Protected ChildrenList.I
  Protected *Name
  Protected Widget.I = WindowID(WindowID)

  Child = gtk_bin_get_child_(Widget)

  Repeat
    ChildrenList = gtk_container_get_children_(Widget)
    Child = g_list_nth_data_(ChildrenList, 0)

    If Child = 0
      Break
    Else
      *Name = gtk_widget_get_name_(Child)
      Widget = Child
    EndIf
  Until PeekS(*Name, -1, #PB_UTF8) = ContainerName

  ProcedureReturn Child
EndProcedure

Procedure SetWindowBackgroundImage(WindowID.I, ImageID.I)
  Protected Container.I

  Container = GetContainer(0, "GtkFixed")

  If Container
    gtk_fixed_put_(Container, gtk_image_new_from_pixbuf_(ImageID(ImageID)), 0, 0)
    gtk_widget_show_all_(WindowID(WindowID))
  EndIf
EndProcedure

If FileSize(GetTemporaryDirectory() + "stargate_atlantis.jpg") <= 0
  ReceiveHTTPFile("http://realsource.de/images/stargate_atlantis.jpg",
    GetTemporaryDirectory() + "stargate_atlantis.jpg")
EndIf

If LoadImage(0, GetTemporaryDirectory() + "stargate_atlantis.jpg")
  OpenWindow(0, 100, 100, ImageWidth(0), ImageHeight(0),
    "Window with background image")
  SetWindowBackgroundImage(0, 0)

  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf