[gnome-software] Add first run dialog



commit 2bff0633449d0536f2e603306efb2fa2660727de
Author: Kalev Lember <kalevlember gmail com>
Date:   Sat Jul 5 22:31:37 2014 +0200

    Add first run dialog
    
    https://bugzilla.gnome.org/show_bug.cgi?id=731973

 data/org.gnome.software.gschema.xml |    4 +
 po/POTFILES.in                      |    1 +
 src/Makefile.am                     |    3 +
 src/gnome-software.gresource.xml    |    1 +
 src/gs-application.c                |   16 +++++
 src/gs-first-run-dialog.c           |   74 ++++++++++++++++++++++++
 src/gs-first-run-dialog.h           |   55 ++++++++++++++++++
 src/gs-first-run-dialog.ui          |  106 +++++++++++++++++++++++++++++++++++
 8 files changed, 260 insertions(+), 0 deletions(-)
---
diff --git a/data/org.gnome.software.gschema.xml b/data/org.gnome.software.gschema.xml
index d819ed1..bfd9fb4 100644
--- a/data/org.gnome.software.gschema.xml
+++ b/data/org.gnome.software.gschema.xml
@@ -10,6 +10,10 @@
       <summary>Whether to automatically download updates</summary>
       <description>If enabled, gnome-software automatically downloads updates in the background and prompts 
the user to install them when ready.</description>
     </key>
+    <key name="first-run" type="b">
+      <default>true</default>
+      <summary>Whether it's the very first run of gnome-software</summary>
+    </key>
     <key name="require-appdata" type="b">
       <default>false</default>
       <summary>Applications require AppData to be shown in the search results</summary>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 3d3e737..1719d7d 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -11,6 +11,7 @@ src/gs-app-addon-row.c
 src/gs-app-row.c
 src/gs-app-tile.c
 src/gs-category.c
+[type: gettext/glade]src/gs-first-run-dialog.ui
 src/gs-feature-tile.c
 src/gs-history-dialog.c
 [type: gettext/glade]src/gs-history-dialog.ui
diff --git a/src/Makefile.am b/src/Makefile.am
index 3f263ad..1ea0b65 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -34,6 +34,7 @@ UI_FILES =                                            \
        gnome-software.ui                               \
        gs-app-addon-row.ui                             \
        gs-app-row.ui                                   \
+       gs-first-run-dialog.ui                          \
        gs-history-dialog.ui                            \
        gs-shell-category.ui                            \
        gs-shell-details.ui                             \
@@ -113,6 +114,8 @@ gnome_software_SOURCES =                            \
        gs-app-tile.h                                   \
        gs-app-folder-dialog.c                          \
        gs-app-folder-dialog.h                          \
+       gs-first-run-dialog.c                           \
+       gs-first-run-dialog.h                           \
        gs-history-dialog.c                             \
        gs-history-dialog.h                             \
        gs-box.h                                        \
diff --git a/src/gnome-software.gresource.xml b/src/gnome-software.gresource.xml
index 92a1866..af4c3cd 100644
--- a/src/gnome-software.gresource.xml
+++ b/src/gnome-software.gresource.xml
@@ -11,6 +11,7 @@
   <file preprocess="xml-stripblanks">screenshot-image.ui</file>
   <file preprocess="xml-stripblanks">gs-app-addon-row.ui</file>
   <file preprocess="xml-stripblanks">gs-app-row.ui</file>
+  <file preprocess="xml-stripblanks">gs-first-run-dialog.ui</file>
   <file preprocess="xml-stripblanks">gs-history-dialog.ui</file>
   <file preprocess="xml-stripblanks">gs-shell-category.ui</file>
   <file preprocess="xml-stripblanks">gs-shell-details.ui</file>
diff --git a/src/gs-application.c b/src/gs-application.c
index 888bb14..26dd5c9 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -31,6 +31,7 @@
 
 #include "gs-dbus-helper.h"
 #include "gs-box.h"
