aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2003-12-27 18:32:42 +0800
committerChristian Persch <chpe@src.gnome.org>2003-12-27 18:32:42 +0800
commita9863f3bfeb5d8852304d4c92e284e0653dc8ee6 (patch)
treefe4f9832b6d522a5c758cf2386c9e435168e436c /src
parentbde4c29f92204eafbe4f953353730946486dc474 (diff)
downloadgsoc2013-epiphany-a9863f3bfeb5d8852304d4c92e284e0653dc8ee6.tar
gsoc2013-epiphany-a9863f3bfeb5d8852304d4c92e284e0653dc8ee6.tar.gz
gsoc2013-epiphany-a9863f3bfeb5d8852304d4c92e284e0653dc8ee6.tar.bz2
gsoc2013-epiphany-a9863f3bfeb5d8852304d4c92e284e0653dc8ee6.tar.lz
gsoc2013-epiphany-a9863f3bfeb5d8852304d4c92e284e0653dc8ee6.tar.xz
gsoc2013-epiphany-a9863f3bfeb5d8852304d4c92e284e0653dc8ee6.tar.zst
gsoc2013-epiphany-a9863f3bfeb5d8852304d4c92e284e0653dc8ee6.zip
Brought type macros in line with the rest of libegg; and use gobject
2003-12-27 Christian Persch <chpe@cvs.gnome.org> * lib/egg/egg-editable-toolbar.c: (find_action), (drag_data_delete_cb), (drag_data_get_cb), (egg_editable_toolbar_set_model), (egg_editable_toolbar_set_merge), (egg_editable_toolbar_class_init), (egg_editable_toolbar_init), (egg_editable_toolbar_finalize), (egg_editable_toolbar_new): * lib/egg/egg-editable-toolbar.h: * lib/egg/egg-toolbar-editor.c: (find_action), (egg_toolbar_editor_set_merge), (egg_toolbar_editor_set_model), (egg_toolbar_editor_class_init), (egg_toolbar_editor_finalize), (egg_toolbar_editor_new), (editor_drag_data_received_cb), (editor_drag_data_delete_cb), (update_editor_sheet), (setup_editor), (egg_toolbar_editor_init): * lib/egg/egg-toolbar-editor.h: * lib/egg/egg-toolbars-model.c: (egg_toolbars_model_to_xml), (egg_toolbars_model_save), (egg_toolbars_model_add_separator), (impl_add_item), (egg_toolbars_model_add_toolbar), (egg_toolbars_model_load), (egg_toolbars_model_class_init), (egg_toolbars_model_init), (egg_toolbars_model_finalize), (egg_toolbars_model_new), (egg_toolbars_model_remove_toolbar), (egg_toolbars_model_remove_item): * lib/egg/egg-toolbars-model.h: Brought type macros in line with the rest of libegg; and use gobject instance private data. * src/ephy-toolbars-model.c: (ephy_toolbars_model_get_type), (update_toolbar_removeable_flag), (ephy_toolbars_model_set_bookmarks), (toolbar_added), (toolbar_removed), (ephy_toolbars_model_new), (ephy_toolbars_model_has_bookmark): * src/ephy-toolbars-model.h: * src/toolbar.c: (toolbar_get_type), (init_normal_mode): Fix crasher bug #129991.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/ephy-toolbars-model.c97
-rwxr-xr-xsrc/ephy-toolbars-model.h6
-rwxr-xr-xsrc/toolbar.c43
3 files changed, 43 insertions, 103 deletions
diff --git a/src/ephy-toolbars-model.c b/src/ephy-toolbars-model.c
index f43acfb83..c022b9ba8 100755
--- a/src/ephy-toolbars-model.c
+++ b/src/ephy-toolbars-model.c
@@ -68,9 +68,9 @@ struct EphyToolbarsModelPrivate
GType
ephy_toolbars_model_get_type (void)
{
- static GType ephy_toolbars_model_type = 0;
+ static GType type = 0;
- if (ephy_toolbars_model_type == 0)
+ if (type == 0)
{
static const GTypeInfo our_info = {
sizeof (EphyToolbarsModelClass),
@@ -84,12 +84,12 @@ ephy_toolbars_model_get_type (void)
(GInstanceInitFunc) ephy_toolbars_model_init
};
- ephy_toolbars_model_type = g_type_register_static (EGG_TOOLBARS_MODEL_TYPE,
- "EphyToolbarsModel",
- &our_info, 0);
+ type = g_type_register_static (EGG_TYPE_TOOLBARS_MODEL,
+ "EphyToolbarsModel",
+ &our_info, 0);
}
- return ephy_toolbars_model_type;
+ return type;
}
char *
@@ -320,13 +320,40 @@ connect_item (EphyToolbarsModel *model,
}
static void
+update_toolbar_removeable_flag (EggToolbarsModel *model)
+{
+ int i, n_toolbars;
+ int flag = 0;
+
+ n_toolbars = egg_toolbars_model_n_toolbars (model);
+
+ /* If there is only one toolbar and the bookmarks bar */
+ if (n_toolbars <= 2)
+ {
+ flag = EGG_TB_MODEL_NOT_REMOVABLE;
+ }
+
+ for (i = 0; i < n_toolbars; i++)
+ {
+ const char *t_name;
+
+ t_name = egg_toolbars_model_toolbar_nth (model, i);
+ g_return_if_fail (t_name != NULL);
+
+ if (!(strcmp (t_name, "BookmarksBar") == 0))
+ {
+ egg_toolbars_model_set_flags (model, flag, i);
+ }
+ }
+}
+
+static void
ephy_toolbars_model_set_bookmarks (EphyToolbarsModel *model, EphyBookmarks *bookmarks)
{
EggToolbarsModel *egg_model = EGG_TOOLBARS_MODEL (model);
gboolean success = FALSE;
- model->priv->bookmarks = bookmarks;
- g_object_ref (model->priv->bookmarks);
+ model->priv->bookmarks = g_object_ref (bookmarks);
model->priv->loading = TRUE;
@@ -451,12 +478,14 @@ static void
toolbar_added (EphyToolbarsModel *model, int position)
{
save_changes (model);
+ update_toolbar_removeable_flag (EGG_TOOLBARS_MODEL (model));
}
static void
toolbar_removed (EphyToolbarsModel *model, int position)
{
save_changes (model);
+ update_toolbar_removeable_flag (EGG_TOOLBARS_MODEL (model));
}
static void
@@ -493,15 +522,9 @@ ephy_toolbars_model_finalize (GObject *object)
EphyToolbarsModel *
ephy_toolbars_model_new (EphyBookmarks *bookmarks)
{
- EphyToolbarsModel *t;
-
- t = EPHY_TOOLBARS_MODEL (g_object_new (EPHY_TYPE_TOOLBARS_MODEL,
- "bookmarks", bookmarks,
- NULL));
-
- g_return_val_if_fail (t->priv != NULL, NULL);
-
- return t;
+ return EPHY_TOOLBARS_MODEL (g_object_new (EPHY_TYPE_TOOLBARS_MODEL,
+ "bookmarks", bookmarks,
+ NULL));
}
static int
@@ -583,43 +606,3 @@ ephy_toolbars_model_has_bookmark (EphyToolbarsModel *model,
return found;
}
-
-void
-ephy_toolbars_model_set_flag (EphyToolbarsModel *model,
- EggTbModelFlags flags)
-{
- EggToolbarsModel *t = EGG_TOOLBARS_MODEL (model);
- int i, n_toolbars;
-
- n_toolbars = egg_toolbars_model_n_toolbars
- (EGG_TOOLBARS_MODEL (model));
-
- for (i = 0; i < n_toolbars; i++)
- {
- EggTbModelFlags old_flags;
-
- old_flags = egg_toolbars_model_get_flags (t, i);
-
- egg_toolbars_model_set_flags (t, old_flags | flags, i);
- }
-}
-
-void
-ephy_toolbars_model_unset_flag (EphyToolbarsModel *model,
- EggTbModelFlags flags)
-{
- EggToolbarsModel *t = EGG_TOOLBARS_MODEL (model);
- int i, n_toolbars;
-
- n_toolbars = egg_toolbars_model_n_toolbars
- (EGG_TOOLBARS_MODEL (model));
-
- for (i = 0; i < n_toolbars; i++)
- {
- EggTbModelFlags old_flags;
-
- old_flags = egg_toolbars_model_get_flags (t, i);
-
- egg_toolbars_model_set_flags (t, old_flags ^ flags, i);
- }
-}
diff --git a/src/ephy-toolbars-model.h b/src/ephy-toolbars-model.h
index bc20da6f6..dd0a412ae 100755
--- a/src/ephy-toolbars-model.h
+++ b/src/ephy-toolbars-model.h
@@ -68,12 +68,6 @@ char *ephy_toolbars_model_get_action_name (EphyToolbarsModel *model
EphyNode *ephy_toolbars_model_get_node (EphyToolbarsModel *model,
const char *action_name);
-void ephy_toolbars_model_set_flag (EphyToolbarsModel *model,
- EggTbModelFlags flags);
-
-void ephy_toolbars_model_unset_flag (EphyToolbarsModel *model,
- EggTbModelFlags flags);
-
G_END_DECLS
#endif
diff --git a/src/toolbar.c b/src/toolbar.c
index dae06f522..bf5596c24 100755
--- a/src/toolbar.c
+++ b/src/toolbar.c
@@ -20,7 +20,7 @@
*/
#ifdef HAVE_CONFIG_H
-#include <config.h>
+#include "config.h"
#endif
#include "toolbar.h"
@@ -116,7 +116,7 @@ toolbar_get_type (void)
(GInstanceInitFunc) toolbar_init
};
- toolbar_type = g_type_register_static (EGG_EDITABLE_TOOLBAR_TYPE,
+ toolbar_type = g_type_register_static (EGG_TYPE_EDITABLE_TOOLBAR,
"Toolbar",
&our_info, 0);
}
@@ -454,50 +454,13 @@ init_bookmarks_toolbar (Toolbar *t)
}
static void
-update_toolbar_remove_flag (EphyToolbarsModel *model, gpointer data)
-{
- int i, n_toolbars;
- int not_removable = 0;
-
- n_toolbars = egg_toolbars_model_n_toolbars
- (EGG_TOOLBARS_MODEL (model));
-
- /* If there is only one toolbar and the bookmarks bar */
- if (n_toolbars <= 2)
- {
- not_removable = EGG_TB_MODEL_NOT_REMOVABLE;
- }
-
- for (i = 0; i < n_toolbars; i++)
- {
- const char *t_name;
-
- t_name = egg_toolbars_model_toolbar_nth
- (EGG_TOOLBARS_MODEL (model), i);
- g_return_if_fail (t_name != NULL);
-
- if (!(strcmp (t_name, "BookmarksBar") == 0))
- {
- egg_toolbars_model_set_flags
- (EGG_TOOLBARS_MODEL (model),
- not_removable, i);
- }
- }
-}
-
-static void
init_normal_mode (Toolbar *t)
{
EphyToolbarsModel *model;
model = EPHY_TOOLBARS_MODEL
(ephy_shell_get_toolbars_model (ephy_shell, FALSE));
- g_signal_connect (EGG_TOOLBARS_MODEL (model), "toolbar_added",
- G_CALLBACK (update_toolbar_remove_flag),
- NULL);
- g_signal_connect (EGG_TOOLBARS_MODEL (model), "toolbar_removed",
- G_CALLBACK (update_toolbar_remove_flag),
- NULL);
+
g_object_set (G_OBJECT (t),
"ToolbarsModel", model,
NULL);