[gnome-builder/wip/greeter] greeter: add GbGreeterPillBox
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/greeter] greeter: add GbGreeterPillBox
- Date: Sun, 10 May 2015 19:41:06 +0000 (UTC)
commit 4848023fcf90d5a01257414fb1a6a25d47e5d08a
Author: Christian Hergert <christian hergert me>
Date: Sun May 10 12:37:54 2015 -0700
greeter: add GbGreeterPillBox
We will probably want to make this more generic in the future once we
know how this type of widget will be used. GbPillBox, or Egg even.
data/theme/Adwaita.css | 2 +-
data/ui/gb-greeter-pill-box.ui | 21 +++++
src/Makefile.am | 2 +
src/greeter/gb-greeter-pill-box.c | 130 +++++++++++++++++++++++++++++
src/greeter/gb-greeter-pill-box.h | 37 ++++++++
src/resources/gnome-builder.gresource.xml | 1 +
6 files changed, 192 insertions(+), 1 deletions(-)
---
diff --git a/data/theme/Adwaita.css b/data/theme/Adwaita.css
index 4e7a61c..804ac54 100644
--- a/data/theme/Adwaita.css
+++ b/data/theme/Adwaita.css
@@ -17,7 +17,7 @@ GbProjectTree.view.cell:selected {
}
-GtkEventBox.pill-box {
+GbGreeterPillBox {
background-color: #eeeeec;
border-radius: 3px;
}
diff --git a/data/ui/gb-greeter-pill-box.ui b/data/ui/gb-greeter-pill-box.ui
new file mode 100644
index 0000000..b6e1824
--- /dev/null
+++ b/data/ui/gb-greeter-pill-box.ui
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.15 -->
+ <template class="GbGreeterPillBox" parent="GtkEventBox">
+ <style>
+ <class name="pill-box"/>
+ </style>
+ <child>
+ <object class="GtkLabel" id="label">
+ <property name="xpad">6</property>
+ <property name="ypad">3</property>
+ <property name="hexpand">false</property>
+ <property name="valign">baseline</property>
+ <property name="visible">true</property>
+ <attributes>
+ <attribute name="scale" value="0.833333"/>
+ </attributes>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/Makefile.am b/src/Makefile.am
index 40a40e9..ea51501 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -72,6 +72,8 @@ libgnome_builder_la_SOURCES = \
editor/gb-editor-workspace.h \
gd/gd-tagged-entry.c \
gd/gd-tagged-entry.h \
+ greeter/gb-greeter-pill-box.c \
+ greeter/gb-greeter-pill-box.h \
greeter/gb-greeter-project-row.c \
greeter/gb-greeter-project-row.h \
greeter/gb-greeter-window.c \
diff --git a/src/greeter/gb-greeter-pill-box.c b/src/greeter/gb-greeter-pill-box.c
new file mode 100644
index 0000000..94c2ea3
--- /dev/null
+++ b/src/greeter/gb-greeter-pill-box.c
@@ -0,0 +1,130 @@
+/* gb-greeter-pill-box.c
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * 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/>.
+ */
+
+#define G_LOG_DOMAIN "gb-greeter-pill-box"
+
+#include <glib/gi18n.h>
+
+#include "gb-greeter-pill-box.h"
+
+struct _GbGreeterPillBox
+{
+ GtkEventBox parent_instance;
+
+ GtkLabel *label;
+};
+
+G_DEFINE_TYPE (GbGreeterPillBox, gb_greeter_pill_box, GTK_TYPE_EVENT_BOX)
+
+enum {
+ PROP_0,
+ PROP_LABEL,
+ LAST_PROP
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+
+const gchar *
+gb_greeter_pill_box_get_label (GbGreeterPillBox *self)
+{
+ g_return_val_if_fail (GB_IS_GREETER_PILL_BOX (self), NULL);
+
+ return gtk_label_get_label (self->label);
+}
+
+void
+gb_greeter_pill_box_set_label (GbGreeterPillBox *self,
+ const gchar *label)
+{
+ g_return_if_fail (GB_IS_GREETER_PILL_BOX (self));
+
+ gtk_label_set_label (self->label, label);
+}
+
+GtkWidget *
+gb_greeter_pill_box_new (const gchar *label)
+{
+ return g_object_new (GB_TYPE_GREETER_PILL_BOX,
+ "label", label,
+ NULL);
+}
+
+static void
+gb_greeter_pill_box_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GbGreeterPillBox *self = GB_GREETER_PILL_BOX (object);
+
+ switch (prop_id)
+ {
+ case PROP_LABEL:
+ g_value_set_string (value, gb_greeter_pill_box_get_label (self));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gb_greeter_pill_box_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GbGreeterPillBox *self = GB_GREETER_PILL_BOX (object);
+
+ switch (prop_id)
+ {
+ case PROP_LABEL:
+ gb_greeter_pill_box_set_label (self, g_value_get_string (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gb_greeter_pill_box_class_init (GbGreeterPillBoxClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->get_property = gb_greeter_pill_box_get_property;
+ object_class->set_property = gb_greeter_pill_box_set_property;
+
+ gParamSpecs [PROP_LABEL] =
+ g_param_spec_string ("label",
+ _("Label"),
+ _("The label for the pill box."),
+ NULL,
+ (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_LABEL, gParamSpecs [PROP_LABEL]);
+
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/builder/ui/gb-greeter-pill-box.ui");
+ gtk_widget_class_bind_template_child (widget_class, GbGreeterPillBox, label);
+}
+
+static void
+gb_greeter_pill_box_init (GbGreeterPillBox *self)
+{
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/src/greeter/gb-greeter-pill-box.h b/src/greeter/gb-greeter-pill-box.h
new file mode 100644
index 0000000..394a333
--- /dev/null
+++ b/src/greeter/gb-greeter-pill-box.h
@@ -0,0 +1,37 @@
+/* gb-greeter-pill-box.h
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * 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/>.
+ */
+
+#ifndef GB_GREETER_PILL_BOX_H
+#define GB_GREETER_PILL_BOX_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_GREETER_PILL_BOX (gb_greeter_pill_box_get_type())
+
+G_DECLARE_FINAL_TYPE (GbGreeterPillBox, gb_greeter_pill_box, GB, GREETER_PILL_BOX, GtkEventBox)
+
+GtkWidget *gb_greeter_pill_box_new (const gchar *label);
+const gchar *gb_greeter_pill_box_get_label (GbGreeterPillBox *self);
+void gb_greeter_pill_box_set_label (GbGreeterPillBox *self,
+ const gchar *label);
+
+G_END_DECLS
+
+#endif /* GB_GREETER_PILL_BOX_H */
diff --git a/src/resources/gnome-builder.gresource.xml b/src/resources/gnome-builder.gresource.xml
index 1329ee3..55e35ba 100644
--- a/src/resources/gnome-builder.gresource.xml
+++ b/src/resources/gnome-builder.gresource.xml
@@ -42,6 +42,7 @@
<file alias="ui/gb-editor-tweak-widget.ui">../../data/ui/gb-editor-tweak-widget.ui</file>
<file alias="ui/gb-editor-view.ui">../../data/ui/gb-editor-view.ui</file>
<file alias="ui/gb-editor-workspace.ui">../../data/ui/gb-editor-workspace.ui</file>
+ <file alias="ui/gb-greeter-pill-box.ui">../../data/ui/gb-greeter-pill-box.ui</file>
<file alias="ui/gb-greeter-project-row.ui">../../data/ui/gb-greeter-project-row.ui</file>
<file alias="ui/gb-greeter-window.ui">../../data/ui/gb-greeter-window.ui</file>
<file alias="ui/gb-html-view.ui">../../data/ui/gb-html-view.ui</file>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]