From 2a0167f82c8a9bd890822491e3d092fa1c648e63 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 17 Apr 2014 11:27:11 -0700 Subject: example: Fix indentation --- examples/application6/exampleapp.c | 89 ++++++++++++----------- examples/application6/exampleappwin.c | 130 ++++++++++++++++++---------------- examples/application6/main.c | 14 ++-- 3 files changed, 120 insertions(+), 113 deletions(-) diff --git a/examples/application6/exampleapp.c b/examples/application6/exampleapp.c index 633216c692..36ef152593 100644 --- a/examples/application6/exampleapp.c +++ b/examples/application6/exampleapp.c @@ -4,12 +4,14 @@ #include "exampleappwin.h" #include "exampleappprefs.h" -struct ExampleApp { - GtkApplication parent; +struct ExampleApp +{ + GtkApplication parent; }; -struct ExampleAppClass { - GtkApplicationClass parent_class; +struct ExampleAppClass +{ + GtkApplicationClass parent_class; }; G_DEFINE_TYPE(ExampleApp, example_app, GTK_TYPE_APPLICATION); @@ -24,12 +26,12 @@ preferences_activated (GSimpleAction *action, GVariant *parameter, gpointer app) { - ExampleAppPrefs *prefs; - GtkWindow *win; + ExampleAppPrefs *prefs; + GtkWindow *win; - win = gtk_application_get_active_window (GTK_APPLICATION (app)); - prefs = example_app_prefs_new (EXAMPLE_APP_WINDOW (win)); - gtk_window_present (GTK_WINDOW (prefs)); + win = gtk_application_get_active_window (GTK_APPLICATION (app)); + prefs = example_app_prefs_new (EXAMPLE_APP_WINDOW (win)); + gtk_window_present (GTK_WINDOW (prefs)); } static void @@ -40,36 +42,37 @@ quit_activated (GSimpleAction *action, g_application_quit (G_APPLICATION (app)); } -static GActionEntry app_entries[] = { - { "preferences", preferences_activated, NULL, NULL, NULL }, - { "quit", quit_activated, NULL, NULL, NULL } +static GActionEntry app_entries[] = +{ + { "preferences", preferences_activated, NULL, NULL, NULL }, + { "quit", quit_activated, NULL, NULL, NULL } }; static void example_app_startup (GApplication *app) { - GtkBuilder *builder; - GMenuModel *app_menu; + GtkBuilder *builder; + GMenuModel *app_menu; - G_APPLICATION_CLASS (example_app_parent_class)->startup (app); + G_APPLICATION_CLASS (example_app_parent_class)->startup (app); - g_action_map_add_action_entries (G_ACTION_MAP (app), - app_entries, G_N_ELEMENTS (app_entries), - app); + g_action_map_add_action_entries (G_ACTION_MAP (app), + app_entries, G_N_ELEMENTS (app_entries), + app); - builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/app-menu.ui"); - app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu")); - gtk_application_set_app_menu (GTK_APPLICATION (app), app_menu); - g_object_unref (builder); + builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/app-menu.ui"); + app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu")); + gtk_application_set_app_menu (GTK_APPLICATION (app), app_menu); + g_object_unref (builder); } static void example_app_activate (GApplication *app) { - ExampleAppWindow *win; + ExampleAppWindow *win; - win = example_app_window_new (EXAMPLE_APP (app)); - gtk_window_present (GTK_WINDOW (win)); + win = example_app_window_new (EXAMPLE_APP (app)); + gtk_window_present (GTK_WINDOW (win)); } static void @@ -78,35 +81,35 @@ example_app_open (GApplication *app, gint n_files, const gchar *hint) { - GList *windows; - ExampleAppWindow *win; - int i; + GList *windows; + ExampleAppWindow *win; + int i; - windows = gtk_application_get_windows (GTK_APPLICATION (app)); - if (windows) - win = EXAMPLE_APP_WINDOW (windows->data); - else - win = example_app_window_new (EXAMPLE_APP (app)); + windows = gtk_application_get_windows (GTK_APPLICATION (app)); + if (windows) + win = EXAMPLE_APP_WINDOW (windows->data); + else + win = example_app_window_new (EXAMPLE_APP (app)); - for (i = 0; i < n_files; i++) - example_app_window_open (win, files[i]); + for (i = 0; i < n_files; i++) + example_app_window_open (win, files[i]); - gtk_window_present (GTK_WINDOW (win)); + gtk_window_present (GTK_WINDOW (win)); } static void example_app_class_init (ExampleAppClass *class) { - G_APPLICATION_CLASS (class)->startup = example_app_startup; - G_APPLICATION_CLASS (class)->activate = example_app_activate; - G_APPLICATION_CLASS (class)->open = example_app_open; + G_APPLICATION_CLASS (class)->startup = example_app_startup; + G_APPLICATION_CLASS (class)->activate = example_app_activate; + G_APPLICATION_CLASS (class)->open = example_app_open; } ExampleApp * example_app_new (void) { - return g_object_new (EXAMPLE_APP_TYPE, - "application-id", "org.gtk.exampleapp", - "flags", G_APPLICATION_HANDLES_OPEN, - NULL); + return g_object_new (EXAMPLE_APP_TYPE, + "application-id", "org.gtk.exampleapp", + "flags", G_APPLICATION_HANDLES_OPEN, + NULL); } diff --git a/examples/application6/exampleappwin.c b/examples/application6/exampleappwin.c index 3f605fe527..223061484f 100644 --- a/examples/application6/exampleappwin.c +++ b/examples/application6/exampleappwin.c @@ -2,19 +2,22 @@ #include "exampleappwin.h" #include -struct ExampleAppWindow { - GtkApplicationWindow parent; +struct ExampleAppWindow +{ + GtkApplicationWindow parent; }; -struct ExampleAppWindowClass { - GtkApplicationWindowClass parent_class; +struct ExampleAppWindowClass +{ + GtkApplicationWindowClass parent_class; }; typedef struct ExampleAppWindowPrivate ExampleAppWindowPrivate; -struct ExampleAppWindowPrivate { - GSettings *settings; - GtkWidget *stack; +struct ExampleAppWindowPrivate +{ + GSettings *settings; + GtkWidget *stack; }; G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW); @@ -22,87 +25,88 @@ G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLIC static void example_app_window_init (ExampleAppWindow *win) { - ExampleAppWindowPrivate *priv; + ExampleAppWindowPrivate *priv; - priv = example_app_window_get_instance_private (win); - gtk_widget_init_template (GTK_WIDGET (win)); - priv->settings = g_settings_new ("org.gtk.exampleapp"); + priv = example_app_window_get_instance_private (win); + gtk_widget_init_template (GTK_WIDGET (win)); + priv->settings = g_settings_new ("org.gtk.exampleapp"); - g_settings_bind (priv->settings, "transition", - priv->stack, "transition-type", - G_SETTINGS_BIND_DEFAULT); + g_settings_bind (priv->settings, "transition", + priv->stack, "transition-type", + G_SETTINGS_BIND_DEFAULT); } static void example_app_window_dispose (GObject *object) { - ExampleAppWindow *win; - ExampleAppWindowPrivate *priv; + ExampleAppWindow *win; + ExampleAppWindowPrivate *priv; - win = EXAMPLE_APP_WINDOW (object); - priv = example_app_window_get_instance_private (win); + win = EXAMPLE_APP_WINDOW (object); + priv = example_app_window_get_instance_private (win); - g_clear_object (&priv->settings); + g_clear_object (&priv->settings); - G_OBJECT_CLASS (example_app_window_parent_class)->dispose (object); + G_OBJECT_CLASS (example_app_window_parent_class)->dispose (object); } static void example_app_window_class_init (ExampleAppWindowClass *class) { - G_OBJECT_CLASS (class)->dispose = example_app_window_dispose; + G_OBJECT_CLASS (class)->dispose = example_app_window_dispose; - gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class), - "/org/gtk/exampleapp/window.ui"); - gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack); + gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class), + "/org/gtk/exampleapp/window.ui"); + gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack); } ExampleAppWindow * example_app_window_new (ExampleApp *app) { - return g_object_new (EXAMPLE_APP_WINDOW_TYPE, "application", app, NULL); + return g_object_new (EXAMPLE_APP_WINDOW_TYPE, "application", app, NULL); } void example_app_window_open (ExampleAppWindow *win, GFile *file) { - ExampleAppWindowPrivate *priv; - gchar *basename; - GtkWidget *scrolled, *view; - gchar *contents; - gsize length; - GtkTextBuffer *buffer; - GtkTextTag *tag; - GtkTextIter start_iter, end_iter; - - priv = example_app_window_get_instance_private (win); - basename = g_file_get_basename (file); - - scrolled = gtk_scrolled_window_new (NULL, NULL); - gtk_widget_show (scrolled); - gtk_widget_set_hexpand (scrolled, TRUE); - gtk_widget_set_vexpand (scrolled, TRUE); - view = gtk_text_view_new (); - gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE); - gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE); - gtk_widget_show (view); - gtk_container_add (GTK_CONTAINER (scrolled), view); - gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename); - - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); - - if (g_file_load_contents (file, NULL, &contents, &length, NULL, NULL)) { - gtk_text_buffer_set_text (buffer, contents, length); - g_free (contents); - } - - tag = gtk_text_buffer_create_tag (buffer, NULL, NULL); - g_settings_bind (priv->settings, "font", tag, "font", G_SETTINGS_BIND_DEFAULT); - - gtk_text_buffer_get_start_iter (buffer, &start_iter); - gtk_text_buffer_get_end_iter (buffer, &end_iter); - gtk_text_buffer_apply_tag (buffer, tag, &start_iter, &end_iter); - - g_free (basename); + ExampleAppWindowPrivate *priv; + gchar *basename; + GtkWidget *scrolled, *view; + gchar *contents; + gsize length; + GtkTextBuffer *buffer; + GtkTextTag *tag; + GtkTextIter start_iter, end_iter; + + priv = example_app_window_get_instance_private (win); + basename = g_file_get_basename (file); + + scrolled = gtk_scrolled_window_new (NULL, NULL); + gtk_widget_show (scrolled); + gtk_widget_set_hexpand (scrolled, TRUE); + gtk_widget_set_vexpand (scrolled, TRUE); + view = gtk_text_view_new (); + gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE); + gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE); + gtk_widget_show (view); + gtk_container_add (GTK_CONTAINER (scrolled), view); + gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename); + + buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); + + if (g_file_load_contents (file, NULL, &contents, &length, NULL, NULL)) + { + gtk_text_buffer_set_text (buffer, contents, length); + g_free (contents); + } + + tag = gtk_text_buffer_create_tag (buffer, NULL, NULL); + g_settings_bind (priv->settings, "font", tag, "font", G_SETTINGS_BIND_DEFAULT); + + gtk_text_buffer_get_start_iter (buffer, &start_iter); + gtk_text_buffer_get_end_iter (buffer, &end_iter); + gtk_text_buffer_apply_tag (buffer, tag, &start_iter, &end_iter); + + g_free (basename); } diff --git a/examples/application6/main.c b/examples/application6/main.c index 7ce327aa0b..546d923dd5 100644 --- a/examples/application6/main.c +++ b/examples/application6/main.c @@ -4,12 +4,12 @@ int main (int argc, char *argv[]) { - /* Since this example is running uninstalled, - * we have to help it find its schema. This - * is *not* necessary in properly installed - * application. - */ - g_setenv ("GSETTINGS_SCHEMA_DIR", ".", FALSE); + /* Since this example is running uninstalled, + * we have to help it find its schema. This + * is *not* necessary in properly installed + * application. + */ + g_setenv ("GSETTINGS_SCHEMA_DIR", ".", FALSE); - return g_application_run (G_APPLICATION (example_app_new ()), argc, argv); + return g_application_run (G_APPLICATION (example_app_new ()), argc, argv); } -- cgit v1.2.1