diff options
author | Marco Pesenti Gritti <mpeseng@src.gnome.org> | 2003-04-25 19:42:37 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <mpeseng@src.gnome.org> | 2003-04-25 19:42:37 +0800 |
commit | f490b816b02230dd74fc78610eae674f2aa8e88d (patch) | |
tree | 6e49b0df372307a9fa2a6afe22017d67377e1859 /src | |
parent | 22bf87253ddffa6a7225ecaad60c15cd0815c974 (diff) | |
download | gsoc2013-epiphany-f490b816b02230dd74fc78610eae674f2aa8e88d.tar gsoc2013-epiphany-f490b816b02230dd74fc78610eae674f2aa8e88d.tar.gz gsoc2013-epiphany-f490b816b02230dd74fc78610eae674f2aa8e88d.tar.bz2 gsoc2013-epiphany-f490b816b02230dd74fc78610eae674f2aa8e88d.tar.lz gsoc2013-epiphany-f490b816b02230dd74fc78610eae674f2aa8e88d.tar.xz gsoc2013-epiphany-f490b816b02230dd74fc78610eae674f2aa8e88d.tar.zst gsoc2013-epiphany-f490b816b02230dd74fc78610eae674f2aa8e88d.zip |
*** empty log message ***
Diffstat (limited to 'src')
-rwxr-xr-x | src/ephy-toolbars-model.c | 148 | ||||
-rwxr-xr-x | src/ephy-toolbars-model.h | 55 |
2 files changed, 203 insertions, 0 deletions
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 |