[gnome-builder] about: stub out an about dialog window.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] about: stub out an about dialog window.
- Date: Sun, 14 Sep 2014 21:23:51 +0000 (UTC)
commit d1379b4002edee5ba8038c0cefbc11751e768789
Author: Christian Hergert <christian hergert me>
Date: Sun Sep 14 14:23:46 2014 -0700
about: stub out an about dialog window.
Lot's of fun stuff we can do here longer term. Just want to stub
something in right now though.
src/about/gb-about-window.c | 79 +++++++++++++++++++++++++++++
src/about/gb-about-window.h | 56 ++++++++++++++++++++
src/app/gb-application.c | 17 ++++++
src/gnome-builder.mk | 3 +
src/resources/gnome-builder.gresource.xml | 1 +
src/resources/ui/gb-about-window.ui | 22 ++++++++
6 files changed, 178 insertions(+), 0 deletions(-)
---
diff --git a/src/about/gb-about-window.c b/src/about/gb-about-window.c
new file mode 100644
index 0000000..0f31134
--- /dev/null
+++ b/src/about/gb-about-window.c
@@ -0,0 +1,79 @@
+/* gb-about-window.c
+ *
+ * Copyright (C) 2014 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/>.
+ */
+
+#include <glib/gi18n.h>
+
+#include "gb-about-window.h"
+
+G_DEFINE_TYPE (GbAboutWindow, gb_about_window, GTK_TYPE_WINDOW)
+
+static gboolean
+gb_about_window_draw (GtkWidget *widget,
+ cairo_t *cr)
+{
+ GtkAllocation alloc;
+
+ g_return_val_if_fail (GB_IS_ABOUT_WINDOW (widget), FALSE);
+ g_return_val_if_fail (cr, FALSE);
+
+ gtk_widget_get_allocation (widget, &alloc);
+
+ cairo_save (cr);
+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+ cairo_set_source_rgba (cr, 1, 1, 1, 0);
+ gdk_cairo_rectangle (cr, &alloc);
+ cairo_paint (cr);
+ cairo_restore (cr);
+
+ GTK_WIDGET_CLASS (gb_about_window_parent_class)->draw (widget, cr);
+
+ return GDK_EVENT_PROPAGATE;
+}
+
+static void
+gb_about_window_constructed (GObject *object)
+{
+ GdkVisual *visual;
+
+ G_OBJECT_CLASS (gb_about_window_parent_class)->constructed (object);
+
+ visual = gdk_screen_get_rgba_visual (gdk_screen_get_default ());
+ gtk_widget_set_visual (GTK_WIDGET (object), visual);
+}
+
+static void
+gb_about_window_class_init (GbAboutWindowClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->constructed = gb_about_window_constructed;
+
+ widget_class->draw = gb_about_window_draw;
+
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/builder/ui/gb-about-window.ui");
+}
+
+static void
+gb_about_window_init (GbAboutWindow *window)
+{
+ window->priv = gb_about_window_get_instance_private (window);
+
+ gtk_widget_init_template (GTK_WIDGET (window));
+}
diff --git a/src/about/gb-about-window.h b/src/about/gb-about-window.h
new file mode 100644
index 0000000..0b64c00
--- /dev/null
+++ b/src/about/gb-about-window.h
@@ -0,0 +1,56 @@
+/* gb-about-window.h
+ *
+ * Copyright (C) 2014 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_ABOUT_WINDOW_H
+#define GB_ABOUT_WINDOW_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_ABOUT_WINDOW (gb_about_window_get_type())
+#define GB_ABOUT_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GB_TYPE_ABOUT_WINDOW,
GbAboutWindow))
+#define GB_ABOUT_WINDOW_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GB_TYPE_ABOUT_WINDOW,
GbAboutWindow const))
+#define GB_ABOUT_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GB_TYPE_ABOUT_WINDOW,
GbAboutWindowClass))
+#define GB_IS_ABOUT_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GB_TYPE_ABOUT_WINDOW))
+#define GB_IS_ABOUT_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GB_TYPE_ABOUT_WINDOW))
+#define GB_ABOUT_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GB_TYPE_ABOUT_WINDOW,
GbAboutWindowClass))
+
+typedef struct _GbAboutWindow GbAboutWindow;
+typedef struct _GbAboutWindowClass GbAboutWindowClass;
+typedef struct _GbAboutWindowPrivate GbAboutWindowPrivate;
+
+struct _GbAboutWindow
+{
+ GtkWindow parent;
+
+ /*< private >*/
+ GbAboutWindowPrivate *priv;
+};
+
+struct _GbAboutWindowClass
+{
+ GtkWindowClass parent_class;
+};
+
+GType gb_about_window_get_type (void) G_GNUC_CONST;
+GtkWidget *gb_about_window_new (void);
+
+G_END_DECLS
+
+#endif /* GB_ABOUT_WINDOW_H */
diff --git a/src/app/gb-application.c b/src/app/gb-application.c
index 23a71ea..5fb8b91 100644
--- a/src/app/gb-application.c
+++ b/src/app/gb-application.c
@@ -21,6 +21,7 @@
#include <glib/gi18n.h>
+#include "gb-about-window.h"
#include "gb-application.h"
#include "gb-log.h"
#include "gb-keybindings.h"
@@ -199,10 +200,26 @@ on_quit_activate (GSimpleAction *action,
}
static void
+on_about_activate (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GtkWindow *window;
+
+ window = g_object_new (GB_TYPE_ABOUT_WINDOW,
+ "title", _("About Builder"),
+ "window-position", GTK_WIN_POS_CENTER,
+ NULL);
+
+ gtk_window_present (window);
+}
+
+static void
gb_application_constructed (GObject *object)
{
static const GActionEntry action_entries[] = {
{ "quit", on_quit_activate },
+ { "about", on_about_activate },
};
static const gchar *quit_accels[] = { "<Control>q", NULL };
diff --git a/src/gnome-builder.mk b/src/gnome-builder.mk
index 332d6b7..c45c726 100644
--- a/src/gnome-builder.mk
+++ b/src/gnome-builder.mk
@@ -6,6 +6,8 @@ BUILT_FILES = \
gnome_builder_SOURCES = \
$(BUILT_FILES) \
+ src/about/gb-about-window.c \
+ src/about/gb-about-window.h \
src/animation/gb-animation.c \
src/animation/gb-animation.h \
src/animation/gb-frame-source.c \
@@ -114,6 +116,7 @@ gnome_builder_CFLAGS = \
$(GTK_CFLAGS) \
$(MAINTAINER_CFLAGS) \
$(WEBKIT_CFLAGS) \
+ -I$(top_srcdir)/src/about \
-I$(top_srcdir)/src/animation \
-I$(top_srcdir)/src/app \
-I$(top_srcdir)/src/devhelp \
diff --git a/src/resources/gnome-builder.gresource.xml b/src/resources/gnome-builder.gresource.xml
index 71cf7e7..da72954 100644
--- a/src/resources/gnome-builder.gresource.xml
+++ b/src/resources/gnome-builder.gresource.xml
@@ -13,6 +13,7 @@
<file>snippets/c.snippets</file>
<file>snippets/chdr.snippets</file>
+ <file>ui/gb-about-window.ui</file>
<file>ui/gb-devhelp-tab.ui</file>
<file>ui/gb-editor-tab.ui</file>
<file>ui/gb-tab-label.ui</file>
diff --git a/src/resources/ui/gb-about-window.ui b/src/resources/ui/gb-about-window.ui
new file mode 100644
index 0000000..7e36469
--- /dev/null
+++ b/src/resources/ui/gb-about-window.ui
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.8 -->
+ <template class="GbAboutWindow" parent="GtkWindow">
+ <property name="icon-name">builder</property>
+ <property name="decorated">False</property>
+ <property name="app_paintable">True</property>
+ <child>
+ <object class="GtkBox" id="box">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkImage" id="image">
+ <property name="visible">True</property>
+ <property name="icon-name">builder</property>
+ <property name="pixel-size">512</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]