add gtk3 ref app

This commit is contained in:
DanyLE 2023-08-21 16:37:31 +02:00
parent deab9ed26b
commit 4ec0d2b4d7
16 changed files with 868 additions and 0 deletions

6
.gitignore vendored
View File

@ -50,3 +50,9 @@ m4/lt~obsolete.m4
# can automatically generate from config.status script # can automatically generate from config.status script
# (which is called by configure script)) # (which is called by configure script))
Makefile Makefile
libtool
*.o
diyafm
data/gschemas.compiled
data/app.iohub.dev.diyafm.gschema.valid
resources.c

42
Makefile.am Normal file
View File

@ -0,0 +1,42 @@
AUTOMAKE_OPTIONS = foreign
AM_CPPFLAGS = -Wl,--no-as-needed
AM_CPPFLAGS += -W -Wall -g
# bin
bin_PROGRAMS = diyafm
diyafm_SOURCES = fm.c \
diyafm_app.c \
diyafm_win.c \
diyafm_prefs.c \
diyafm_app.h \
diyafm_win.h \
diyafm_prefs.h \
resources.c
diyafm_CPPFLAGS = $(GTK_CFLAGS)
diyafm_LDFLAGS= $(GTK_LIBS)
BUILT_SOURCES = \
resources.c \
gschemas.compiled
resources.c: diyafm.gresource.xml resources/fm.ui resources/app-menu.ui resources/prefs.ui resources/gears-menu.ui
glib-compile-resources $(srcdir)/diyafm.gresource.xml \
--target=$@ --sourcedir=$(srcdir) --generate-source
gsettings_SCHEMAS = data/app.iohub.dev.diyafm.gschema.xml
@GSETTINGS_RULES@
gschemas.compiled: data/app.iohub.dev.diyafm.gschema.xml
$(GLIB_COMPILE_SCHEMAS) ./data
CLEANFILES = data/gschemas.compiled
EXTRA_DIST = README.md \
diyafm.gresource.xml \
resources \
data

38
configure.ac Normal file
View File

@ -0,0 +1,38 @@
# initialise autoconf and set up some basic information about the program were packaging
AC_INIT([diya-fm], [0.1.0], [xsang.le@gmail.com])
# Were going to use automake for this project
# [subdir-objects] if needed
AM_INIT_AUTOMAKE()
# dependencies
# C compiler
AC_PROG_CC
# libtool for linking
AC_CONFIG_MACRO_DIRS([m4])
AC_PROG_LIBTOOL
GLIB_GSETTINGS
PKG_CHECK_MODULES(GTK, gtk+-3.0, [], [
AC_MSG_ERROR([Unable to find gtk+-3.0 module])
])
# AC_DEFINE([_GNU_SOURCE], [1],[Use GNU source])
# debug option
AC_ARG_ENABLE([debug],
[ --enable-debug Turn on debugging],
[case "${enableval}" in
yes) AC_DEFINE([DEBUG], [1],[Enable debug]) ;;
no) ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
esac],[debug=false])
AC_CANONICAL_HOST
# find a file called Makefile.in, substitute placeholders
# like @PACKAGE_VERSION@ with values like 0.1.0a,
# and write the results to Makefile.
AC_CONFIG_FILES([Makefile])
# output the script:
AC_OUTPUT

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<schema path="/app/iohub/dev/diyafm/" id="app.iohub.dev.diyafm">
<key name="font" type="s">
<default>'Monospace 12'</default>
<summary>Font</summary>
<description>The font to be used for content.</description>
</key>
<key name="transition" type="s">
<choices>
<choice value='none'/>
<choice value='crossfade'/>
<choice value='slide-left-right'/>
</choices>
<default>'none'</default>
<summary>Transition</summary>
<description>The transition to use when switching tabs.</description>
</key>
<key name="show-words" type="b">
<default>false</default>
<summary>Show words</summary>
<description>Whether to show a word list in the sidebar</description>
</key>
</schema>
</schemalist>

