[buoh/cleanups] Port comic-list to GtkBuilder
- From: Jan Tojnar <jtojnar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [buoh/cleanups] Port comic-list to GtkBuilder
- Date: Fri, 14 Sep 2018 21:43:47 +0000 (UTC)
commit d0bdfac588000eb59c141d2eec0b7d9eb5d305bd
Author: Jan Tojnar <jtojnar gmail com>
Date: Fri Sep 14 23:42:50 2018 +0200
Port comic-list to GtkBuilder
https://gitlab.gnome.org/GNOME/buoh/issues/5
data/meson.build | 1 +
data/org.gnome.buoh.gresource.xml | 1 +
data/ui/comic-list.ui | 40 ++++++++++++++++++++++++++++++++++
po/POTFILES.in | 1 +
src/buoh-comic-list.c | 45 +++++++++------------------------------
5 files changed, 53 insertions(+), 35 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index d9941ad..b141a07 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -1,5 +1,6 @@
ui_files = files(
'ui/add-comic-dialog.ui',
+ 'ui/comic-list.ui',
'ui/properties-dialog.ui',
'ui/view-comic.ui',
'ui/view-message.ui',
diff --git a/data/org.gnome.buoh.gresource.xml b/data/org.gnome.buoh.gresource.xml
index 9aa884c..a8e54ed 100644
--- a/data/org.gnome.buoh.gresource.xml
+++ b/data/org.gnome.buoh.gresource.xml
@@ -3,6 +3,7 @@
<gresource prefix="/org/gnome/buoh">
<file>buoh-ui.xml</file>
<file>ui/add-comic-dialog.ui</file>
+ <file>ui/comic-list.ui</file>
<file>ui/properties-dialog.ui</file>
<file>ui/view-comic.ui</file>
<file>ui/view-message.ui</file>
diff --git a/data/ui/comic-list.ui b/data/ui/comic-list.ui
new file mode 100644
index 0000000..f0f7d9d
--- /dev/null
+++ b/data/ui/comic-list.ui
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <template class="BuohComicList" id="comic_list" parent="GtkBin">
+ <child>
+ <object class="GtkScrolledWindow">
+ <property name="visible">1</property>
+ <property name="can-focus">1</property>
+ <property name="shadow-type">in</property>
+ <child>
+ <object class="GtkTreeView" id="tree_view">
+ <property name="visible">1</property>
+ <property name="can-focus">1</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection">
+ <signal handler="buoh_comic_list_selection_changed" name="changed" object="comic_list"
swapped="no"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn">
+ <property name="title" translatable="yes">Title</property>
+ <child>
+ <object class="GtkCellRendererText">
+ <property name="xalign">0</property>
+ <property name="ellipsize">end</property>
+ </object>
+ <attributes>
+ <!-- COMIC_LIST_TITLE -->
+ <attribute name="text">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index acdf245..5c4eb4c 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -3,6 +3,7 @@
data/buoh.desktop.in
data/org.gnome.buoh.gschema.xml
data/ui/add-comic-dialog.ui
+data/ui/comic-list.ui
data/ui/properties-dialog.ui
data/ui/view-comic.ui
data/ui/view-message.ui
diff --git a/src/buoh-comic-list.c b/src/buoh-comic-list.c
index 1c9b5b1..bb197e6 100644
--- a/src/buoh-comic-list.c
+++ b/src/buoh-comic-list.c
@@ -26,7 +26,6 @@
#include "buoh-comic-list.h"
struct _BuohComicListPrivate {
- GtkWidget *swindow;
GtkWidget *tree_view;
GtkTreeModel *model;
BuohComicManager *comic_manager;
@@ -92,9 +91,6 @@ static void
buoh_comic_list_init (BuohComicList *buoh_comic_list)
{
GtkTreeModel *model;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
- GtkTreeSelection *selection;
buoh_comic_list->priv = buoh_comic_list_get_instance_private (buoh_comic_list);
@@ -107,37 +103,10 @@ buoh_comic_list_init (BuohComicList *buoh_comic_list)
buoh_comic_list_visible,
NULL, NULL);
- buoh_comic_list->priv->tree_view = gtk_tree_view_new_with_model (buoh_comic_list->priv->model);
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (renderer),
- "ellipsize-set", TRUE,
- "ellipsize", PANGO_ELLIPSIZE_END,
- NULL);
- column = gtk_tree_view_column_new_with_attributes (_("Title"), renderer,
- "text", COMIC_LIST_TITLE,
- NULL);
- gtk_tree_view_insert_column (GTK_TREE_VIEW (buoh_comic_list->priv->tree_view),
- column, COMIC_LIST_TITLE);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (buoh_comic_list->priv->tree_view));
- g_signal_connect (selection, "changed",
- G_CALLBACK (buoh_comic_list_selection_changed),
- (gpointer) buoh_comic_list);
-
- buoh_comic_list->priv->swindow = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (buoh_comic_list->priv->swindow),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (buoh_comic_list->priv->swindow),
- GTK_SHADOW_IN);
- gtk_container_add (GTK_CONTAINER (buoh_comic_list->priv->swindow),
- buoh_comic_list->priv->tree_view);
- gtk_widget_show (buoh_comic_list->priv->tree_view);
-
- gtk_container_add (GTK_CONTAINER (buoh_comic_list), buoh_comic_list->priv->swindow);
- gtk_widget_show (buoh_comic_list->priv->swindow);
-
- gtk_widget_show (GTK_WIDGET (buoh_comic_list));
+ gtk_widget_init_template (GTK_WIDGET (buoh_comic_list));
+
+ gtk_tree_view_set_model (GTK_TREE_VIEW (buoh_comic_list->priv->tree_view),
+ buoh_comic_list->priv->model);
}
static void
@@ -150,6 +119,12 @@ buoh_comic_list_class_init (BuohComicListClass *klass)
widget_class->size_allocate = buoh_comic_list_size_allocate;
object_class->finalize = buoh_comic_list_finalize;
+
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/buoh/ui/comic-list.ui");
+
+ gtk_widget_class_bind_template_child_private (widget_class, BuohComicList, tree_view);
+
+ gtk_widget_class_bind_template_callback (widget_class, buoh_comic_list_selection_changed);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]