Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main(string[] args){
- Gtk.init(ref args);
- // Declare Window
- var exampleWindow = new Gtk.Window();
- exampleWindow.title = "example";
- exampleWindow.border_width = 0;
- exampleWindow.window_position = Gtk.WindowPosition.CENTER;
- exampleWindow.set_default_size(800, 600);
- // End of Declaring Window
- // Declare Container for Window
- var exampleContainer = new Gtk.Grid();
- exampleContainer.set_column_homogeneous(false);
- exampleContainer.set_hexpand(true);
- exampleWindow.add(exampleContainer);
- // Create / Declare Toolbar
- var exampleMainToolbar = new Gtk.Toolbar();
- exampleMainToolbar.icon_size = 32;
- exampleMainToolbar.show_arrow = false;
- exampleMainToolbar.margin = 0;
- exampleMainToolbar.set_hexpand(true);
- // Search Box
- var exampleSearchBoxContainer = new Gtk.ToolItem();
- exampleSearchBoxContainer.set_margin_left(6);
- var exampleSearchBox = new Gtk.Entry();
- exampleSearchBox.set_text("Search Your Tasks..."); // Set the search box text to...
- exampleSearchBox.set_icon_from_stock(Gtk.EntryIconPosition.PRIMARY, Gtk.Stock.FIND); // Set the icon on the right of the entry box to be the clear button
- exampleSearchBox.icon_press.connect((pos, event) => {
- if (pos == Gtk.EntryIconPosition.SECONDARY){ // If we in fact clicked on the Clear button
- exampleSearchBox.set_text("Search Your Tasks"); // Reset the search box text
- }
- else{ // If we didn't click the clear button a.k.a we clicked elsewhere on the input
- exampleSearchBox.set_text(""); // Clear the input.
- }
- });
- // End of Search Box
- // Global menu
- var exampleGlobalMenuContainer = new Gtk.ToolItem();
- exampleGlobalMenuContainer.tooltip_text = "Menu";
- var exampleGlobalMenuButton = new Gtk.ToolButton.from_stock(Gtk.Stock.PROPERTIES);
- var exampleGlobalMenu = new Gtk.Menu();
- exampleGlobalMenuButton.clicked.connect(() => {
- // I shall do nothing...for now
- });
- var exampleGlobalMenu_SettingsMenuItem = new Gtk.MenuItem();
- exampleGlobalMenu_SettingsMenuItem.set_label("Settings");
- exampleGlobalMenu.attach(exampleGlobalMenu_SettingsMenuItem, 0, 0, 0, 0);
- // End of Global menu
- exampleSearchBoxContainer.add(exampleSearchBox); // Insert the search box into the toolitem container
- exampleGlobalMenuContainer.add(exampleGlobalMenuButton); // Insert the menu button and menu into the menu container
- exampleGlobalMenuContainer.add(exampleGlobalMenu); // Insert the menu into the menu container
- exampleMainToolbar.insert(exampleSearchBoxContainer, 0); // Insert the search box container to the left in the toolbar
- exampleMainToolbar.insert(exampleGlobalMenuContainer, 1); // Insert the global menu container to the right in the toolbar
- // End of Creating / Declaring Toolbar
- exampleContainer.add(exampleMainToolbar); // Add the toolbar to the grid container
- exampleWindow.add(exampleContainer); // Add the grid container to the window
- exampleWindow.show_all();
- Gtk.main();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment