Skip to content

Instantly share code, notes, and snippets.

@MattRead
Created September 7, 2010 02:54
Show Gist options
  • Save MattRead/567799 to your computer and use it in GitHub Desktop.
Save MattRead/567799 to your computer and use it in GitHub Desktop.
Add a menu entry and toolbar item to epiphany
// create the tomboy icon
var f = new Gtk.IconFactory();
f.add('tomboy', new Gtk.IconSet.from_pixbuf(
new GdkPixbuf.Pixbuf.from_file('/usr/share/icons/hicolor/scalable/apps/tomboy.svg')
));
f.add_default();
// Create the action and group to add to menubar
var action = new Gtk.Action({
name: 'TomboyNote',
label: '_Tomboy Note',
tooltip: 'Create a Tomboy note from selection',
stock_id: 'tomboy'
});
action.signal.activate.connect(create_tomboy_note, window);
var group = new Gtk.ActionGroup({name: "TomboyNoteActionGroup"});
group.add_action(action);
var ui_manager = window.get_ui_manager();
ui_manager.insert_action_group(group, 0);
var merge_id = ui_manager.new_merge_id();
ui_manager.add_ui(merge_id, "/menubar/ToolsMenu", "TomboyNoteMenu", "TomboyNote",
Gtk.UIManagerItemType.MENUITEM, false);
// store everything so we can remove it on detach
window._tomboy_menu = {
ui_manager: ui_manager,
merge_id: merge_id,
action: action,
group: group
};
var model = Epiphany.EphyShell.get_default().get_toolbars_model(false);
model.set_name_flags("TomboyNote", 4); // EGG_TB_MODEL_NAME_KNOWN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment