Ejemplo n.º 1
0
void plugin_init(G_GNUC_UNUSED GeanyData *data){

   /* init gettext and friends */
   main_locale_init(LOCALEDIR, GETTEXT_PACKAGE);

   menu_item_shift_left = gtk_menu_item_new_with_mnemonic(_("Shift Left"));
   gtk_widget_show(menu_item_shift_left);
   gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu),
       menu_item_shift_left);
   g_signal_connect(menu_item_shift_left, "activate",
       G_CALLBACK(shift_left_cb), NULL);

   menu_item_shift_right = gtk_menu_item_new_with_mnemonic(_("Shift Right"));
   gtk_widget_show(menu_item_shift_right);
   gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu),
       menu_item_shift_right);
   g_signal_connect(menu_item_shift_right, "activate",
       G_CALLBACK(shift_right_cb), NULL);

   /* make sure our menu items aren't called when there is no doc open */
   ui_add_document_sensitive(menu_item_shift_right);
   ui_add_document_sensitive(menu_item_shift_left);

   /* setup keybindings */
   keybindings_set_item(plugin_key_group, KB_SHIFT_LEFT, kb_shift_left,
      0, GDK_CONTROL_MASK, "shift_left", _("Shift Left"), menu_item_shift_left);
   keybindings_set_item(plugin_key_group, KB_SHIFT_RIGHT, kb_shift_right,
      0, GDK_CONTROL_MASK, "shift_right", _("Shift Right"), menu_item_shift_right);
   }
Ejemplo n.º 2
0
/* creates plugin's tool's menu */
static GtkWidget *
create_tools_menu_item (void)
{
  GtkWidget  *menu;
  GtkWidget  *item;
  
  /* build submenu */
  menu = gtk_menu_new ();
  /* build "document current symbol" item */
  item = menu_add_item (GTK_MENU_SHELL (menu),
                        _("_Document Current Symbol"),
                        _("Generate documentation for the current symbol"),
                        NULL,
                        G_CALLBACK (document_current_symbol_handler), NULL);
  ui_add_document_sensitive (item);
  /* build "document all" item */
  item = menu_add_item (GTK_MENU_SHELL (menu),
                        _("Document _All Symbols"),
                        _("Generate documentation for all symbols in the "
                          "current document"),
                        NULL,
                        G_CALLBACK (document_all_symbols_handler), NULL);
  ui_add_document_sensitive (item);
  /* separator */
  item = gtk_separator_menu_item_new ();
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
  /* build "reload" item */
  item = menu_add_item (GTK_MENU_SHELL (menu),
                        _("_Reload Configuration Files"),
                        _("Force reloading of the configuration files"),
                        GTK_STOCK_REFRESH,
                        G_CALLBACK (reload_configuration_hanlder), NULL);
  /* language filetypes opener */
  item = menu_add_item (GTK_MENU_SHELL (menu),
                        _("_Edit Current Language Configuration"),
                        _("Open the current language configuration file for "
                          "editing"),
                        GTK_STOCK_EDIT,
                        G_CALLBACK (open_current_filetype_conf_handler), NULL);
  ui_add_document_sensitive (item);
  /* separator */
  item = gtk_separator_menu_item_new ();
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
  /* help/manual opening */
  item = menu_add_item (GTK_MENU_SHELL (menu),
                        _("Open _Manual"),
                        _("Open the manual in a browser"),
                        GTK_STOCK_HELP,
                        G_CALLBACK (open_manual_handler), NULL);
  /* build tools menu item */
  item = gtk_menu_item_new_with_mnemonic (_("_Documentation Generator"));
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), menu);
  gtk_widget_show_all (item);
  
  return item;
}
Ejemplo n.º 3
0
void sc_gui_update_toolbar(void)
{
    /* toolbar item is not requested, so remove the item if it exists */
    if (! sc_info->show_toolbar_item)
    {
        if (sc_info->toolbar_button != NULL)
        {
            gtk_widget_hide(GTK_WIDGET(sc_info->toolbar_button));
        }
    }
    else
    {
        if (sc_info->toolbar_button == NULL)
        {
            sc_info->toolbar_button = gtk_toggle_tool_button_new_from_stock(GTK_STOCK_SPELL_CHECK);

            plugin_add_toolbar_item(geany_plugin, sc_info->toolbar_button);
            ui_add_document_sensitive(GTK_WIDGET(sc_info->toolbar_button));

            g_signal_connect(sc_info->toolbar_button, "toggled",
                             G_CALLBACK(toolbar_item_toggled_cb), NULL);
        }
        gtk_widget_show(GTK_WIDGET(sc_info->toolbar_button));

        sc_ignore_callback = TRUE;
        gtk_toggle_tool_button_set_active(
            GTK_TOGGLE_TOOL_BUTTON(sc_info->toolbar_button), sc_info->check_while_typing);
        sc_ignore_callback = FALSE;
    }
}
Ejemplo n.º 4
0
/* Called by Geany to initialize the plugin */
static gboolean demo_init(GeanyPlugin *plugin, gpointer data)
{
	GtkWidget *demo_item;
	GeanyData *geany_data = plugin->geany_data;

	/* Add an item to the Tools menu */
	demo_item = gtk_menu_item_new_with_mnemonic(_("_Demo Plugin"));
	gtk_widget_show(demo_item);
	gtk_container_add(GTK_CONTAINER(geany_data->main_widgets->tools_menu), demo_item);
	g_signal_connect(demo_item, "activate", G_CALLBACK(item_activate), plugin);

	/* make the menu item sensitive only when documents are open */
	ui_add_document_sensitive(demo_item);
	/* keep a pointer to the menu item, so we can remove it when the plugin is unloaded */
	main_menu_item = demo_item;

	welcome_text = g_strdup(_("Hello World!"));

	/* This might seem strange but is a method to get the GeanyPlugin pointer passed to
	 * on_editor_notify(). PluginCallback functions get the same data that was set via
	 * GEANY_PLUING_REGISTER_FULL() or geany_plugin_set_data() by default (unless the data pointer
	 * was set to non-NULL at compile time).
	 * This is really only done for demoing PluginCallback. Actual plugins will use real custom
	 * data and perhaps embed the GeanyPlugin or GeanyData pointer their if they also use
	 * PluginCallback. */
	geany_plugin_set_data(plugin, plugin, NULL);
	return TRUE;
}
Ejemplo n.º 5
0
/* ---------------------------------------------------------------------
 *  Initialization
 * ---------------------------------------------------------------------
 */
