diff options
author | Matthias Clasen <mclasen@redhat.com> | 2013-07-23 19:04:12 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2013-07-24 07:31:05 -0400 |
commit | 99203f09f27a7426cf4879a874432047134d2bba (patch) | |
tree | 56fc43306f85f163a83546ee38d14b59633dc4d5 /examples/application3 | |
parent | e6c5faed739d69acc9e4ed1be6f1c7908ddd72a1 (diff) | |
download | gtk+-99203f09f27a7426cf4879a874432047134d2bba.tar.gz |
Getting started: Coding style updates
Make the new examples use GTK+ coding style.
Diffstat (limited to 'examples/application3')
-rw-r--r-- | examples/application3/exampleapp.c | 50 | ||||
-rw-r--r-- | examples/application3/exampleapp.h | 4 | ||||
-rw-r--r-- | examples/application3/exampleappwin.c | 75 | ||||
-rw-r--r-- | examples/application3/exampleappwin.h | 4 | ||||
-rw-r--r-- | examples/application3/main.c | 2 |
5 files changed, 71 insertions, 64 deletions
diff --git a/examples/application3/exampleapp.c b/examples/application3/exampleapp.c index bdd6a778e0..6c4c5ed3cc 100644 --- a/examples/application3/exampleapp.c +++ b/examples/application3/exampleapp.c @@ -3,12 +3,14 @@ #include "exampleapp.h" #include "exampleappwin.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); @@ -21,10 +23,10 @@ example_app_init (ExampleApp *app) 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 @@ -33,34 +35,34 @@ 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)->activate = example_app_activate; - G_APPLICATION_CLASS (class)->open = example_app_open; + 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/application3/exampleapp.h b/examples/application3/exampleapp.h index 8b51c598ea..824049d699 100644 --- a/examples/application3/exampleapp.h +++ b/examples/application3/exampleapp.h @@ -8,8 +8,8 @@ #define EXAMPLE_APP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXAMPLE_APP_TYPE, ExampleApp)) -typedef struct ExampleApp ExampleApp; -typedef struct ExampleAppClass ExampleAppClass; +typedef struct _ExampleApp ExampleApp; +typedef struct _ExampleAppClass ExampleAppClass; GType example_app_get_type (void); diff --git a/examples/application3/exampleappwin.c b/examples/application3/exampleappwin.c index 52306e1fd7..e36290c689 100644 --- a/examples/application3/exampleappwin.c +++ b/examples/application3/exampleappwin.c @@ -2,18 +2,21 @@ #include "exampleappwin.h" #include <gtk/gtk.h> -struct ExampleAppWindow { - GtkApplicationWindow parent; +struct _ExampleAppWindow +{ + GtkApplicationWindow parent; }; -struct ExampleAppWindowClass { - GtkApplicationWindowClass parent_class; +struct _ExampleAppWindowClass +{ + GtkApplicationWindowClass parent_class; }; -typedef struct ExampleAppWindowPrivate ExampleAppWindowPrivate; +typedef struct _ExampleAppWindowPrivate ExampleAppWindowPrivate; -struct ExampleAppWindowPrivate { - GtkWidget *stack; +struct _ExampleAppWindowPrivate +{ + GtkWidget *stack; }; G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW); @@ -21,53 +24,55 @@ G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLIC static void example_app_window_init (ExampleAppWindow *win) { - gtk_widget_init_template (GTK_WIDGET (win)); + gtk_widget_init_template (GTK_WIDGET (win)); } static void example_app_window_class_init (ExampleAppWindowClass *class) { - gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class), - "/org/gtk/exampleapp/window.ui"); - gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppWindowPrivate, stack); + gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class), + "/org/gtk/exampleapp/window.ui"); + gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppWindowPrivate, 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 = example_app_window_get_instance_private (win); - gchar *basename; - GtkWidget *scrolled, *view; - gchar *contents; - gsize length; + ExampleAppWindowPrivate *priv; + gchar *basename; + GtkWidget *scrolled, *view; + gchar *contents; + gsize length; - basename = g_file_get_basename (file); + 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); + 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); - if (g_file_load_contents (file, NULL, &contents, &length, NULL, NULL)) { - GtkTextBuffer *buffer; + if (g_file_load_contents (file, NULL, &contents, &length, NULL, NULL)) + { + GtkTextBuffer *buffer; - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); - gtk_text_buffer_set_text (buffer, contents, length); - g_free (contents); - } + buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); + gtk_text_buffer_set_text (buffer, contents, length); + g_free (contents); + } - g_free (basename); + g_free (basename); } diff --git a/examples/application3/exampleappwin.h b/examples/application3/exampleappwin.h index 11ff3c27a7..ed4b34fcf5 100644 --- a/examples/application3/exampleappwin.h +++ b/examples/application3/exampleappwin.h @@ -9,8 +9,8 @@ #define EXAMPLE_APP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXAMPLE_APP_WINDOW_TYPE, ExampleAppWindow)) -typedef struct ExampleAppWindow ExampleAppWindow; -typedef struct ExampleAppWindowClass ExampleAppWindowClass; +typedef struct _ExampleAppWindow ExampleAppWindow; +typedef struct _ExampleAppWindowClass ExampleAppWindowClass; GType example_app_window_get_type (void); diff --git a/examples/application3/main.c b/examples/application3/main.c index 7c24d8b04e..ccbf16a5fa 100644 --- a/examples/application3/main.c +++ b/examples/application3/main.c @@ -4,5 +4,5 @@ int main (int argc, char *argv[]) { - return g_application_run (G_APPLICATION (example_app_new ()), argc, argv); + return g_application_run (G_APPLICATION (example_app_new ()), argc, argv); } |