[buoh/cleanups: 1/3] Port view-comic to GtkBuilder
- From: Jan Tojnar <jtojnar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [buoh/cleanups: 1/3] Port view-comic to GtkBuilder
- Date: Tue, 18 Sep 2018 18:14:56 +0000 (UTC)
commit 07d0264c50ff9b2fa716163c4ba001ec0eb48dcd
Author: Jan Tojnar <jtojnar gmail com>
Date: Fri Sep 14 22:20:17 2018 +0200
Port view-comic to GtkBuilder
https://gitlab.gnome.org/GNOME/buoh/issues/5
data/meson.build | 1 +
data/org.gnome.buoh.gresource.xml | 1 +
data/ui/view-comic.ui | 17 +++++++++++++++++
po/POTFILES.in | 1 +
src/buoh-view-comic.c | 31 +++++++++----------------------
5 files changed, 29 insertions(+), 22 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index 19614a8..d9941ad 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -1,6 +1,7 @@
ui_files = files(
'ui/add-comic-dialog.ui',
'ui/properties-dialog.ui',
+ 'ui/view-comic.ui',
'ui/view-message.ui',
)
if gtk_builder_tool.found()
diff --git a/data/org.gnome.buoh.gresource.xml b/data/org.gnome.buoh.gresource.xml
index 9de2ca0..9aa884c 100644
--- a/data/org.gnome.buoh.gresource.xml
+++ b/data/org.gnome.buoh.gresource.xml
@@ -4,6 +4,7 @@
<file>buoh-ui.xml</file>
<file>ui/add-comic-dialog.ui</file>
<file>ui/properties-dialog.ui</file>
+ <file>ui/view-comic.ui</file>
<file>ui/view-message.ui</file>
</gresource>
</gresources>
diff --git a/data/ui/view-comic.ui b/data/ui/view-comic.ui
new file mode 100644
index 0000000..4d86b2c
--- /dev/null
+++ b/data/ui/view-comic.ui
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <template class="BuohViewComic" parent="GtkViewport">
+ <property name="visible">1</property>
+ <signal handler="buoh_view_comic_drag_begin" name="drag-begin" swapped="no"/>
+ <signal handler="buoh_view_comic_drag_data_get" name="drag-data-get" swapped="no"/>
+ <signal handler="bouh_view_comic_changed_comic_cb" name="notify::comic" swapped="no"/>
+ <child>
+ <object class="GtkImage" id="image">
+ <property name="visible">1</property>
+ <property name="icon-name">image-missing</property>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 7ac081b..acdf245 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -4,6 +4,7 @@ data/buoh.desktop.in
data/org.gnome.buoh.gschema.xml
data/ui/add-comic-dialog.ui
data/ui/properties-dialog.ui
+data/ui/view-comic.ui
data/ui/view-message.ui
src/buoh-add-comic-dialog.c
src/buoh-comic-list.c
diff --git a/src/buoh-view-comic.c b/src/buoh-view-comic.c
index 989eb6a..d431782 100644
--- a/src/buoh-view-comic.c
+++ b/src/buoh-view-comic.c
@@ -114,8 +114,6 @@ G_DEFINE_TYPE_WITH_PRIVATE (BuohViewComic, buoh_view_comic, GTK_TYPE_VIEWPORT)
static void
buoh_view_comic_init (BuohViewComic *c_view)
{
- gtk_widget_set_can_focus (GTK_WIDGET (c_view), TRUE);
-
c_view->priv = buoh_view_comic_get_instance_private (c_view);
c_view->priv->zoom_mode = VIEW_ZOOM_FIT_WIDTH;
@@ -123,31 +121,12 @@ buoh_view_comic_init (BuohViewComic *c_view)
c_view->priv->comic_loader = buoh_comic_loader_new ();
c_view->priv->comic_data = g_string_sized_new (DATA_SIZE);
- c_view->priv->image = gtk_image_new ();
- gtk_container_add (GTK_CONTAINER (c_view),
- c_view->priv->image);
- gtk_widget_show (c_view->priv->image);
-
- /* Callbacks */
- g_signal_connect (G_OBJECT (c_view),
- "notify::comic",
- G_CALLBACK (bouh_view_comic_changed_comic_cb),
- NULL);
- g_signal_connect (G_OBJECT (c_view),
- "drag-begin",
- G_CALLBACK (buoh_view_comic_drag_begin),
- NULL);
- g_signal_connect (G_OBJECT (c_view),
- "drag-data-get",
- G_CALLBACK (buoh_view_comic_drag_data_get),
- NULL);
+ gtk_widget_init_template (GTK_WIDGET (c_view));
g_signal_connect_swapped (G_OBJECT (c_view->priv->comic_loader),
"finished",
G_CALLBACK (buoh_view_comic_load_finished),
(gpointer) c_view);
-
- gtk_widget_show (GTK_WIDGET (c_view));
}
static void
@@ -190,6 +169,14 @@ buoh_view_comic_class_init (BuohViewComicClass *klass)
object_class->finalize = buoh_view_comic_finalize;
object_class->dispose = buoh_view_comic_dispose;
+
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/buoh/ui/view-comic.ui");
+
+ gtk_widget_class_bind_template_child_private (widget_class, BuohViewComic, image);
+
+ gtk_widget_class_bind_template_callback (widget_class, bouh_view_comic_changed_comic_cb);
+ gtk_widget_class_bind_template_callback (widget_class, buoh_view_comic_drag_begin);
+ gtk_widget_class_bind_template_callback (widget_class, buoh_view_comic_drag_data_get);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]