<commit_before>/* Copyright 2011 Yorba Foundation
 *
 * This software is licensed under the GNU Lesser General Public License
 * (version 2.1 or later).  See the COPYING file in this distribution. 
 */

// Draws the main toolbar.
public class MainToolbar : Gtk.VBox {
    private Gtk.Toolbar toolbar;
    private Gtk.Menu menu;
    private Gtk.ToolButton menu_button;
    
    public MainToolbar() {
        GearyApplication.instance.load_ui_file("toolbar_menu.ui");
        menu = GearyApplication.instance.ui_manager.get_widget("/ui/ToolbarMenu") as Gtk.Menu;
        
        Gtk.Builder builder = GearyApplication.instance.create_builder("toolbar.glade");
        toolbar = builder.get_object("toolbar") as Gtk.Toolbar;
        
        Gtk.ToolButton new_message = builder.get_object("new_button") as Gtk.ToolButton;
        new_message.set_related_action(GearyApplication.instance.actions.get_action(
            GearyApplication.ACTION_NEW_MESSAGE));
        
        menu_button = builder.get_object("menu_button") as Gtk.ToolButton;
        menu_button.clicked.connect(on_show_menu);
        
        add(toolbar);
    }
    
    private void on_show_menu() {
        menu.popup(null, null, popup_pos, 0, 0);
    }
    
    private void popup_pos(Gtk.Menu menu, out int x, out int y, out bool push_in) {
        menu.realize();
        
        int rx, ry;
        get_window().get_root_origin(out rx, out ry);
        
        Gtk.Allocation menu_button_allocation;
        menu_button.get_allocation(out menu_button_allocation);
        
        Gtk.Allocation toolbar_allocation;
        get_allocation(out toolbar_allocation);
        
        x = rx + menu_button_allocation.x;
        y = ry + menu_button_allocation.height + toolbar_allocation.height;
        
        push_in = false;
    }
}
<commit_msg>Toolbar now styled properly. Closes #4273<commit_after>/* Copyright 2011 Yorba Foundation
 *
 * This software is licensed under the GNU Lesser General Public License
 * (version 2.1 or later).  See the COPYING file in this distribution. 
 */

// Draws the main toolbar.
public class MainToolbar : Gtk.VBox {
    private Gtk.Toolbar toolbar;
    private Gtk.Menu menu;
    private Gtk.ToolButton menu_button;
    
    public MainToolbar() {
        GearyApplication.instance.load_ui_file("toolbar_menu.ui");
        menu = GearyApplication.instance.ui_manager.get_widget("/ui/ToolbarMenu") as Gtk.Menu;
        
        Gtk.Builder builder = GearyApplication.instance.create_builder("toolbar.glade");
        toolbar = builder.get_object("toolbar") as Gtk.Toolbar;
        
        Gtk.ToolButton new_message = builder.get_object("new_button") as Gtk.ToolButton;
        new_message.set_related_action(GearyApplication.instance.actions.get_action(
            GearyApplication.ACTION_NEW_MESSAGE));
        
        menu_button = builder.get_object("menu_button") as Gtk.ToolButton;
        menu_button.clicked.connect(on_show_menu);
        
        toolbar.get_style_context().add_class("primary-toolbar");
        
        add(toolbar);
    }
    
    private void on_show_menu() {
        menu.popup(null, null, popup_pos, 0, 0);
    }
    
    private void popup_pos(Gtk.Menu menu, out int x, out int y, out bool push_in) {
        menu.realize();
        
        int rx, ry;
        get_window().get_root_origin(out rx, out ry);
        
        Gtk.Allocation menu_button_allocation;
        menu_button.get_allocation(out menu_button_allocation);
        
        Gtk.Allocation toolbar_allocation;
        get_allocation(out toolbar_allocation);
        
        x = rx + menu_button_allocation.x;
        y = ry + menu_button_allocation.height + toolbar_allocation.height;
        
        push_in = false;
    }
}

{'fraction_non_alphanumeric': 0.08913797704830531, 'fraction_numerical': 0.0053376034160661865, 'mean_word_length': 2.631782945736434, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5808561', 'n_tokens_mistral': 1143, 'n_tokens_neox': 1118, 'n_words': 240}