Uncrustified sources

Also, added astrognome-uncrustify.cfg for later use
This commit is contained in:
Gergely Polonkai 2013-09-21 18:37:27 +02:00
parent 7fc700bf4e
commit ea3b038b57
10 changed files with 386 additions and 222 deletions

View File

@ -47,6 +47,8 @@ The project is currently hosted on [GitHub](https://github.com/gergelypolonkai/a
The entire project is written in C, utilizing GTK+ (3.8 currently, but the final version may come only with 3.10) and SWE-GLib (which is used for the calculations part).
Astrognome follows a well-defined coding style. If you contribute, please follow that by looking at existing sources, or use [Uncrustify](http://uncrustify.sourceforge.net/) with the config file under docs/. The only thing it messes up currently is the alignment of object type #definitions.
## !!!WARNING!!!
-------------

View File

@ -0,0 +1,140 @@
newlines lf
input_tab_size 8
output_tab_size 8
string_escape_char 92
string_escape_char2 0
# indenting
indent_columns 4
indent_with_tabs 0
indent_align_string True
indent_brace 0
indent_braces False
indent_braces_no_func True
indent_func_call_param False
indent_func_def_param False
indent_func_proto_param False
indent_switch_case indent_columns
indent_case_brace indent_columns
indent_paren_close 1
indent_var_def_cont False
# spacing
sp_arith Add
sp_assign Add
sp_enum_assign Add
sp_bool Add
sp_compare Add
sp_inside_paren Remove
sp_inside_fparens Remove
sp_func_def_paren Remove
sp_func_proto_paren Remove
sp_paren_paren Remove
sp_balance_nested_parens False
sp_paren_brace Remove
sp_before_square Remove
sp_before_squares Remove
sp_inside_square Remove
sp_after_comma Add
sp_before_comma Remove
sp_after_cast Remove
sp_sizeof_paren Remove
sp_not Remove
sp_inv Remove
sp_addr Remove
sp_member Remove
sp_deref Remove
sp_sign Remove
sp_incdec Remove
sp_attribute_paren Remove
sp_macro Force
sp_func_call_paren Remove
sp_brace_typedef add
sp_cond_colon add
sp_cond_question add
sp_defined_paren Remove
sp_inside_paren_cast Ignore
sp_else_brace Add
sp_between_ptr_star Remove
sp_before_ptr_star Add
# alignment
align_keep_tabs False
align_with_tabs False
align_on_tabstop False
align_number_left True
align_func_params True
align_var_def_span 2
align_var_def_amp_style 1
align_var_def_colon True
align_enum_equ_span 0
align_var_struct_span 2
align_var_def_star_style 1
align_var_def_amp_style 1
align_typedef_span 2
align_typedef_func 0
align_typedef_star_style 1
align_typedef_amp_style 2
align_var_def_inline True
align_assign_span 1
align_pp_define_together True
# newlines
nl_assign_leave_one_liners True
nl_enum_leave_one_liners False
nl_func_leave_one_liners False
nl_if_leave_one_liners False
nl_end_of_file Add
nl_end_of_file_min 2
nl_assign_brace Remove
nl_func_var_def_blk 1
nl_fcall_brace Add
nl_enum_brace Remove
nl_struct_brace Remove
nl_union_brace Remove
nl_if_brace Remove
nl_brace_else Remove
nl_elseif_brace Remove
nl_else_brace Remove
nl_for_brace Remove
nl_while_brace Remove
nl_do_brace Remove
nl_brace_while Remove
nl_switch_brace Remove
nl_before_case True
nl_after_case True
nl_func_type_name Force
nl_func_proto_type_name Remove
nl_func_paren Remove
nl_func_decl_start Remove
nl_func_decl_args Force
nl_func_decl_end Remove
nl_fdef_brace Force
nl_after_return False
nl_define_macro False
nl_create_if_one_liner False
nl_create_for_one_liner False
nl_create_while_one_liner False
nl_after_semicolon True
nl_multi_line_cond False
nl_var_def_blk_in 2
nl_multi_line_define True
# mod
mod_full_brace_for Force
mod_full_brace_if Force
mod_full_brace_while Force
mod_full_brace_do Remove
mod_full_brace_nl 3
mod_paren_on_return Remove
# line splitting
#code_width = 78
ls_for_split_full True
ls_func_split_full True
# positioning
pos_bool Trail
pos_conditional Lead

View File

@ -17,7 +17,7 @@ ag_app_peek_first_window(AgApp *app)
for (l = gtk_application_get_windows(GTK_APPLICATION(app)); l; l = g_list_next(l)) {
if (GTK_IS_WINDOW(l->data)) {
return (GTK_WINDOW(l->data));
return GTK_WINDOW(l->data);
}
}

View File

@ -36,7 +36,9 @@ GtkWindow *ag_app_peek_first_window(AgApp *self);
void ag_app_new_window(AgApp *self);
void ag_app_quit(AgApp *self);
void ag_app_raise(AgApp *self);
void ag_app_run_action(AgApp *app, gboolean is_remote, const AstrognomeOptions *options);
void ag_app_run_action(AgApp *app,
gboolean is_remote,
const AstrognomeOptions *options);
G_END_DECLS

View File

@ -31,17 +31,24 @@ typedef enum {
XML_CONVERT_INT
} XmlConvertType;
G_DEFINE_QUARK(ag-chart-error-quark, ag_chart_error);
G_DEFINE_QUARK(ag_chart_error_quark, ag_chart_error);
G_DEFINE_TYPE(AgChart, ag_chart, GSWE_TYPE_MOMENT);
#define GET_PRIVATE(instance) (G_TYPE_INSTANCE_GET_PRIVATE((instance), AG_TYPE_CHART, AgChartPrivate))
#define ag_g_variant_unref(v) if ((v) != NULL) { \
#define ag_g_variant_unref(v) \
if ((v) != NULL) { \
g_variant_unref((v)); \
}
static void ag_chart_set_property(GObject *gobject, guint prop_id, const GValue *value, GParamSpec *param_spec);
static void ag_chart_get_property(GObject *gobject, guint prop_id, GValue *value, GParamSpec *param_spec);
static void ag_chart_set_property(GObject *gobject,
guint prop_id,
const GValue *value,
GParamSpec *param_spec);
static void ag_chart_get_property(GObject *gobject,
guint prop_id,
GValue *value,
GParamSpec *param_spec);
static void ag_chart_finalize(GObject *gobject);
static void
@ -325,26 +332,26 @@ AgChart *
ag_chart_load_from_file(GFile *file, GError **err)
{
AgChart *chart = NULL;
gchar *uri,
*xml = NULL,
*country_name,
*city_name;
gchar *uri;
gchar *xml = NULL;
gchar *country_name;
gchar *city_name;
guint length;
xmlDocPtr doc;
xmlXPathContextPtr xpath_context;
GVariant *chart_name,
*country,
*city,
*longitude,
*latitude,
*altitude,
*year,
*month,
*day,
*hour,
*minute,
*second,
*timezone;
GVariant *chart_name;
GVariant *country;
GVariant *city;
GVariant *longitude;
GVariant *latitude;
GVariant *altitude;
GVariant *year;
GVariant *month;
GVariant *day;
GVariant *hour;
GVariant *minute;
GVariant *second;
GVariant *timezone;
GsweTimestamp *timestamp;
gboolean found_error = FALSE;
@ -604,33 +611,33 @@ ag_chart_save_to_file(AgChart *chart, GFile *file, GError **err)
gchar *
ag_chart_create_svg(AgChart *chart, GError **err)
{
xmlDocPtr doc = create_save_doc(chart),
xslt_doc,
svg_doc;
xmlNodePtr root_node = NULL,
ascmcs_node = NULL,
houses_node = NULL,
bodies_node = NULL,
aspects_node = NULL,
antiscia_node = NULL,
node = NULL;
gchar *value,
*stylesheet_path,
*css_path,
*save_content = NULL,
*css_uri,
*css_final_uri,
**params;
GList *houses,
*house,
*planet,
*aspect,
*antiscion;
xmlDocPtr doc = create_save_doc(chart);
xmlDocPtr xslt_doc;
xmlDocPtr svg_doc;
xmlNodePtr root_node = NULL;
xmlNodePtr ascmcs_node = NULL;
xmlNodePtr houses_node = NULL;
xmlNodePtr bodies_node = NULL;
xmlNodePtr aspects_node = NULL;
xmlNodePtr antiscia_node = NULL;
xmlNodePtr node = NULL;
gchar *value;
gchar *stylesheet_path;
gchar *css_path;
gchar *save_content = NULL;
gchar *css_uri;
gchar *css_final_uri;
gchar **params;
GList *houses;
GList *house;
GList *planet;
GList *aspect;
GList *antiscion;
const GswePlanetData *planet_data;
const GsweAspectData *aspect_data;
GEnumClass *planets_class,
*aspects_class,
*antiscia_class;
GEnumClass *planets_class;
GEnumClass *aspects_class;
GEnumClass *antiscia_class;
gint save_length;
GFile *css_file;
xsltStylesheetPtr xslt_proc;
@ -700,9 +707,9 @@ ag_chart_create_svg(AgChart *chart, GError **err)
GEnumValue *enum_value;
if (
(planet_data->planet_id == GSWE_PLANET_ASCENDENT)
|| (planet_data->planet_id == GSWE_PLANET_MC)
|| (planet_data->planet_id == GSWE_PLANET_VERTEX)
(planet_data->planet_id == GSWE_PLANET_ASCENDENT) ||
(planet_data->planet_id == GSWE_PLANET_MC) ||
(planet_data->planet_id == GSWE_PLANET_VERTEX)
) {
continue;
}

View File

@ -32,17 +32,28 @@ struct _AgChartClass {
};
GType ag_chart_get_type(void) G_GNUC_CONST;
AgChart *ag_chart_new_full(GsweTimestamp *timestamp, gdouble longitude, gdouble latitude, gdouble altitude, GsweHouseSystem house_system);
AgChart *ag_chart_load_from_file(GFile *file, GError **err);
void ag_chart_save_to_file(AgChart *chart, GFile *file, GError **err);
AgChart *ag_chart_new_full(GsweTimestamp *timestamp,
gdouble longitude,
gdouble latitude,
gdouble altitude,
GsweHouseSystem house_system);
AgChart *ag_chart_load_from_file(GFile *file,
GError **err);
void ag_chart_save_to_file(AgChart *chart,
GFile *file,
GError **err);
void ag_chart_set_name(AgChart *chart, const gchar *name);
void ag_chart_set_name(AgChart *chart,
const gchar *name);
gchar *ag_chart_get_name(AgChart *chart);
void ag_chart_set_country(AgChart *chart, const gchar *country);
void ag_chart_set_country(AgChart *chart,
const gchar *country);
gchar *ag_chart_get_country(AgChart *chart);
void ag_chart_set_city(AgChart *chart, const gchar *city);
void ag_chart_set_city(AgChart *chart,
const gchar *city);
gchar *ag_chart_get_city(AgChart *chart);
gchar *ag_chart_create_svg(AgChart *chart, GError **err);
gchar *ag_chart_create_svg(AgChart *chart,
GError **err);
#define AG_CHART_ERROR (ag_chart_error_quark())
GQuark ag_chart_error_quark(void);

View File

@ -41,7 +41,7 @@ struct _AgWindowPrivate {
gchar *uri;
};
G_DEFINE_QUARK(ag-window-error-quark, ag_window_error);
G_DEFINE_QUARK(ag_window_error_quark, ag_window_error);
G_DEFINE_TYPE(AgWindow, ag_window, GTK_TYPE_APPLICATION_WINDOW);
@ -72,8 +72,8 @@ ag_window_close_action(GSimpleAction *action, GVariant *parameter, gpointer user
static void
ag_window_save_as(AgWindow *window, GError **err)
{
gchar *name,
*file_name;
gchar *name;
gchar *file_name;
GtkWidget *fs;
gint response;
@ -446,8 +446,8 @@ static void
window_populate(AgWindow *window)
{
AgWindowPrivate *priv = window->priv;
GtkWidget *menu_button,
*scroll;
GtkWidget *menu_button;
GtkWidget *scroll;
GObject *menu;
priv->header_bar = gd_header_bar_new();

View File

@ -34,10 +34,12 @@ struct _AgWindowClass {
GType ag_window_get_type(void) G_GNUC_CONST;
GtkWidget *ag_window_new(AgApp *app);
void ag_window_set_chart(AgWindow *window, AgChart *chart);
void ag_window_set_chart(AgWindow *window,
AgChart *chart);
AgChart *ag_window_get_chart(AgWindow *window);
void ag_window_update_from_chart(AgWindow *window);
void ag_window_set_uri(AgWindow *window, const gchar *uri);
void ag_window_set_uri(AgWindow *window,
const gchar *uri);
gchar *ag_window_get_uri(AgWindow *window);
#define AG_WINDOW_ERROR (ag_window_error_quark())

View File

@ -18,8 +18,8 @@
#define UI_FILE PKGDATADIR "/astrognome.ui"
GtkBuilder *builder;
GtkFileFilter *filter_all = NULL,
*filter_chart = NULL;
GtkFileFilter *filter_all = NULL;
GtkFileFilter *filter_chart = NULL;
const char *moonStateName[] = {
"New Moon",

View File

@ -7,8 +7,8 @@ typedef struct {
gboolean new_window;
} AstrognomeOptions;
extern GtkFileFilter *filter_all,
*filter_chart;
extern GtkFileFilter *filter_all;
extern GtkFileFilter *filter_chart;
#endif /* __ASTROGNOME_H__ */