summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2012-04-30 19:24:14 +0100
committerBastien Nocera <hadess@hadess.net>2012-04-30 19:24:14 +0100
commite843cd612783b718879113fb74febddf007b54cd (patch)
treec218c3ed238fe82c4e2a6194f22af8ab4efc9a25
parent62b99f7d8f92dc0a30b0c68b7cb0f07778cd1a20 (diff)
downloadgnome-control-center-e843cd612783b718879113fb74febddf007b54cd.tar.gz
shell: Add animated notebook
Powered by gtk-clutter.
-rw-r--r--configure.ac2
-rw-r--r--shell/Makefile.am2
-rw-r--r--shell/cc-notebook.c197
-rw-r--r--shell/cc-notebook.h64
4 files changed, 264 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 7560be134..95cfb48bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -91,7 +91,7 @@ COMMON_MODULES="gtk+-3.0 >= $GTK_REQUIRED_VERSION
PKG_CHECK_MODULES(LIBGNOME_CONTROL_CENTER, $COMMON_MODULES)
PKG_CHECK_MODULES(LIBLANGUAGE, $COMMON_MODULES gnome-desktop-3.0 fontconfig)
PKG_CHECK_MODULES(LIBSHORTCUTS, $COMMON_MODULES x11)
-PKG_CHECK_MODULES(SHELL, $COMMON_MODULES libgnome-menu-3.0 gio-unix-2.0 x11)
+PKG_CHECK_MODULES(SHELL, $COMMON_MODULES libgnome-menu-3.0 gio-unix-2.0 x11 clutter-gtk-1.0)
PKG_CHECK_MODULES(BACKGROUND_PANEL, $COMMON_MODULES libxml-2.0 gnome-desktop-3.0
gdk-pixbuf-2.0 >= $GDKPIXBUF_REQUIRED_VERSION)
PKG_CHECK_MODULES(DATETIME_PANEL, $COMMON_MODULES
diff --git a/shell/Makefile.am b/shell/Makefile.am
index 58117f8e4..b785b7e2f 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -19,6 +19,8 @@ gnome_control_center_SOURCES = \
cc-shell-log.h \
gnome-control-center.c \
gnome-control-center.h \
+ cc-notebook.c \
+ cc-notebook.h \
shell-search-renderer.c \
shell-search-renderer.h \
cc-shell-category-view.c \
diff --git a/shell/cc-notebook.c b/shell/cc-notebook.c
new file mode 100644
index 000000000..d8c95c92a
--- /dev/null
+++ b/shell/cc-notebook.c
@@ -0,0 +1,197 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright © 2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Written by:
+ * Bastien Nocera <hadess@hadess.net>
+ */
+
+#include "config.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#include "cc-notebook.h"
+
+#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CC_TYPE_NOTEBOOK, CcNotebookPrivate))
+
+struct _CcNotebookPrivate
+{
+ ClutterActor *stage;
+ ClutterActor *scroll_actor;
+ ClutterActor *bin;
+ GList *children; /* GList of ClutterActor */
+};
+
+G_DEFINE_TYPE (CcNotebook, cc_notebook, GTK_CLUTTER_TYPE_EMBED);
+
+static void
+cc_notebook_add (GtkContainer *container,
+ GtkWidget *widget)
+{
+ CcNotebook *notebook;
+ ClutterActor *child;
+
+ notebook = CC_NOTEBOOK (container);
+ child = gtk_clutter_actor_new_with_contents (widget);
+ clutter_actor_add_child (notebook->priv->bin, child);
+
+ notebook->priv->children = g_list_prepend (notebook->priv->children,
+ child);
+}
+
+static int
+_cc_notebook_find_widget (GtkClutterActor *actor,
+ GtkWidget *widget)
+{
+ if (gtk_clutter_actor_get_contents (actor) == widget)
+ return 0;
+ return -1;
+}
+
+static void
+cc_notebook_remove (GtkContainer *container,
+ GtkWidget *widget)
+{
+ CcNotebook *notebook;
+ GList *l;
+
+ notebook = CC_NOTEBOOK (container);
+
+ l = g_list_find_custom (notebook->priv->children,
+ widget,
+ (GCompareFunc) _cc_notebook_find_widget);
+ if (!l)
+ return;
+ clutter_actor_remove_child (notebook->priv->bin, l->data);
+ notebook->priv->children = g_list_remove (notebook->priv->children, l->data);
+}
+
+static GType
+cc_notebook_child_type (GtkContainer *container)
+{
+ return GTK_TYPE_WIDGET;
+}
+
+static void
+cc_notebook_forall (GtkContainer *container,
+ gboolean include_internals,
+ GtkCallback callback,
+ gpointer callback_data)
+{
+#if 0
+ CcNotebook *notebook;
+ GList *children;
+ ClutterActor *child;
+
+ notebook = CC_NOTEBOOK (container);
+
+ children = notebook->priv->children;
+ while (children) {
+ child = children->data;
+ children = children->next;
+
+ (* callback) (gtk_clutter_actor_get_contents (GTK_CLUTTER_ACTOR (child)), callback_data);
+ }
+#endif
+}
+
+static void
+cc_notebook_class_init (CcNotebookClass *class)
+{
+ GObjectClass *gobject_class;
+ GtkWidgetClass *widget_class;
+ GtkContainerClass *container_class;
+
+ gobject_class = (GObjectClass*)class;
+ widget_class = (GtkWidgetClass*)class;
+ container_class = (GtkContainerClass*)class;
+
+ container_class->add = cc_notebook_add;
+ container_class->remove = cc_notebook_remove;
+ container_class->child_type = cc_notebook_child_type;
+ container_class->forall = cc_notebook_forall;
+
+ g_type_class_add_private (class, sizeof (CcNotebookPrivate));
+}
+
+static void
+cc_notebook_init (CcNotebook *notebook)
+{
+ CcNotebookPrivate *priv;
+ ClutterConstraint *constraint;
+
+ priv = GET_PRIVATE (notebook);
+ notebook->priv = priv;
+
+ priv->stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (notebook));
+
+ priv->scroll_actor = clutter_scroll_actor_new ();
+ clutter_actor_add_child (priv->stage, priv->scroll_actor);
+ clutter_scroll_actor_set_scroll_mode (CLUTTER_SCROLL_ACTOR (priv->scroll_actor),
+ CLUTTER_SCROLL_HORIZONTALLY);
+// constraint = clutter_bind_constraint_new (priv->stage, CLUTTER_BIND_SIZE, 0.0);
+// clutter_actor_add_constraint_with_name (priv->scroll_actor, "size", constraint);
+
+ priv->bin = clutter_actor_new ();
+ clutter_actor_set_layout_manager (priv->bin, clutter_box_layout_new ());
+ clutter_actor_add_child (priv->scroll_actor, priv->bin);
+// constraint = clutter_bind_constraint_new (priv->scroll_actor, CLUTTER_BIND_SIZE, 0.0);
+// clutter_actor_add_constraint_with_name (priv->bin, "size", constraint);
+}
+
+GtkWidget *
+cc_notebook_new (void)
+{
+ return (GtkWidget*) g_object_new (CC_TYPE_NOTEBOOK, NULL);
+}
+
+void
+cc_notebook_set_current (CcNotebook *notebook,
+ GtkWidget *widget)
+{
+ ClutterPoint pos;
+ GList *l;
+
+ g_return_if_fail (CC_IS_NOTEBOOK (notebook));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ l = g_list_find_custom (notebook->priv->children,
+ widget,
+ (GCompareFunc) _cc_notebook_find_widget);
+ g_return_if_fail (l != NULL);
+
+ g_message ("setting %p as the current widget", l->data);
+
+ clutter_actor_get_position (l->data, &pos.x, &pos.y);
+
+ clutter_actor_save_easing_state (notebook->priv->scroll_actor);
+ clutter_actor_set_easing_duration (notebook->priv->scroll_actor, 500);
+ clutter_actor_set_easing_mode (notebook->priv->scroll_actor, CLUTTER_EASE_OUT_BOUNCE);
+
+ clutter_scroll_actor_scroll_to_point (CLUTTER_SCROLL_ACTOR (notebook->priv->scroll_actor), &pos);
+
+ clutter_actor_restore_easing_state (notebook->priv->scroll_actor);
+}
+
+GtkWidget *
+cc_notebook_get_current (CcNotebook *notebook)
+{
+ g_return_val_if_fail (CC_IS_NOTEBOOK (notebook), NULL);
+
+ return NULL;
+}
diff --git a/shell/cc-notebook.h b/shell/cc-notebook.h
new file mode 100644
index 000000000..3245e7ad4
--- /dev/null
+++ b/shell/cc-notebook.h
@@ -0,0 +1,64 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright © 2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Written by:
+ * Bastien Nocera <hadess@hadess.net>
+ */
+
+#ifndef _CC_NOTEBOOK_H_
+#define _CC_NOTEBOOK_H_
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+#include <clutter-gtk/clutter-gtk.h>
+
+G_BEGIN_DECLS
+
+#define CC_TYPE_NOTEBOOK (cc_notebook_get_type ())
+#define CC_NOTEBOOK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CC_TYPE_NOTEBOOK, \
+ CcNotebook))
+#define CC_NOTEBOOK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CC_TYPE_NOTEBOOK, \
+ CcNotebookClass))
+#define CC_IS_NOTEBOOK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CC_TYPE_NOTEBOOK))
+#define CC_IS_NOTEBOOK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CC_TYPE_NOTEBOOK))
+#define CC_NOTEBOOK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CC_TYPE_NOTEBOOK, \
+ CcNotebookClass))
+
+typedef struct _CcNotebookClass CcNotebookClass;
+typedef struct _CcNotebook CcNotebook;
+typedef struct _CcNotebookPrivate CcNotebookPrivate;
+
+struct _CcNotebookClass {
+ GtkClutterEmbedClass parent_class;
+};
+
+struct _CcNotebook {
+ GtkClutterEmbed parent_instance;
+ CcNotebookPrivate *priv;
+};
+
+GType cc_notebook_get_type (void) G_GNUC_CONST;
+
+GtkWidget *cc_notebook_new (void);
+
+void cc_notebook_set_current (CcNotebook *notebook,
+ GtkWidget *widget);
+GtkWidget *cc_notebook_get_current (CcNotebook *notebook);
+
+G_END_DECLS
+
+#endif /* _CC_NOTEBOOK_H_ */