9
diyafm.gresource.xml Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/app/iohub/dev/diyafm">
<file preprocess="xml-stripblanks">resources/fm.ui</file>
<file preprocess="xml-stripblanks">resources/app-menu.ui</file>
<file preprocess="xml-stripblanks">resources/gears-menu.ui</file>
<file preprocess="xml-stripblanks">resources/prefs.ui</file>
</gresource>
</gresources>

87
diyafm_app.c Normal file
View File

@ -0,0 +1,87 @@
#include <gtk/gtk.h>
#include "diyafm_app.h"
#include "diyafm_win.h"
#include "diyafm_prefs.h"
struct _DiyafmApp
{
GtkApplication parent;
};
G_DEFINE_TYPE(DiyafmApp, diyafm_app, GTK_TYPE_APPLICATION);
static void preferences_activated(GSimpleAction *action, GVariant *parameter, gpointer app)
{
DiyafmPrefs *prefs;
GtkWindow *win;
win = gtk_application_get_active_window(GTK_APPLICATION(app));
prefs = diyafm_prefs_new(DIYAFM_WINDOW(win));
gtk_window_present(GTK_WINDOW(prefs));
}
static void quit_activated(GSimpleAction *action, GVariant *parameter, gpointer app)
{
g_application_quit(G_APPLICATION(app));
}
static GActionEntry app_entries[] =
{
{"preferences", preferences_activated, NULL, NULL, NULL},
{"quit", quit_activated, NULL, NULL, NULL}};
static void diyafm_app_startup(GApplication *app)
{
GtkBuilder *builder;
GMenuModel *app_menu;
const gchar *quit_accels[2] = {"<Ctrl>Q", NULL};
G_APPLICATION_CLASS(diyafm_app_parent_class)->startup(app);
g_action_map_add_action_entries(G_ACTION_MAP(app), app_entries, G_N_ELEMENTS(app_entries), app);
gtk_application_set_accels_for_action(GTK_APPLICATION(app), "app.quit", quit_accels);
builder = gtk_builder_new_from_resource("/app/iohub/dev/diyafm/resources/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 diyafm_app_init(DiyafmApp *app)
{
}
static void diyafm_app_activate(GApplication *app)
{
DiyafmWindow *win;
win = diyafm_window_new(DIYAFM_APP(app));
gtk_window_present(GTK_WINDOW(win));
}
static void diyafm_app_open(GApplication *app, GFile **files, gint n_files, const gchar *hint)
{
GList *windows;
DiyafmWindow *win;
int i;
windows = gtk_application_get_windows(GTK_APPLICATION(app));
if (windows)
win = DIYAFM_WINDOW(windows->data);
else
win = diyafm_window_new(DIYAFM_APP(app));
for (i = 0; i < n_files; i++)
diyafm_window_open(win, files[i], i==0);
gtk_window_present(GTK_WINDOW(win));
}
static void diyafm_app_class_init(DiyafmAppClass *class)
{
G_APPLICATION_CLASS(class)->startup = diyafm_app_startup;
G_APPLICATION_CLASS(class)->activate = diyafm_app_activate;
G_APPLICATION_CLASS(class)->open = diyafm_app_open;
}
DiyafmApp *diyafm_app_new(void)
{
return g_object_new(DIYAFM_APP_TYPE, "application-id", "app.iohub.dev.diyafm", "flags", G_APPLICATION_HANDLES_OPEN, NULL);
}

11
diyafm_app.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef __DIYAFM_APP_H__
#define __DIYAFM_APP_H__
#include <gtk/gtk.h>
#define DIYAFM_APP_TYPE (diyafm_app_get_type())
G_DECLARE_FINAL_TYPE(DiyafmApp, diyafm_app, DIYAFM, APP, GtkApplication)
DiyafmApp *diyafm_app_new(void);
#endif

70
diyafm_prefs.c Normal file
View File

@ -0,0 +1,70 @@
#include <gtk/gtk.h>
#include "diyafm_app.h"
#include "diyafm_win.h"
#include "diyafm_prefs.h"
/**
schema_source = Gio.SettingsSchemaSource.new_from_directory(
os.path.expanduser("~/schemas"),
Gio.SettingsSchemaSource.get_default(),
False,
)
schema = schema_source.lookup('com.companyname.appname', False)
settings = Gio.Settings.new_full(schema, None, None)
settings.set_boolean('mybool', True)
*/
struct _DiyafmPrefs
{
GtkDialog parent;
};
typedef struct __DiyafmPrefsPrivate DiyafmPrefsPrivate;
struct __DiyafmPrefsPrivate
{
GSettings *settings;
GtkWidget *font;
GtkWidget *transition;
};
G_DEFINE_TYPE_WITH_PRIVATE(DiyafmPrefs, diyafm_prefs, GTK_TYPE_DIALOG)
static void diyafm_prefs_init(DiyafmPrefs *prefs)
{
DiyafmPrefsPrivate *priv;
priv = diyafm_prefs_get_instance_private(prefs);
gtk_widget_init_template(GTK_WIDGET(prefs));
priv->settings = g_settings_new("app.iohub.dev.diyafm");
g_settings_bind(priv->settings, "font",
priv->font, "font",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind(priv->settings, "transition",
priv->transition, "active-id",
G_SETTINGS_BIND_DEFAULT);
}
static void diyafm_prefs_dispose(GObject *object)
{
DiyafmPrefsPrivate *priv;
priv = diyafm_prefs_get_instance_private(DIYAFM_PREFS(object));
g_clear_object(&priv->settings);
G_OBJECT_CLASS(diyafm_prefs_parent_class)->dispose(object);
}
static void diyafm_prefs_class_init(DiyafmPrefsClass *class)
{
G_OBJECT_CLASS(class)->dispose = diyafm_prefs_dispose;
gtk_widget_class_set_template_from_resource(GTK_WIDGET_CLASS(class),"/app/iohub/dev/diyafm/resources/prefs.ui");
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS(class), DiyafmPrefs, font);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS(class), DiyafmPrefs, transition);
}
DiyafmPrefs * diyafm_prefs_new(DiyafmWindow *win)
{
return g_object_new(DIYAFM_PREFS_TYPE, "transient-for", win, "use-header-bar", TRUE, NULL);
}

12
diyafm_prefs.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef __DIYAFM_PREFS_H__
#define __DIYAFM_PREFS_H__
#include <gtk/gtk.h>
#include "diyafm_win.h"
#define DIYAFM_PREFS_TYPE (diyafm_prefs_get_type())
G_DECLARE_FINAL_TYPE(DiyafmPrefs, diyafm_prefs, DIYAFM, PREFS, GtkDialog)
DiyafmPrefs *diyafm_prefs_new(DiyafmWindow *win);
#endif

320
diyafm_win.c Normal file
View File

@ -0,0 +1,320 @@
#include <gtk/gtk.h>
#include "diyafm_app.h"
#include "diyafm_win.h"
struct _DiyafmWindow
{
GtkApplicationWindow parent;
};
// G_DEFINE_TYPE(DiyafmWindow, diyafm_window, GTK_TYPE_APPLICATION_WINDOW);
typedef struct _DiyafmWindowPrivate DiyafmWindowPrivate;
struct _DiyafmWindowPrivate
{
GSettings *settings;
GtkWidget *stack;
GtkWidget *search;
GtkWidget *searchbar;
GtkWidget *searchentry;
GtkWidget *gears;
GtkWidget *sidebar;
GtkWidget *words;
GtkWidget *lines;
GtkWidget *lines_label;
};
G_DEFINE_TYPE_WITH_PRIVATE(DiyafmWindow, diyafm_window, GTK_TYPE_APPLICATION_WINDOW);
static void search_text_changed(GtkEntry *entry)
{
DiyafmWindow *win;
DiyafmWindowPrivate *priv;
const gchar *text;
GtkWidget *tab;
GtkWidget *view;
GtkTextBuffer *buffer;
GtkTextIter start, match_start, match_end;
text = gtk_entry_get_text(entry);
if (text[0] == '\0')
return;
win = DIYAFM_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(entry)));
priv = diyafm_window_get_instance_private(win);
tab = gtk_stack_get_visible_child(GTK_STACK(priv->stack));
view = gtk_bin_get_child(GTK_BIN(tab));
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);
}
}
static void find_word(GtkButton *button, DiyafmWindow *win)
{
DiyafmWindowPrivate *priv;
const gchar *word;
priv = diyafm_window_get_instance_private(win);
word = gtk_button_get_label(button);
gtk_entry_set_text(GTK_ENTRY(priv->searchentry), word);
}
static void update_words(DiyafmWindow *win)
{
DiyafmWindowPrivate *priv;
GHashTable *strings;
GHashTableIter iter;
GtkWidget *tab, *view, *row;
GtkTextBuffer *buffer;
GtkTextIter start, end;
GList *children, *l;
gchar *word, *key;
priv = diyafm_window_get_instance_private(win);
tab = gtk_stack_get_visible_child(GTK_STACK(priv->stack));
if (tab == NULL)
return;
view = gtk_bin_get_child(GTK_BIN(tab));
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;
}
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;
}
done:
children = gtk_container_get_children(GTK_CONTAINER(priv->words));
for (l = children; l; l = l->next)
gtk_container_remove(GTK_CONTAINER(priv->words), GTK_WIDGET(l->data));
g_list_free(children);
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);
gtk_widget_show(row);
gtk_container_add(GTK_CONTAINER(priv->words), row);
}
g_hash_table_unref(strings);
}
static void words_changed(GObject *sidebar,
GParamSpec *pspec,
DiyafmWindow *win)
{
update_words(win);
}
static void update_lines (DiyafmWindow *win)
{
DiyafmWindowPrivate *priv;
GtkWidget *tab, *view;
GtkTextBuffer *buffer;
GtkTextIter iter;
int count;
gchar *lines;
priv = diyafm_window_get_instance_private (win);
tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
if (tab == NULL)
return;
view = gtk_bin_get_child (GTK_BIN (tab));
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
count = 0;
gtk_text_buffer_get_start_iter (buffer, &iter);
while (!gtk_text_iter_is_end (&iter))
{
count++;
if (!gtk_text_iter_forward_line (&iter))
break;
}
lines = g_strdup_printf ("%d", count);
gtk_label_set_text (GTK_LABEL (priv->lines), lines);
g_free (lines);
}
static void visible_child_changed(GObject *stack, GParamSpec *pspec)
{
DiyafmWindow *win;
DiyafmWindowPrivate *priv;
if (gtk_widget_in_destruction(GTK_WIDGET(stack)))
return;
win = DIYAFM_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(stack)));
priv = diyafm_window_get_instance_private(win);
gtk_search_bar_set_search_mode(GTK_SEARCH_BAR(priv->searchbar), FALSE);
if(g_settings_get_boolean(priv->settings,"show-words"))
{
printf("visible changed update worlds\n");
update_words(win);
}
update_lines (win);
}
static void diyafm_window_init(DiyafmWindow *win)
{
DiyafmWindowPrivate *priv;
GtkBuilder *builder;
GMenuModel *menu;
GAction *action;
priv = diyafm_window_get_instance_private(win);
gtk_widget_init_template(GTK_WIDGET(win));
g_signal_connect(priv->sidebar, "notify::reveal-child",
G_CALLBACK(words_changed), win);
priv->settings = g_settings_new("app.iohub.dev.diyafm");
g_settings_bind(priv->settings, "transition",
priv->stack, "transition-type",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind(priv->settings, "show-words",
priv->sidebar, "reveal-child",
G_SETTINGS_BIND_DEFAULT);
g_object_bind_property(priv->search, "active",
priv->searchbar, "search-mode-enabled",
G_BINDING_BIDIRECTIONAL);
builder = gtk_builder_new_from_resource("/app/iohub/dev/diyafm/resources/gears-menu.ui");
menu = G_MENU_MODEL(gtk_builder_get_object(builder, "menu"));
gtk_menu_button_set_menu_model(GTK_MENU_BUTTON(priv->gears), menu);
g_object_unref(builder);
action = g_settings_create_action(priv->settings, "show-words");
g_action_map_add_action(G_ACTION_MAP(win), action);
g_object_unref(action);
action = (GAction*) g_property_action_new ("show-lines", priv->lines, "visible");
g_action_map_add_action (G_ACTION_MAP (win), action);
g_object_unref (action);
g_object_bind_property (priv->lines, "visible",
priv->lines_label, "visible",
G_BINDING_DEFAULT);
}
static void diyafm_window_dispose(GObject *object)
{
DiyafmWindow *win;
DiyafmWindowPrivate *priv;
win = DIYAFM_WINDOW(object);
priv = diyafm_window_get_instance_private(win);
g_clear_object(&priv->settings);
G_OBJECT_CLASS(diyafm_window_parent_class)->dispose(object);
}
static void diyafm_window_class_init(DiyafmWindowClass *class)
{
G_OBJECT_CLASS(class)->dispose = diyafm_window_dispose;
gtk_widget_class_set_template_from_resource(GTK_WIDGET_CLASS(class), "/app/iohub/dev/diyafm/resources/fm.ui");
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS(class), DiyafmWindow, stack);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS(class), DiyafmWindow, search);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS(class), DiyafmWindow, searchbar);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS(class), DiyafmWindow, searchentry);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS(class), DiyafmWindow, gears);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS(class), DiyafmWindow, words);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS(class), DiyafmWindow, sidebar);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), DiyafmWindow, lines);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), DiyafmWindow, lines_label);
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);
}
DiyafmWindow *diyafm_window_new(DiyafmApp *app)
{
return g_object_new(DIYAFM_WINDOW_TYPE, "application", app, NULL);
}
void diyafm_window_open(DiyafmWindow *win, GFile *file, gboolean active)
{
DiyafmWindowPrivate *priv;
gchar *basename;
GtkWidget *scrolled, *view;
gchar *contents;
gsize length;
GtkTextIter start_iter, end_iter;
GtkTextTag *tag;
priv = diyafm_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);
GtkTextBuffer *buffer;
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);
gtk_widget_set_sensitive(priv->search, TRUE);
if(active)
{
printf("active file is %s\n", basename);
update_words(win);
}
update_lines (win);
g_free(basename);
}