void
switch_head_impl_init()
{
	log_func();

	GtkWidget* edit_menu = ui_lookup_widget(geany->main_widgets->window, "edit1_menu");

	/* Add the menu item and make it sensitive only when a document is opened */
	menu_item = gtk_menu_item_new_with_mnemonic(_("Switch header/implementation"));
	gtk_widget_show(menu_item);
	gtk_container_add(GTK_CONTAINER(edit_menu), menu_item);
	ui_add_document_sensitive(menu_item);

	/* Callback connection */
	g_signal_connect(G_OBJECT(menu_item), "activate", G_CALLBACK(menu_item_activate), NULL);

	/* Initialize the key binding : */
	keybindings_set_item(	plugin_key_group,
 							KEY_ID_SWITCH_HEAD_IMPL,
 							(GeanyKeyCallback)(&menu_item_activate),
 							GDK_s, GDK_MOD1_MASK | GDK_SHIFT_MASK,
 							"switch_head_impl",
 							_("Switch header/implementation"),	/* used in the Preferences dialog */
 							menu_item);

	/* TODO : we should use the languages specified by the user or the default list */
	fill_default_languages_list();
}
Ejemplo n.º 6
0
/* adds the menu item in the editor's popup menu */
static void
add_edit_menu_item (PluginData *pdata)
{
  GtkWidget *parent_menu;
  
  parent_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (
    ui_lookup_widget (geany->main_widgets->editor_menu, "comments")));
  if (! parent_menu) {
    parent_menu = geany->main_widgets->editor_menu;
    pdata->separator_item = gtk_separator_menu_item_new ();
    gtk_menu_shell_append (GTK_MENU_SHELL (parent_menu), pdata->separator_item);
    gtk_widget_show (pdata->separator_item);
  }
  pdata->edit_menu_item = gtk_menu_item_new_with_label (_("Insert Documentation Comment"));
  pdata->edit_menu_item_hid = g_signal_connect (pdata->edit_menu_item, "activate",
                                                G_CALLBACK (editor_menu_acivated_handler),
                                                pdata);
  gtk_menu_shell_append (GTK_MENU_SHELL (parent_menu), pdata->edit_menu_item);
  gtk_widget_show (pdata->edit_menu_item);
  /* make item document-presence sensitive */
  ui_add_document_sensitive (pdata->edit_menu_item);
  /* and attach a keybinding */
  keybindings_set_item (pdata->kb_group, KB_INSERT, insert_comment_keybinding_handler,
                        GDK_d, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
                        "instert_doc", _("Insert Documentation Comment"),
                        pdata->edit_menu_item);
}
Ejemplo n.º 7
0
/* ---------------------------------------------------------------------
 * Initialization
 * ---------------------------------------------------------------------
 */
void
goto_file_init(void)
{
	GtkWidget* edit_menu;

	log_func();

	edit_menu = ui_lookup_widget(geany->main_widgets->window, "edit1_menu");

	/* Add the menu item, sensitive only when a document is opened */
	menu_item = gtk_menu_item_new_with_mnemonic(_("Go to File..."));
	gtk_widget_show(menu_item);
	gtk_container_add(GTK_CONTAINER(edit_menu), menu_item);
	ui_add_document_sensitive(menu_item);

	/* Callback connection */
	g_signal_connect(G_OBJECT(menu_item), "activate", G_CALLBACK(menu_item_activate), NULL);

	/* Initialize the key binding : */
	keybindings_set_item(	plugin_key_group,
 							KEY_ID_GOTO_FILE,
 							(GeanyKeyCallback)(&menu_item_activate),
 							GDK_g, GDK_MOD1_MASK | GDK_SHIFT_MASK,
 							"goto_file",
 							_("Go to File"),	/* used in the Preferences dialog */
 							menu_item);
}
Ejemplo n.º 8
0
static void show_icon(void)
{
	mailbutton = GTK_WIDGET(gtk_tool_button_new_from_stock(GEANYSENDMAIL_STOCK_MAIL));
	plugin_add_toolbar_item(geany_plugin, GTK_TOOL_ITEM(mailbutton));
	ui_add_document_sensitive(mailbutton);
#if GTK_CHECK_VERSION(2, 12, 0)
	gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(mailbutton), _("Send by mail"));
