[gnome-todo] WIP
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo] WIP
- Date: Thu, 18 Jun 2020 22:27:34 +0000 (UTC)
commit ece5a3c92669196244ea54b016a7652f1df41de2
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri May 22 10:33:19 2020 -0300
WIP
src/gui/gtd-command-bar.c | 147 ++++++++++++++++++++++++++++++++++++++
src/gui/gtd-command-bar.h | 34 +++++++++
src/gui/gtd-command-bar.ui | 50 +++++++++++++
src/themes/Adwaita-commandbar.css | 27 +++++++
4 files changed, 258 insertions(+)
---
diff --git a/src/gui/gtd-command-bar.c b/src/gui/gtd-command-bar.c
new file mode 100644
index 0000000..a1ad511
--- /dev/null
+++ b/src/gui/gtd-command-bar.c
@@ -0,0 +1,147 @@
+/* gtd-command-bar.c
+ *
+ * Copyright 2020 Georges Basile Stavracas Neto <georges stavracas gmail com>
+ *
+ * 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
+ */
+
+#include "gtd-command-bar.h"
+
+struct _GtdCommandBar
+{
+ GtdWidget parent_instance;
+
+ GtkEntry *entry;
+ GtkRevealer *revealer;
+};
+
+G_DEFINE_TYPE (GtdCommandBar, gtd_command_bar, GTD_TYPE_WIDGET)
+
+/*
+ * Callbacks
+ */
+
+static void
+on_revealer_child_revealed_cb (GtkRevealer *revealer,
+ GParamSpec *pspec,
+ GtdCommandBar *self)
+{
+ g_assert (GTD_IS_COMMAND_BAR (self));
+ g_assert (GTK_IS_REVEALER (revealer));
+
+ if (gtk_revealer_get_child_revealed (revealer))
+ {
+ if (!gtk_widget_has_focus (GTK_WIDGET (self->entry)))
+ gtk_widget_grab_focus (GTK_WIDGET (self->entry));
+ }
+ else
+ {
+ gtk_widget_hide (GTK_WIDGET (self));
+ }
+}
+
+
+/*
+ * GObject overrides
+ */
+
+static void
+gtd_command_bar_finalize (GObject *object)
+{
+ GtdCommandBar *self = (GtdCommandBar *)object;
+
+ G_OBJECT_CLASS (gtd_command_bar_parent_class)->finalize (object);
+}
+
+static void
+gtd_command_bar_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GtdCommandBar *self = GTD_COMMAND_BAR (object);
+
+ switch (prop_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gtd_command_bar_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GtdCommandBar *self = GTD_COMMAND_BAR (object);
+
+ switch (prop_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gtd_command_bar_class_init (GtdCommandBarClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->finalize = gtd_command_bar_finalize;
+ object_class->get_property = gtd_command_bar_get_property;
+ object_class->set_property = gtd_command_bar_set_property;
+
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/todo/ui/gtd-command-bar.ui");
+
+ gtk_widget_class_bind_template_child (widget_class, GtdCommandBar, entry);
+ gtk_widget_class_bind_template_child (widget_class, GtdCommandBar, revealer);
+
+ gtk_widget_class_bind_template_callback (widget_class, on_revealer_child_revealed_cb);
+
+ gtk_widget_class_set_css_name (widget_class, "commandbar");
+}
+
+static void
+gtd_command_bar_init (GtdCommandBar *self)
+{
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
+
+void
+gtd_command_bar_reveal (GtdCommandBar *self)
+{
+ g_return_if_fail (GTD_IS_COMMAND_BAR (self));
+
+ if (!gtk_widget_get_visible (GTK_WIDGET (self)))
+ {
+ gtk_revealer_set_reveal_child (self->revealer, FALSE);
+ gtk_widget_show (GTK_WIDGET (self));
+ }
+
+ gtk_revealer_set_reveal_child (self->revealer, TRUE);
+ gtk_widget_grab_focus (GTK_WIDGET (self->entry));
+}
+
+void
+gtd_command_bar_dismiss (GtdCommandBar *self)
+{
+ g_return_if_fail (GTD_IS_COMMAND_BAR (self));
+
+ gtk_revealer_set_reveal_child (self->revealer, FALSE);
+ gtk_entry_buffer_set_text (gtk_entry_get_buffer (self->entry), "", 0);
+}
diff --git a/src/gui/gtd-command-bar.h b/src/gui/gtd-command-bar.h
new file mode 100644
index 0000000..9fc2135
--- /dev/null
+++ b/src/gui/gtd-command-bar.h
@@ -0,0 +1,34 @@
+/* gtd-command-bar.h
+ *
+ * Copyright 2020 Georges Basile Stavracas Neto <georges stavracas gmail com>
+ *
+ * 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 "gnome-todo.h"
+
+G_BEGIN_DECLS
+
+#define GTD_TYPE_COMMAND_BAR (gtd_command_bar_get_type())
+G_DECLARE_FINAL_TYPE (GtdCommandBar, gtd_command_bar, GTD, COMMAND_BAR, GtdWidget)
+
+void gtd_command_bar_reveal (GtdCommandBar *self);
+
+void gtd_command_bar_dismiss (GtdCommandBar *self);
+
+G_END_DECLS
diff --git a/src/gui/gtd-command-bar.ui b/src/gui/gtd-command-bar.ui
new file mode 100644
index 0000000..390abd9
--- /dev/null
+++ b/src/gui/gtd-command-bar.ui
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="GtdCommandBar" parent="GtdWidget">
+ <property name="can_focus">1</property>
+ <property name="margin-top">12</property>
+
+ <property name="layout-manager">
+ <object class="GtdMaxSizeLayout">
+ <property name="width-chars">20</property>
+ <property name="max-width-chars">40</property>
+ </object>
+ </property>
+
+ <child>
+ <object class="GtkRevealer" id="revealer">
+ <property name="reveal-child">false</property>
+ <property name="transition-type">crossfade</property>
+ <property name="visible">true</property>
+ <signal name="notify::child-revealed" handler="on_revealer_child_revealed_cb" object="GtdCommandBar"
swapped="no" />
+ <child>
+ <object class="GtkOverlay">
+ <property name="visible">true</property>
+ <child>
+ <object class="GtkEntry" id="entry">
+ <property name="visible">true</property>
+ </object>
+ </child>
+ <child type="overlay">
+ <object class="GtkButton">
+ <property name="visible">true</property>
+ <property name="halign">end</property>
+ <property name="valign">start</property>
+ <style>
+ <class name="circular"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">window-close-symbolic</property>
+ <property name="pixel-size">20</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/themes/Adwaita-commandbar.css b/src/themes/Adwaita-commandbar.css
new file mode 100644
index 0000000..5f4a6fd
--- /dev/null
+++ b/src/themes/Adwaita-commandbar.css
@@ -0,0 +1,27 @@
+commandbar {
+ padding: 10px;
+}
+
+commandbar entry {
+ margin: 10px;
+ box-shadow: 0 0 5px @wm_shadow;
+}
+
+commandbar entry text {
+ border-width: 3px;
+}
+
+commandbar button.circular {
+ background: @theme_selected_bg_color;
+ color: @theme_selected_fg_color;
+ box-shadow: 0 3px 5px mix(@wm_shadow, @theme_selected_bg_color, 0.2);
+ padding: 0px;
+ margin: 0px;
+ min-width: 26px;
+ min-height: 26px;
+ border: 0;
+}
+
+commandbar button.circular:hover {
+ background: mix(@theme_selected_bg_color, @theme_selected_fg_color, 0.1);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]