13
diyafm_win.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef __DIYAFMWIN_H__
#define __DIYAFMWIN_H__
#include <gtk/gtk.h>
#include "diyafm_app.h"
#define DIYAFM_WINDOW_TYPE (diyafm_window_get_type())
G_DECLARE_FINAL_TYPE(DiyafmWindow, diyafm_window, DIYAFM, WINDOW, GtkApplicationWindow)
DiyafmWindow *diyafm_window_new(DiyafmApp *app);
void diyafm_window_open(DiyafmWindow *win,GFile *file, gboolean active);
#endif

14
fm.c Normal file
View File

@ -0,0 +1,14 @@
#include <gtk/gtk.h>
#include "diyafm_app.h"
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", "./data", FALSE);
return g_application_run(G_APPLICATION(diyafm_app_new()), argc, argv);
}

18
resources/app-menu.ui Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<menu id="appmenu">
<section>
<item>
<attribute name="label" translatable="yes">_Preferences</attribute>
<attribute name="action">app.preferences</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">_Quit</attribute>
<attribute name="action">app.quit</attribute>
</item>
</section>
</menu>
</interface>

117
resources/fm.ui Normal file
View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.8 -->
<template class="DiyafmWindow" parent="GtkApplicationWindow">
<property name="title" translatable="yes">DiyaFM</property>
<property name="default-width">600</property>
<property name="default-height">400</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="header">
<property name="visible">True</property>
<property name="show-close-button">True</property>
<child>
<object class="GtkLabel" id="lines_label">
<property name="visible">False</property>
<property name="label" translatable="yes">Lines:</property>
</object>
<packing>
<property name="pack-type">start</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lines">
<property name="visible">False</property>
</object>
<packing>
<property name="pack-type">start</property>
</packing>
</child>
<child type="title">
<object class="GtkStackSwitcher" id="tabs">
<property name="visible">True</property>
<property name="stack">stack</property>
</object>
</child>
<child>
<object class="GtkToggleButton" id="search">
<property name="visible">True</property>
<property name="sensitive">False</property>
<style>
<class name="image-button"/>
</style>
<child>
<object class="GtkImage" id="search-icon">
<property name="visible">True</property>
<property name="icon-name">edit-find-symbolic</property>
<property name="icon-size">1</property>
</object>
</child>
</object>
<packing>
<property name="pack-type">end</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="gears">
<property name="visible">True</property>
<property name="direction">none</property>
<property name="use-popover">True</property>
<style>
<class name="image-button"/>
</style>
</object>
<packing>
<property name="pack-type">end</property>
</packing>
</child>
</object>
</child>
<child>
<object class="GtkBox" id="content_box">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkSearchBar" id="searchbar">
<property name="visible">True</property>
<child>
<object class="GtkSearchEntry" id="searchentry">
<signal name="search-changed" handler="search_text_changed"/>
<property name="visible">True</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox" id="hbox">
<property name="visible">True</property>
<child>
<object class="GtkRevealer" id="sidebar">
<property name="visible">True</property>
<property name="transition-type">slide-right</property>
<child>
<object class="GtkScrolledWindow" id="sidebar-sw">
<property name="visible">True</property>
<property name="hscrollbar-policy">never</property>
<property name="vscrollbar-policy">automatic</property>
<child>
<object class="GtkListBox" id="words">
<property name="visible">True</property>
<property name="selection-mode">none</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkStack" id="stack">
<signal name="notify::visible-child" handler="visible_child_changed"/>
<property name="visible">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
</interface>

16
resources/gears-menu.ui Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<menu id="menu">
<section>
<item>
<attribute name="label" translatable="yes">_Words</attribute>
<attribute name="action">win.show-words</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Lines</attribute>
<attribute name="action">win.show-lines</attribute>
</item>
</section>
</menu>
</interface>

70
resources/prefs.ui Normal file
View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.8 -->
<template class="DiyafmPrefs" parent="GtkDialog">
<property name="title" translatable="yes">Preferences</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<child internal-child="vbox">
<object class="GtkBox" id="vbox">
<child>
<object class="GtkGrid" id="grid">
<property name="visible">True</property>
<property name="margin">6</property>
<property name="row-spacing">12</property>
<property name="column-spacing">6</property>
<child>
<object class="GtkLabel" id="fontlabel">
<property name="visible">True</property>
<property name="label">_Font:</property>
<property name="use-underline">True</property>
<property name="mnemonic-widget">font</property>
<property name="xalign">1</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkFontButton" id="font">
<property name="visible">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="transitionlabel">
<property name="visible">True</property>
<property name="label">_Transition:</property>
<property name="use-underline">True</property>
<property name="mnemonic-widget">transition</property>
<property name="xalign">1</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="transition">
<property name="visible">True</property>
<items>
<item translatable="yes" id="none">None</item>
<item translatable="yes" id="crossfade">Fade</item>
<item translatable="yes" id="slide-left-right">Slide</item>
</items>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</template>
</interface>