+#include "gs-first-run-dialog.h"
 #include "gs-shell.h"
 #include "gs-update-monitor.h"
 #include "gs-proxy-settings.h"
@@ -165,6 +166,20 @@ gs_application_provide_search (GsApplication *app)
 }
 
 static void
+gs_application_show_first_run_dialog (GsApplication *app)
+{
+       GtkWidget *dialog;
+
+       if (g_settings_get_boolean (app->settings, "first-run") == TRUE) {
+               dialog = gs_first_run_dialog_new ();
+               gtk_window_set_transient_for (GTK_WINDOW (dialog), gs_shell_get_window (app->shell));
+               gtk_window_present (GTK_WINDOW (dialog));
+
+               g_settings_set_boolean (app->settings, "first-run", FALSE);
+       }
+}
+
+static void
 gs_application_initialize_ui (GsApplication *app)
 {
        static gboolean initialized = FALSE;
@@ -477,6 +492,7 @@ gs_application_activate (GApplication *application)
        gs_application_initialize_ui (GS_APPLICATION (application));
        gs_shell_set_mode (GS_APPLICATION (application)->shell, GS_SHELL_MODE_OVERVIEW);
        gs_shell_activate (GS_APPLICATION (application)->shell);
+       gs_application_show_first_run_dialog (GS_APPLICATION (application));
 }
 
 static void
