aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-shortcut.c
diff options
context:
space:
mode:
authorArturo Espinosa <unammx@src.gnome.org>2000-01-17 16:58:29 +0800
committerArturo Espinosa <unammx@src.gnome.org>2000-01-17 16:58:29 +0800
commit173a42036986044bc7907033a299cc1c71aa72e7 (patch)
tree7eb91284a687ae4f0c4e8f1cf4b81dd56249da1d /shell/e-shortcut.c
parent3bdd857a4a69e83841c2fbae83d96101912ebf69 (diff)
downloadgsoc2013-evolution-173a42036986044bc7907033a299cc1c71aa72e7.tar.gz
gsoc2013-evolution-173a42036986044bc7907033a299cc1c71aa72e7.tar.zst
gsoc2013-evolution-173a42036986044bc7907033a299cc1c71aa72e7.zip
Shaping up; Model/view is still not fully setup, but coming, coming
svn path=/trunk/; revision=1580
Diffstat (limited to 'shell/e-shortcut.c')
-rw-r--r--shell/e-shortcut.c204
1 files changed, 204 insertions, 0 deletions
diff --git a/shell/e-shortcut.c b/shell/e-shortcut.c
new file mode 100644
index 0000000000..ec83bc3854
--- /dev/null
+++ b/shell/e-shortcut.c
@@ -0,0 +1,204 @@
+/*
+ * Shortcut.c: implements shortcuts and shortcut group models
+ *
+ * Author:
+ * Miguel de Icaza (miguel@kernel.org)
+ *
+ * (C) 2000 Helix Code, Inc.
+ *
+ */
+#include <config.h>
+#include <gtk/gtksignal.h>
+#include "e-util/e-util.h"
+#include "e-shortcut.h"
+
+#define SHORTCUT_PARENT_TYPE gtk_object_get_type ()
+#define SHORTCUT_GROUP_PARENT_TYPE gtk_object_get_type ()
+
+static GtkObjectClass *shortcut_parent_class;
+static GtkObjectClass *shortcut_group_parent_class;
+
+enum {
+ STRUCTURE_CHANGED,
+ LAST_SIGNAL
+};
+
+static unsigned int sg_signals [LAST_SIGNAL] = { 0, };
+
+static void
+es_destroy (GtkObject *object)
+{
+ EShortcut *ef = E_SHORTCUT (object);
+
+ gtk_object_unref (GTK_OBJECT (ef->efolder));
+
+ shortcut_parent_class->destroy (object);
+}
+
+static void
+e_shortcut_class_init (GtkObjectClass *object_class)
+{
+ object_class->destroy = es_destroy;
+ shortcut_parent_class = gtk_type_class (SHORTCUT_PARENT_TYPE);
+}
+
+static void
+esg_destroy (GtkObject *object)
+{
+ EShortcutGroup *efg = E_SHORTCUT_GROUP (object);
+ const int shortcut_count = efg->shortcuts->len;
+ int i;
+
+ g_free (efg->title);
+
+ for (i = 0; i < shortcut_count; i++){
+ EShortcut *es = g_array_index (efg->shortcuts, EShortcut *, i);
+
+ gtk_object_unref (GTK_OBJECT (es));
+ }
+
+ g_array_free (efg->shortcuts, TRUE);
+
+ shortcut_group_parent_class->destroy (object);
+}
+
+typedef void (*MyGtkSignal_NONE__INT_INT_INT) (GtkObject * object,
+ int arg1,
+ int arg2,
+ int arg3,
+ gpointer user_data);
+static void
+mygtk_marshal_NONE__INT_INT_INT (GtkObject * object,
+ GtkSignalFunc func,
+ gpointer func_data,
+ GtkArg * args)
+{
+ MyGtkSignal_NONE__INT_INT_INT rfunc;
+ rfunc = (MyGtkSignal_NONE__INT_INT_INT) func;
+
+ (*rfunc) (object,
+ GTK_VALUE_INT (args[0]),
+ GTK_VALUE_INT (args[1]),
+ GTK_VALUE_INT (args[2]),
+ func_data);
+}
+
+static void
+e_shortcut_group_class_init (GtkObjectClass *object_class)
+{
+ object_class->destroy = esg_destroy;
+ shortcut_parent_class = gtk_type_class (SHORTCUT_GROUP_PARENT_TYPE);
+
+ sg_signals [STRUCTURE_CHANGED] =
+ gtk_signal_new ("structure_changed",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (EShortcutGroupClass, structure_changed),
+ mygtk_marshal_NONE__INT_INT_INT,
+ GTK_TYPE_NONE,
+ 3,
+ GTK_TYPE_ENUM, GTK_TYPE_INT, GTK_TYPE_INT);
+ gtk_object_class_add_signals (
+ object_class, sg_signals, LAST_SIGNAL);
+
+}
+
+static void
+e_shortcut_group_init (GtkObject *object)
+{
+ EShortcutGroup *esg = E_SHORTCUT_GROUP (object);
+
+ esg->shortcuts = g_array_new (FALSE, FALSE, sizeof (EShortcut *));
+}
+
+E_MAKE_TYPE (e_shortcut, "EShortcut", EShortcut, e_shortcut_class_init, NULL, SHORTCUT_PARENT_TYPE);
+E_MAKE_TYPE (e_shortcut_group, "EShortcutGroup", EShortcutGroup, e_shortcut_group_class_init, e_shortcut_group_init, SHORTCUT_GROUP_PARENT_TYPE);
+
+EShortcut *
+e_shortcut_new (EFolder *efolder)
+{
+ EShortcut *shortcut = gtk_type_new (e_shortcut_get_type ());
+
+ shortcut->efolder = efolder;
+ gtk_object_ref (GTK_OBJECT (efolder));
+
+ return shortcut;
+}
+
+EShortcutGroup *
+e_shortcut_group_new (const char *title, gboolean small_icons)
+{
+ EShortcutGroup *shortcut_group = gtk_type_new (e_shortcut_group_get_type ());
+
+ shortcut_group->title = g_strdup (title);
+ shortcut_group->small_icons = small_icons;
+ return shortcut_group;
+}
+
+static void
+es_emit (EShortcutGroup *sg, EShortcutGroupChange change, int arg1, int arg2)
+{
+ gtk_signal_emit (GTK_OBJECT (sg), sg_signals [STRUCTURE_CHANGED], change, arg1, arg2);
+}
+
+void
+e_shortcut_group_append (EShortcutGroup *sg, EShortcut *shortcut)
+{
+ g_return_if_fail (sg != NULL);
+ g_return_if_fail (E_IS_SHORTCUT_GROUP (sg));
+ g_return_if_fail (shortcut != NULL);
+ g_return_if_fail (E_IS_SHORTCUT (shortcut));
+
+ gtk_object_ref (GTK_OBJECT (shortcut));
+ g_array_append_val (sg->shortcuts, shortcut);
+
+ es_emit (sg, E_SHORTCUT_GROUP_ITEM_ADDED, sg->shortcuts->len-1, 0);
+}
+
+void
+e_shortcut_group_remove (EShortcutGroup *sg, EShortcut *shortcut)
+{
+ g_return_if_fail (sg != NULL);
+ g_return_if_fail (E_IS_SHORTCUT_GROUP (sg));
+ g_return_if_fail (shortcut != NULL);
+ g_return_if_fail (E_IS_SHORTCUT (sg));
+
+ {
+ const int len = sg->shortcuts->len;
+ int i;
+
+ for (i = 0; i < len; i++){
+ EShortcut *es = g_array_index (sg->shortcuts, EShortcut *, i);
+
+ if (es == shortcut){
+ g_array_remove_index (sg->shortcuts, i);
+ es_emit (sg, E_SHORTCUT_GROUP_ITEM_REMOVED, i, 0);
+ return;
+ }
+ }
+ }
+}
+
+void
+e_shortcut_group_move (EShortcutGroup *sg, int from, int to)
+{
+ EShortcut *t;
+
+ g_return_if_fail (sg != NULL);
+ g_return_if_fail (E_IS_SHORTCUT_GROUP (sg));
+
+ g_return_if_fail (from < sg->shortcuts->len);
+ g_return_if_fail (to < sg->shortcuts->len);
+ g_return_if_fail (from >= 0);
+ g_return_if_fail (to >= 0);
+
+ if (from == to)
+ return;
+
+ t = g_array_index (sg->shortcuts, EShortcut *, from);
+ g_array_index (sg->shortcuts, EShortcut *, from) =
+ g_array_index (sg->shortcuts, EShortcut *, to);
+ g_array_index (sg->shortcuts, EShortcut *, to) = t;
+
+ es_emit (sg, E_SHORTCUT_GROUP_ITEM_MOVED, from, to);
+}