2014-11-29 04:55:03 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
#include "exampleapp.h"
|
|
|
|
#include "exampleappwin.h"
|
|
|
|
|
2013-07-23 23:04:12 +00:00
|
|
|
struct _ExampleAppWindow
|
|
|
|
{
|
|
|
|
GtkApplicationWindow parent;
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
|
2013-07-23 23:04:12 +00:00
|
|
|
GtkWidget *stack;
|
2020-05-11 01:26:19 +00:00
|
|
|
GtkWidget *gears;
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
};
|
|
|
|
|
2018-05-08 09:04:03 +00:00
|
|
|
G_DEFINE_TYPE (ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW)
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
example_app_window_init (ExampleAppWindow *win)
|
|
|
|
{
|
2020-05-11 01:26:19 +00:00
|
|
|
GtkBuilder *builder;
|
|
|
|
GMenuModel *menu;
|
|
|
|
|
2013-07-23 23:04:12 +00:00
|
|
|
gtk_widget_init_template (GTK_WIDGET (win));
|
2020-05-11 01:26:19 +00:00
|
|
|
|
|
|
|
builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/gears-menu.ui");
|
|
|
|
menu = G_MENU_MODEL (gtk_builder_get_object (builder, "menu"));
|
|
|
|
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (win->gears), menu);
|
|
|
|
g_object_unref (builder);
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
example_app_window_class_init (ExampleAppWindowClass *class)
|
|
|
|
{
|
2013-07-23 23:04:12 +00:00
|
|
|
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
|
|
|
|
"/org/gtk/exampleapp/window.ui");
|
2018-05-08 09:04:03 +00:00
|
|
|
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
|
2020-05-11 01:26:19 +00:00
|
|
|
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, gears);
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ExampleAppWindow *
|
|
|
|
example_app_window_new (ExampleApp *app)
|
|
|
|
{
|
2013-07-23 23:04:12 +00:00
|
|
|
return g_object_new (EXAMPLE_APP_WINDOW_TYPE, "application", app, NULL);
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
example_app_window_open (ExampleAppWindow *win,
|
|
|
|
GFile *file)
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
char *basename;
|
2013-07-23 23:04:12 +00:00
|
|
|
GtkWidget *scrolled, *view;
|
2020-07-24 18:40:36 +00:00
|
|
|
char *contents;
|
2013-07-23 23:04:12 +00:00
|
|
|
gsize length;
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
|
2013-07-23 23:04:12 +00:00
|
|
|
basename = g_file_get_basename (file);
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
|
2020-06-24 15:25:09 +00:00
|
|
|
scrolled = gtk_scrolled_window_new ();
|
2013-07-23 23:04:12 +00:00
|
|
|
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);
|
2020-05-02 04:51:20 +00:00
|
|
|
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolled), view);
|
2018-05-08 09:04:03 +00:00
|
|
|
gtk_stack_add_titled (GTK_STACK (win->stack), scrolled, basename, basename);
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
|
2013-07-23 23:04:12 +00:00
|
|
|
if (g_file_load_contents (file, NULL, &contents, &length, NULL, NULL))
|
|
|
|
{
|
|
|
|
GtkTextBuffer *buffer;
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
|
2013-07-23 23:04:12 +00:00
|
|
|
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
|
|
|
gtk_text_buffer_set_text (buffer, contents, length);
|
|
|
|
g_free (contents);
|
|
|
|
}
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
|
2013-07-23 23:04:12 +00:00
|
|
|
g_free (basename);
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
}
|