Page 1 of 1

Re: GTK3 HeaderBar Example

Posted: Thu Oct 01, 2015 8:36 pm
by Shardik
fsw,

thank you for your nice GtkHeaderBar example which uses only Gtk3 API functions. I have tried to program a stripped down version which uses a PB window and PB menu bar so that the event handling becomes much easier. I am currently only able to test my example successfully on Ubuntu 14.04 x64 with KDE and PB 5.40 Beta 8 (Unity and Enlightenment don't display or handle the GtkHeaderBar correctly as documented in this thread).

My example has one improvement to your example: the menu bar is fully integrated into the header bar while your example displays the menu bar below the header bar.

Code: Select all

EnableExplicit

ImportC ""
  gtk_header_bar_new()
  gtk_header_bar_pack_start (*HeaderBar, *Child)
  gtk_header_bar_set_show_close_button(*HeaderBar, ShowCloseButton.I)
  gtk_header_bar_set_subtitle(*HeaderBar, Title.P-UTF8)
  gtk_header_bar_set_title(*HeaderBar, Subtitle.P-UTF8)
  gtk_window_set_titlebar(*Window.GtkWindow, *Titlebar)
EndImport

Define HeaderBar.I

OpenWindow(0, 0, 0, 275, 275, "GtkHeaderBar demo",
  #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CreateMenu(0, WindowID(0))
MenuTitle("Application")
MenuItem(0, "Preferences")
MenuBar()
MenuItem(1, "Quit")

HeaderBar = gtk_header_bar_new()

If HeaderBar
  gtk_header_bar_set_title(HeaderBar, "GTK3")
  gtk_header_bar_set_subtitle(HeaderBar, "Test")
  gtk_header_bar_set_show_close_button(HeaderBar, #True)
  gtk_window_set_titlebar(WindowID(0), HeaderBar)
  gtk_widget_reparent_(MenuID(0), HeaderBar)
EndIf

gtk_widget_show_all_(WindowID(0))

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow

Re: GTK3 HeaderBar Example

Posted: Thu Oct 01, 2015 10:33 pm
by fsw
That's a very nice example.
Shardik wrote:My example has one improvement to your example: the menu bar is fully integrated into the header bar...
Your code works probably better on all Linux desktop environments.
Shardik wrote:...while your example displays the menu bar below the header bar.
Not on Gnome 3.
There it's shown in the application-menu (inside the single black panel at the top of the screen) and not inside the window.
(looks the same as the OSX menus...)

Your version will be better suited in conjunction with all the other PB GUI elements.
Thanks

EDIT
Just realized that your example app doesn't recognize the maximize keyboard shortcut (super & arrow-up) and other shortcuts.
(normalize size = super & arrow-down, move to the left side = super & arrow-left, move to the right side = super & arrow-right).
Suppose they are only available on Gnome 3.
This is because gtk_application_new is not used...

Re: GTK3 HeaderBar Example

Posted: Sat Apr 16, 2016 9:14 am
by mestnyi
Ubuntu 14.04 lts purebasic 531 lts не работают ваши примеры Your examples do not work the compiler complains

Re: GTK3 HeaderBar Example

Posted: Sat Apr 16, 2016 6:16 pm
by Oma
@mestnyi
Like the topic says: GTK3 HeaderBar... :wink: