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;
|
|
|
|
|
|
|
|
GSettings *settings;
|
|
|
|
GtkWidget *stack;
|
2020-05-11 01:26:19 +00:00
|
|
|
GtkWidget *gears;
|
2013-07-23 23:04:12 +00:00
|
|
|
GtkWidget *search;
|
|
|
|
GtkWidget *searchbar;
|
|
|
|
GtkWidget *searchentry;
|
|
|
|
GtkWidget *sidebar;
|
|
|
|
GtkWidget *words;
|
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
|
2018-05-08 12:47:54 +00:00
|
|
|
search_text_changed (GtkEntry *entry,
|
|
|
|
ExampleAppWindow *win)
|
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-07-24 18:40:36 +00:00
|
|
|
const char *text;
|
2013-07-23 23:04:12 +00:00
|
|
|
GtkWidget *tab;
|
|
|
|
GtkWidget *view;
|
|
|
|
GtkTextBuffer *buffer;
|
|
|
|
GtkTextIter start, match_start, match_end;
|
|
|
|
|
2019-02-28 19:31:36 +00:00
|
|
|
text = gtk_editable_get_text (GTK_EDITABLE (entry));
|
2013-07-23 23:04:12 +00:00
|
|
|
|
|
|
|
if (text[0] == '\0')
|
|
|
|
return;
|
|
|
|
|
2018-05-08 09:04:03 +00:00
|
|
|
tab = gtk_stack_get_visible_child (GTK_STACK (win->stack));
|
2020-05-02 04:51:20 +00:00
|
|
|
view = gtk_scrolled_window_get_child (GTK_SCROLLED_WINDOW (tab));
|
2013-07-23 23:04:12 +00:00
|
|
|
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
|
|
|
|
|
|
|
/* Very simple-minded search implementation */
|
|
|
|
gtk_text_buffer_get_start_iter (buffer, &start);
|
|
|
|
if (gtk_text_iter_forward_search (&start, text, GTK_TEXT_SEARCH_CASE_INSENSITIVE,
|
|
|
|
&match_start, &match_end, NULL))
|
|
|
|
{
|
|
|
|
gtk_text_buffer_select_range (buffer, &match_start, &match_end);
|
|
|
|
gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (view), &match_start,
|
|
|
|
0.0, FALSE, 0.0, 0.0);
|
|
|
|
}
|
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
|
|
|
|
find_word (GtkButton *button,
|
|
|
|
ExampleAppWindow *win)
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *word;
|
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
|
|
|
word = gtk_button_get_label (button);
|
2019-02-28 19:31:36 +00:00
|
|
|
gtk_editable_set_text (GTK_EDITABLE (win->searchentry), word);
|
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
|
|
|
|
update_words (ExampleAppWindow *win)
|
|
|
|
{
|
2013-07-23 23:04:12 +00:00
|
|
|
GHashTable *strings;
|
|
|
|
GHashTableIter iter;
|
|
|
|
GtkWidget *tab, *view, *row;
|
|
|
|
GtkTextBuffer *buffer;
|
|
|
|
GtkTextIter start, end;
|
2020-07-24 18:40:36 +00:00
|
|
|
char *word, *key;
|
2020-05-09 12:26:52 +00:00
|
|
|
GtkWidget *child;
|
2013-07-23 23:04:12 +00:00
|
|
|
|
2018-05-08 09:04:03 +00:00
|
|
|
tab = gtk_stack_get_visible_child (GTK_STACK (win->stack));
|
2013-07-24 00:18:54 +00:00
|
|
|
|
|
|
|
if (tab == NULL)
|
|
|
|
return;
|
|
|
|
|
2020-05-02 04:51:20 +00:00
|
|
|
view = gtk_scrolled_window_get_child (GTK_SCROLLED_WINDOW (tab));
|
2013-07-23 23:04:12 +00:00
|
|
|
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
|
|
|
|
|
|
|
strings = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
|
|
|
|
|
|
|
gtk_text_buffer_get_start_iter (buffer, &start);
|
|
|
|
while (!gtk_text_iter_is_end (&start))
|
|
|
|
{
|
|
|
|
while (!gtk_text_iter_starts_word (&start))
|
|
|
|
{
|
|
|
|
if (!gtk_text_iter_forward_char (&start))
|
|
|
|
goto done;
|
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
|
|
|
end = start;
|
|
|
|
if (!gtk_text_iter_forward_word_end (&end))
|
|
|
|
goto done;
|
|
|
|
word = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
|
|
|
g_hash_table_add (strings, g_utf8_strdown (word, -1));
|
|
|
|
g_free (word);
|
|
|
|
start = end;
|
|
|
|
}
|
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
|
|
|
|
|
|
|
done:
|
2020-05-09 12:26:52 +00:00
|
|
|
while ((child = gtk_widget_get_first_child (win->words)))
|
|
|
|
gtk_list_box_remove (GTK_LIST_BOX (win->words), child);
|
2013-07-23 23:04:12 +00:00
|
|
|
|
|
|
|
g_hash_table_iter_init (&iter, strings);
|
|
|
|
while (g_hash_table_iter_next (&iter, (gpointer *)&key, NULL))
|
|
|
|
{
|
|
|
|
row = gtk_button_new_with_label (key);
|
|
|
|
g_signal_connect (row, "clicked",
|
|
|
|
G_CALLBACK (find_word), win);
|
2020-08-13 21:30:47 +00:00
|
|
|
gtk_list_box_insert (GTK_LIST_BOX (win->words), row, -1);
|
2013-07-23 23:04:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_hash_table_unref (strings);
|
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
|
2018-05-08 12:47:54 +00:00
|
|
|
visible_child_changed (GObject *stack,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
ExampleAppWindow *win)
|
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-28 00:33:08 +00:00
|
|
|
if (gtk_widget_in_destruction (GTK_WIDGET (stack)))
|
2013-07-24 05:10:08 +00:00
|
|
|
return;
|
|
|
|
|
2018-05-08 09:04:03 +00:00
|
|
|
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (win->searchbar), FALSE);
|
2013-07-23 23:04:12 +00:00
|
|
|
update_words (win);
|
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
|
|
|
|
words_changed (GObject *sidebar,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
ExampleAppWindow *win)
|
|
|
|
{
|
2013-07-23 23:04:12 +00:00
|
|
|
update_words (win);
|
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)
|
|
|
|
{
|
2013-07-23 23:04:12 +00:00
|
|
|
GtkBuilder *builder;
|
|
|
|
GMenuModel *menu;
|
|
|
|
GAction *action;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2018-05-08 09:04:03 +00:00
|
|
|
win->settings = g_settings_new ("org.gtk.exampleapp");
|
2013-07-23 23:04:12 +00:00
|
|
|
|
2018-05-08 09:04:03 +00:00
|
|
|
g_settings_bind (win->settings, "transition",
|
|
|
|
win->stack, "transition-type",
|
2013-07-23 23:04:12 +00:00
|
|
|
G_SETTINGS_BIND_DEFAULT);
|
|
|
|
|
2018-05-08 09:04:03 +00:00
|
|
|
g_settings_bind (win->settings, "show-words",
|
|
|
|
win->sidebar, "reveal-child",
|
2013-07-23 23:04:12 +00:00
|
|
|
G_SETTINGS_BIND_DEFAULT);
|
|
|
|
|
2018-05-08 09:04:03 +00:00
|
|
|
g_object_bind_property (win->search, "active",
|
|
|
|
win->searchbar, "search-mode-enabled",
|
2013-07-23 23:04:12 +00:00
|
|
|
G_BINDING_BIDIRECTIONAL);
|
|
|
|
|
2018-05-08 09:04:03 +00:00
|
|
|
g_signal_connect (win->sidebar, "notify::reveal-child",
|
2013-07-24 05:10:08 +00:00
|
|
|
G_CALLBACK (words_changed), win);
|
2013-07-23 23:04:12 +00:00
|
|
|
|
2018-05-08 09:04:03 +00:00
|
|
|
action = g_settings_create_action (win->settings, "show-words");
|
2013-07-23 23:04:12 +00:00
|
|
|
g_action_map_add_action (G_ACTION_MAP (win), action);
|
|
|
|
g_object_unref (action);
|
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_dispose (GObject *object)
|
|
|
|
{
|
2013-07-23 23:04:12 +00:00
|
|
|
ExampleAppWindow *win;
|
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
|
|
|
win = EXAMPLE_APP_WINDOW (object);
|
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_clear_object (&win->settings);
|
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_OBJECT_CLASS (example_app_window_parent_class)->dispose (object);
|
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
|
|
|
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");
|
2013-07-28 00:33:08 +00:00
|
|
|
|
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);
|
2018-05-08 09:04:03 +00:00
|
|
|
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, search);
|
|
|
|
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchbar);
|
|
|
|
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchentry);
|
|
|
|
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, words);
|
|
|
|
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, sidebar);
|
2013-07-28 00:33:08 +00:00
|
|
|
|
|
|
|
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), search_text_changed);
|
|
|
|
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), visible_child_changed);
|
|
|
|
|
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;
|
|
|
|
GtkTextBuffer *buffer;
|
|
|
|
GtkTextTag *tag;
|
|
|
|
GtkTextIter start_iter, end_iter;
|
|
|
|
|
|
|
|
basename = g_file_get_basename (file);
|
|
|
|
|
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);
|
2013-07-23 23:04:12 +00:00
|
|
|
|
|
|
|
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);
|
2018-05-08 09:04:03 +00:00
|
|
|
g_settings_bind (win->settings, "font",
|
2013-07-23 23:04:12 +00:00
|
|
|
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);
|
|
|
|
|
2018-05-08 09:04:03 +00:00
|
|
|
gtk_widget_set_sensitive (win->search, TRUE);
|
2013-07-23 23:04:12 +00:00
|
|
|
|
|
|
|
update_words (win);
|
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
|
|
|
}
|