diff --git a/src/gs-first-run-dialog.c b/src/gs-first-run-dialog.c
new file mode 100644
index 0000000..84a9ae1
--- /dev/null
+++ b/src/gs-first-run-dialog.c
@@ -0,0 +1,74 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2014 Kalev Lember <kalevlember gmail com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+
+#include "gs-first-run-dialog.h"
+
+struct _GsFirstRunDialogPrivate
+{
+       GtkWidget       *button;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GsFirstRunDialog, gs_first_run_dialog, GTK_TYPE_DIALOG)
+
+static void
+button_clicked_cb (GtkWidget *widget, GsFirstRunDialog *dialog)
+{
+       gtk_window_close (GTK_WINDOW (dialog));
+}
+
+static void
+gs_first_run_dialog_init (GsFirstRunDialog *dialog)
+{
+       GsFirstRunDialogPrivate *priv = gs_first_run_dialog_get_instance_private (dialog);
+       GtkWidget *button_label;
+
+       gtk_widget_init_template (GTK_WIDGET (dialog));
+
+       button_label = gtk_bin_get_child (GTK_BIN (priv->button));
+       gtk_widget_set_margin_start (button_label, 16);
+       gtk_widget_set_margin_end (button_label, 16);
+
+       g_signal_connect (priv->button, "clicked", G_CALLBACK (button_clicked_cb), dialog);
+}
+
+static void
+gs_first_run_dialog_class_init (GsFirstRunDialogClass *klass)
+{
+       GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+       gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/software/gs-first-run-dialog.ui");
+
+       gtk_widget_class_bind_template_child_private (widget_class, GsFirstRunDialog, button);
+}
+
+GtkWidget *
+gs_first_run_dialog_new (void)
+{
+       return GTK_WIDGET (g_object_new (GS_TYPE_FIRST_RUN_DIALOG,
+                                        "use-header-bar", TRUE,
+                                        NULL));
+}
+
+/* vim: set noexpandtab: */
diff --git a/src/gs-first-run-dialog.h b/src/gs-first-run-dialog.h
new file mode 100644
index 0000000..6982bd7
--- /dev/null
+++ b/src/gs-first-run-dialog.h
@@ -0,0 +1,55 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2014 Kalev Lember <kalevlember gmail com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef GS_FIRST_RUN_DIALOG_H
+#define GS_FIRST_RUN_DIALOG_H
+
+#include <gtk/gtk.h>
+
+#define GS_TYPE_FIRST_RUN_DIALOG               (gs_first_run_dialog_get_type())
+#define GS_FIRST_RUN_DIALOG(obj)               (G_TYPE_CHECK_INSTANCE_CAST((obj), GS_TYPE_FIRST_RUN_DIALOG, 
GsFirstRunDialog))
+#define GS_FIRST_RUN_DIALOG_CLASS(cls)         (G_TYPE_CHECK_CLASS_CAST((cls), GS_TYPE_FIRST_RUN_DIALOG, 
GsFirstRunDialogClass))
+#define GS_IS_FIRST_RUN_DIALOG(obj)            (G_TYPE_CHECK_INSTANCE_TYPE((obj), GS_TYPE_FIRST_RUN_DIALOG))
+#define GS_IS_FIRST_RUN_DIALOG_CLASS(cls)      (G_TYPE_CHECK_CLASS_TYPE((cls), GS_TYPE_FIRST_RUN_DIALOG))
+#define GS_FIRST_RUN_DIALOG_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS((obj), GS_TYPE_FIRST_RUN_DIALOG, 
GsFirstRunDialogClass))
+
+G_BEGIN_DECLS
+
+typedef struct _GsFirstRunDialog               GsFirstRunDialog;
+typedef struct _GsFirstRunDialogClass          GsFirstRunDialogClass;
+typedef struct _GsFirstRunDialogPrivate                GsFirstRunDialogPrivate;
+
+struct _GsFirstRunDialog
+{
+       GtkDialog        parent;
+};
+
+struct _GsFirstRunDialogClass
+{
+       GtkDialogClass   parent_class;
+};
+
+GType           gs_first_run_dialog_get_type   (void);
+GtkWidget      *gs_first_run_dialog_new                (void);
+
+#endif /* GS_FIRST_RUN_DIALOG_H */
+
+/* vim: set noexpandtab: */
diff --git a/src/gs-first-run-dialog.ui b/src/gs-first-run-dialog.ui
new file mode 100644
index 0000000..391ed7a
--- /dev/null
+++ b/src/gs-first-run-dialog.ui
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.1 -->
+<interface>
+  <requires lib="gtk+" version="3.12"/>
+  <template class="GsFirstRunDialog" parent="GtkDialog">
+    <property name="can_focus">False</property>
+    <property name="title" translatable="yes">Welcome</property>
+    <property name="modal">True</property>
+    <property name="destroy_with_parent">True</property>
+    <property name="type_hint">dialog</property>
+    <property name="skip_taskbar_hint">True</property>
+    <property name="use_header_bar">1</property>
+    <child internal-child="headerbar">
+      <object class="GtkHeaderBar">
+        <property name="title" translatable="yes">Welcome</property>
+        <property name="show_close_button">False</property>
+      </object>
+    </child>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="dialog-vbox1">
+        <property name="can_focus">False</property>
+        <property name="margin_start">55</property>
+        <property name="margin_end">55</property>
+        <property name="margin_top">44</property>
+        <property name="orientation">vertical</property>
+        <child>
+          <object class="GtkBox" id="box_empty">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">16</property>
+            <child>
+              <object class="GtkImage" id="image1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="pixel_size">128</property>
+                <property name="icon_name">gnome-software</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Welcome to Software</property>
+                <attributes>
+                  <attribute name="weight" value="bold"/>
+                  <attribute name="scale" value="1.7"/>
+                </attributes>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label2">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Software lets you install all the software you 
need, all from one place. See our recommendations, browse the categories, or search for the applications you 
want.</property>
+                <property name="wrap">True</property>
+                <property name="max_width_chars">48</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="button">
+            <property name="label" translatable="yes">_Let's Get Started</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="halign">center</property>
+            <property name="valign">center</property>
+            <property name="margin_top">2</property>
+            <property name="margin_bottom">5</property>
+            <property name="use_underline">True</property>
+            <style>
+              <class name="suggested-action"/>
+            </style>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>


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