[bijiben/wip/sadiq/rewrite: 7/7] Add grid-view-item class
- From: Mohammed Sadiq <pksadiq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bijiben/wip/sadiq/rewrite: 7/7] Add grid-view-item class
- Date: Tue, 13 Mar 2018 13:19:10 +0000 (UTC)
commit 46c5aed65a18b118e3c3e222b2a3fa4983c0c31a
Author: Mohammed Sadiq <sadiq sadiqpk org>
Date: Mon Mar 12 13:52:37 2018 +0530
Add grid-view-item class
src/resources/bijiben.gresource.xml | 1 +
src/resources/ui/bjb-grid-view-item.ui | 29 +++++++++++
src/views/bjb-grid-view-item.c | 83 ++++++++++++++++++++++++++++++++
src/views/bjb-grid-view-item.h | 35 +++++++++++++
4 files changed, 148 insertions(+), 0 deletions(-)
---
diff --git a/src/resources/bijiben.gresource.xml b/src/resources/bijiben.gresource.xml
index c4903d1..cfb5278 100644
--- a/src/resources/bijiben.gresource.xml
+++ b/src/resources/bijiben.gresource.xml
@@ -4,6 +4,7 @@
<file preprocess="xml-stripblanks">gtk/menus.ui</file>
<file preprocess="xml-stripblanks">ui/bjb-window.ui</file>
<file preprocess="xml-stripblanks">ui/bjb-main-view.ui</file>
+ <file preprocess="xml-stripblanks">ui/bjb-grid-view-item.ui</file>
<file>css/style.css</file>
</gresource>
</gresources>
diff --git a/src/resources/ui/bjb-grid-view-item.ui b/src/resources/ui/bjb-grid-view-item.ui
new file mode 100644
index 0000000..8e847ff
--- /dev/null
+++ b/src/resources/ui/bjb-grid-view-item.ui
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk 3.12 -->
+ <template class="BjbGridViewItem" parent="GtkFlowBoxChild">
+ <property name="visible">1</property>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">1</property>
+ <property name="orientation">vertical</property>
+
+ <child>
+ <object class="GtkImage" id="thumbnail">
+ <property name="visible">1</property>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkLabel" id="title_label">
+ <property name="visible">1</property>
+ <property name="max-width-chars">10</property>
+ <property name="lines">2</property>
+ <property name="ellipsize">end</property>
+ </object>
+ </child>
+
+ </object>
+ </child> <!-- ./GtkGrid -->
+ </template>
+</interface>
diff --git a/src/views/bjb-grid-view-item.c b/src/views/bjb-grid-view-item.c
new file mode 100644
index 0000000..8f855df
--- /dev/null
+++ b/src/views/bjb-grid-view-item.c
@@ -0,0 +1,83 @@
+/* bjb-grid-view-item.c
+ *
+ * Copyright 2018 Mohammed Sadiq <sadiq sadiqpk org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "bjb-grid-view-item"
+
+#include "config.h"
+
+#include "bjb-item.h"
+#include "bjb-provider.h"
+#include "bjb-trace.h"
+
+#include "bjb-grid-view-item.h"
+
+/**
+ * SECTION: bjb-grid-view-item
+ * @title: BjbGridViewItem
+ * @short_description: A widget to show the note or notebook
+ * @include: "bjb-grid-view-item.h"
+ */
+
+struct _BjbGridViewItem
+{
+ GtkFlowBoxChild parent_instance;
+
+ GtkWidget *thumbnail;
+ GtkWidget *title_label;
+ GtkWidget *check_box;
+};
+
+G_DEFINE_TYPE (BjbGridViewItem, bjb_grid_view_item, GTK_TYPE_FLOW_BOX_CHILD)
+
+static void
+bjb_grid_view_item_class_init (BjbGridViewItemClass *klass)
+{
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/bijiben/"
+ "ui/bjb-grid-view-item.ui");
+
+ gtk_widget_class_bind_template_child (widget_class, BjbGridViewItem, thumbnail);
+ gtk_widget_class_bind_template_child (widget_class, BjbGridViewItem, title_label);
+ /* gtk_widget_class_bind_template_child (widget_class, BjbGridViewItem, check_button); */
+}
+
+static void
+bjb_grid_view_item_init (BjbGridViewItem *self)
+{
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
+
+GtkWidget *
+bjb_grid_view_item_new (GdkPixbuf *pixbuf,
+ const gchar *title)
+{
+ BjbGridViewItem *self;
+
+ BJB_ENTRY;
+
+ self = g_object_new (BJB_TYPE_GRID_VIEW_ITEM, NULL);
+
+ gtk_label_set_label (GTK_LABEL (self->title_label), title);
+ gtk_image_set_from_pixbuf (GTK_IMAGE (self->thumbnail), pixbuf);
+
+ BJB_RETURN (GTK_WIDGET (self));
+}
diff --git a/src/views/bjb-grid-view-item.h b/src/views/bjb-grid-view-item.h
new file mode 100644
index 0000000..7e1fd5d
--- /dev/null
+++ b/src/views/bjb-grid-view-item.h
@@ -0,0 +1,35 @@
+/* bjb-grid-view-item.h
+ *
+ * Copyright 2018 Mohammed Sadiq <sadiq sadiqpk org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <gtk/gtk.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define BJB_TYPE_GRID_VIEW_ITEM (bjb_grid_view_item_get_type ())
+
+G_DECLARE_FINAL_TYPE (BjbGridViewItem, bjb_grid_view_item, BJB, GRID_VIEW_ITEM, GtkFlowBoxChild)
+
+GtkWidget *bjb_grid_view_item_new (GdkPixbuf *pixbuf,
+ const gchar *title);
+
+G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]