Commit 8c7f33e7 authored by Sebastien Granjoux's avatar Sebastien Granjoux
Browse files

project-wizard: bgo #563986 - wizard generates modeline inconsistent with indentation prefs

parent 70b56b50
......@@ -37,6 +37,7 @@
#include <libanjuta/anjuta-debug.h>
#include <libanjuta/anjuta-utils.h>
#include <libanjuta/interfaces/ianjuta-wizard.h>
#include <libanjuta/interfaces/ianjuta-editor.h>
#include <stdlib.h>
#include <glib/gi18n.h>
#include <glib.h>
......@@ -56,6 +57,13 @@
#define ANJUTA_PROJECT_DIRECTORY_PROPERTY "AnjutaProjectDirectory"
#define USER_NAME_PROPERTY "UserName"
#define EMAIL_ADDRESS_PROPERTY "EmailAddress"
#define INDENT_WIDTH_PROPERTY "IndentWidth"
#define TAB_WIDTH_PROPERTY "TabWidth"
#define USE_TABS_PROPERTY "UseTabs"
/* Common editor preferences */
#define ANJUTA_PREF_SCHEMA_PREFIX "org.gnome.anjuta."
/* Widget and signal name found in glade file
*---------------------------------------------------------------------------*/
......@@ -1204,8 +1212,10 @@ npw_druid_add_default_property (NPWDruid* druid)
{
NPWValue* value;
gchar* s;
/* gchar* email; */
AnjutaPreferences* pref;
GSettings *settings;
gboolean flag;
gint i;
pref = anjuta_shell_get_preferences (ANJUTA_PLUGIN (druid->plugin)->shell, NULL);
......@@ -1217,13 +1227,34 @@ npw_druid_add_default_property (NPWDruid* druid)
value = npw_value_heap_find_value (druid->values, USER_NAME_PROPERTY);
s = (gchar *)g_get_real_name();
npw_value_set_value (value, s, NPW_VALID_VALUE);
/* Add Email address */
value = npw_value_heap_find_value (druid->values, EMAIL_ADDRESS_PROPERTY);
/* FIXME: We need a default way for the mail */
s = anjuta_util_get_user_mail();
npw_value_set_value (value, s, NPW_VALID_VALUE);
g_free (s);
/* Add use-tabs property */
settings = g_settings_new (ANJUTA_PREF_SCHEMA_PREFIX IANJUTA_EDITOR_PREF_SCHEMA);
flag = g_settings_get_boolean (settings, IANJUTA_EDITOR_USE_TABS_KEY);
value = npw_value_heap_find_value (druid->values, USE_TABS_PROPERTY);
npw_value_set_value (value, flag ? "1" : "0", NPW_VALID_VALUE);
/* Add tab-width property */
i = g_settings_get_int (settings, IANJUTA_EDITOR_TAB_WIDTH_KEY);
value = npw_value_heap_find_value (druid->values, TAB_WIDTH_PROPERTY);
s = g_strdup_printf("%d", i);
npw_value_set_value (value, s, NPW_VALID_VALUE);
g_free (s);
/* Add indent-width property */
i = g_settings_get_int (settings, IANJUTA_EDITOR_INDENT_WIDTH_KEY);
value = npw_value_heap_find_value (druid->values, INDENT_WIDTH_PROPERTY);
s = g_strdup_printf("%d", i);
npw_value_set_value (value, s, NPW_VALID_VALUE);
g_free (s);
g_object_unref (settings);
}
/* Druid public functions
......
......@@ -46,7 +46,8 @@ wizard_files_DATA = \
appwiz_sdl.png \
gnome.png \
gnome.svg \
$(template_in_files:.in=)
$(template_in_files:.in=) \
indent.tpl
# Translate wiz file
%.wiz: %.wiz.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -x -u -c $(top_builddir)/po/.intltool-merge-cache
......
[+ autogen5 template +]
[+INCLUDE (string-append "licenses/" (get "License") ".tpl") \+]
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
[+INCLUDE (string-append "indent.tpl") \+]
/* [+INVOKE EMACS-MODELINE MODE="C" \+] */
[+INVOKE START-INDENT\+]
/*
* plugin.c
* Copyright (C) [+(shell "date +%Y")+] [+Author+] <[+Email+]>
......@@ -174,3 +176,4 @@ static void
ANJUTA_PLUGIN_BOILERPLATE ([+PluginClass+], [+NameCLower+]);
ANJUTA_SIMPLE_PLUGIN ([+PluginClass+], [+NameCLower+]);
[+INVOKE END-INDENT\+]
[+ autogen5 template +]
[+INCLUDE (string-append "licenses/" (get "License") ".tpl") \+]
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
[+INCLUDE (string-append "indent.tpl") \+]
/* [+INVOKE EMACS-MODELINE MODE="C" \+] */
[+INVOKE START-INDENT\+]
/*
* plugin.h
* Copyright (C) [+(shell "date +%Y")+] [+Author+] <[+Email+]>
......@@ -28,3 +30,4 @@ struct _[+PluginClass+]Class{
};
#endif
[+INVOKE END-INDENT\+]
[+ autogen5 template +]
[+INCLUDE (string-append "licenses/" (get "License") ".tpl") \+]
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
[+INCLUDE (string-append "indent.tpl") \+]
/* [+INVOKE EMACS-MODELINE MODE="C" \+] */
[+INVOKE START-INDENT\+]
/*
* main.cc
* Copyright (C) [+(shell "date +%Y")+] [+Author+] <[+Email+]>
......@@ -15,3 +17,4 @@ int main()
std::cout << "Hello world!" << std::endl;
return 0;
}
[+INVOKE END-INDENT\+]
[+ autogen5 template +]
[+INCLUDE (string-append "licenses/" (get "License") ".tpl") \+]
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
[+INCLUDE (string-append "indent.tpl") \+]
/* [+INVOKE EMACS-MODELINE MODE="js2" \+] */
[+INVOKE START-INDENT\+]
/*
* extension.js
* Copyright (C) [+(shell "date +%Y")+] [+Author+] <[+Email+]>
......@@ -18,50 +20,50 @@ const Extension = imports.ui.extensionSystem.extensions['[+UUID+]'];
let text, button;
function _hideHello() {
Main.uiGroup.remove_actor(text);
text = null;
Main.uiGroup.remove_actor(text);
text = null;
}
function _showHello() {
if (!text) {
text = new St.Label({ style_class: '[+NameHLower+]-label', text: "Hello, world!" });
Main.uiGroup.add_actor(text);
}
if (!text) {
text = new St.Label({ style_class: '[+NameHLower+]-label', text: "Hello, world!" });
Main.uiGroup.add_actor(text);
}
text.opacity = 255;
text.opacity = 255;
let monitor = Main.layoutManager.primaryMonitor;
let monitor = Main.layoutManager.primaryMonitor;
text.set_position(Math.floor(monitor.width / 2 - text.width / 2),
Math.floor(monitor.height / 2 - text.height / 2));
text.set_position(Math.floor(monitor.width / 2 - text.width / 2),
Math.floor(monitor.height / 2 - text.height / 2));
Tweener.addTween(text,
{ opacity: 0,
time: 2,
transition: 'easeOutQuad',
onComplete: _hideHello });
Tweener.addTween(text,
{ opacity: 0,
time: 2,
transition: 'easeOutQuad',
onComplete: _hideHello });
}
function init() {
button = new St.Bin({ style_class: 'panel-button',
reactive: true,
can_focus: true,
x_fill: true,
y_fill: false,
track_hover: true });
let icon = new St.Icon({ icon_name: 'system-run',
icon_type: St.IconType.SYMBOLIC,
style_class: 'system-status-icon' });
button = new St.Bin({ style_class: 'panel-button',
reactive: true,
can_focus: true,
x_fill: true,
y_fill: false,
track_hover: true });
let icon = new St.Icon({ icon_name: 'system-run',
icon_type: St.IconType.SYMBOLIC,
style_class: 'system-status-icon' });
button.set_child(icon);
button.connect('button-press-event', _showHello);
button.set_child(icon);
button.connect('button-press-event', _showHello);
}
function enable() {
Main.panel._rightBox.insert_actor(button, 0);
Main.panel._rightBox.insert_actor(button, 0);
}
function disable() {
Main.panel._rightBox.remove_actor(button);
Main.panel._rightBox.remove_actor(button);
}
[+INVOKE END-INDENT\+]
[+ autogen5 template +]
[+INCLUDE (string-append "licenses/" (get "License") ".tpl") \+]
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
[+INCLUDE (string-append "indent.tpl") \+]
/* [+INVOKE EMACS-MODELINE MODE="C" \+] */
[+INVOKE START-INDENT\+]
/*
* main.c
* Copyright (C) [+(shell "date +%Y")+] [+Author+] <[+Email+]>
......@@ -115,3 +117,4 @@ main (int argc, char *argv[])
[+ENDIF+]
return 0;
}
[+INVOKE END-INDENT\+]
[+ autogen5 template +]
[+INCLUDE (string-append "licenses/" (get "License") ".tpl") \+]
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
[+INCLUDE (string-append "indent.tpl") \+]
/* [+INVOKE EMACS-MODELINE MODE="C" \+] */
[+INVOKE START-INDENT\+]
/*
* [+NameLower+].c
* Copyright (C) [+(shell "date +%Y")+] [+Author+] <[+Email+]>
......@@ -58,7 +60,7 @@ static void
window = GTK_WIDGET (gtk_builder_get_object (builder, TOP_WINDOW));
if (!window)
{
g_critical ("Widget \"%s\" is missing in file %s.",
g_critical ("Widget \"%s\" is missing in file %s.",
TOP_WINDOW,
UI_FILE);
}
......@@ -85,7 +87,7 @@ static void
static void
[+NameCLower+]_activate (GApplication *application)
{
[+NameCLower+]_new_window (application, NULL);
[+NameCLower+]_new_window (application, NULL);
}
static void
......@@ -94,10 +96,10 @@ static void
gint n_files,
const gchar *hint)
{
gint i;
gint i;
for (i = 0; i < n_files; i++)
[+NameCLower+]_new_window (application, files[i]);
for (i = 0; i < n_files; i++)
[+NameCLower+]_new_window (application, files[i]);
}
static void
......@@ -109,7 +111,6 @@ static void
static void
[+NameCLower+]_finalize (GObject *object)
{
G_OBJECT_CLASS ([+NameCLower+]_parent_class)->finalize (object);
}
......@@ -134,3 +135,4 @@ static void
"flags", G_APPLICATION_HANDLES_OPEN,
NULL);
}
[+INVOKE END-INDENT\+]
[+ autogen5 template +]
[+INCLUDE (string-append "licenses/" (get "License") ".tpl") \+]
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
[+INCLUDE (string-append "indent.tpl") \+]
/* [+INVOKE EMACS-MODELINE MODE="C" \+] */
[+INVOKE START-INDENT\+]
/*
* [+NameLower+].h
* Copyright (C) [+(shell "date +%Y")+] [+Author+] <[+Email+]>
......@@ -47,3 +49,4 @@ GType [+NameCLower+]_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* _APPLICATION_H_ */
[+INVOKE END-INDENT\+]
[+ autogen5 template +]
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
[+INCLUDE (string-append "licenses/" (get "License") ".tpl") \+]
[+INCLUDE (string-append "indent.tpl") \+]
/* [+INVOKE EMACS-MODELINE MODE="C" \+] */
[+INVOKE START-INDENT\+]
/*
* main.c
* Copyright (C) [+Author+] [+(shell "date +%Y")+] <[+Email+]>
*
[+CASE (get "License") +]
[+ == "BSD" +][+(bsd (get "Name") (get "Author") " * ")+]
[+ == "LGPL" +][+(lgpl (get "Name") (get "Author") " * ")+]
[+ == "GPL" +][+(gpl (get "Name") " * ")+]
[+ESAC+] */
* Copyright (C) [+(shell "date +%Y")+] [+Author+] <[+Email+]>
*
[+INVOKE LICENSE-DESCRIPTION PFX=" * " PROGRAM=(get "Name") OWNER=(get "Author") \+]
*/
#include <config.h>
#include <gtk/gtk.h>
......@@ -32,9 +32,10 @@ main (int argc, char *argv[])
#endif
[+ENDIF+]
app = [+NameCLower+]_new ();
status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
app = [+NameCLower+]_new ();
status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
return status;
return status;
}
[+INVOKE END-INDENT\+]
[+ autogen5 template +]
[+INCLUDE (string-append "licenses/" (get "License") ".tpl") \+]
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
[+INCLUDE (string-append "indent.tpl") \+]
/* [+INVOKE EMACS-MODELINE MODE="C" \+] */
[+INVOKE START-INDENT\+]
/*
* main.cc
* Copyright (C) [+(shell "date +%Y")+] [+Author+] <[+Email+]>
......@@ -55,3 +57,4 @@ main (int argc, char *argv[])
}
return 0;
}
[+INVOKE END-INDENT\+]
[+ autogen5 template +]
[+DEFINE START-INDENT \+]
[+(out-push-new)\+]
[+ENDDEF \+]
[+DEFINE END-INDENT \+]
[+(for-each
indent
(string-split (out-pop #t) #\nl);
)\+]
[+ENDDEF \+]
[+(define
indentation
(lambda
(tab)
(let*
(
(use-tabs (not (zero? (or (string->number (get "UseTabs")) 8))))
(tab-width (or (string->number (get "TabWidth")) 8))
(indent-width (or (string->number (get "IndentWidth")) 1))
(spaces (* tab indent-width))
(tab-indent (if use-tabs (quotient spaces tab-width) 0))
(space-indent (- spaces (* tab-indent tab-width)))
)
(string-append
(make-string tab-indent #\ht)
(make-string space-indent #\sp)
)
)
)
)
(define
indent
(lambda
(line)
(let
((tab (or (string-skip line #\ht) 0)))
(emit
(string-append
(indentation tab)
(string-drop line tab)
"\n"
)
)
)
)
) \+]
[+DEFINE EMACS-MODELINE \+]
-*- Mode: [+MODE+]; indent-tabs-mode: [+(if (== (get "UseTabs") "1") "t" "nil")+]; c-basic-offset: [+IndentWidth+]; tab-width: [+TabWidth+] -*- [+ENDDEF \+]
[+ autogen5 template +]
[+INCLUDE (string-append "licenses/" (get "License") ".tpl") \+]
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
[+INCLUDE (string-append "indent.tpl") \+]
/* [+INVOKE EMACS-MODELINE MODE="C" \+] */
[+INVOKE START-INDENT\+]
/*
* [+MainClass+].java
* Copyright (C) [+(shell "date +%Y")+] [+Author+] <[+Email+]>
......@@ -9,7 +11,8 @@
*/
class [+MainClass+] {
public static void main(String[] args) {
System.out.println("Hello World!");
}
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
[+INVOKE END-INDENT\+]
[+ autogen5 template +]
[+INCLUDE (string-append "licenses/" (get "License") ".tpl") \+]
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
[+INCLUDE (string-append "indent.tpl") \+]
/* [+INVOKE EMACS-MODELINE MODE="C" \+] */
[+INVOKE START-INDENT\+]
/*
* lib.c
* Copyright (C) [+(shell "date +%Y")+] [+Author+] <[+Email+]>
......@@ -15,3 +17,4 @@ int [+NameCLower+]_func(void)
printf("Hello world\n");
return (0);
}
[+INVOKE END-INDENT\+]
[+ autogen5 template +]
[+INCLUDE (string-append "licenses/" (get "License") ".tpl") \+]
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
[+INCLUDE (string-append "indent.tpl") \+]
/* [+INVOKE EMACS-MODELINE MODE="C" \+] */
[+INVOKE START-INDENT\+]
/*
* lib.h
* Copyright (C) [+(shell "date +%Y")+] [+Author+] <[+Email+]>
......@@ -9,3 +11,4 @@
*/
int [+NameCLower+]_func (void);
[+INVOKE END-INDENT\+]
[+ autogen5 template +]
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
[+INCLUDE (string-append "licenses/" (get "License") ".tpl") \+]
[+INCLUDE (string-append "indent.tpl") \+]
/* [+INVOKE EMACS-MODELINE MODE="C" \+] */
[+INVOKE START-INDENT\+]
/*
* main.c - Auto-generated by Anjuta's Makefile project wizard
* main.c
* Copyright (C) [+(shell "date +%Y")+] [+Author+] <[+Email+]>
*
[+INVOKE LICENSE-DESCRIPTION PFX=" * " PROGRAM=(get "Name") OWNER=(get "Author") \+]
*/
#include <stdio.h>
......@@ -11,3 +16,4 @@ int main()
printf("Hello world\n");
return (0);
}
[+INVOKE END-INDENT\+]
[+ autogen5 template +]
[+INCLUDE (string-append "licenses/" (get "License") ".tpl") \+]
[+INCLUDE (string-append "indent.tpl") \+]
# [+INVOKE EMACS-MODELINE MODE="Python" \+]
[+INVOKE START-INDENT\+]
#!/usr/bin/python
#
# main.py
......@@ -41,4 +44,5 @@ def main():
Gtk.main()
if __name__ == "__main__":
sys.exit(main())
sys.exit(main())
[+INVOKE END-INDENT\+]
[+ autogen5 template +]
[+INCLUDE (string-append "licenses/" (get "License") ".tpl") \+]
[+INCLUDE (string-append "indent.tpl") \+]
# [+INVOKE EMACS-MODELINE MODE="Python" \+]
[+INVOKE START-INDENT\+]
#!/usr/bin/python
#
# main.py
......@@ -8,3 +11,4 @@
[+INVOKE LICENSE-DESCRIPTION PFX="# " PROGRAM=(get "Name") OWNER=(get "Author") \+]
print "Hello World!"
[+INVOKE END-INDENT\+]
[+ autogen5 template +]
[+INCLUDE (string-append "licenses/" (get "License") ".tpl") \+]
[+INCLUDE (string-append "indent.tpl") \+]
/* [+INVOKE EMACS-MODELINE MODE="C" \+] */
[+INVOKE START-INDENT\+]
/*
* main.c
* Copyright (C) [+(shell "date +%Y")+] [+Author+] <[+Email+]>
......@@ -65,3 +68,4 @@ int main (int argc, char *argv[])
return(0);
}
[+INVOKE END-INDENT\+]
[+ autogen5 template +]
[+INCLUDE (string-append "licenses/" (get "License") ".tpl") \+]
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
[+INCLUDE (string-append "indent.tpl") \+]
/* [+INVOKE EMACS-MODELINE MODE="C" \+] */
[+INVOKE START-INDENT\+]
/*
* main.c
* Copyright (C) [+(shell "date +%Y")+] [+Author+] <[+Email+]>
......@@ -14,3 +16,4 @@ int main()
printf("Hello world\n");
return (0);
}
[+INVOKE END-INDENT\+]
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment