[gitg] Add simple notification
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Add simple notification
- Date: Thu, 13 Aug 2015 06:19:57 +0000 (UTC)
commit 5e88377b0be22f8870d08797ed74df0b4a16f626
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Thu Aug 13 08:08:54 2015 +0200
Add simple notification
gitg/Makefile.am | 1 +
gitg/gitg-simple-notification.vala | 144 +++++++++++++++++++++++++
gitg/resources/gitg-resources.xml | 1 +
gitg/resources/ui/gitg-simple-notification.ui | 69 ++++++++++++
4 files changed, 215 insertions(+), 0 deletions(-)
---
diff --git a/gitg/Makefile.am b/gitg/Makefile.am
index 100a4ec..4be7d14 100644
--- a/gitg/Makefile.am
+++ b/gitg/Makefile.am
@@ -79,6 +79,7 @@ gitg_gitg_VALASOURCES = \
gitg/gitg-remote-manager.vala \
gitg/gitg-remote-notification.vala \
gitg/gitg-resource.vala \
+ gitg/gitg-simple-notification.vala \
gitg/gitg-ui-elements.vala \
gitg/gitg-window.vala \
gitg/gitg.vala \
diff --git a/gitg/gitg-simple-notification.vala b/gitg/gitg-simple-notification.vala
new file mode 100644
index 0000000..7c68107
--- /dev/null
+++ b/gitg/gitg-simple-notification.vala
@@ -0,0 +1,144 @@
+/*
+ * This file is part of gitg
+ *
+ * Copyright (C) 2012 - Ignacio Casal Quinteiro
+ *
+ * gitg 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * gitg 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 gitg. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Gitg
+{
+
+[GtkTemplate (ui = "/org/gnome/gitg/ui/gitg-simple-notification.ui")]
+public class SimpleNotification : Gtk.Grid, GitgExt.Notification
+{
+ // Do this to pull in config.h before glib.h (for gettext...)
+ private const string version = Gitg.Config.VERSION;
+
+ [GtkChild( name = "spinner" )]
+ private Gtk.Spinner d_spinner;
+
+ [GtkChild( name = "image_icon" )]
+ private Gtk.Image d_image_icon;
+
+ [GtkChild( name = "label_title" )]
+ private Gtk.Label d_label_title;
+
+ [GtkChild( name = "label_message" )]
+ private Gtk.Label d_label_message;
+
+ [GtkChild( name = "button_cancel" )]
+ private Gtk.Button d_button_cancel;
+
+ private bool d_finished;
+
+ public signal void cancel();
+
+ public SimpleNotification(string? title = null, string? message = null)
+ {
+ Object(title: title, message: message);
+ d_spinner.start();
+ }
+
+ public Gtk.Widget? widget
+ {
+ owned get { return this; }
+ }
+
+ public void success(string message)
+ {
+ Idle.add(() => {
+ d_spinner.stop();
+ d_spinner.hide();
+
+ d_image_icon.icon_name = "emblem-ok-symbolic";
+ d_image_icon.show();
+
+ this.message = message;
+
+ get_style_context().add_class("success");
+ finish();
+
+ return false;
+ });
+ }
+
+ public void error(string message)
+ {
+ Idle.add(() => {
+ d_spinner.stop();
+ d_spinner.hide();
+
+ d_image_icon.icon_name = "dialog-error-symbolic";
+ d_image_icon.show();
+
+ this.message = message;
+
+ get_style_context().add_class("error");
+ finish();
+
+ return false;
+ });
+ }
+
+ private void finish()
+ {
+ Idle.add(() => {
+ d_finished = true;
+ d_button_cancel.label = _("Close");
+
+ close(3000);
+ return false;
+ });
+ }
+
+ public string title
+ {
+ set
+ {
+ Idle.add(() => {
+ d_label_title.label = value;
+ return false;
+ });
+ }
+ }
+
+ public string message
+ {
+ set
+ {
+ Idle.add(() => {
+ d_label_message.label = value;
+ return false;
+ });
+ }
+ }
+
+ [GtkCallback]
+ private void on_button_cancel_clicked()
+ {
+ if (d_finished)
+ {
+ close();
+ }
+ else
+ {
+ cancel();
+ }
+ }
+}
+
+}
+
+// ex:ts=4 noet
diff --git a/gitg/resources/gitg-resources.xml b/gitg/resources/gitg-resources.xml
index 515e65f..3b80541 100644
--- a/gitg/resources/gitg-resources.xml
+++ b/gitg/resources/gitg-resources.xml
@@ -21,6 +21,7 @@
<file compressed="true" preprocess="xml-stripblanks">ui/gitg-create-branch-dialog.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/gitg-create-tag-dialog.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/gitg-dash-view.ui</file>
+ <file compressed="true" preprocess="xml-stripblanks">ui/gitg-simple-notification.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/gitg-remote-notification.ui</file>
<file compressed="true">ui/style.css</file>
diff --git a/gitg/resources/ui/gitg-simple-notification.ui b/gitg/resources/ui/gitg-simple-notification.ui
new file mode 100644
index 0000000..44cfa70
--- /dev/null
+++ b/gitg/resources/ui/gitg-simple-notification.ui
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.3 -->
+ <!-- interface-requires gitg 0.0 -->
+ <template class="GitgSimpleNotification" parent="GtkGrid">
+ <property name="visible">True</property>
+ <property name="hexpand">True</property>
+ <property name="spacing">12</property>
+ <property name="border_width">12</property>
+ <child>
+ <object class="GtkSpinner" id="spinner">
+ <property name="visible">True</property>
+ <property name="valign">baseline</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="image_icon">
+ <property name="visible">False</property>
+ <property name="size">1</property>
+ <property name="valign">baseline</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_title">
+ <property name="visible">True</property>
+ <property name="hexpand">False</property>
+ <property name="halign">start</property>
+ <property name="xalign">0</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_message">
+ <property name="visible">True</property>
+ <property name="hexpand">True</property>
+ <property name="halign">start</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_cancel">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Cancel</property>
+ <property name="halign">end</property>
+ <property name="valign">baseline</property>
+
+ <signal name="clicked" handler="on_button_cancel_clicked"/>
+ </object>
+ <packing>
+ <property name="left_attach">4</property>
+ </packing>
+ </child>
+ </template>
+</interface>
+<!-- vi:ts=2:et -->
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]