From f490b816b02230dd74fc78610eae674f2aa8e88d Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Fri, 25 Apr 2003 11:42:37 +0000 Subject: *** empty log message *** --- src/ephy-toolbars-model.c | 148 ++++++++++++++++++++++++++++++++++++++++++++++ src/ephy-toolbars-model.h | 55 +++++++++++++++++ 2 files changed, 203 insertions(+) create mode 100755 src/ephy-toolbars-model.c create mode 100755 src/ephy-toolbars-model.h (limited to 'src') diff --git a/src/ephy-toolbars-model.c b/src/ephy-toolbars-model.c new file mode 100755 index 000000000..da842e719 --- /dev/null +++ b/src/ephy-toolbars-model.c @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2002 Marco Pesenti Gritti + * + * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "ephy-toolbars-model.h" +#include "ephy-dnd.h" +#include "ephy-new-bookmark.h" +#include "ephy-shell.h" +#include "ephy-debug.h" + +static void ephy_toolbars_model_class_init (EphyToolbarsModelClass *klass); +static void ephy_toolbars_model_init (EphyToolbarsModel *t); +static void ephy_toolbars_model_finalize (GObject *object); + +static GObjectClass *parent_class = NULL; + +struct EphyToolbarsModelPrivate +{ + gpointer dummy; +}; + +GType +ephy_toolbars_model_get_type (void) +{ + static GType ephy_toolbars_model_type = 0; + + if (ephy_toolbars_model_type == 0) + { + static const GTypeInfo our_info = { + sizeof (EphyToolbarsModelClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) ephy_toolbars_model_class_init, + NULL, + NULL, /* class_data */ + sizeof (EphyToolbarsModel), + 0, /* n_preallocs */ + (GInstanceInitFunc) ephy_toolbars_model_init + }; + + ephy_toolbars_model_type = g_type_register_static (EGG_TOOLBARS_MODEL_TYPE, + "EphyToolbarsModel", + &our_info, 0); + } + + return ephy_toolbars_model_type; +} + +static const char * +impl_add_item (EggToolbarsModel *t, + int toolbar_position, + int position, + GdkAtom type, + const char *name) +{ + EphyBookmarks *bookmarks; + char *res = NULL; + + bookmarks = ephy_shell_get_bookmarks (ephy_shell); + + if (gdk_atom_intern (EPHY_DND_TOPIC_TYPE, FALSE) == type) + { + GList *nodes; + int id; + + nodes = ephy_dnd_node_list_extract_nodes (name); + id = ephy_node_get_id (EPHY_NODE (nodes->data)); + res = g_strdup_printf ("GoTopicId%d", id); + g_list_free (nodes); + } + else if (gdk_atom_intern (EPHY_DND_TOPIC_TYPE, FALSE) == type) + { + GList *nodes; + int id; + + nodes = ephy_dnd_node_list_extract_nodes (name); + id = ephy_node_get_id (EPHY_NODE (nodes->data)); + res = g_strdup_printf ("GoBookmarkId%d", id); + g_list_free (nodes); + } + else + { + EGG_TOOLBARS_MODEL_CLASS (parent_class)->add_item + (t, toolbar_position, position, type, name); + } + + return res; +} + +static void +ephy_toolbars_model_class_init (EphyToolbarsModelClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + EggToolbarsModelClass *etm_class; + + etm_class = EGG_TOOLBARS_MODEL_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + object_class->finalize = ephy_toolbars_model_finalize; + + etm_class->add_item = impl_add_item; +} + +static void +ephy_toolbars_model_init (EphyToolbarsModel *t) +{ + t->priv = g_new0 (EphyToolbarsModelPrivate, 1); +} + +static void +ephy_toolbars_model_finalize (GObject *object) +{ + EphyToolbarsModel *t = EPHY_TOOLBARS_MODEL (object); + + g_return_if_fail (object != NULL); + g_return_if_fail (IS_EPHY_TOOLBARS_MODEL (object)); + + g_free (t->priv); + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +EphyToolbarsModel * +ephy_toolbars_model_new (void) +{ + EphyToolbarsModel *t; + + t = EPHY_TOOLBARS_MODEL (g_object_new (EPHY_TOOLBARS_MODEL_TYPE, NULL)); + + g_return_val_if_fail (t->priv != NULL, NULL); + + return t; +} diff --git a/src/ephy-toolbars-model.h b/src/ephy-toolbars-model.h new file mode 100755 index 000000000..4ebf48057 --- /dev/null +++ b/src/ephy-toolbars-model.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2003 Marco Pesenti Gritti + * + * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef EPHY_TOOLBARS_MODEL_H +#define EPHY_TOOLBARS_MODEL_H + +#include "egg-toolbars-model.h" + +G_BEGIN_DECLS + +typedef struct EphyToolbarsModelClass EphyToolbarsModelClass; + +#define EPHY_TOOLBARS_MODEL_TYPE (ephy_toolbars_model_get_type ()) +#define EPHY_TOOLBARS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EPHY_TOOLBARS_MODEL_TYPE, EphyToolbarsModel)) +#define EPHY_TOOLBARS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EPHY_TOOLBARS_MODEL_TYPE, EphyToolbarsModelClass)) +#define IS_EPHY_TOOLBARS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EPHY_TOOLBARS_MODEL_TYPE)) +#define IS_EPHY_TOOLBARS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EPHY_TOOLBARS_MODEL_TYPE)) +#define EPHY_TOOLBARS_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EPHY_TOOLBARS_MODEL_TYPE, EphyToolbarsModelClass)) + +typedef struct EphyToolbarsModel EphyToolbarsModel; +typedef struct EphyToolbarsModelPrivate EphyToolbarsModelPrivate; + +struct EphyToolbarsModel +{ + EggToolbarsModel parent_object; + EphyToolbarsModelPrivate *priv; +}; + +struct EphyToolbarsModelClass +{ + EggToolbarsModelClass parent_class; +}; + +GType ephy_toolbars_model_get_type (void); + +EphyToolbarsModel *ephy_toolbars_model_new (void); + +G_END_DECLS + +#endif -- cgit v1.2.3