Gnome JavaScript 创建简易HeaderBar

Gnome 平台上 JS api。

JS Gnome 项目参考 git.gnome.org,文档参考 devdocs.baznga.org

JS Gnome 简易HeaderBar Demo,解释器采用 Seed(Gnome3 + JavaScriptCore)。

headerBar.js

#!/usr/bin/env seed
// Gnome headerBar demo using seed (Gtk+3.0)

Gtk = imports.gi.Gtk;

Gtk.init(Seed.argv);

// Top window
window = new Gtk.Window();
window.resize(400, 100);
window.signal.hide.connect(Gtk.main_quit);

// Header bar
headerBar = new Gtk.HeaderBar();
headerBar.set_show_close_button(true);
headerBar.set_title('Header Bar');
headerBar.set_has_subtitle(false);

// Top right button
buttonRight = new Gtk.Button.from_icon_name(
  'mail-send-receive-symbolic',
  Gtk.IconSize.BUTTON
);
headerBar.pack_end(buttonRight)

// Top left buttons
buttonLeft1 = new Gtk.Button.from_icon_name(
  'pan-start-symbolic',
  Gtk.IconSize.BUTTON
);
headerBar.pack_start(buttonLeft1);
buttonLeft2 = new Gtk.Button.from_icon_name(
  'pan-end-symbolic',
  Gtk.IconSize.BUTTON
);
headerBar.pack_start(buttonLeft2);

window.set_titlebar(headerBar);

// Run
window.show_all();

Gtk.main();

API:gtk_window_set_titlebar ,效果:

Gnome JavaScript HeaderBar
Gnome JavaScript HeaderBar

Gist: Gist.Github

作者: YanWen

Web 开发者

发表评论

Fill in your details below or click an icon to log in:

WordPress.com 徽标

You are commenting using your WordPress.com account. Log Out /  更改 )

Google photo

You are commenting using your Google account. Log Out /  更改 )

Twitter picture

You are commenting using your Twitter account. Log Out /  更改 )

Facebook photo

You are commenting using your Facebook account. Log Out /  更改 )

Connecting to %s