#endif
	g_signal_connect (G_OBJECT(mailbutton), "clicked", G_CALLBACK(send_as_attachment), NULL);
	gtk_widget_show_all (mailbutton);
	icon_in_toolbar = TRUE;
}
Ejemplo n.º 9
0
void plugin_init(GeanyData *data)
{
	GeanyKeyGroup *key_group;
	GKeyFile *config = g_key_file_new();
	gchar *default_lang;

	default_lang = sc_speller_get_default_lang();
	sc_info = g_new0(SpellCheck, 1);

	sc_info->config_file = g_strconcat(geany->app->configdir,
		G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S,
		"spellcheck", G_DIR_SEPARATOR_S, "spellcheck.conf", NULL);

	g_key_file_load_from_file(config, sc_info->config_file, G_KEY_FILE_NONE, NULL);
	sc_info->default_language = utils_get_setting_string(config,
		"spellcheck", "language", default_lang);
	sc_info->check_while_typing = utils_get_setting_boolean(config,
		"spellcheck", "check_while_typing", FALSE);
	sc_info->check_on_document_open = utils_get_setting_boolean(config,
		"spellcheck", "check_on_document_open", FALSE);
	sc_info->show_toolbar_item = utils_get_setting_boolean(config,
		"spellcheck", "show_toolbar_item", TRUE);
	sc_info->show_editor_menu_item = utils_get_setting_boolean(config,
		"spellcheck", "show_editor_menu_item", TRUE);
	sc_info->show_editor_menu_item_sub_menu = utils_get_setting_boolean(config,
		"spellcheck", "show_editor_menu_item_sub_menu", TRUE);
	sc_info->dictionary_dir = utils_get_setting_string(config,
		"spellcheck", "dictionary_dir", NULL);
	sc_info->use_msgwin = utils_get_setting_boolean(config, "spellcheck", "use_msgwin", FALSE);
	g_key_file_free(config);
	g_free(default_lang);

	sc_info->menu_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_SPELL_CHECK, NULL);
	ui_add_document_sensitive(sc_info->menu_item);

	sc_gui_update_toolbar();

	sc_gui_init();
	sc_speller_init();

	sc_gui_update_menu();
	gtk_widget_show_all(sc_info->menu_item);

	/* setup keybindings */
	key_group = plugin_set_key_group(geany_plugin, "spellcheck", KB_COUNT, NULL);
	keybindings_set_item(key_group, KB_SPELL_CHECK, sc_gui_kb_run_activate_cb,
		0, 0, "spell_check", _("Run Spell Check"), sc_info->submenu_item_default);
	keybindings_set_item(key_group, KB_SPELL_TOOGLE_TYPING,
		sc_gui_kb_toggle_typing_activate_cb, 0, 0, "spell_toggle_typing",
		_("Toggle Check While Typing"), NULL);
}
Ejemplo n.º 10
0
void init_menuentries(void)
{
	int i = 0;
	GtkWidget *tmp = NULL;

	/* Build up menu entry for table_convert based on global file type*/
	main_menu_item = gtk_menu_item_new_with_mnemonic(_("_Convert to table"));
	gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), main_menu_item);
	ui_widget_set_tooltip_text(main_menu_item,
		_("Converts current marked list to a table."));
	g_signal_connect(G_OBJECT(main_menu_item), "activate", G_CALLBACK(cb_table_convert), NULL);
	gtk_widget_show_all(main_menu_item);
	ui_add_document_sensitive(main_menu_item);

	/* Build up menu entries for table convert based on explicit choice
	 * This is needed for e.g. different wiki-Syntax or differenz stiles
	 * within a special file type */

	menu_tableconvert = gtk_image_menu_item_new_with_mnemonic(_("_More TableConvert"));
	gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), menu_tableconvert);

	menu_tableconvert_menu = gtk_menu_new ();
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_tableconvert),
							  menu_tableconvert_menu);

	for (i = 0; i < TC_END; i++)
	{
		tmp = NULL;
		tmp = gtk_menu_item_new_with_mnemonic(_(tablerules[i].type));
		gtk_container_add(GTK_CONTAINER(menu_tableconvert_menu), tmp);
		g_signal_connect(G_OBJECT(tmp), "activate",
			G_CALLBACK(cb_table_convert_type), GINT_TO_POINTER(i));
	}
	ui_add_document_sensitive(menu_tableconvert);

	/* Show the menu */
	gtk_widget_show_all(menu_tableconvert);
}
Ejemplo n.º 11
0
/** 
 * name: plugin_init
 * 
 * The Geany plugin initialization function. This is called automatically by Geany when a user installs the plugin.
 *   
 * @param data GeanyData.
 * @return void
 **/
void plugin_init(G_GNUC_UNUSED GeanyData *data)
{
	//Get hold of the Edit menu widget.
	GtkWidget* parent_menu = ui_lookup_widget(GTK_WIDGET(geany->main_widgets->window), "edit1_menu");//"tools1_menu"
	
	// Create the 'LispEdit: eval' menu, assign it to the callback function cb_eval
	// and attach it to parent_menu.
	eval_menu_item = gtk_menu_item_new_with_mnemonic(EVAL_MENU_STR);
	gtk_widget_show(eval_menu_item);
	gtk_container_add(GTK_CONTAINER(parent_menu),							
		eval_menu_item);
	g_signal_connect(eval_menu_item, "activate",
		G_CALLBACK(cb_eval), NULL);
   
    // Create the 'LispEdit: macroexpand-1' menu, assign it to the callback function cb_macroexpand_1
	// and attach it to parent_menu.
	macroexpand_1_menu_item = gtk_menu_item_new_with_mnemonic(MACROEXPAND_MENU_STR);
	gtk_widget_show(macroexpand_1_menu_item);
	gtk_container_add(GTK_CONTAINER(parent_menu),
		macroexpand_1_menu_item);
	g_signal_connect(macroexpand_1_menu_item, "activate",
		G_CALLBACK(cb_macroexpand_1), NULL);

	/* make sure our menu items aren't called when there is no doc open */
	ui_add_document_sensitive(eval_menu_item);
	ui_add_document_sensitive(macroexpand_1_menu_item);

	// setup keybindings for the callback functions.
	keybindings_set_item(plugin_key_group, KB_MACROEXPAND, on_macroexpand_1_key,
		GDK_Return, MACROEXPAND_KEY_SEQ, MACROEXPAND_ID_STR, MACROEXPAND_MENU_STR, macroexpand_1_menu_item);
	keybindings_set_item(plugin_key_group, KB_EVAL, on_eval_key,
		GDK_Return, EVAL_KEY_SEQ, EVAL_ID_STR, EVAL_MENU_STR, eval_menu_item);
	
	//Initialiase the binding to the Geany virtual terminal (VTE).
	init_vte();

}
Ejemplo n.º 12
0
void plugin_init(GeanyData *data)
{
    GtkWidget * submenu;
    GtkWidget * encrypt;
    GtkWidget * sign;
    GtkWidget * decrypt;
    GtkWidget * verify;

    gpgme_error_t err = geanypg_init_gpgme();
    if (err)
    {
        geanypg_show_err_msg(err);
        return;
    }
    /* Create a new menu item and show it */
    main_menu_item = gtk_menu_item_new_with_mnemonic("GeanyPG");
    gtk_widget_show(main_menu_item);
    ui_add_document_sensitive(main_menu_item);

    submenu = gtk_menu_new();
    gtk_widget_show(submenu);
    encrypt = gtk_menu_item_new_with_mnemonic(_("Encrypt"));
    sign = gtk_menu_item_new_with_mnemonic(_("Sign"));
    decrypt = gtk_menu_item_new_with_mnemonic(_("Decrypt / Verify"));
    verify = gtk_menu_item_new_with_mnemonic(_("Verify detached signature"));

    gtk_widget_show(encrypt);
    gtk_widget_show(sign);
    gtk_widget_show(decrypt);
    gtk_widget_show(verify);

    gtk_menu_shell_append(GTK_MENU_SHELL(submenu), encrypt);
    gtk_menu_shell_append(GTK_MENU_SHELL(submenu), sign);
    gtk_menu_shell_append(GTK_MENU_SHELL(submenu), decrypt);
    gtk_menu_shell_append(GTK_MENU_SHELL(submenu), verify);

    gtk_menu_item_set_submenu(GTK_MENU_ITEM(main_menu_item), submenu);

    /* Attach the new menu item to the Tools menu */
    gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu),
        main_menu_item);

    /* Connect the menu item with a callback function
     * which is called when the item is clicked */
    g_signal_connect(encrypt, "activate", G_CALLBACK(geanypg_encrypt_cb), NULL);
    g_signal_connect(sign,    "activate", G_CALLBACK(geanypg_sign_cb), NULL);
    g_signal_connect(decrypt, "activate", G_CALLBACK(geanypg_decrypt_cb), NULL);
    g_signal_connect(verify, "activate", G_CALLBACK(geanypg_verify_cb), NULL);
}
Ejemplo n.º 13
0
/**
 * \brief Called by Geany to initialize the plugin.
 * \note data is the same as geany_data.
 */
void plugin_init(GeanyData *data)
{
    const GeanyIndentPrefs *iprefs = editor_get_indent_prefs(NULL);

    gms_hnd = gms_new(geany->main_widgets->window,
                    data->interface_prefs->editor_font ,
                    iprefs->width,
					geany->app->configdir
                    ) ;

    /* Add an item to the Tools menu */
    gms_item = gtk_menu_item_new_with_mnemonic(_("_Mini-Script"));
    gtk_widget_show(gms_item);
    gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), gms_item);
    g_signal_connect(gms_item, "activate", G_CALLBACK(item_activate), NULL);

    /* make the menu item sensitive only when documents are open */
    ui_add_document_sensitive(gms_item);

}
Ejemplo n.º 14
0
/* Called by Geany to initialize the plugin */
void plugin_init(GeanyData G_GNUC_UNUSED *data)
{
	GKeyFile *config = g_key_file_new();
	gchar *kb_label = _("Send file by mail");
	GtkWidget *menu_mail = NULL;
	GeanyKeyGroup *key_group;

	config_file = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S,
		"geanysendmail", G_DIR_SEPARATOR_S, "mail.conf", NULL);

	/* Initialising options from config file */
	g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL);
	mailer = g_key_file_get_string(config, "tools", "mailer", NULL);
	address = g_key_file_get_string(config, "tools", "address", NULL);
	use_address_dialog = g_key_file_get_boolean(config, "tools", "address_usage", NULL);
	icon_in_toolbar = g_key_file_get_boolean(config, "icon", "show_icon", NULL);

	g_key_file_free(config);

	add_stock_item();
	if (icon_in_toolbar == TRUE)
	{
		show_icon();
	}

	/* Build up menu entry */
	menu_mail = gtk_menu_item_new_with_mnemonic(_("_Mail document"));
	gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), menu_mail);
	gtk_widget_set_tooltip_text(menu_mail,
		_("Sends the opened file as unzipped attachment by any mailer from your $PATH"));
	g_signal_connect(G_OBJECT(menu_mail), "activate", G_CALLBACK(send_as_attachment), NULL);

	/* setup keybindings */
	key_group = plugin_set_key_group(geany_plugin, "sendmail", COUNT_KB, NULL);
	keybindings_set_item(key_group, SENDMAIL_KB, key_send_as_attachment,
		0, 0, "send_file_as_attachment", kb_label, menu_mail);

	gtk_widget_show_all(menu_mail);
	ui_add_document_sensitive(menu_mail);
	main_menu_item = menu_mail;
}
Ejemplo n.º 15
0
void plugin_init(GeanyData *data)
{
    GtkWidget *item, *menu;
    GeanyKeyGroup *key_group;

    menu_items.main = item = gtk_menu_item_new_with_mnemonic(_("_Split Window"));
    gtk_menu_shell_append(GTK_MENU_SHELL(geany_data->main_widgets->tools_menu), item);
    ui_add_document_sensitive(item);

    menu = gtk_menu_new();
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_items.main), menu);

    menu_items.horizontal = item =
                                gtk_menu_item_new_with_mnemonic(_("_Side by Side"));
    g_signal_connect(item, "activate", G_CALLBACK(on_split_horizontally), NULL);
    gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);

    menu_items.vertical = item =
                              gtk_menu_item_new_with_mnemonic(_("_Top and Bottom"));
    g_signal_connect(item, "activate", G_CALLBACK(on_split_vertically), NULL);
    gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);

    menu_items.unsplit = item =
                             gtk_menu_item_new_with_mnemonic(_("_Unsplit"));
    g_signal_connect(item, "activate", G_CALLBACK(on_unsplit), NULL);
    gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);

    gtk_widget_show_all(menu_items.main);

    set_state(STATE_UNSPLIT);

    /* setup keybindings */
    key_group = plugin_set_key_group(geany_plugin, "split_window", KB_COUNT, NULL);
    keybindings_set_item(key_group, KB_SPLIT_HORIZONTAL, kb_activate,
                         0, 0, "split_horizontal", _("Side by Side"), menu_items.horizontal);
    keybindings_set_item(key_group, KB_SPLIT_VERTICAL, kb_activate,
                         0, 0, "split_vertical", _("Top and Bottom"), menu_items.vertical);
    keybindings_set_item(key_group, KB_SPLIT_UNSPLIT, kb_activate,
                         0, 0, "split_unsplit", _("_Unsplit"), menu_items.unsplit);
}
Ejemplo n.º 16
0
/* Called by Geany to initialize the plugin */
void
plugin_init(G_GNUC_UNUSED GeanyData *data)
{
	GtkWidget *menu_lipsum = NULL;
	GKeyFile *config = g_key_file_new();
	gchar *config_file = NULL;
	GeanyKeyGroup *key_group;

	main_locale_init(LOCALEDIR, GETTEXT_PACKAGE);

	config_file = g_strconcat(geany->app->configdir,
		G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S,
		"geanylipsum", G_DIR_SEPARATOR_S, "lipsum.conf", NULL);

	/* Initialising options from config file  if there is any*/
	g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL);
	lipsum = utils_get_setting_string(config, "snippets", "lipsumtext", default_loremipsum);

	g_key_file_free(config);
	g_free(config_file);

	/* Building menu entry */
	menu_lipsum = gtk_image_menu_item_new_with_mnemonic(_("_Lipsum"));
	gtk_widget_set_tooltip_text(menu_lipsum, _("Include Pseudotext to your code"));
	gtk_widget_show(menu_lipsum);
	g_signal_connect((gpointer) menu_lipsum, "activate",
			 G_CALLBACK(lipsum_activated), NULL);
	gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), menu_lipsum);


	ui_add_document_sensitive(menu_lipsum);

	main_menu_item = menu_lipsum;

	/* init keybindings */
	key_group = plugin_set_key_group(geany_plugin, "geanylipsum", COUNT_KB, NULL);
	keybindings_set_item(key_group, LIPSUM_KB_INSERT, kblipsum_insert,
		0, 0, "insert_lipsum", _("Insert Lipsum text"), menu_lipsum);
}
Ejemplo n.º 17
0
void plugin_init(GeanyData *data)
{
    /* initializes the libxml2 */
    LIBXML_TEST_VERSION

    /* mutilanguage support */
    main_locale_init(LOCALEDIR, GETTEXT_PACKAGE);

    /* put the menu into the Tools */
    main_menu_item = gtk_menu_item_new_with_mnemonic(_("PrettyPrinter XML"));
    ui_add_document_sensitive(main_menu_item);

    gtk_widget_show(main_menu_item);
    gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), main_menu_item);

    /* init keybindings */
    keybindings_set_item(plugin_key_group, 0, kb_run_xml_pretty_print,
                         0, 0, "run_pretty_printer_xml", _("Run the PrettyPrinter XML"),
                         main_menu_item);

    /* add activation callback */
    g_signal_connect(main_menu_item, "activate", G_CALLBACK(xml_format), NULL);
}
Ejemplo n.º 18
0
void plugin_init(G_GNUC_UNUSED GeanyData *data)
{
  GeanyKeyGroup *group;
  GtkWidget *menu, *item;

  fmt_prefs_init();

#define CONNECT(sig, cb) \
  plugin_signal_connect(geany_plugin, NULL, sig, TRUE, G_CALLBACK(cb), NULL)

  CONNECT("editor-notify", on_editor_notify);
  CONNECT("project-dialog-open", on_project_dialog_open);
  CONNECT("project-dialog-close", on_project_dialog_close);
  CONNECT("project-dialog-confirmed", on_project_dialog_confirmed);
  CONNECT("project-open", on_project_open);
  CONNECT("project-close", on_project_close);
  CONNECT("project-save", on_project_save);
  CONNECT("document-before-save", on_document_before_save);

#undef CONNECT

  group = plugin_set_key_group(geany_plugin, _("Code Formatting"), 3,
                               (GeanyKeyGroupCallback)on_key_binding);

  main_menu_item = gtk_menu_item_new_with_label(_("Code Format"));
  ui_add_document_sensitive(main_menu_item);
  g_signal_connect(main_menu_item, "map", G_CALLBACK(on_tools_item_map), NULL);
  menu = gtk_menu_new();
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(main_menu_item), menu);

  item = gtk_check_menu_item_new_with_label(_("Auto-Formatting"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
  g_signal_connect(item, "toggled", G_CALLBACK(on_auto_format_item_toggled),
                   NULL);
  g_signal_connect(item, "map", G_CALLBACK(on_auto_format_item_map), NULL);

  item = gtk_separator_menu_item_new();
  gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);

  item = gtk_menu_item_new_with_label(_("Current Line or Selection"));
  g_signal_connect(item, "activate", G_CALLBACK(on_menu_item_activate),
                   GINT_TO_POINTER(FORMAT_KEY_REGION));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
  keybindings_set_item(group, FORMAT_KEY_REGION, NULL, 0, 0, "format_region",
                       _("Format current line or selection"), item);

  item = gtk_menu_item_new_with_label(_("Entire Document"));
  g_signal_connect(item, "activate", G_CALLBACK(on_menu_item_activate),
                   GINT_TO_POINTER(FORMAT_KEY_DOCUMENT));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
  keybindings_set_item(group, FORMAT_KEY_DOCUMENT, NULL, 0, 0,
                       "format_document", _("Format entire document"), item);

  item = gtk_menu_item_new_with_label(_("Entire Session"));
  g_signal_connect(item, "activate", G_CALLBACK(on_menu_item_activate),
                   GINT_TO_POINTER(FORMAT_KEY_SESSION));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
  keybindings_set_item(group, FORMAT_KEY_SESSION, NULL, 0, 0, "format_session",
                       _("Format entire session"), item);

  item = gtk_separator_menu_item_new();
  gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);

  item = gtk_menu_item_new_with_label(_("Open Configuration File"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
  g_signal_connect(item, "activate", G_CALLBACK(on_open_config_file), NULL);
  g_signal_connect(item, "map", G_CALLBACK(on_open_config_item_map), NULL);

  gtk_widget_show_all(main_menu_item);

  gtk_menu_shell_append(GTK_MENU_SHELL(geany_data->main_widgets->tools_menu),
                        main_menu_item);
}
Ejemplo n.º 19
0
/* Called by Geany to initialize the plugin */
void plugin_init(GeanyData G_GNUC_UNUSED *data)
{
	GKeyFile *config = g_key_file_new();
	gchar *config_file_old = NULL;
	gchar *config_dir = NULL;
	gchar *config_dir_old = NULL;
	gchar *kb_label = _("Send file by mail");
	GtkWidget *menu_mail = NULL;
	GeanyKeyGroup *key_group;

	config_file = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S,
		"sendmail", G_DIR_SEPARATOR_S, "mail.conf", NULL);

	#ifndef G_OS_WIN32
	/* We try only to move if we are on not Windows platform */
	config_file_old = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S,
		"plugins", G_DIR_SEPARATOR_S,
		"geanysendmail", G_DIR_SEPARATOR_S, "mail.conf", NULL);
	config_dir = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S,
		"plugins", G_DIR_SEPARATOR_S, "sendmail", NULL);
	config_dir_old = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S,
		"plugins", G_DIR_SEPARATOR_S, "geanysendmail", NULL);

	if (g_file_test(config_file_old, G_FILE_TEST_EXISTS))
	{
		if (dialogs_show_question(
			_("Renamed plugin detected!\n"
			  "\n"
			  "GeanySendMail has been renamed to sendmail -- you surely have "
			  "already recognised it. \n"
			  "Geany is able to migrate your old plugin configuration by "
			  "moving the old configuration file to new location.\n"
			  "Move now?")))
		{
			if (g_rename(config_dir_old, config_dir) == 0)
			{
				dialogs_show_msgbox(GTK_MESSAGE_INFO,
					_("Your configuration directory has been "
					  "successfully moved from \"%s\" to \"%s\"."),
					config_dir_old, config_dir);
			}
			else
			{
				/* If there was an error on migrating we need
				 * to load from original one.
				 * When saving new configuration it will go to
				 * new folder so migration should
				 * be implicit. */
				g_free(config_file);
				config_file = g_strdup(config_file_old);
				dialogs_show_msgbox(
					GTK_MESSAGE_WARNING,
					_("Your old configuration directory \"%s\" could "
					  "not be moved to \"%s\" (%s). "
					  "Please move manually the directory to the new location."),
					config_dir_old,
					config_dir,
					g_strerror(errno));
			}
		}
	}

	g_free(config_dir_old);
	g_free(config_dir);
	g_free(config_file_old);
	#endif

	/* Initialising options from config file */
	g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL);
	mailer = g_key_file_get_string(config, "tools", "mailer", NULL);
	address = g_key_file_get_string(config, "tools", "address", NULL);
	use_address_dialog = g_key_file_get_boolean(config, "tools", "address_usage", NULL);
	icon_in_toolbar = g_key_file_get_boolean(config, "icon", "show_icon", NULL);

	g_key_file_free(config);

	add_stock_item();
	if (icon_in_toolbar == TRUE)
	{
		show_icon();
	}

	/* Build up menu entry */
	menu_mail = gtk_menu_item_new_with_mnemonic(_("_Mail document"));
	gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), menu_mail);
	gtk_widget_set_tooltip_text(menu_mail,
		_("Sends the opened file as unzipped attachment by any mailer from your $PATH"));
	g_signal_connect(G_OBJECT(menu_mail), "activate", G_CALLBACK(send_as_attachment), NULL);

	/* setup keybindings */
	key_group = plugin_set_key_group(geany_plugin, "sendmail", COUNT_KB, NULL);
	keybindings_set_item(key_group, SENDMAIL_KB, key_send_as_attachment,
		0, 0, "send_file_as_attachment", kb_label, menu_mail);

	gtk_widget_show_all(menu_mail);
	ui_add_document_sensitive(menu_mail);
	main_menu_item = menu_mail;
}
Ejemplo n.º 20
0
void plugin_init(G_GNUC_UNUSED GeanyData *data)
{
	GtkContainer *menu;
	GtkWidget *item;
	GeanyKeyGroup *plugin_key_group;

	plugin_key_group = plugin_set_key_group(geany_plugin, "extra_select", COUNT_KB, NULL);

	item = gtk_menu_item_new_with_mnemonic(_("E_xtra Selection"));
	main_menu_item = item;
	gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), item);
	ui_add_document_sensitive(item);
	menu = GTK_CONTAINER(gtk_menu_new());
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), GTK_WIDGET(menu));

	item = gtk_check_menu_item_new_with_mnemonic(_("_Column Mode"));
	column_mode_item = GTK_CHECK_MENU_ITEM(item);
	gtk_container_add(menu, item);
	g_signal_connect(item, "toggled", G_CALLBACK(on_column_mode_toggled), NULL);
	keybindings_set_item(plugin_key_group, COLUMN_MODE_KB, on_column_mode_key, 0, 0,
		"column_mode", _("Column mode"), item);

	item = gtk_menu_item_new_with_mnemonic(_("Select to _Line"));
	gtk_container_add(menu, item);
	g_signal_connect(item, "activate", G_CALLBACK(on_goto_line_activate), NULL);
	keybindings_set_item(plugin_key_group, GOTO_LINE_EXTEND_KB, on_goto_line_key, 0, 0,
		"goto_line_extend", _("Select to line"), item);

	item = gtk_menu_item_new_with_mnemonic(_("Select to Matching _Brace"));
	gtk_container_add(menu, item);
	g_signal_connect(item, "activate", G_CALLBACK(on_brace_match_activate), NULL);
	keybindings_set_item(plugin_key_group, BRACE_MATCH_EXTEND_KB, on_brace_match_key, 0, 0,
		"brace_match_extend", _("Select to matching brace"), item);

	item = gtk_menu_item_new_with_mnemonic(_("_Toggle Stream/Rectangular"));
	gtk_container_add(menu, item);
	g_signal_connect(item, "activate", G_CALLBACK(on_convert_selection_activate), NULL);
	keybindings_set_item(plugin_key_group, CONVERT_SELECTION_KB, on_convert_selection_key,
		0, 0, "convert_selection", _("Convert selection"), item);
	g_signal_connect(main_menu_item, "activate", G_CALLBACK(on_extra_select_activate), item);

	gtk_container_add(menu, gtk_separator_menu_item_new());

	item = gtk_menu_item_new_with_mnemonic(_("_Set Anchor"));
	gtk_container_add(menu, item);
	g_signal_connect(item, "activate", G_CALLBACK(on_set_anchor_activate), NULL);
	keybindings_set_item(plugin_key_group, SET_ANCHOR_KB, on_set_anchor_key, 0, 0,
		"set_anchor", _("Set anchor"), item);

	item = gtk_menu_item_new_with_mnemonic(_("Select to _Anchor"));
	gtk_container_add(menu, item);
	g_signal_connect(item, "activate", G_CALLBACK(on_select_to_anchor_activate), NULL);
	keybindings_set_item(plugin_key_group, ANCHOR_EXTEND_KB, on_select_to_anchor_key, 0, 0,
		"select_to_anchor", _("Select to anchor"), item);

	item = gtk_menu_item_new_with_mnemonic(_("_Rectangle Select to Anchor"));
	anchor_rect_select_item = item;
	gtk_container_add(menu, item);
	g_signal_connect(item, "activate", G_CALLBACK(on_select_rectangle_activate), NULL);
	keybindings_set_item(plugin_key_group, ANCHOR_RECTEXTEND_KB, on_select_rectangle_key, 0,
		0, "rect_select_to_anchor", _("Rectangle select to anchor"), item);

	gtk_widget_show_all(main_menu_item);

	go_to_line1_item = g_object_get_data((gpointer) geany->main_widgets->window,
		"go_to_line1");

	update_home_key();
	plugin_signal_connect(geany_plugin, G_OBJECT(geany->main_widgets->window),
		"key-press-event", FALSE, G_CALLBACK(on_key_press_event), NULL);
}
Ejemplo n.º 21
0
/* Called by Geany to initialize the plugin */
void
plugin_init(G_GNUC_UNUSED GeanyData *data)
{
	GtkWidget *menu_lipsum = NULL;
	GKeyFile *config = g_key_file_new();
	gchar *config_file = NULL;
	gchar *config_file_old = NULL;
	gchar *config_dir = NULL;
	gchar *config_dir_old = NULL;
	GeanyKeyGroup *key_group;


	config_file = g_strconcat(geany->app->configdir,
		G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S,
		"geanylipsum", G_DIR_SEPARATOR_S, "lipsum.conf", NULL);

	#ifndef G_OS_WIN32
	/* We try only to move if we are on not Windows platform */
	config_dir_old = g_build_filename(geany->app->configdir,
		"plugins", "geanylipsum", NULL);
	config_file_old = g_build_filename(config_dir_old,
		"lipsum.conf", NULL);
	config_dir = g_build_filename(geany->app->configdir,
		"plugins", "lipsum", NULL);
	if (g_file_test(config_file_old, G_FILE_TEST_EXISTS))
	{
		if (dialogs_show_question(
			_("Renamed plugin detected!\n"
			  "\n"
			  "As you may have already noticed, GeanyLipsum has been "
			  "renamed to just Lipsum. \n"
			  "Geany is able to migrate your old plugin configuration by "
			  "moving the old configuration file to new location.\n"
			  "Warning: This will not include your keybindings.\n"
			  "Move now?")))
		{
			if (g_rename(config_dir_old, config_dir) == 0)
			{
				dialogs_show_msgbox(GTK_MESSAGE_INFO,
					_("Your configuration directory has been "
					  "successfully moved from \"%s\" to \"%s\"."),
					config_dir_old, config_dir);
			}
			else
			{
				/* If there was an error on migrating we need
				 * to load from original one.
				 * When saving new configuration it will go to
				 * new folder so migration should
				 * be implicit. */
				g_free(config_file);
				config_file = g_strdup(config_file_old);
				dialogs_show_msgbox(
					GTK_MESSAGE_WARNING,
					_("Your old configuration directory \"%s\" could "
					  "not be moved to \"%s\" (%s). "
					  "Please manually move the directory to the new location."),
					config_dir_old,
					config_dir,
					g_strerror(errno));
			}
		}
	}

	g_free(config_dir_old);
	g_free(config_dir);
	g_free(config_file_old);
	#endif

	/* Initialising options from config file  if there is any*/
	g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL);
	lipsum = utils_get_setting_string(config, "snippets", "lipsumtext", default_loremipsum);

	g_key_file_free(config);
	g_free(config_file);

	/* Building menu entry */
	menu_lipsum = gtk_image_menu_item_new_with_mnemonic(_("_Lipsum..."));
	gtk_widget_set_tooltip_text(menu_lipsum, _("Include Pseudotext to your code"));
	gtk_widget_show(menu_lipsum);
	g_signal_connect((gpointer) menu_lipsum, "activate",
			 G_CALLBACK(lipsum_activated), NULL);
	gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), menu_lipsum);


	ui_add_document_sensitive(menu_lipsum);

	main_menu_item = menu_lipsum;

	/* init keybindings */
	key_group = plugin_set_key_group(geany_plugin, "lipsum", COUNT_KB, NULL);
	keybindings_set_item(key_group, LIPSUM_KB_INSERT, kblipsum_insert,
		0, 0, "insert_lipsum", _("Insert Lipsum text"), menu_lipsum);
}
Ejemplo n.º 22
0
void plugin_init(G_GNUC_UNUSED GeanyData *gdata)
{
	GeanyKeyGroup *scope_key_group;
	char *gladefile = g_build_filename(PLUGINDATADIR, "scope.glade", NULL);
	GError *gerror = NULL;
	GtkWidget *menubar1 = find_widget(geany->main_widgets->window, "menubar1");
	guint item;
	const MenuKey *menu_key = debug_menu_keys;
	ToolItem *tool_item = toolbar_items;
	const ScopeCallback *scb;

	main_locale_init(LOCALEDIR, GETTEXT_PACKAGE);
	scope_key_group = plugin_set_key_group(geany_plugin, "scope", COUNT_KB, NULL);
	builder = gtk_builder_new();
	gtk_builder_set_translation_domain(builder, GETTEXT_PACKAGE);
	scp_tree_store_register_dynamic();

	if (!gtk_builder_add_from_file(builder, gladefile, &gerror))
	{
		msgwin_status_add(_("Scope: %s."), gerror->message);
		g_warning(_("Scope: %s."), gerror->message);
		g_error_free(gerror);
		g_object_unref(builder);
		builder = NULL;
	}

	g_free(gladefile);
	if (!builder)
		return;

	/* interface */
#ifndef G_OS_UNIX
	gtk_widget_hide(get_widget("terminal_show"));
#endif
	debug_item = get_widget("debug_item");
	if (menubar1)
		gtk_menu_shell_insert(GTK_MENU_SHELL(menubar1), debug_item, DEBUG_MENU_ITEM_POS);
	else
		gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), debug_item);

	menu_connect("debug_menu", &debug_menu_info, NULL);
	ui_add_document_sensitive(get_widget("scope_reset_markers"));
	ui_add_document_sensitive(get_widget("scope_cleanup_files"));

	for (item = 0; item < EVALUATE_KB; item++, menu_key++)
	{
		keybindings_set_item(scope_key_group, item, on_scope_key, 0, 0, menu_key->name,
			_(menu_key->label), debug_menu_items[item].widget);
	}

	geany_statusbar = GTK_STATUSBAR(gtk_widget_get_parent(geany->main_widgets->progressbar));
	debug_statusbar = get_widget("debug_statusbar");
	debug_state_label = GTK_LABEL(get_widget("debug_state_label"));
	gtk_box_pack_end(GTK_BOX(geany_statusbar), debug_statusbar, FALSE, FALSE, 0);

	debug_panel = get_widget("debug_panel");
	gtk_notebook_append_page(GTK_NOTEBOOK(geany->main_widgets->message_window_notebook),
		debug_panel, get_widget("debug_label"));

	/* startup */
	gtk216_init();
	program_init();
	prefs_init();
	conterm_init();
	inspect_init();
	register_init();
	parse_init();
	debug_init();
	views_init();
	thread_init();
	break_init();
	watch_init();
	stack_init();
	local_init();
	memory_init();
	menu_init();
	menu_set_popup_keybindings(scope_key_group, item);

	for (item = 0; tool_item->index != -1; item++, tool_item++)
	{
		GtkMenuItem *menu_item = GTK_MENU_ITEM(debug_menu_items[tool_item->index].widget);
		GtkToolItem *button = gtk_tool_button_new(NULL, gtk_menu_item_get_label(menu_item));

		gtk_tool_button_set_use_underline(GTK_TOOL_BUTTON(button),
			gtk_menu_item_get_use_underline(menu_item));
		g_signal_connect(button, "clicked", G_CALLBACK(on_toolbar_button_clicked),
			GINT_TO_POINTER(tool_item->index));
		g_signal_connect(button, "toolbar-reconfigured",
			G_CALLBACK(on_toolbar_reconfigured), tool_item);
		tool_item->widget = GTK_WIDGET(button);
		plugin_add_toolbar_item(geany_plugin, button);
	}

	toolbar_update_state(DS_INACTIVE);
	views_update_state(DS_INACTIVE);
	configure_toolbar();

	g_signal_connect(debug_panel, "switch-page", G_CALLBACK(on_view_changed), NULL);
	for (scb = scope_callbacks; scb->name; scb++)
		plugin_signal_connect(geany_plugin, NULL, scb->name, FALSE, scb->callback, NULL);
}