[bijiben/wip/sadiq/rewrite: 15/16] Add grid-view-item class



commit 1101c03c85ef93de710fdcf5b0bdaf78698cc48c
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 |   41 +++++++++++++
 src/views/bjb-grid-view-item.c         |   98 ++++++++++++++++++++++++++++++++
 src/views/bjb-grid-view-item.h         |   35 +++++++++++
 4 files changed, 175 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..2c34e43
--- /dev/null
+++ b/src/resources/ui/bjb-grid-view-item.ui
@@ -0,0 +1,41 @@
+<?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="GtkFrame">
+            <property name="visible">1</property>
+            <child>
+              <object class="GtkOverlay">
+                <property name="visible">1</property>
+                <property name="halign">start</property>
+                <property name="valign">start</property>
+                <property name="width-request">200</property>
+                <property name="height-request">200</property>
+                <child type="overlay">
+                  <object class="BjbitemThumbnail" id="preview_label"/>
+                </child>
+              </object> <!-- ./GtkOverlay -->
+            </child>
+          </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..6ffd1a7
--- /dev/null
+++ b/src/views/bjb-grid-view-item.c
@@ -0,0 +1,98 @@
+/* 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-item-thumbnail.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;
+
+  BjbItem *item;
+
+  GtkWidget *preview_label;
+  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);
+
+  g_type_ensure (BJB_TYPE_ITEM_THUMBNAIL);
+
+  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, preview_label);
+  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 (gpointer data,
+                        gpointer user_data)
+{
+  BjbGridViewItem *self;
+  BjbItem *item = data;
+  GdkRGBA rgba;
+
+  BJB_ENTRY;
+
+  g_return_val_if_fail (BJB_IS_ITEM (item), NULL);
+
+  self = g_object_new (BJB_TYPE_GRID_VIEW_ITEM, NULL);
+  bjb_item_get_rgba (item, &rgba);
+
+  gtk_label_set_label (GTK_LABEL (self->title_label), "Test Button");
+
+  g_object_set (G_OBJECT (self->preview_label),
+                "rgba", &rgba,
+                "label", "reall very nice to have it\nNice\n\n\n\\n\n\n\n\n\n\n\n\nasdfsdf",
+                NULL);
+
+  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..11ece47
--- /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 (gpointer data,
+                                   gpointer user_data);
+
+G_END_DECLS


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]