summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichael Catanzaro <mcatanzaro@igalia.com>2016-03-21 23:13:34 -0500
committerMichael Catanzaro <mcatanzaro@igalia.com>2016-03-29 13:03:13 -0500
commit9ccb9da9eb9601c66e615d7a4a44c747832ddac1 (patch)
tree3b7f694c37af6e77e264bf9ded228f1a43aa7516 /lib
parent5a5e0d7cf463c14f4769de4e9a3ae9e8b38d54b4 (diff)
downloadepiphany-9ccb9da9eb9601c66e615d7a4a44c747832ddac1.tar.gz
Uncrustify
For a better future. Apologies when your 'git blame' resolves to this. I'm actually really impressed how well uncrustify works. This required only a little one-time manual work to avoid extra space in 'else {'. This breaks function prototype alignment, but we should get rid of most of those anyway. We decided to start aligning function parameters, like other GNOME applications. It looks nicer this way, and I couldn't teach uncrustify the previous Epiphany style.
Diffstat (limited to 'lib')
-rw-r--r--lib/egg/eggtreemultidnd.c270
-rw-r--r--lib/ephy-debug.c268
-rw-r--r--lib/ephy-dnd.c109
-rw-r--r--lib/ephy-file-helpers.c1226
-rw-r--r--lib/ephy-form-auth-data.c61
-rw-r--r--lib/ephy-gui.c535
-rw-r--r--lib/ephy-initial-state.c75
-rw-r--r--lib/ephy-langs.c451
-rw-r--r--lib/ephy-node-db.c512
-rw-r--r--lib/ephy-node-filter.c604
-rw-r--r--lib/ephy-node.c1814
-rw-r--r--lib/ephy-nss-glue.c89
-rw-r--r--lib/ephy-profile-migrator.c106
-rw-r--r--lib/ephy-profile-utils.c6
-rw-r--r--lib/ephy-security-levels.c28
-rw-r--r--lib/ephy-signal-accumulator.c81
-rw-r--r--lib/ephy-smaps.c30
-rw-r--r--lib/ephy-snapshot-service.c149
-rw-r--r--lib/ephy-sqlite-connection.c8
-rw-r--r--lib/ephy-sqlite-statement.c9
-rw-r--r--lib/ephy-string.c36
-rw-r--r--lib/ephy-time-helpers.c370
-rw-r--r--lib/ephy-uri-helpers.c46
-rw-r--r--lib/ephy-web-app-utils.c30
-rw-r--r--lib/ephy-zoom.c2
-rw-r--r--lib/history/ephy-history-service-hosts-table.c80
-rw-r--r--lib/history/ephy-history-service-urls-table.c124
-rw-r--r--lib/history/ephy-history-service-visits-table.c34
-rw-r--r--lib/history/ephy-history-service.c206
-rw-r--r--lib/history/ephy-history-types.c8
-rw-r--r--lib/widgets/ephy-certificate-dialog.c106
-rw-r--r--lib/widgets/ephy-download-widget.c135
-rw-r--r--lib/widgets/ephy-downloads-popover.c3
-rw-r--r--lib/widgets/ephy-downloads-progress-icon.c3
-rw-r--r--lib/widgets/ephy-file-chooser.c343
-rw-r--r--lib/widgets/ephy-location-entry.c2062
-rw-r--r--lib/widgets/ephy-middle-clickable-button.c11
-rw-r--r--lib/widgets/ephy-node-view.c2657
-rw-r--r--lib/widgets/ephy-security-popover.c130
-rw-r--r--lib/widgets/ephy-tree-model-node.c653
-rw-r--r--lib/widgets/ephy-tree-model-sort.c164
-rw-r--r--lib/widgets/ephy-zoom-action.c245
-rw-r--r--lib/widgets/nautilus-floating-bar.c658
43 files changed, 7041 insertions, 7496 deletions
diff --git a/lib/egg/eggtreemultidnd.c b/lib/egg/eggtreemultidnd.c
index f140c2591..cb584856e 100644
--- a/lib/egg/eggtreemultidnd.c
+++ b/lib/egg/eggtreemultidnd.c
@@ -24,8 +24,7 @@
#define EGG_TREE_MULTI_DND_STRING "EggTreeMultiDndString"
-typedef struct
-{
+typedef struct {
guint pressed_button;
gint x;
gint y;
@@ -37,8 +36,7 @@ typedef struct
/* CUT-N-PASTE from gtktreeview.c */
typedef struct _TreeViewDragInfo TreeViewDragInfo;
-struct _TreeViewDragInfo
-{
+struct _TreeViewDragInfo {
GdkModifierType start_button_mask;
GtkTargetList *source_target_list;
GdkDragAction source_actions;
@@ -55,24 +53,23 @@ egg_tree_multi_drag_source_get_type (void)
{
static GType our_type = 0;
- if (!our_type)
+ if (!our_type) {
+ static const GTypeInfo our_info =
{
- static const GTypeInfo our_info =
- {
- sizeof (EggTreeMultiDragSourceIface), /* class_size */
- NULL, /* base_init */
- NULL, /* base_finalize */
- NULL,
- NULL, /* class_finalize */
- NULL, /* class_data */
- 0,
- 0, /* n_preallocs */
- NULL
- };
-
- our_type = g_type_register_static (G_TYPE_INTERFACE, "EggTreeMultiDragSource", &our_info, 0);
- }
-
+ sizeof (EggTreeMultiDragSourceIface), /* class_size */
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ NULL,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ 0,
+ 0, /* n_preallocs */
+ NULL
+ };
+
+ our_type = g_type_register_static (G_TYPE_INTERFACE, "EggTreeMultiDragSource", &our_info, 0);
+ }
+
return our_type;
}
@@ -81,7 +78,7 @@ egg_tree_multi_drag_source_get_type (void)
* egg_tree_multi_drag_source_row_draggable:
* @drag_source: a #EggTreeMultiDragSource
* @path: row on which user is initiating a drag
- *
+ *
* Asks the #EggTreeMultiDragSource whether a particular row can be used as
* the source of a DND operation. If the source doesn't implement
* this interface, the row is assumed draggable.
@@ -90,7 +87,7 @@ egg_tree_multi_drag_source_get_type (void)
**/
gboolean
egg_tree_multi_drag_source_row_draggable (EggTreeMultiDragSource *drag_source,
- GList *path_list)
+ GList *path_list)
{
EggTreeMultiDragSourceIface *iface = EGG_TREE_MULTI_DRAG_SOURCE_GET_IFACE (drag_source);
@@ -99,7 +96,7 @@ egg_tree_multi_drag_source_row_draggable (EggTreeMultiDragSource *drag_source,
g_return_val_if_fail (path_list != NULL, FALSE);
if (iface->row_draggable)
- return (* iface->row_draggable) (drag_source, path_list);
+ return (*iface->row_draggable)(drag_source, path_list);
else
return TRUE;
}
@@ -109,18 +106,18 @@ egg_tree_multi_drag_source_row_draggable (EggTreeMultiDragSource *drag_source,
* egg_tree_multi_drag_source_drag_data_delete:
* @drag_source: a #EggTreeMultiDragSource
* @path: row that was being dragged
- *
+ *
* Asks the #EggTreeMultiDragSource to delete the row at @path, because
* it was moved somewhere else via drag-and-drop. Returns %FALSE
* if the deletion fails because @path no longer exists, or for
* some model-specific reason. Should robustly handle a @path no
* longer found in the model!
- *
+ *
* Return value: %TRUE if the row was successfully deleted
**/
gboolean
egg_tree_multi_drag_source_drag_data_delete (EggTreeMultiDragSource *drag_source,
- GList *path_list)
+ GList *path_list)
{
EggTreeMultiDragSourceIface *iface = EGG_TREE_MULTI_DRAG_SOURCE_GET_IFACE (drag_source);
@@ -128,7 +125,7 @@ egg_tree_multi_drag_source_drag_data_delete (EggTreeMultiDragSource *drag_source
g_return_val_if_fail (iface->drag_data_delete != NULL, FALSE);
g_return_val_if_fail (path_list != NULL, FALSE);
- return (* iface->drag_data_delete) (drag_source, path_list);
+ return (*iface->drag_data_delete)(drag_source, path_list);
}
/**
@@ -136,18 +133,18 @@ egg_tree_multi_drag_source_drag_data_delete (EggTreeMultiDragSource *drag_source
* @drag_source: a #EggTreeMultiDragSource
* @path: row that was dragged
* @selection_data: a #EggSelectionData to fill with data from the dragged row
- *
+ *
* Asks the #EggTreeMultiDragSource to fill in @selection_data with a
* representation of the row at @path. @selection_data->target gives
* the required type of the data. Should robustly handle a @path no
* longer found in the model!
- *
- * Return value: %TRUE if data of the required type was provided
+ *
+ * Return value: %TRUE if data of the required type was provided
**/
gboolean
-egg_tree_multi_drag_source_drag_data_get (EggTreeMultiDragSource *drag_source,
- GList *path_list,
- GtkSelectionData *selection_data)
+egg_tree_multi_drag_source_drag_data_get (EggTreeMultiDragSource *drag_source,
+ GList *path_list,
+ GtkSelectionData *selection_data)
{
EggTreeMultiDragSourceIface *iface = EGG_TREE_MULTI_DRAG_SOURCE_GET_IFACE (drag_source);
@@ -156,7 +153,7 @@ egg_tree_multi_drag_source_drag_data_get (EggTreeMultiDragSource *drag_source
g_return_val_if_fail (path_list != NULL, FALSE);
g_return_val_if_fail (selection_data != NULL, FALSE);
- return (* iface->drag_data_get) (drag_source, path_list, selection_data);
+ return (*iface->drag_data_get)(drag_source, path_list, selection_data);
}
static void
@@ -166,10 +163,10 @@ stop_drag_check (GtkWidget *widget)
GSList *l;
priv_data = g_object_get_data (G_OBJECT (widget), EGG_TREE_MULTI_DND_STRING);
-
+
for (l = priv_data->event_list; l != NULL; l = l->next)
gdk_event_free (l->data);
-
+
g_slist_free (priv_data->event_list);
priv_data->event_list = NULL;
g_signal_handler_disconnect (widget, priv_data->motion_notify_handler);
@@ -178,17 +175,17 @@ stop_drag_check (GtkWidget *widget)
static gboolean
egg_tree_multi_drag_button_release_event (GtkWidget *widget,
- GdkEventButton *event,
- gpointer data)
+ GdkEventButton *event,
+ gpointer data)
{
EggTreeMultiDndData *priv_data;
GSList *l;
priv_data = g_object_get_data (G_OBJECT (widget), EGG_TREE_MULTI_DND_STRING);
- for (l = priv_data->event_list; l != NULL; l = l->next)
+ for (l = priv_data->event_list; l != NULL; l = l->next)
gtk_propagate_event (widget, l->data);
-
+
stop_drag_check (widget);
return FALSE;
@@ -196,13 +193,13 @@ egg_tree_multi_drag_button_release_event (GtkWidget *widget,
static void
selection_foreach (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer data)
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer data)
{
GList **list_ptr;
- list_ptr = (GList **) data;
+ list_ptr = (GList **)data;
*list_ptr = g_list_prepend (*list_ptr, gtk_tree_row_reference_new (model, path));
}
@@ -210,29 +207,29 @@ selection_foreach (GtkTreeModel *model,
static void
path_list_free (GList *path_list)
{
- g_list_foreach (path_list, (GFunc) gtk_tree_row_reference_free, NULL);
+ g_list_foreach (path_list, (GFunc)gtk_tree_row_reference_free, NULL);
g_list_free (path_list);
}
static void
set_context_data (GdkDragContext *context,
- GList *path_list)
+ GList *path_list)
{
g_object_set_data_full (G_OBJECT (context),
"egg-tree-view-multi-source-row",
path_list,
- (GDestroyNotify) path_list_free);
+ (GDestroyNotify)path_list_free);
}
static GList *
get_context_data (GdkDragContext *context)
{
return g_object_get_data (G_OBJECT (context),
- "egg-tree-view-multi-source-row");
+ "egg-tree-view-multi-source-row");
}
/* CUT-N-PASTE from gtktreeview.c */
-static TreeViewDragInfo*
+static TreeViewDragInfo *
get_info (GtkTreeView *tree_view)
{
return g_object_get_data (G_OBJECT (tree_view), "gtk-tree-view-drag-info");
@@ -241,10 +238,10 @@ get_info (GtkTreeView *tree_view)
static void
egg_tree_multi_drag_drag_data_get (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint info,
- guint time)
+ GdkDragContext *context,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint time)
{
GtkTreeView *tree_view;
GtkTreeModel *model;
@@ -273,71 +270,65 @@ egg_tree_multi_drag_drag_data_get (GtkWidget *widget,
* we also support.
*/
- if (EGG_IS_TREE_MULTI_DRAG_SOURCE (model))
- {
- egg_tree_multi_drag_source_drag_data_get (EGG_TREE_MULTI_DRAG_SOURCE (model),
- path_list,
- selection_data);
- }
+ if (EGG_IS_TREE_MULTI_DRAG_SOURCE (model)) {
+ egg_tree_multi_drag_source_drag_data_get (EGG_TREE_MULTI_DRAG_SOURCE (model),
+ path_list,
+ selection_data);
+ }
}
static gboolean
egg_tree_multi_drag_motion_event (GtkWidget *widget,
- GdkEventMotion *event,
- gpointer data)
+ GdkEventMotion *event,
+ gpointer data)
{
EggTreeMultiDndData *priv_data;
priv_data = g_object_get_data (G_OBJECT (widget), EGG_TREE_MULTI_DND_STRING);
if (gtk_drag_check_threshold (widget,
- priv_data->x,
- priv_data->y,
- event->x,
- event->y))
- {
- GList *path_list = NULL;
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GdkDragContext *context;
- TreeViewDragInfo *di;
-
- di = get_info (GTK_TREE_VIEW (widget));
-
- if (di == NULL)
- return FALSE;
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
- stop_drag_check (widget);
- gtk_tree_selection_selected_foreach (selection, selection_foreach, &path_list);
- path_list = g_list_reverse (path_list);
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
- if (egg_tree_multi_drag_source_row_draggable (EGG_TREE_MULTI_DRAG_SOURCE (model), path_list))
- {
- context = gtk_drag_begin_with_coordinates (widget,
- gtk_drag_source_get_target_list (widget),
- di->source_actions,
- priv_data->pressed_button,
- (GdkEvent*)event,
- event->x,
- event->y);
- set_context_data (context, path_list);
- gtk_drag_set_icon_default (context);
-
- }
- else
- {
- path_list_free (path_list);
- }
+ priv_data->x,
+ priv_data->y,
+ event->x,
+ event->y)) {
+ GList *path_list = NULL;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GdkDragContext *context;
+ TreeViewDragInfo *di;
+
+ di = get_info (GTK_TREE_VIEW (widget));
+
+ if (di == NULL)
+ return FALSE;
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
+ stop_drag_check (widget);
+ gtk_tree_selection_selected_foreach (selection, selection_foreach, &path_list);
+ path_list = g_list_reverse (path_list);
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
+ if (egg_tree_multi_drag_source_row_draggable (EGG_TREE_MULTI_DRAG_SOURCE (model), path_list)) {
+ context = gtk_drag_begin_with_coordinates (widget,
+ gtk_drag_source_get_target_list (widget),
+ di->source_actions,
+ priv_data->pressed_button,
+ (GdkEvent *)event,
+ event->x,
+ event->y);
+ set_context_data (context, path_list);
+ gtk_drag_set_icon_default (context);
+ } else {
+ path_list_free (path_list);
}
+ }
return TRUE;
}
static gboolean
egg_tree_multi_drag_button_press_event (GtkWidget *widget,
- GdkEventButton *event,
- gpointer data)
+ GdkEventButton *event,
+ gpointer data)
{
GtkTreeView *tree_view;
GtkTreePath *path = NULL;
@@ -348,58 +339,53 @@ egg_tree_multi_drag_button_press_event (GtkWidget *widget,
tree_view = GTK_TREE_VIEW (widget);
priv_data = g_object_get_data (G_OBJECT (tree_view), EGG_TREE_MULTI_DND_STRING);
- if (priv_data == NULL)
- {
- priv_data = g_new0 (EggTreeMultiDndData, 1);
- g_object_set_data (G_OBJECT (tree_view), EGG_TREE_MULTI_DND_STRING, priv_data);
- }
+ if (priv_data == NULL) {
+ priv_data = g_new0 (EggTreeMultiDndData, 1);
+ g_object_set_data (G_OBJECT (tree_view), EGG_TREE_MULTI_DND_STRING, priv_data);
+ }
- if (g_slist_find (priv_data->event_list, event))
+ if (g_slist_find (priv_data->event_list, event))
return FALSE;
- if (priv_data->event_list)
- {
- /* save the event to be propagated in order */
- priv_data->event_list = g_slist_append (priv_data->event_list, gdk_event_copy ((GdkEvent*)event));
- return TRUE;
- }
-
+ if (priv_data->event_list) {
+ /* save the event to be propagated in order */
+ priv_data->event_list = g_slist_append (priv_data->event_list, gdk_event_copy ((GdkEvent *)event));
+ return TRUE;
+ }
+
if (event->type == GDK_2BUTTON_PRESS)
return FALSE;
gtk_tree_view_get_path_at_pos (tree_view,
- event->x, event->y,
- &path, &column,
- &cell_x, &cell_y);
+ event->x, event->y,
+ &path, &column,
+ &cell_x, &cell_y);
selection = gtk_tree_view_get_selection (tree_view);
- if (path && gtk_tree_selection_path_is_selected (selection, path))
- {
- priv_data->pressed_button = event->button;
- priv_data->x = event->x;
- priv_data->y = event->y;
- priv_data->event_list = g_slist_append (priv_data->event_list, gdk_event_copy ((GdkEvent*)event));
- priv_data->motion_notify_handler =
- g_signal_connect (G_OBJECT (tree_view), "motion_notify_event", G_CALLBACK (egg_tree_multi_drag_motion_event), NULL);
- priv_data->button_release_handler =
- g_signal_connect (G_OBJECT (tree_view), "button_release_event", G_CALLBACK (egg_tree_multi_drag_button_release_event), NULL);
-
- if (priv_data->drag_data_get_handler == 0)
- {
- priv_data->drag_data_get_handler =
- g_signal_connect (G_OBJECT (tree_view), "drag_data_get", G_CALLBACK (egg_tree_multi_drag_drag_data_get), NULL);
- }
-
- gtk_tree_path_free (path);
-
- return TRUE;
+ if (path && gtk_tree_selection_path_is_selected (selection, path)) {
+ priv_data->pressed_button = event->button;
+ priv_data->x = event->x;
+ priv_data->y = event->y;
+ priv_data->event_list = g_slist_append (priv_data->event_list, gdk_event_copy ((GdkEvent *)event));
+ priv_data->motion_notify_handler =
+ g_signal_connect (G_OBJECT (tree_view), "motion_notify_event", G_CALLBACK (egg_tree_multi_drag_motion_event), NULL);
+ priv_data->button_release_handler =
+ g_signal_connect (G_OBJECT (tree_view), "button_release_event", G_CALLBACK (egg_tree_multi_drag_button_release_event), NULL);
+
+ if (priv_data->drag_data_get_handler == 0) {
+ priv_data->drag_data_get_handler =
+ g_signal_connect (G_OBJECT (tree_view), "drag_data_get", G_CALLBACK (egg_tree_multi_drag_drag_data_get), NULL);
}
- if (path)
- {
- gtk_tree_path_free (path);
- }
+ gtk_tree_path_free (path);
+
+ return TRUE;
+ }
+
+ if (path) {
+ gtk_tree_path_free (path);
+ }
return FALSE;
}
diff --git a/lib/ephy-debug.c b/lib/ephy-debug.c
index 6a6997d7d..43ffc9004 100644
--- a/lib/ephy-debug.c
+++ b/lib/ephy-debug.c
@@ -48,24 +48,22 @@ static gboolean ephy_profile_all_modules;
static char **
build_modules (const char *name,
- gboolean* is_all)
+ gboolean *is_all)
{
- const char *env;
+ const char *env;
- *is_all = FALSE;
+ *is_all = FALSE;
- env = g_getenv (name);
- if (env == NULL) return NULL;
+ env = g_getenv (name);
+ if (env == NULL) return NULL;
- if (strcmp (env, "all") == 0)
- {
- *is_all = TRUE;
- return NULL;
- }
+ if (strcmp (env, "all") == 0) {
+ *is_all = TRUE;
+ return NULL;
+ }
- return g_strsplit (g_getenv (name), ":", -1);
+ return g_strsplit (g_getenv (name), ":", -1);
}
-
#endif
#ifndef DISABLE_LOGGING
@@ -74,92 +72,77 @@ static char **ephy_log_modules;
static gboolean ephy_log_all_modules;
static void
-log_module (const gchar *log_domain,
- GLogLevelFlags log_level,
- const char *message,
- gpointer user_data)
+log_module (const gchar *log_domain,
+ GLogLevelFlags log_level,
+ const char *message,
+ gpointer user_data)
{
- gboolean should_log = ephy_log_all_modules;
-
- if (!ephy_log_all_modules && !ephy_log_modules) return;
-
- if (ephy_log_modules != NULL)
- {
- guint i;
-
- for (i = 0; ephy_log_modules[i] != NULL; i++)
- {
- if (strstr (message, ephy_log_modules [i]) != NULL)
- {
- should_log = TRUE;
- break;
- }
- }
- }
-
- if (should_log)
- {
- g_print ("%s\n", message);
- }
-}
+ gboolean should_log = ephy_log_all_modules;
+
+ if (!ephy_log_all_modules && !ephy_log_modules) return;
+
+ if (ephy_log_modules != NULL) {
+ guint i;
+
+ for (i = 0; ephy_log_modules[i] != NULL; i++) {
+ if (strstr (message, ephy_log_modules [i]) != NULL) {
+ should_log = TRUE;
+ break;
+ }
+ }
+ }
+ if (should_log) {
+ g_print ("%s\n", message);
+ }
+}
#endif /* !DISABLE_LOGGING */
#define MAX_DEPTH 200
-static void
-trap_handler (const char *log_domain,
- GLogLevelFlags log_level,
- const char *message,
- gpointer user_data)
+static void
+trap_handler (const char *log_domain,
+ GLogLevelFlags log_level,
+ const char *message,
+ gpointer user_data)
{
- g_log_default_handler (log_domain, log_level, message, user_data);
-
- if (ephy_debug_break != NULL &&
- (log_level & (G_LOG_LEVEL_WARNING |
- G_LOG_LEVEL_ERROR |
- G_LOG_LEVEL_CRITICAL |
- G_LOG_FLAG_FATAL)))
- {
- if (strcmp (ephy_debug_break, "suspend") == 0)
- {
- /* the suspend case is first because we wanna send the signal before
- * other threads have had a chance to get too far from the state that
- * caused this assertion (in case they happen to have been involved).
- */
- g_print ("Suspending program; attach with the debugger.\n");
-
- raise (SIGSTOP);
- }
- else if (strcmp (ephy_debug_break, "stack") == 0)
- {
+ g_log_default_handler (log_domain, log_level, message, user_data);
+
+ if (ephy_debug_break != NULL &&
+ (log_level & (G_LOG_LEVEL_WARNING |
+ G_LOG_LEVEL_ERROR |
+ G_LOG_LEVEL_CRITICAL |
+ G_LOG_FLAG_FATAL))) {
+ if (strcmp (ephy_debug_break, "suspend") == 0) {
+ /* the suspend case is first because we wanna send the signal before
+ * other threads have had a chance to get too far from the state that
+ * caused this assertion (in case they happen to have been involved).
+ */
+ g_print ("Suspending program; attach with the debugger.\n");
+
+ raise (SIGSTOP);
+ } else if (strcmp (ephy_debug_break, "stack") == 0) {
#ifdef HAVE_EXECINFO_H
- void *array[MAX_DEPTH];
- size_t size;
-
- size = backtrace (array, MAX_DEPTH);
- backtrace_symbols_fd (array, size, 2);
+ void *array[MAX_DEPTH];
+ size_t size;
+
+ size = backtrace (array, MAX_DEPTH);
+ backtrace_symbols_fd (array, size, 2);
#else
- g_on_error_stack_trace (g_get_prgname ());
+ g_on_error_stack_trace (g_get_prgname ());
#endif /* HAVE_EXECINFO_H */
- }
- else if (strcmp (ephy_debug_break, "trap") == 0)
- {
- /* FIXME: disable the handler for a moment so we
- * don't crash if we don't actually run under gdb
- */
- G_BREAKPOINT ();
- }
- else if (strcmp (ephy_debug_break, "warn") == 0)
- {
- /* default behaviour only */
- }
- else if (ephy_debug_break[0] != '\0')
- {
- g_print ("Unrecognised value of EPHY_DEBUG_BREAK env var: %s!\n",
- ephy_debug_break);
- }
- }
+ } else if (strcmp (ephy_debug_break, "trap") == 0) {
+ /* FIXME: disable the handler for a moment so we
+ * don't crash if we don't actually run under gdb
+ */
+ G_BREAKPOINT ();
+ } else if (strcmp (ephy_debug_break, "warn") == 0) {
+ /* default behaviour only */
+ } else if (ephy_debug_break[0] != '\0') {
+ g_print ("Unrecognised value of EPHY_DEBUG_BREAK env var: %s!\n",
+ ephy_debug_break);
+ }
+ }
}
/**
@@ -173,17 +156,16 @@ void
ephy_debug_init (void)
{
#ifndef DISABLE_LOGGING
- ephy_log_modules = build_modules ("EPHY_LOG_MODULES", &ephy_log_all_modules);
-
- g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, log_module, NULL);
+ ephy_log_modules = build_modules ("EPHY_LOG_MODULES", &ephy_log_all_modules);
+ g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, log_module, NULL);
#endif
- ephy_debug_break = g_getenv ("EPHY_DEBUG_BREAK");
- g_log_set_default_handler (trap_handler, NULL);
+ ephy_debug_break = g_getenv ("EPHY_DEBUG_BREAK");
+ g_log_set_default_handler (trap_handler, NULL);
#ifndef DISABLE_PROFILING
- ephy_profile_modules = build_modules ("EPHY_PROFILE_MODULES", &ephy_profile_all_modules);
+ ephy_profile_modules = build_modules ("EPHY_PROFILE_MODULES", &ephy_profile_all_modules);
#endif
}
@@ -192,65 +174,63 @@ ephy_debug_init (void)
static EphyProfiler *
ephy_profiler_new (const char *name, const char *module)
{
- EphyProfiler *profiler;
+ EphyProfiler *profiler;
- profiler = g_new0 (EphyProfiler, 1);
- profiler->timer = g_timer_new ();
- profiler->name = g_strdup (name);
- profiler->module = g_strdup (module);
+ profiler = g_new0 (EphyProfiler, 1);
+ profiler->timer = g_timer_new ();
+ profiler->name = g_strdup (name);
+ profiler->module = g_strdup (module);
- g_timer_start (profiler->timer);
+ g_timer_start (profiler->timer);
- return profiler;
+ return profiler;
}
static gboolean
ephy_should_profile (const char *module)
{
- char *slash;
- gboolean result = FALSE;
- guint i;
+ char *slash;
+ gboolean result = FALSE;
+ guint i;
- slash = strrchr (module, '/');
+ slash = strrchr (module, '/');
- /* Happens on builddir != srcdir builds */
- if (slash != NULL) module = slash + 1;
+ /* Happens on builddir != srcdir builds */
+ if (slash != NULL) module = slash + 1;
- for (i = 0; ephy_profile_modules[i] != NULL; i++)
- {
- if (strcmp (ephy_profile_modules[i], module) == 0)
- {
- result = TRUE;
- break;
- }
- }
+ for (i = 0; ephy_profile_modules[i] != NULL; i++) {
+ if (strcmp (ephy_profile_modules[i], module) == 0) {
+ result = TRUE;
+ break;
+ }
+ }
- return result;
+ return result;
}
static void
ephy_profiler_dump (EphyProfiler *profiler)
{
- double seconds;
+ double seconds;
- g_return_if_fail (profiler != NULL);
+ g_return_if_fail (profiler != NULL);
- seconds = g_timer_elapsed (profiler->timer, NULL);
+ seconds = g_timer_elapsed (profiler->timer, NULL);
- g_print ("[ %s ] %s %f s elapsed\n",
- profiler->module, profiler->name,
- seconds);
+ g_print ("[ %s ] %s %f s elapsed\n",
+ profiler->module, profiler->name,
+ seconds);
}
static void
ephy_profiler_free (EphyProfiler *profiler)
{
- g_return_if_fail (profiler != NULL);
+ g_return_if_fail (profiler != NULL);
- g_timer_destroy (profiler->timer);
- g_free (profiler->name);
- g_free (profiler->module);
- g_free (profiler);
+ g_timer_destroy (profiler->timer);
+ g_free (profiler->name);
+ g_free (profiler->module);
+ g_free (profiler);
}
/**
@@ -263,21 +243,20 @@ ephy_profiler_free (EphyProfiler *profiler)
void
ephy_profiler_start (const char *name, const char *module)
{
- EphyProfiler *profiler;
+ EphyProfiler *profiler;
- if (ephy_profilers_hash == NULL)
- {
- ephy_profilers_hash =
- g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, NULL);
- }
+ if (ephy_profilers_hash == NULL) {
+ ephy_profilers_hash =
+ g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, NULL);
+ }
- if (!ephy_profile_all_modules &&
- (ephy_profile_modules == NULL || !ephy_should_profile (module))) return;
+ if (!ephy_profile_all_modules &&
+ (ephy_profile_modules == NULL || !ephy_should_profile (module))) return;
- profiler = ephy_profiler_new (name, module);
+ profiler = ephy_profiler_new (name, module);
- g_hash_table_insert (ephy_profilers_hash, g_strdup (name), profiler);
+ g_hash_table_insert (ephy_profilers_hash, g_strdup (name), profiler);
}
/**
@@ -289,14 +268,13 @@ ephy_profiler_start (const char *name, const char *module)
void
ephy_profiler_stop (const char *name)
{
- EphyProfiler *profiler;
+ EphyProfiler *profiler;
- profiler = g_hash_table_lookup (ephy_profilers_hash, name);
- if (profiler == NULL) return;
- g_hash_table_remove (ephy_profilers_hash, name);
+ profiler = g_hash_table_lookup (ephy_profilers_hash, name);
+ if (profiler == NULL) return;
+ g_hash_table_remove (ephy_profilers_hash, name);
- ephy_profiler_dump (profiler);
- ephy_profiler_free (profiler);
+ ephy_profiler_dump (profiler);
+ ephy_profiler_free (profiler);
}
-
#endif
diff --git a/lib/ephy-dnd.c b/lib/ephy-dnd.c
index bb7b61acf..fe4289f4a 100644
--- a/lib/ephy-dnd.c
+++ b/lib/ephy-dnd.c
@@ -32,82 +32,73 @@
static void
add_one_netscape_url (const char *url, const char *title, gpointer data)
{
- GString *result;
-
- result = (GString *) data;
- if (result->len == 0)
- {
- g_string_append (result, url);
- if (title)
- {
- g_string_append (result, "\n");
- g_string_append (result, title);
- }
- }
+ GString *result;
+
+ result = (GString *)data;
+ if (result->len == 0) {
+ g_string_append (result, url);
+ if (title) {
+ g_string_append (result, "\n");
+ g_string_append (result, title);
+ }
+ }
}
static void
add_one_uri (const char *uri, const char *title, gpointer data)
{
- GString *result;
+ GString *result;
- result = (GString *) data;
+ result = (GString *)data;
- g_string_append (result, uri);
- g_string_append (result, "\r\n");
+ g_string_append (result, uri);
+ g_string_append (result, "\r\n");
}
static void
add_one_topic (const char *uri, const char *title, gpointer data)
{
- GString *result;
+ GString *result;
- result = (GString *) data;
+ result = (GString *)data;
- g_string_append (result, uri);
- g_string_append (result, "\r\n");
+ g_string_append (result, uri);
+ g_string_append (result, "\r\n");
}
gboolean
-ephy_dnd_drag_data_get (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint32 time,
- gpointer container_context,
+ephy_dnd_drag_data_get (GtkWidget *widget,
+ GdkDragContext *context,
+ GtkSelectionData *selection_data,
+ guint32 time,
+ gpointer container_context,
EphyDragEachSelectedItemIterator each_selected_item_iterator)
{
- GString *result = NULL;
- GdkAtom target;
-
- target = gtk_selection_data_get_target (selection_data);
-
- if (target == gdk_atom_intern (EPHY_DND_URI_LIST_TYPE, FALSE) ||
- target == gdk_atom_intern (EPHY_DND_TEXT_TYPE, FALSE))
- {
- result = g_string_new (NULL);
- (* each_selected_item_iterator) (add_one_uri, container_context, result);
- }
- else if (target == gdk_atom_intern (EPHY_DND_URL_TYPE, FALSE))
- {
- result = g_string_new (NULL);
- (* each_selected_item_iterator) (add_one_netscape_url, container_context, result);
- }
- else if (target == gdk_atom_intern (EPHY_DND_TOPIC_TYPE, FALSE))
- {
- result = g_string_new (NULL);
- (* each_selected_item_iterator) (add_one_topic, container_context, result);
- g_string_erase (result, result->len - 2, -1);
- }
- else
- {
- g_assert_not_reached ();
- }
-
- gtk_selection_data_set (selection_data,
- target,
- 8, (const guchar *) result->str, result->len);
-
- g_string_free (result, TRUE);
-
- return TRUE;
+ GString *result = NULL;
+ GdkAtom target;
+
+ target = gtk_selection_data_get_target (selection_data);
+
+ if (target == gdk_atom_intern (EPHY_DND_URI_LIST_TYPE, FALSE) ||
+ target == gdk_atom_intern (EPHY_DND_TEXT_TYPE, FALSE)) {
+ result = g_string_new (NULL);
+ (*each_selected_item_iterator)(add_one_uri, container_context, result);
+ } else if (target == gdk_atom_intern (EPHY_DND_URL_TYPE, FALSE)) {
+ result = g_string_new (NULL);
+ (*each_selected_item_iterator)(add_one_netscape_url, container_context, result);
+ } else if (target == gdk_atom_intern (EPHY_DND_TOPIC_TYPE, FALSE)) {
+ result = g_string_new (NULL);
+ (*each_selected_item_iterator)(add_one_topic, container_context, result);
+ g_string_erase (result, result->len - 2, -1);
+ } else {
+ g_assert_not_reached ();
+ }
+
+ gtk_selection_data_set (selection_data,
+ target,
+ 8, (const guchar *)result->str, result->len);
+
+ g_string_free (result, TRUE);
+
+ return TRUE;
}
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c
index 69de1345f..0545733d8 100644
--- a/lib/ephy-file-helpers.c
+++ b/lib/ephy-file-helpers.c
@@ -50,8 +50,8 @@
* atomically.
*/
-#define DELAY_MAX_TICKS 64
-#define INITIAL_TICKS 2
+#define DELAY_MAX_TICKS 64
+#define INITIAL_TICKS 2
static GHashTable *files = NULL;
static GHashTable *mime_table = NULL;
@@ -74,38 +74,36 @@ GQuark ephy_file_helpers_error_quark;
const char *
ephy_file_tmp_dir (void)
{
- if (tmp_dir == NULL)
- {
- char *partial_name;
- char *full_name;
-
- partial_name = g_strconcat ("epiphany-", g_get_user_name (),
- "-XXXXXX", NULL);
- full_name = g_build_filename (g_get_tmp_dir (), partial_name,
- NULL);
- tmp_dir = mkdtemp (full_name);
- g_free (partial_name);
-
- if (tmp_dir == NULL)
- {
- g_free (full_name);
- }
- }
-
- return tmp_dir;
+ if (tmp_dir == NULL) {
+ char *partial_name;
+ char *full_name;
+
+ partial_name = g_strconcat ("epiphany-", g_get_user_name (),
+ "-XXXXXX", NULL);
+ full_name = g_build_filename (g_get_tmp_dir (), partial_name,
+ NULL);
+ tmp_dir = mkdtemp (full_name);
+ g_free (partial_name);
+
+ if (tmp_dir == NULL) {
+ g_free (full_name);
+ }
+ }
+
+ return tmp_dir;
}
static char *
ephy_file_download_dir (void)
{
- const char *xdg_download_dir;
+ const char *xdg_download_dir;
- xdg_download_dir = g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD);
- if (xdg_download_dir != NULL)
- return g_strdup (xdg_download_dir);
+ xdg_download_dir = g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD);
+ if (xdg_download_dir != NULL)
+ return g_strdup (xdg_download_dir);
- /* If we don't have XDG user dirs info, return an educated guess. */
- return g_build_filename (g_get_home_dir (), _("Downloads"), NULL);
+ /* If we don't have XDG user dirs info, return an educated guess. */
+ return g_build_filename (g_get_home_dir (), _("Downloads"), NULL);
}
/**
@@ -127,18 +125,18 @@ ephy_file_download_dir (void)
char *
ephy_file_get_downloads_dir (void)
{
- char *download_dir;
+ char *download_dir;
- download_dir = g_settings_get_string (EPHY_SETTINGS_STATE,
- EPHY_PREFS_STATE_DOWNLOAD_DIR);
+ download_dir = g_settings_get_string (EPHY_SETTINGS_STATE,
+ EPHY_PREFS_STATE_DOWNLOAD_DIR);
- if (g_str_equal (download_dir, "Desktop"))
- download_dir = ephy_file_desktop_dir ();
- if (g_str_equal (download_dir, "Downloads") ||
- g_path_is_absolute (download_dir) != TRUE)
- download_dir = ephy_file_download_dir ();
+ if (g_str_equal (download_dir, "Desktop"))
+ download_dir = ephy_file_desktop_dir ();
+ if (g_str_equal (download_dir, "Downloads") ||
+ g_path_is_absolute (download_dir) != TRUE)
+ download_dir = ephy_file_download_dir ();
- return download_dir;
+ return download_dir;
}
/**
@@ -151,14 +149,14 @@ ephy_file_get_downloads_dir (void)
char *
ephy_file_desktop_dir (void)
{
- const char *xdg_desktop_dir;
+ const char *xdg_desktop_dir;
- xdg_desktop_dir = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
- if (xdg_desktop_dir != NULL)
- return g_strdup (xdg_desktop_dir);
+ xdg_desktop_dir = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
+ if (xdg_desktop_dir != NULL)
+ return g_strdup (xdg_desktop_dir);
- /* If we don't have XDG user dirs info, return an educated guess. */
- return g_build_filename (g_get_home_dir (), _("Desktop"), NULL);
+ /* If we don't have XDG user dirs info, return an educated guess. */
+ return g_build_filename (g_get_home_dir (), _("Desktop"), NULL);
}
/**
@@ -177,35 +175,31 @@ ephy_file_desktop_dir (void)
**/
char *
ephy_file_tmp_filename (const char *base,
- const char *extension)
+ const char *extension)
{
- int fd;
- char *name = g_strdup (base);
-
- fd = g_mkstemp (name);
-
- if (fd != -1)
- {
- unlink (name);
- close (fd);
- }
- else
- {
- g_free (name);
-
- return NULL;
- }
-
- if (extension)
- {
- char *tmp;
- tmp = g_strconcat (name, ".",
- extension, NULL);
- g_free (name);
- name = tmp;
- }
-
- return name;
+ int fd;
+ char *name = g_strdup (base);
+
+ fd = g_mkstemp (name);
+
+ if (fd != -1) {
+ unlink (name);
+ close (fd);
+ } else {
+ g_free (name);
+
+ return NULL;
+ }
+
+ if (extension) {
+ char *tmp;
+ tmp = g_strconcat (name, ".",
+ extension, NULL);
+ g_free (name);
+ name = tmp;
+ }
+
+ return name;
}
/**
@@ -219,41 +213,39 @@ ephy_file_tmp_filename (const char *base,
const char *
ephy_file (const char *filename)
{
- char *ret;
- guint i;
+ char *ret;
+ guint i;
- static const char * const paths[] =
- {
+ static const char * const paths[] =
+ {
#ifndef NDEBUG
- TOP_SRC_DATADIR "/",
- TOP_SRC_DATADIR "/icons/",
- TOP_SRC_DATADIR "/pages/",
+ TOP_SRC_DATADIR "/",
+ TOP_SRC_DATADIR "/icons/",
+ TOP_SRC_DATADIR "/pages/",
#endif
- SHARE_DIR "/",
- SHARE_DIR "/icons/",
- SHARE_DIR "/pages/"
- };
-
- g_assert (files != NULL);
-
- ret = g_hash_table_lookup (files, filename);
- if (ret != NULL)
- return ret;
-
- for (i = 0; i < G_N_ELEMENTS (paths); i++)
- {
- ret = g_strconcat (paths[i], filename, NULL);
- if (g_file_test (ret, G_FILE_TEST_EXISTS) == TRUE)
- {
- g_hash_table_insert (files, g_strdup (filename), ret);
- return (const char *) ret;
- }
- g_free (ret);
- }
-
- g_warning ("Failed to find %s\n", filename);
-
- return NULL;
+ SHARE_DIR "/",
+ SHARE_DIR "/icons/",
+ SHARE_DIR "/pages/"
+ };
+
+ g_assert (files != NULL);
+
+ ret = g_hash_table_lookup (files, filename);
+ if (ret != NULL)
+ return ret;
+
+ for (i = 0; i < G_N_ELEMENTS (paths); i++) {
+ ret = g_strconcat (paths[i], filename, NULL);
+ if (g_file_test (ret, G_FILE_TEST_EXISTS) == TRUE) {
+ g_hash_table_insert (files, g_strdup (filename), ret);
+ return (const char *)ret;
+ }
+ g_free (ret);
+ }
+
+ g_warning ("Failed to find %s\n", filename);
+
+ return NULL;
}
/**
@@ -267,7 +259,7 @@ ephy_file (const char *filename)
const char *
ephy_dot_dir (void)
{
- return dot_dir;
+ return dot_dir;
}
/**
@@ -281,7 +273,7 @@ ephy_dot_dir (void)
gboolean
ephy_dot_dir_is_default (void)
{
- return is_default_dot_dir;
+ return is_default_dot_dir;
}
/**
@@ -294,7 +286,7 @@ ephy_dot_dir_is_default (void)
char *
ephy_default_dot_dir (void)
{
- return g_build_filename (g_get_user_config_dir (), "epiphany", NULL);
+ return g_build_filename (g_get_user_config_dir (), "epiphany", NULL);
}
/**
@@ -309,111 +301,99 @@ ephy_default_dot_dir (void)
* Returns: %FALSE if the profile dir couldn't be created or accessed
**/
gboolean
-ephy_file_helpers_init (const char *profile_dir,
- EphyFileHelpersFlags flags,
- GError **error)
+ephy_file_helpers_init (const char *profile_dir,
+ EphyFileHelpersFlags flags,
+ GError **error)
{
- gboolean ret = TRUE;
- gboolean private_profile;
- gboolean steal_data_from_profile;
-
- ephy_file_helpers_error_quark = g_quark_from_static_string ("ephy-file-helpers-error");
-
- files = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) g_free);
-
- keep_directory = flags & EPHY_FILE_HELPERS_KEEP_DIR;
- private_profile = flags & EPHY_FILE_HELPERS_PRIVATE_PROFILE;
- steal_data_from_profile = flags & EPHY_FILE_HELPERS_STEAL_DATA;
-
- if (profile_dir != NULL && !steal_data_from_profile)
- {
- if (g_path_is_absolute (profile_dir))
- {
- dot_dir = g_strdup (profile_dir);
- }
- else
- {
- GFile *file = g_file_new_for_path (profile_dir);
- dot_dir = g_file_get_path (file);
- g_object_unref (file);
- }
- }
- else if (private_profile)
- {
- if (ephy_file_tmp_dir () == NULL)
- {
- g_set_error (error,
- EPHY_FILE_HELPERS_ERROR_QUARK,
- 0,
- _("Could not create a temporary directory in “%s”."),
- g_get_tmp_dir ());
- return FALSE;
- }
-
- dot_dir = g_build_filename (ephy_file_tmp_dir (),
- "epiphany",
- NULL);
- }
-
- if (dot_dir == NULL)
- {
- dot_dir = ephy_default_dot_dir ();
- is_default_dot_dir = TRUE;
- }
-
- if (flags & EPHY_FILE_HELPERS_ENSURE_EXISTS)
- ret = ephy_ensure_dir_exists (ephy_dot_dir (), error);
-
- if (steal_data_from_profile && profile_dir)
- {
- guint i;
- const char *files_to_copy[] = { EPHY_HISTORY_FILE, EPHY_BOOKMARKS_FILE };
-
- for (i = 0; i < G_N_ELEMENTS (files_to_copy); i++)
- {
- char *filename;
- GError *err = NULL;
- GFile *source, *destination;
-
- filename = g_build_filename (profile_dir,
- files_to_copy[i],
- NULL);
- source = g_file_new_for_path (filename);
- g_free (filename);
-
- filename = g_build_filename (dot_dir,
- files_to_copy[i],
- NULL);
- destination = g_file_new_for_path (filename);
- g_free (filename);
-
- g_file_copy (source, destination,
- G_FILE_COPY_OVERWRITE,
- NULL, NULL, NULL, &err);
- if (err)
- {
- printf("Error stealing file %s from profile: %s\n", files_to_copy[i], err->message);
- g_error_free (err);
- }
-
- g_object_unref (source);
- g_object_unref (destination);
- }
- }
-
- return ret;
+ gboolean ret = TRUE;
+ gboolean private_profile;
+ gboolean steal_data_from_profile;
+
+ ephy_file_helpers_error_quark = g_quark_from_static_string ("ephy-file-helpers-error");
+
+ files = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ (GDestroyNotify)g_free,
+ (GDestroyNotify)g_free);
+
+ keep_directory = flags & EPHY_FILE_HELPERS_KEEP_DIR;
+ private_profile = flags & EPHY_FILE_HELPERS_PRIVATE_PROFILE;
+ steal_data_from_profile = flags & EPHY_FILE_HELPERS_STEAL_DATA;
+
+ if (profile_dir != NULL && !steal_data_from_profile) {
+ if (g_path_is_absolute (profile_dir)) {
+ dot_dir = g_strdup (profile_dir);
+ } else {
+ GFile *file = g_file_new_for_path (profile_dir);
+ dot_dir = g_file_get_path (file);
+ g_object_unref (file);
+ }
+ } else if (private_profile) {
+ if (ephy_file_tmp_dir () == NULL) {
+ g_set_error (error,
+ EPHY_FILE_HELPERS_ERROR_QUARK,
+ 0,
+ _("Could not create a temporary directory in “%s”."),
+ g_get_tmp_dir ());
+ return FALSE;
+ }
+
+ dot_dir = g_build_filename (ephy_file_tmp_dir (),
+ "epiphany",
+ NULL);
+ }
+
+ if (dot_dir == NULL) {
+ dot_dir = ephy_default_dot_dir ();
+ is_default_dot_dir = TRUE;
+ }
+
+ if (flags & EPHY_FILE_HELPERS_ENSURE_EXISTS)
+ ret = ephy_ensure_dir_exists (ephy_dot_dir (), error);
+
+ if (steal_data_from_profile && profile_dir) {
+ guint i;
+ const char *files_to_copy[] = { EPHY_HISTORY_FILE, EPHY_BOOKMARKS_FILE };
+
+ for (i = 0; i < G_N_ELEMENTS (files_to_copy); i++) {
+ char *filename;
+ GError *err = NULL;
+ GFile *source, *destination;
+
+ filename = g_build_filename (profile_dir,
+ files_to_copy[i],
+ NULL);
+ source = g_file_new_for_path (filename);
+ g_free (filename);
+
+ filename = g_build_filename (dot_dir,
+ files_to_copy[i],
+ NULL);
+ destination = g_file_new_for_path (filename);
+ g_free (filename);
+
+ g_file_copy (source, destination,
+ G_FILE_COPY_OVERWRITE,
+ NULL, NULL, NULL, &err);
+ if (err) {
+ printf ("Error stealing file %s from profile: %s\n", files_to_copy[i], err->message);
+ g_error_free (err);
+ }
+
+ g_object_unref (source);
+ g_object_unref (destination);
+ }
+ }
+
+ return ret;
}
static void
delete_files (GList *l)
{
- for (; l != NULL; l = l->next)
- {
- unlink (l->data);
- }
+ for (; l != NULL; l = l->next) {
+ unlink (l->data);
+ }
}
/**
@@ -424,37 +404,34 @@ delete_files (GList *l)
void
ephy_file_helpers_shutdown (void)
{
- g_hash_table_destroy (files);
-
- del_on_exit = g_list_reverse (del_on_exit);
- delete_files (del_on_exit);
- g_list_foreach (del_on_exit, (GFunc)g_free, NULL);
- g_list_free (del_on_exit);
- del_on_exit = NULL;
-
- if (mime_table != NULL)
- {
- LOG ("Destroying mime type hashtable");
- g_hash_table_destroy (mime_table);
- mime_table = NULL;
- }
-
- g_free (dot_dir);
- dot_dir = NULL;
-
- if (tmp_dir != NULL)
- {
- if (!keep_directory)
- {
- /* recursively delete the contents and the
- * directory */
- LOG ("shutdown: delete tmp_dir %s", tmp_dir);
- ephy_file_delete_dir_recursively (tmp_dir, NULL);
- }
-
- g_free (tmp_dir);
- tmp_dir = NULL;
- }
+ g_hash_table_destroy (files);
+
+ del_on_exit = g_list_reverse (del_on_exit);
+ delete_files (del_on_exit);
+ g_list_foreach (del_on_exit, (GFunc)g_free, NULL);
+ g_list_free (del_on_exit);
+ del_on_exit = NULL;
+
+ if (mime_table != NULL) {
+ LOG ("Destroying mime type hashtable");
+ g_hash_table_destroy (mime_table);
+ mime_table = NULL;
+ }
+
+ g_free (dot_dir);
+ dot_dir = NULL;
+
+ if (tmp_dir != NULL) {
+ if (!keep_directory) {
+ /* recursively delete the contents and the
+ * directory */
+ LOG ("shutdown: delete tmp_dir %s", tmp_dir);
+ ephy_file_delete_dir_recursively (tmp_dir, NULL);
+ }
+
+ g_free (tmp_dir);
+ tmp_dir = NULL;
+ }
}
/**
@@ -470,79 +447,69 @@ ephy_file_helpers_shutdown (void)
**/
gboolean
ephy_ensure_dir_exists (const char *dir,
- GError **error)
+ GError **error)
{
- if (g_file_test (dir, G_FILE_TEST_EXISTS) &&
- !g_file_test (dir, G_FILE_TEST_IS_DIR))
- {
- g_set_error (error,
- EPHY_FILE_HELPERS_ERROR_QUARK,
- 0,
- _("The file “%s” exists. Please move it out of the way."),
- dir);
-
- return FALSE;
- }
-
- if (!g_file_test (dir, G_FILE_TEST_EXISTS))
- {
- if (g_mkdir_with_parents (dir, 488) == 0)
- {
- if (dir == ephy_dot_dir ())
- {
- /* We need to set the .migrated file to the
- * current profile migration version,
- * otherwise the next time the browser runs
- * things might go awry. */
- ephy_profile_utils_set_migration_version (EPHY_PROFILE_MIGRATION_VERSION);
- }
- }
- else
- {
- g_set_error (error,
- EPHY_FILE_HELPERS_ERROR_QUARK,
- 0,
- _("Failed to create directory “%s”."),
- dir);
-
- return FALSE;
- }
- }
-
- return TRUE;
+ if (g_file_test (dir, G_FILE_TEST_EXISTS) &&
+ !g_file_test (dir, G_FILE_TEST_IS_DIR)) {
+ g_set_error (error,
+ EPHY_FILE_HELPERS_ERROR_QUARK,
+ 0,
+ _("The file “%s” exists. Please move it out of the way."),
+ dir);
+
+ return FALSE;
+ }
+
+ if (!g_file_test (dir, G_FILE_TEST_EXISTS)) {
+ if (g_mkdir_with_parents (dir, 488) == 0) {
+ if (dir == ephy_dot_dir ()) {
+ /* We need to set the .migrated file to the
+ * current profile migration version,
+ * otherwise the next time the browser runs
+ * things might go awry. */
+ ephy_profile_utils_set_migration_version (EPHY_PROFILE_MIGRATION_VERSION);
+ }
+ } else {
+ g_set_error (error,
+ EPHY_FILE_HELPERS_ERROR_QUARK,
+ 0,
+ _("Failed to create directory “%s”."),
+ dir);
+
+ return FALSE;
+ }
+ }
+
+ return TRUE;
}
static void
ephy_find_file_recursive (const char *path,
- const char *fname,
- GSList **list,
- gint depth,
- gint maxdepth)
+ const char *fname,
+ GSList **list,
+ gint depth,
+ gint maxdepth)
{
- GDir *dir;
- const gchar *file;
-
- dir = g_dir_open (path, 0, NULL);
- if (dir != NULL)
- {
- while ((file = g_dir_read_name (dir)))
- {
- if (depth < maxdepth)
- {
- char *new_path = g_build_filename (path, file, NULL);
- ephy_find_file_recursive (new_path, fname, list,
- depth + 1, maxdepth);
- g_free (new_path);
- }
- if (strcmp (file, fname) == 0)
- {
- char *new_path = g_build_filename (path, file, NULL);
- *list = g_slist_prepend (*list, new_path);
- }
- }
-
- g_dir_close (dir);
- }
+ GDir *dir;
+ const gchar *file;
+
+ dir = g_dir_open (path, 0, NULL);
+ if (dir != NULL) {
+ while ((file = g_dir_read_name (dir))) {
+ if (depth < maxdepth) {
+ char *new_path = g_build_filename (path, file, NULL);
+ ephy_find_file_recursive (new_path, fname, list,
+ depth + 1, maxdepth);
+ g_free (new_path);
+ }
+ if (strcmp (file, fname) == 0) {
+ char *new_path = g_build_filename (path, file, NULL);
+ *list = g_slist_prepend (*list, new_path);
+ }
+ }
+
+ g_dir_close (dir);
+ }
}
/**
@@ -557,12 +524,12 @@ ephy_find_file_recursive (const char *path,
**/
GSList *
ephy_file_find (const char *path,
- const char *fname,
- gint maxdepth)
+ const char *fname,
+ gint maxdepth)
{
- GSList *ret = NULL;
- ephy_find_file_recursive (path, fname, &ret, 0, maxdepth);
- return ret;
+ GSList *ret = NULL;
+ ephy_find_file_recursive (path, fname, &ret, 0, maxdepth);
+ return ret;
}
/**
@@ -575,66 +542,58 @@ ephy_file_find (const char *path,
void
ephy_file_delete_on_exit (GFile *file)
{
- /* does nothing now */
+ /* does nothing now */
}
static void
load_mime_from_xml (void)
{
- xmlTextReaderPtr reader;
- const char *xml_file;
- int ret;
- EphyMimePermission permission = EPHY_MIME_PERMISSION_UNKNOWN;
-
- g_return_if_fail (mime_table == NULL);
-
- mime_table = g_hash_table_new_full (g_str_hash, g_str_equal,
- xmlFree, NULL);
-
- xml_file = ephy_file ("mime-types-permissions.xml");
- if (xml_file == NULL)
- {
- g_warning ("MIME types permissions file not found!\n");
- return;
- }
-
- reader = xmlNewTextReaderFilename (xml_file);
- if (reader == NULL)
- {
- g_warning ("Could not load MIME types permissions file!\n");
- return;
- }
-
- ret = xmlTextReaderRead (reader);
- while (ret == 1)
- {
- const xmlChar *tag;
- xmlReaderTypes type;
-
- tag = xmlTextReaderConstName (reader);
- type = xmlTextReaderNodeType (reader);
-
- if (xmlStrEqual (tag, (const xmlChar *)"safe") && type == XML_READER_TYPE_ELEMENT)
- {
- permission = EPHY_MIME_PERMISSION_SAFE;
- }
- else if (xmlStrEqual (tag, (const xmlChar *)"unsafe") && type == XML_READER_TYPE_ELEMENT)
- {
- permission = EPHY_MIME_PERMISSION_UNSAFE;
- }
- else if (xmlStrEqual (tag, (const xmlChar *)"mime-type"))
- {
- xmlChar *t;
-
- t = xmlTextReaderGetAttribute (reader, (const xmlChar *)"type");
- g_hash_table_insert (mime_table, t,
- GINT_TO_POINTER (permission));
- }
-
- ret = xmlTextReaderRead (reader);
- }
-
- xmlFreeTextReader (reader);
+ xmlTextReaderPtr reader;
+ const char *xml_file;
+ int ret;
+ EphyMimePermission permission = EPHY_MIME_PERMISSION_UNKNOWN;
+
+ g_return_if_fail (mime_table == NULL);
+
+ mime_table = g_hash_table_new_full (g_str_hash, g_str_equal,
+ xmlFree, NULL);
+
+ xml_file = ephy_file ("mime-types-permissions.xml");
+ if (xml_file == NULL) {
+ g_warning ("MIME types permissions file not found!\n");
+ return;
+ }
+
+ reader = xmlNewTextReaderFilename (xml_file);
+ if (reader == NULL) {
+ g_warning ("Could not load MIME types permissions file!\n");
+ return;
+ }
+
+ ret = xmlTextReaderRead (reader);
+ while (ret == 1) {
+ const xmlChar *tag;
+ xmlReaderTypes type;
+
+ tag = xmlTextReaderConstName (reader);
+ type = xmlTextReaderNodeType (reader);
+
+ if (xmlStrEqual (tag, (const xmlChar *)"safe") && type == XML_READER_TYPE_ELEMENT) {
+ permission = EPHY_MIME_PERMISSION_SAFE;
+ } else if (xmlStrEqual (tag, (const xmlChar *)"unsafe") && type == XML_READER_TYPE_ELEMENT) {
+ permission = EPHY_MIME_PERMISSION_UNSAFE;
+ } else if (xmlStrEqual (tag, (const xmlChar *)"mime-type")) {
+ xmlChar *t;
+
+ t = xmlTextReaderGetAttribute (reader, (const xmlChar *)"type");
+ g_hash_table_insert (mime_table, t,
+ GINT_TO_POINTER (permission));
+ }
+
+ ret = xmlTextReaderRead (reader);
+ }
+
+ xmlFreeTextReader (reader);
}
/**
@@ -649,27 +608,23 @@ load_mime_from_xml (void)
EphyMimePermission
ephy_file_check_mime (const char *mime_type)
{
- EphyMimePermission permission;
- gpointer tmp;
-
- g_return_val_if_fail (mime_type != NULL, EPHY_MIME_PERMISSION_UNKNOWN);
-
- if (mime_table == NULL)
- {
- load_mime_from_xml ();
- }
-
- tmp = g_hash_table_lookup (mime_table, mime_type);
- if (tmp == NULL)
- {
- permission = EPHY_MIME_PERMISSION_UNKNOWN;
- }
- else
- {
- permission = GPOINTER_TO_INT (tmp);
- }
-
- return permission;
+ EphyMimePermission permission;
+ gpointer tmp;
+
+ g_return_val_if_fail (mime_type != NULL, EPHY_MIME_PERMISSION_UNKNOWN);
+
+ if (mime_table == NULL) {
+ load_mime_from_xml ();
+ }
+
+ tmp = g_hash_table_lookup (mime_table, mime_type);
+ if (tmp == NULL) {
+ permission = EPHY_MIME_PERMISSION_UNKNOWN;
+ } else {
+ permission = GPOINTER_TO_INT (tmp);
+ }
+
+ return permission;
}
/**
@@ -686,36 +641,33 @@ ephy_file_check_mime (const char *mime_type)
* Returns: %TRUE if g_app_info_launch() succeeded
**/
gboolean
-ephy_file_launch_application (GAppInfo *app,
- GList *list,
- guint32 user_time,
- GtkWidget *widget)
+ephy_file_launch_application (GAppInfo *app,
+ GList *list,
+ guint32 user_time,
+ GtkWidget *widget)
{
- GdkAppLaunchContext *context;
- GdkDisplay *display;
- GdkScreen *screen;
- gboolean res;
-
- if (widget)
- {
- display = gtk_widget_get_display (widget);
- screen = gtk_widget_get_screen (widget);
- }
- else
- {
- display = gdk_display_get_default ();
- screen = gdk_screen_get_default ();
- }
-
- context = gdk_display_get_app_launch_context (display);
- gdk_app_launch_context_set_screen (context, screen);
- gdk_app_launch_context_set_timestamp (context, user_time);
-
- res = g_app_info_launch (app, list,
- G_APP_LAUNCH_CONTEXT (context), NULL);
- g_object_unref (context);
-
- return res;
+ GdkAppLaunchContext *context;
+ GdkDisplay *display;
+ GdkScreen *screen;
+ gboolean res;
+
+ if (widget) {
+ display = gtk_widget_get_display (widget);
+ screen = gtk_widget_get_screen (widget);
+ } else {
+ display = gdk_display_get_default ();
+ screen = gdk_screen_get_default ();
+ }
+
+ context = gdk_display_get_app_launch_context (display);
+ gdk_app_launch_context_set_screen (context, screen);
+ gdk_app_launch_context_set_timestamp (context, user_time);
+
+ res = g_app_info_launch (app, list,
+ G_APP_LAUNCH_CONTEXT (context), NULL);
+ g_object_unref (context);
+
+ return res;
}
/**
@@ -732,68 +684,62 @@ ephy_file_launch_application (GAppInfo *app,
**/
gboolean
ephy_file_launch_desktop_file (const char *filename,
- const char *parameter,
- guint32 user_time,
- GtkWidget *widget)
+ const char *parameter,
+ guint32 user_time,
+ GtkWidget *widget)
{
- GDesktopAppInfo *app;
- GFile *file = NULL;
- GList *list = NULL;
- gboolean ret;
-
- app = g_desktop_app_info_new (filename);
- if (parameter)
- {
- file = g_file_new_for_path (parameter);
- list = g_list_append (list, file);
- }
-
- ret = ephy_file_launch_application (G_APP_INFO (app), list, user_time, widget);
- g_list_free (list);
- if (file)
- g_object_unref (file);
- return ret;
+ GDesktopAppInfo *app;
+ GFile *file = NULL;
+ GList *list = NULL;
+ gboolean ret;
+
+ app = g_desktop_app_info_new (filename);
+ if (parameter) {
+ file = g_file_new_for_path (parameter);
+ list = g_list_append (list, file);
+ }
+
+ ret = ephy_file_launch_application (G_APP_INFO (app), list, user_time, widget);
+ g_list_free (list);
+ if (file)
+ g_object_unref (file);
+ return ret;
}
GAppInfo *
-ephy_file_launcher_get_app_info_for_file (GFile *file,
- const char *mime_type)
+ephy_file_launcher_get_app_info_for_file (GFile *file,
+ const char *mime_type)
{
- GAppInfo *app = NULL;
-
- g_return_val_if_fail (file || mime_type, FALSE);
-
- if (mime_type != NULL)
- {
- app = g_app_info_get_default_for_type (mime_type,
- FALSE);
- }
- else
- {
- GFileInfo *file_info;
- char *type;
-
- /* Sniff mime type and check if it's safe to open */
- file_info = g_file_query_info (file,
- G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
- 0, NULL, NULL);
- if (file_info == NULL)
- {
- return FALSE;
- }
- type = g_strdup (g_file_info_get_content_type (file_info));
-
- g_object_unref (file_info);
-
- if (type != NULL && type[0] != '\0' &&
- ephy_file_check_mime (type) == EPHY_MIME_PERMISSION_SAFE)
- {
- app = g_app_info_get_default_for_type (type, FALSE);
- }
- g_free (type);
- }
-
- return app;
+ GAppInfo *app = NULL;
+
+ g_return_val_if_fail (file || mime_type, FALSE);
+
+ if (mime_type != NULL) {
+ app = g_app_info_get_default_for_type (mime_type,
+ FALSE);
+ } else {
+ GFileInfo *file_info;
+ char *type;
+
+ /* Sniff mime type and check if it's safe to open */
+ file_info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+ 0, NULL, NULL);
+ if (file_info == NULL) {
+ return FALSE;
+ }
+ type = g_strdup (g_file_info_get_content_type (file_info));
+
+ g_object_unref (file_info);
+
+ if (type != NULL && type[0] != '\0' &&
+ ephy_file_check_mime (type) == EPHY_MIME_PERMISSION_SAFE) {
+ app = g_app_info_get_default_for_type (type, FALSE);
+ }
+ g_free (type);
+ }
+
+ return app;
}
/**
@@ -809,58 +755,56 @@ ephy_file_launcher_get_app_info_for_file (GFile *file,
**/
gboolean
ephy_file_launch_handler (const char *mime_type,
- GFile *file,
- guint32 user_time)
+ GFile *file,
+ guint32 user_time)
{
- GAppInfo *app = NULL;
- gboolean ret = FALSE;
+ GAppInfo *app = NULL;
+ gboolean ret = FALSE;
+
+ g_return_val_if_fail (file != NULL, FALSE);
- g_return_val_if_fail (file != NULL, FALSE);
+ app = ephy_file_launcher_get_app_info_for_file (file, mime_type);
- app = ephy_file_launcher_get_app_info_for_file (file, mime_type);
+ if (app != NULL) {
+ GList *list = NULL;
- if (app != NULL)
- {
- GList *list = NULL;
-
- list = g_list_append (list, file);
- ret = ephy_file_launch_application (app, list, user_time, NULL);
- g_list_free (list);
- }
+ list = g_list_append (list, file);
+ ret = ephy_file_launch_application (app, list, user_time, NULL);
+ g_list_free (list);
+ }
- return ret;
+ return ret;
}
gboolean
ephy_file_open_uri_in_default_browser (const char *uri,
- guint32 timestamp,
- GdkScreen *screen)
+ guint32 timestamp,
+ GdkScreen *screen)
{
- GdkAppLaunchContext *context;
- GAppInfo *appinfo;
- GList uris;
- gboolean retval = TRUE;
- GError *error = NULL;
-
- context = gdk_display_get_app_launch_context (screen ? gdk_screen_get_display (screen) : gdk_display_get_default ());
- gdk_app_launch_context_set_screen (context, screen);
- gdk_app_launch_context_set_timestamp (context, timestamp);
-
- appinfo = g_app_info_get_default_for_type ("x-scheme-handler/http", TRUE);
- uris.data = (gpointer)uri;
- uris.next = uris.prev = NULL;
-
- if (!g_app_info_launch_uris (appinfo, &uris, G_APP_LAUNCH_CONTEXT (context), &error))
- {
- g_warning ("Failed to launch %s: %s", uri, error->message);
- g_error_free (error);
- retval = FALSE;
- }
-
- g_object_unref (context);
- g_object_unref (appinfo);
-
- return retval;
+ GdkAppLaunchContext *context;
+ GAppInfo *appinfo;
+ GList uris;
+ gboolean retval = TRUE;
+ GError *error = NULL;
+
+ context = gdk_display_get_app_launch_context (screen ? gdk_screen_get_display (screen) : gdk_display_get_default ());
+ gdk_app_launch_context_set_screen (context, screen);
+ gdk_app_launch_context_set_timestamp (context, timestamp);
+
+ appinfo = g_app_info_get_default_for_type ("x-scheme-handler/http", TRUE);
+ uris.data = (gpointer)uri;
+ uris.next = uris.prev = NULL;
+
+ if (!g_app_info_launch_uris (appinfo, &uris, G_APP_LAUNCH_CONTEXT (context), &error)) {
+ g_warning ("Failed to launch %s: %s", uri, error->message);
+ g_error_free (error);
+ retval = FALSE;
+ }
+
+ g_object_unref (context);
+ g_object_unref (appinfo);
+
+ return retval;
}
/**
@@ -875,10 +819,10 @@ ephy_file_open_uri_in_default_browser (const char *uri,
* Returns: %TRUE if the launch succeeded
**/
gboolean
-ephy_file_browse_to (GFile *file,
- guint32 user_time)
+ephy_file_browse_to (GFile *file,
+ guint32 user_time)
{
- return ephy_file_launch_handler ("inode/directory", file, user_time);
+ return ephy_file_launch_handler ("inode/directory", file, user_time);
}
/**
@@ -893,60 +837,54 @@ ephy_file_browse_to (GFile *file,
gboolean
ephy_file_delete_dir_recursively (const char *directory, GError **error)
{
- GDir* dir;
- const char* file_name;
- gboolean failed = FALSE;
-
- dir = g_dir_open (directory, 0, error);
- if (!dir)
- return FALSE;
-
- file_name = g_dir_read_name (dir);
- while (file_name && !failed) {
- char *file_path;
-
- file_path = g_build_filename (directory, file_name, NULL);
- if (g_file_test (file_path, G_FILE_TEST_IS_DIR))
- {
- failed = !ephy_file_delete_dir_recursively (file_path, error);
- }
- else
- {
- int result = g_unlink (file_path);
-
- if (result == -1)
- {
- int errsv = errno;
-
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errsv),
- "Error removing file %s: %s",
- file_path, g_strerror (errsv));
- failed = TRUE;
- }
- }
- g_free (file_path);
- file_name = g_dir_read_name (dir);
- }
- g_dir_close (dir);
-
- if (!failed)
- {
- int result = g_rmdir (directory);
-
- if (result == -1)
- {
- int errsv = errno;
-
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errsv),
- "Error removing directory %s: %s",
- directory, g_strerror (errsv));
- failed = TRUE;
- }
- }
-
- return !failed;
+ GDir *dir;
+ const char *file_name;
+ gboolean failed = FALSE;
+
+ dir = g_dir_open (directory, 0, error);
+ if (!dir)
+ return FALSE;
+
+ file_name = g_dir_read_name (dir);
+ while (file_name && !failed) {
+ char *file_path;
+
+ file_path = g_build_filename (directory, file_name, NULL);
+ if (g_file_test (file_path, G_FILE_TEST_IS_DIR)) {
+ failed = !ephy_file_delete_dir_recursively (file_path, error);
+ } else {
+ int result = g_unlink (file_path);
+
+ if (result == -1) {
+ int errsv = errno;
+
+ g_set_error (error, G_IO_ERROR,
+ g_io_error_from_errno (errsv),
+ "Error removing file %s: %s",
+ file_path, g_strerror (errsv));
+ failed = TRUE;
+ }
+ }
+ g_free (file_path);
+ file_name = g_dir_read_name (dir);
+ }
+ g_dir_close (dir);
+
+ if (!failed) {
+ int result = g_rmdir (directory);
+
+ if (result == -1) {
+ int errsv = errno;
+
+ g_set_error (error, G_IO_ERROR,
+ g_io_error_from_errno (errsv),
+ "Error removing directory %s: %s",
+ directory, g_strerror (errsv));
+ failed = TRUE;
+ }
+ }
+
+ return !failed;
}
/**
@@ -958,24 +896,21 @@ ephy_file_delete_dir_recursively (const char *directory, GError **error)
void
ephy_file_delete_uri (const char *uri)
{
- GFile *file;
- gboolean ret;
+ GFile *file;
+ gboolean ret;
- g_return_if_fail (uri);
+ g_return_if_fail (uri);
- file = g_file_new_for_uri (uri);
+ file = g_file_new_for_uri (uri);
- ret = g_file_delete (file, NULL, NULL);
+ ret = g_file_delete (file, NULL, NULL);
- if (ret == TRUE)
- {
- LOG ("Deleted file at URI '%s'", uri);
- }
- else
- {
- LOG ("Couldn't file at URI '%s'", uri);
- }
- g_object_unref (file);
+ if (ret == TRUE) {
+ LOG ("Deleted file at URI '%s'", uri);
+ } else {
+ LOG ("Couldn't file at URI '%s'", uri);
+ }
+ g_object_unref (file);
}
/**
@@ -990,29 +925,26 @@ ephy_file_delete_uri (const char *uri)
gboolean
ephy_file_move_uri (const char *source_uri, const char *dest_uri)
{
- GFile *src;
- GFile *dest;
- gboolean ret;
-
- g_return_val_if_fail (source_uri && dest_uri, FALSE);
-
- src = g_file_new_for_uri (source_uri);
- dest = g_file_new_for_uri (dest_uri);
-
- ret = g_file_move (src, dest, G_FILE_COPY_OVERWRITE | G_FILE_COPY_ALL_METADATA,
- NULL, NULL, NULL, NULL);
-
- if (ret == TRUE)
- {
- LOG ("Moved file '%s' to '%s'", source_uri, dest_uri);
- }
- else
- {
- LOG ("Couldn't move file '%s' to '%s'", source_uri, dest_uri);
- }
- g_object_unref (src);
- g_object_unref (dest);
- return ret;
+ GFile *src;
+ GFile *dest;
+ gboolean ret;
+
+ g_return_val_if_fail (source_uri && dest_uri, FALSE);
+
+ src = g_file_new_for_uri (source_uri);
+ dest = g_file_new_for_uri (dest_uri);
+
+ ret = g_file_move (src, dest, G_FILE_COPY_OVERWRITE | G_FILE_COPY_ALL_METADATA,
+ NULL, NULL, NULL, NULL);
+
+ if (ret == TRUE) {
+ LOG ("Moved file '%s' to '%s'", source_uri, dest_uri);
+ } else {
+ LOG ("Couldn't move file '%s' to '%s'", source_uri, dest_uri);
+ }
+ g_object_unref (src);
+ g_object_unref (dest);
+ return ret;
}
/**
@@ -1029,42 +961,42 @@ ephy_file_move_uri (const char *source_uri, const char *dest_uri)
*/
char *
ephy_file_create_data_uri_for_filename (const char *filename,
- const char *mime_type)
+ const char *mime_type)
{
- gchar *data;
- gsize data_length;
- gchar *base64;
- gchar *uri = NULL;
- GFileInfo *file_info = NULL;
+ gchar *data;
+ gsize data_length;
+ gchar *base64;
+ gchar *uri = NULL;
+ GFileInfo *file_info = NULL;
- g_return_val_if_fail (filename != NULL, NULL);
+ g_return_val_if_fail (filename != NULL, NULL);
- if (!g_file_get_contents (filename, &data, &data_length, NULL))
- return NULL;
+ if (!g_file_get_contents (filename, &data, &data_length, NULL))
+ return NULL;
- base64 = g_base64_encode ((const guchar *)data, data_length);
- g_free (data);
+ base64 = g_base64_encode ((const guchar *)data, data_length);
+ g_free (data);
- if (!mime_type) {
- GFile *file;
+ if (!mime_type) {
+ GFile *file;
- file = g_file_new_for_path (filename);
- file_info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
- G_FILE_QUERY_INFO_NONE, NULL, NULL);
- if (file_info)
- mime_type = g_file_info_get_content_type (file_info);
+ file = g_file_new_for_path (filename);
+ file_info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+ G_FILE_QUERY_INFO_NONE, NULL, NULL);
+ if (file_info)
+ mime_type = g_file_info_get_content_type (file_info);
- g_object_unref (file);
- }
+ g_object_unref (file);
+ }
- if (mime_type)
- uri = g_strdup_printf ("data:%s;charset=utf8;base64,%s", mime_type, base64);
- g_free(base64);
+ if (mime_type)
+ uri = g_strdup_printf ("data:%s;charset=utf8;base64,%s", mime_type, base64);
+ g_free (base64);
- if (file_info)
- g_object_unref (file_info);
+ if (file_info)
+ g_object_unref (file_info);
- return uri;
+ return uri;
}
/**
@@ -1083,31 +1015,31 @@ ephy_file_create_data_uri_for_filename (const char *filename,
char *
ephy_sanitize_filename (char *filename)
{
- g_return_val_if_fail (filename != NULL, NULL);
+ g_return_val_if_fail (filename != NULL, NULL);
- return g_strdelimit (filename, G_DIR_SEPARATOR_S, '_');
+ return g_strdelimit (filename, G_DIR_SEPARATOR_S, '_');
}
void
ephy_open_incognito_window (const char *uri)
{
- char *command;
- GError *error = NULL;
+ char *command;
+ GError *error = NULL;
- command = g_strdup_printf ("epiphany --incognito-mode --profile %s ", ephy_dot_dir ());
+ command = g_strdup_printf ("epiphany --incognito-mode --profile %s ", ephy_dot_dir ());
- if (uri) {
- char *str = g_strconcat (command, uri, NULL);
- g_free (command);
- command = str;
- }
+ if (uri) {
+ char *str = g_strconcat (command, uri, NULL);
+ g_free (command);
+ command = str;
+ }
- g_spawn_command_line_async (command, &error);
+ g_spawn_command_line_async (command, &error);
- if (error) {
- g_warning ("Couldn't open link in incognito window: %s", error->message);
- g_error_free (error);
- }
+ if (error) {
+ g_warning ("Couldn't open link in incognito window: %s", error->message);
+ g_error_free (error);
+ }
- g_free (command);
+ g_free (command);
}
diff --git a/lib/ephy-form-auth-data.c b/lib/ephy-form-auth-data.c
index 020c13af5..7985e31d3 100644
--- a/lib/ephy-form-auth-data.c
+++ b/lib/ephy-form-auth-data.c
@@ -42,8 +42,8 @@ ephy_form_auth_data_get_password_schema (void)
}
static void
-normalize_and_prepare_uri (SoupURI *uri,
- gboolean remove_path)
+normalize_and_prepare_uri (SoupURI *uri,
+ gboolean remove_path)
{
g_assert (uri != NULL);
@@ -81,8 +81,8 @@ ephy_form_auth_data_get_secret_attributes_table (const char *uri,
static void
store_form_password_cb (SecretService *service,
- GAsyncResult *res,
- GTask *task)
+ GAsyncResult *res,
+ GTask *task)
{
GError *error = NULL;
@@ -96,13 +96,13 @@ store_form_password_cb (SecretService *service,
}
void
-ephy_form_auth_data_store (const char *uri,
- const char *form_username,
- const char *form_password,
- const char *username,
- const char *password,
+ephy_form_auth_data_store (const char *uri,
+ const char *form_username,
+ const char *form_password,
+ const char *username,
+ const char *password,
GAsyncReadyCallback callback,
- gpointer userdata)
+ gpointer userdata)
{
SoupURI *fake_uri;
char *fake_uri_str;
@@ -160,7 +160,7 @@ ephy_form_auth_data_store (const char *uri,
gboolean
ephy_form_auth_data_store_finish (GAsyncResult *result,
- GError **error)
+ GError **error)
{
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
g_return_val_if_fail (g_task_is_valid (result, NULL), FALSE);
@@ -168,8 +168,7 @@ ephy_form_auth_data_store_finish (GAsyncResult *result,
return g_task_propagate_boolean (G_TASK (result), error);
}
-typedef struct
-{
+typedef struct {
EphyFormAuthDataQueryCallback callback;
gpointer data;
GDestroyNotify destroy_data;
@@ -185,13 +184,13 @@ ephy_form_auth_data_query_closure_free (EphyFormAuthDataQueryClosure *closure)
}
static void
-search_form_data_cb (SecretService *service,
- GAsyncResult *res,
+search_form_data_cb (SecretService *service,
+ GAsyncResult *res,
EphyFormAuthDataQueryClosure *closure)
{
GList *results;
SecretItem *item;
- const char* username = NULL, *password = NULL;
+ const char *username = NULL, *password = NULL;
SecretValue *value = NULL;
GHashTable *attributes = NULL;
GError *error = NULL;
@@ -206,7 +205,7 @@ search_form_data_cb (SecretService *service,
if (!results)
goto out;
- item = (SecretItem*)results->data;
+ item = (SecretItem *)results->data;
attributes = secret_item_get_attributes (item);
username = g_hash_table_lookup (attributes, USERNAME_KEY);
value = secret_item_get_secret (item);
@@ -214,7 +213,7 @@ search_form_data_cb (SecretService *service,
g_list_free_full (results, (GDestroyNotify)g_object_unref);
-out:
+ out:
if (closure->callback)
closure->callback (username, password, closure->data);
@@ -227,13 +226,13 @@ out:
}
void
-ephy_form_auth_data_query (const char *uri,
- const char *form_username,
- const char *form_password,
- const char *username,
+ephy_form_auth_data_query (const char *uri,
+ const char *form_username,
+ const char *form_password,
+ const char *username,
EphyFormAuthDataQueryCallback callback,
- gpointer user_data,
- GDestroyNotify destroy_data)
+ gpointer user_data,
+ GDestroyNotify destroy_data)
{
SoupURI *key;
char *key_str;
@@ -301,8 +300,8 @@ ephy_form_auth_data_free (EphyFormAuthData *data)
}
static void
-screcet_service_search_finished (SecretService *service,
- GAsyncResult *result,
+screcet_service_search_finished (SecretService *service,
+ GAsyncResult *result,
EphyFormAuthDataCache *cache)
{
GList *results, *p;
@@ -391,10 +390,10 @@ ephy_form_auth_data_cache_free (EphyFormAuthDataCache *cache)
void
ephy_form_auth_data_cache_add (EphyFormAuthDataCache *cache,
- const char *uri,
- const char *form_username,
- const char *form_password,
- const char *username)
+ const char *uri,
+ const char *form_username,
+ const char *form_password,
+ const char *username)
{
EphyFormAuthData *data;
GSList *l;
@@ -412,7 +411,7 @@ ephy_form_auth_data_cache_add (EphyFormAuthDataCache *cache,
GSList *
ephy_form_auth_data_cache_get_list (EphyFormAuthDataCache *cache,
- const char *uri)
+ const char *uri)
{
g_return_val_if_fail (cache, NULL);
g_return_val_if_fail (uri, NULL);
diff --git a/lib/ephy-gui.c b/lib/ephy-gui.c
index 331d3d12b..bc5bc777b 100644
--- a/lib/ephy-gui.c
+++ b/lib/ephy-gui.c
@@ -28,70 +28,69 @@
#include <unistd.h>
void
-ephy_gui_sanitise_popup_position (GtkMenu *menu,
- GtkWidget *widget,
- gint *x,
- gint *y)
+ephy_gui_sanitise_popup_position (GtkMenu *menu,
+ GtkWidget *widget,
+ gint *x,
+ gint *y)
{
- GdkScreen *screen = gtk_widget_get_screen (widget);
- gint monitor_num;
- GdkRectangle monitor;
- GtkRequisition req;
+ GdkScreen *screen = gtk_widget_get_screen (widget);
+ gint monitor_num;
+ GdkRectangle monitor;
+ GtkRequisition req;
- g_return_if_fail (widget != NULL);
+ g_return_if_fail (widget != NULL);
- gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
- monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
- gtk_menu_set_monitor (menu, monitor_num);
- gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+ monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
+ gtk_menu_set_monitor (menu, monitor_num);
+ gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
- *x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width));
- *y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));
+ *x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width));
+ *y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));
}
void
-ephy_gui_menu_position_tree_selection (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data)
+ephy_gui_menu_position_tree_selection (GtkMenu *menu,
+ gint *x,
+ gint *y,
+ gboolean *push_in,
+ gpointer user_data)
{
- GtkTreeSelection *selection;
- GList *selected_rows;
- GtkTreeModel *model;
- GtkTreeView *tree_view = GTK_TREE_VIEW (user_data);
- GtkWidget *widget = GTK_WIDGET (user_data);
- GtkRequisition req;
- GtkAllocation allocation;
- GdkRectangle visible;
+ GtkTreeSelection *selection;
+ GList *selected_rows;
+ GtkTreeModel *model;
+ GtkTreeView *tree_view = GTK_TREE_VIEW (user_data);
+ GtkWidget *widget = GTK_WIDGET (user_data);
+ GtkRequisition req;
+ GtkAllocation allocation;
+ GdkRectangle visible;
- gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
- gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
- gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
+ gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
+ gtk_widget_get_allocation (widget, &allocation);
- *x += (allocation.width - req.width) / 2;
+ *x += (allocation.width - req.width) / 2;
- /* Add on height for the treeview title */
- gtk_tree_view_get_visible_rect (tree_view, &visible);
- *y += allocation.height - visible.height;
+ /* Add on height for the treeview title */
+ gtk_tree_view_get_visible_rect (tree_view, &visible);
+ *y += allocation.height - visible.height;
- selection = gtk_tree_view_get_selection (tree_view);
- selected_rows = gtk_tree_selection_get_selected_rows (selection, &model);
- if (selected_rows)
- {
- GdkRectangle cell_rect;
+ selection = gtk_tree_view_get_selection (tree_view);
+ selected_rows = gtk_tree_selection_get_selected_rows (selection, &model);
+ if (selected_rows) {
+ GdkRectangle cell_rect;
- gtk_tree_view_get_cell_area (tree_view, selected_rows->data,
- NULL, &cell_rect);
+ gtk_tree_view_get_cell_area (tree_view, selected_rows->data,
+ NULL, &cell_rect);
- *y += CLAMP (cell_rect.y + cell_rect.height, 0, visible.height);
+ *y += CLAMP (cell_rect.y + cell_rect.height, 0, visible.height);
- g_list_foreach (selected_rows, (GFunc)gtk_tree_path_free, NULL);
- g_list_free (selected_rows);
- }
+ g_list_foreach (selected_rows, (GFunc)gtk_tree_path_free, NULL);
+ g_list_free (selected_rows);
+ }
- ephy_gui_sanitise_popup_position (menu, widget, x, y);
+ ephy_gui_sanitise_popup_position (menu, widget, x, y);
}
/**
@@ -101,167 +100,160 @@ ephy_gui_menu_position_tree_selection (GtkMenu *menu,
* @y:
* @push_in:
* @user_data: a #GtkWidget
- *
+ *
* Positions @menu under (or over, depending on space available) the widget
* @user_data.
*/
void
-ephy_gui_menu_position_under_widget (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data)
+ephy_gui_menu_position_under_widget (GtkMenu *menu,
+ gint *x,
+ gint *y,
+ gboolean *push_in,
+ gpointer user_data)
{
- /* Adapted from gtktoolbar.c */
- GtkWidget *widget = GTK_WIDGET (user_data);
- GtkWidget *container;
- GtkRequisition req;
- GtkRequisition menu_req;
- GtkAllocation allocation;
- GdkRectangle monitor;
- GdkWindow *window;
- int monitor_num;
- GdkScreen *screen;
-
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- container = gtk_widget_get_ancestor (widget, GTK_TYPE_CONTAINER);
- g_return_if_fail (container != NULL);
-
- gtk_widget_get_preferred_size (widget, &req, NULL);
- gtk_widget_get_preferred_size (GTK_WIDGET (menu), &menu_req, NULL);
-
- screen = gtk_widget_get_screen (GTK_WIDGET (menu));
- window = gtk_widget_get_window (widget);
- monitor_num = gdk_screen_get_monitor_at_window (screen, window);
- if (monitor_num < 0)
- monitor_num = 0;
- gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
-
- gtk_widget_get_allocation (widget, &allocation);
- gdk_window_get_origin (window, x, y);
- if (!gtk_widget_get_has_window (widget))
- {
- *x += allocation.x;
- *y += allocation.y;
- }
-
- if (gtk_widget_get_direction (container) == GTK_TEXT_DIR_LTR)
- *x += allocation.width - req.width;
- else
- *x += req.width - menu_req.width;
-
- if ((*y + allocation.height + menu_req.height) <= monitor.y + monitor.height)
- *y += allocation.height;
- else if ((*y - menu_req.height) >= monitor.y)
- *y -= menu_req.height;
- else if (monitor.y + monitor.height - (*y + allocation.height) > *y)
- *y += allocation.height;
- else
- *y -= menu_req.height;
-
- *push_in = FALSE;
+ /* Adapted from gtktoolbar.c */
+ GtkWidget *widget = GTK_WIDGET (user_data);
+ GtkWidget *container;
+ GtkRequisition req;
+ GtkRequisition menu_req;
+ GtkAllocation allocation;
+ GdkRectangle monitor;
+ GdkWindow *window;
+ int monitor_num;
+ GdkScreen *screen;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ container = gtk_widget_get_ancestor (widget, GTK_TYPE_CONTAINER);
+ g_return_if_fail (container != NULL);
+
+ gtk_widget_get_preferred_size (widget, &req, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu), &menu_req, NULL);
+
+ screen = gtk_widget_get_screen (GTK_WIDGET (menu));
+ window = gtk_widget_get_window (widget);
+ monitor_num = gdk_screen_get_monitor_at_window (screen, window);
+ if (monitor_num < 0)
+ monitor_num = 0;
+ gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+
+ gtk_widget_get_allocation (widget, &allocation);
+ gdk_window_get_origin (window, x, y);
+ if (!gtk_widget_get_has_window (widget)) {
+ *x += allocation.x;
+ *y += allocation.y;
+ }
+
+ if (gtk_widget_get_direction (container) == GTK_TEXT_DIR_LTR)
+ *x += allocation.width - req.width;
+ else
+ *x += req.width - menu_req.width;
+
+ if ((*y + allocation.height + menu_req.height) <= monitor.y + monitor.height)
+ *y += allocation.height;
+ else if ((*y - menu_req.height) >= monitor.y)
+ *y -= menu_req.height;
+ else if (monitor.y + monitor.height - (*y + allocation.height) > *y)
+ *y += allocation.height;
+ else
+ *y -= menu_req.height;
+
+ *push_in = FALSE;
}
GtkWindowGroup *
ephy_gui_ensure_window_group (GtkWindow *window)
{
- GtkWindowGroup *group;
+ GtkWindowGroup *group;
- group = gtk_window_get_group (window);
- if (group == NULL)
- {
- group = gtk_window_group_new ();
- gtk_window_group_add_window (group, window);
- g_object_unref (group);
- }
+ group = gtk_window_get_group (window);
+ if (group == NULL) {
+ group = gtk_window_group_new ();
+ gtk_window_group_add_window (group, window);
+ g_object_unref (group);
+ }
- return group;
+ return group;
}
gboolean
-ephy_gui_check_location_writable (GtkWidget *parent,
- const char *filename)
+ephy_gui_check_location_writable (GtkWidget *parent,
+ const char *filename)
{
- GtkWidget *dialog;
- char *display_name;
+ GtkWidget *dialog;
+ char *display_name;
- if (filename == NULL) return FALSE;
+ if (filename == NULL) return FALSE;
- if (!g_file_test (filename, G_FILE_TEST_EXISTS))
- {
- char *path = g_path_get_dirname (filename);
- gboolean writable = access (path, W_OK) == 0;
+ if (!g_file_test (filename, G_FILE_TEST_EXISTS)) {
+ char *path = g_path_get_dirname (filename);
+ gboolean writable = access (path, W_OK) == 0;
- /* check if path is writable to */
- if (!writable)
- {
- dialog = gtk_message_dialog_new (
- parent ? GTK_WINDOW(parent) : NULL,
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- _("Directory “%s” is not writable"), path);
+ /* check if path is writable to */
+ if (!writable) {
+ dialog = gtk_message_dialog_new (
+ parent ? GTK_WINDOW (parent) : NULL,
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("Directory “%s” is not writable"), path);
- gtk_message_dialog_format_secondary_text (
- GTK_MESSAGE_DIALOG (dialog),
- _("You do not have permission to "
- "create files in this directory."));
+ gtk_message_dialog_format_secondary_text (
+ GTK_MESSAGE_DIALOG (dialog),
+ _("You do not have permission to "
+ "create files in this directory."));
- gtk_window_set_title (GTK_WINDOW (dialog), _("Directory not Writable"));
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Directory not Writable"));
- if (parent != NULL)
- {
- gtk_window_group_add_window (
- ephy_gui_ensure_window_group (GTK_WINDOW (parent)),
- GTK_WINDOW (dialog));
- }
+ if (parent != NULL) {
+ gtk_window_group_add_window (
+ ephy_gui_ensure_window_group (GTK_WINDOW (parent)),
+ GTK_WINDOW (dialog));
+ }
- gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- }
+ gtk_widget_destroy (dialog);
+ }
- g_free (path);
+ g_free (path);
- return writable;
- }
+ return writable;
+ }
- display_name = g_filename_display_basename (filename);
+ display_name = g_filename_display_basename (filename);
- /* check if file is writable */
- if (access (filename, W_OK) != 0)
- {
- dialog = gtk_message_dialog_new (
- parent ? GTK_WINDOW(parent) : NULL,
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- _("Cannot overwrite existing file “%s”"), display_name);
+ /* check if file is writable */
+ if (access (filename, W_OK) != 0) {
+ dialog = gtk_message_dialog_new (
+ parent ? GTK_WINDOW (parent) : NULL,
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("Cannot overwrite existing file “%s”"), display_name);
- gtk_message_dialog_format_secondary_text (
- GTK_MESSAGE_DIALOG (dialog),
- _("A file with this name already exists and "
- "you don't have permission to overwrite it."));
+ gtk_message_dialog_format_secondary_text (
+ GTK_MESSAGE_DIALOG (dialog),
+ _("A file with this name already exists and "
+ "you don't have permission to overwrite it."));
- gtk_window_set_title (GTK_WINDOW (dialog), _("Cannot Overwrite File"));
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Cannot Overwrite File"));
- if (parent != NULL)
- {
- gtk_window_group_add_window (
- ephy_gui_ensure_window_group (GTK_WINDOW (parent)),
- GTK_WINDOW (dialog));
- }
+ if (parent != NULL) {
+ gtk_window_group_add_window (
+ ephy_gui_ensure_window_group (GTK_WINDOW (parent)),
+ GTK_WINDOW (dialog));
+ }
- gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_widget_destroy (dialog);
- return FALSE;
- }
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
/**
@@ -275,130 +267,119 @@ ephy_gui_check_location_writable (GtkWidget *parent,
* window.
**/
void
-ephy_gui_help (GtkWidget *parent,
- const char *page)
+ephy_gui_help (GtkWidget *parent,
+ const char *page)
{
- GError *error = NULL;
- GdkScreen *screen;
- char *url;
-
- if (page)
- url = g_strdup_printf ("help:epiphany/%s", page);
- else
- url = g_strdup ("help:epiphany");
-
- if (parent)
- screen = gtk_widget_get_screen (parent);
- else
- screen = gdk_screen_get_default ();
-
- gtk_show_uri (screen, url, gtk_get_current_event_time (), &error);
-
- if (error != NULL)
- {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("Could not display help: %s"),
- error->message);
- g_error_free (error);
-
- g_signal_connect (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
- gtk_widget_show (dialog);
- }
-
- g_free (url);
+ GError *error = NULL;
+ GdkScreen *screen;
+ char *url;
+
+ if (page)
+ url = g_strdup_printf ("help:epiphany/%s", page);
+ else
+ url = g_strdup ("help:epiphany");
+
+ if (parent)
+ screen = gtk_widget_get_screen (parent);
+ else
+ screen = gdk_screen_get_default ();
+
+ gtk_show_uri (screen, url, gtk_get_current_event_time (), &error);
+
+ if (error != NULL) {
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("Could not display help: %s"),
+ error->message);
+ g_error_free (error);
+
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (gtk_widget_destroy), NULL);
+ gtk_widget_show (dialog);
+ }
+
+ g_free (url);
}
void
ephy_gui_get_current_event (GdkEventType *otype,
- guint *ostate,
- guint *obutton)
+ guint *ostate,
+ guint *obutton)
{
- GdkEvent *event;
- GdkEventType type = GDK_NOTHING;
- guint state = 0, button = (guint) -1;
-
- event = gtk_get_current_event ();
- if (event != NULL)
- {
- type = event->type;
-
- if (type == GDK_KEY_PRESS ||
- type == GDK_KEY_RELEASE)
- {
- state = event->key.state;
- }
- else if (type == GDK_BUTTON_PRESS ||
- type == GDK_BUTTON_RELEASE ||
- type == GDK_2BUTTON_PRESS ||
- type == GDK_3BUTTON_PRESS)
- {
- button = event->button.button;
- state = event->button.state;
- }
-
- gdk_event_free (event);
- }
-
- if (otype) *otype = type;
- if (ostate) *ostate = state & gtk_accelerator_get_default_mod_mask ();
- if (obutton) *obutton = button;
+ GdkEvent *event;
+ GdkEventType type = GDK_NOTHING;
+ guint state = 0, button = (guint) - 1;
+
+ event = gtk_get_current_event ();
+ if (event != NULL) {
+ type = event->type;
+
+ if (type == GDK_KEY_PRESS ||
+ type == GDK_KEY_RELEASE) {
+ state = event->key.state;
+ } else if (type == GDK_BUTTON_PRESS ||
+ type == GDK_BUTTON_RELEASE ||
+ type == GDK_2BUTTON_PRESS ||
+ type == GDK_3BUTTON_PRESS) {
+ button = event->button.button;
+ state = event->button.state;
+ }
+
+ gdk_event_free (event);
+ }
+
+ if (otype) *otype = type;
+ if (ostate) *ostate = state & gtk_accelerator_get_default_mod_mask ();
+ if (obutton) *obutton = button;
}
gboolean
ephy_gui_is_middle_click (void)
{
- gboolean is_middle_click = FALSE;
- GdkEvent *event;
-
- event = gtk_get_current_event ();
- if (event != NULL)
- {
- if (event->type == GDK_BUTTON_RELEASE)
- {
- guint modifiers, button, state;
-
- modifiers = gtk_accelerator_get_default_mod_mask ();
- button = event->button.button;
- state = event->button.state;
-
- /* middle-click or control-click */
- if ((button == 1 && ((state & modifiers) == GDK_CONTROL_MASK)) ||
- (button == 2 && ((state & modifiers) == 0)))
- {
- is_middle_click = TRUE;
- }
- }
-
- gdk_event_free (event);
- }
-
- return is_middle_click;
+ gboolean is_middle_click = FALSE;
+ GdkEvent *event;
+
+ event = gtk_get_current_event ();
+ if (event != NULL) {
+ if (event->type == GDK_BUTTON_RELEASE) {
+ guint modifiers, button, state;
+
+ modifiers = gtk_accelerator_get_default_mod_mask ();
+ button = event->button.button;
+ state = event->button.state;
+
+ /* middle-click or control-click */
+ if ((button == 1 && ((state & modifiers) == GDK_CONTROL_MASK)) ||
+ (button == 2 && ((state & modifiers) == 0))) {
+ is_middle_click = TRUE;
+ }
+ }
+
+ gdk_event_free (event);
+ }
+
+ return is_middle_click;
}
void
ephy_gui_window_update_user_time (GtkWidget *window,
- guint32 user_time)
+ guint32 user_time)
{
- LOG ("updating user time on window %p to %d", window, user_time);
+ LOG ("updating user time on window %p to %d", window, user_time);
- if (user_time != 0)
- {
- gtk_widget_realize (window);
+ if (user_time != 0) {
+ gtk_widget_realize (window);
#ifdef GDK_WINDOWING_X11
- if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
- {
- gdk_x11_window_set_user_time (gtk_widget_get_window (window),
- user_time);
- }
+ if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+ gdk_x11_window_set_user_time (gtk_widget_get_window (window),
+ user_time);
+ }
#endif
- }
-
+ }
}
diff --git a/lib/ephy-initial-state.c b/lib/ephy-initial-state.c
index 99cbb3873..2b4aa18a1 100644
--- a/lib/ephy-initial-state.c
+++ b/lib/ephy-initial-state.c
@@ -33,8 +33,7 @@
#define EPHY_STATES_XML_ROOT (const xmlChar *)"ephy_states"
#define EPHY_STATES_XML_VERSION (const xmlChar *)"1.0"
-enum
-{
+enum {
EPHY_NODE_INITIAL_STATE_PROP_NAME = 2,
EPHY_NODE_INITIAL_STATE_PROP_WIDTH = 3,
EPHY_NODE_INITIAL_STATE_PROP_HEIGHT = 4,
@@ -58,15 +57,15 @@ ephy_states_save (void)
EPHY_STATES_XML_FILE,
NULL);
- ephy_node_db_write_to_xml_safe (states_db,
+ ephy_node_db_write_to_xml_safe (states_db,
(const xmlChar *)xml_file,
EPHY_STATES_XML_ROOT,
EPHY_STATES_XML_VERSION,
NULL, /* comment */
states, NULL, NULL,
NULL);
-
- g_free (xml_file);
+
+ g_free (xml_file);
}
static EphyNode *
@@ -84,7 +83,7 @@ find_by_name (const char *name)
kid = g_ptr_array_index (children, i);
node_name = ephy_node_get_property_string
- (kid, EPHY_NODE_INITIAL_STATE_PROP_NAME);
+ (kid, EPHY_NODE_INITIAL_STATE_PROP_NAME);
if (strcmp (node_name, name) == 0)
result = kid;
@@ -108,7 +107,7 @@ ensure_states (void)
ephy_node_db_load_from_file (states_db, xml_file,
EPHY_STATES_XML_ROOT,
EPHY_STATES_XML_VERSION);
-
+
g_free (xml_file);
}
}
@@ -165,7 +164,7 @@ ephy_state_window_set_position (GtkWidget *window, EphyNode *node)
y = ephy_node_get_property_int (node, EPHY_NODE_INITIAL_STATE_PROP_POSITION_Y);
screen = gtk_window_get_screen (GTK_WINDOW (window));
- screen_width = gdk_screen_get_width (screen);
+ screen_width = gdk_screen_get_width (screen);
screen_height = gdk_screen_get_height (screen);
if ((x <= screen_width) && (y <= screen_height) &&
@@ -207,12 +206,12 @@ ephy_state_window_save_size (GtkWidget *window, EphyNode *node)
state = gdk_window_get_state (gtk_widget_get_window (GTK_WIDGET (window)));
maximize = ((state & GDK_WINDOW_STATE_MAXIMIZED) > 0);
- gtk_window_get_size (GTK_WINDOW(window),
+ gtk_window_get_size (GTK_WINDOW (window),
&width, &height);
if (!maximize)
ephy_state_save_unmaximized_size (node, width, height);
-
+
ephy_node_set_property_boolean (node,
EPHY_NODE_INITIAL_STATE_PROP_MAXIMIZE,
maximize);
@@ -221,7 +220,7 @@ ephy_state_window_save_size (GtkWidget *window, EphyNode *node)
static void
ephy_state_window_save_position (GtkWidget *window, EphyNode *node)
{
- int x,y;
+ int x, y;
gboolean maximize;
GdkWindowState state;
@@ -250,9 +249,9 @@ ephy_state_window_save (GtkWidget *widget, EphyNode *node)
}
static gboolean
-window_configure_event_cb (GtkWidget *widget,
+window_configure_event_cb (GtkWidget *widget,
GdkEventConfigure *event,
- EphyNode *node)
+ EphyNode *node)
{
GdkWindowState state;
@@ -265,9 +264,9 @@ window_configure_event_cb (GtkWidget *widget,
}
static gboolean
-window_state_event_cb (GtkWidget *widget,
+window_state_event_cb (GtkWidget *widget,
GdkEventWindowState *event,
- EphyNode *node)
+ EphyNode *node)
{
if (!(event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN))
ephy_state_window_save (widget, node);
@@ -276,10 +275,10 @@ window_state_event_cb (GtkWidget *widget,
}
static EphyNode *
-create_window_node (const char *name,
- int default_width,
- int default_height,
- gboolean maximize,
+create_window_node (const char *name,
+ int default_width,
+ int default_height,
+ gboolean maximize,
EphyInitialStateWindowFlags flags)
{
EphyNode *node;
@@ -315,21 +314,21 @@ create_window_node (const char *name,
* @default_height: the default height we want to give it
* @maximize: whether it should be maximized by default
* @flags: #EphyInitialStateWindowFlags defining what state we want to saze
- *
+ *
* This method will set the correct default size and position for
* @window given the previously stored state information for its type
* (defined by @name). If there's no data available, the default
* values passed as parameters will be used. The @flags parameter
* controls whether we want to track the window's size or position in
* order to update our default values for this type.
- *
+ *
**/
void
-ephy_initial_state_add_window (GtkWidget *window,
- const char *name,
- int default_width,
- int default_height,
- gboolean maximize,
+ephy_initial_state_add_window (GtkWidget *window,
+ const char *name,
+ int default_width,
+ int default_height,
+ gboolean maximize,
EphyInitialStateWindowFlags flags)
{
EphyNode *node;
@@ -357,9 +356,9 @@ ephy_initial_state_add_window (GtkWidget *window,
}
static gboolean
-paned_sync_position_cb (GtkWidget *paned,
+paned_sync_position_cb (GtkWidget *paned,
GParamSpec *pspec,
- EphyNode *node)
+ EphyNode *node)
{
int width;
@@ -370,9 +369,9 @@ paned_sync_position_cb (GtkWidget *paned,
}
void
-ephy_initial_state_add_paned (GtkWidget *paned,
+ephy_initial_state_add_paned (GtkWidget *paned,
const char *name,
- int default_width)
+ int default_width)
{
EphyNode *node;
int width;
@@ -402,8 +401,8 @@ ephy_initial_state_add_paned (GtkWidget *paned,
static void
sync_expander_cb (GtkExpander *expander,
- GParamSpec *pspec,
- EphyNode *node)
+ GParamSpec *pspec,
+ EphyNode *node)
{
gboolean is_expanded;
@@ -415,8 +414,8 @@ sync_expander_cb (GtkExpander *expander,
static void
sync_toggle_cb (GtkToggleButton *toggle,
- GParamSpec *pspec,
- EphyNode *node)
+ GParamSpec *pspec,
+ EphyNode *node)
{
gboolean is_active;
@@ -426,10 +425,10 @@ sync_toggle_cb (GtkToggleButton *toggle,
is_active);
}
-void
-ephy_initial_state_add_expander (GtkWidget *widget,
+void
+ephy_initial_state_add_expander (GtkWidget *widget,
const char *name,
- gboolean default_state)
+ gboolean default_state)
{
EphyNode *node;
gboolean active;
@@ -451,7 +450,7 @@ ephy_initial_state_add_expander (GtkWidget *widget,
}
active = ephy_node_get_property_boolean
- (node, EPHY_NODE_INITIAL_STATE_PROP_ACTIVE);
+ (node, EPHY_NODE_INITIAL_STATE_PROP_ACTIVE);
if (GTK_IS_TOGGLE_BUTTON (widget)) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), active);
diff --git a/lib/ephy-langs.c b/lib/ephy-langs.c
index cae80de47..01135a12b 100644
--- a/lib/ephy-langs.c
+++ b/lib/ephy-langs.c
@@ -33,304 +33,269 @@
void
ephy_langs_sanitise (GArray *array)
{
- char *lang1, *lang2;
- int i, j;
-
- /* if we have 'xy-ab' in list but not 'xy', append 'xy' */
- for (i = 0; i < (int) array->len; i++)
- {
- gboolean found = FALSE;
- char *dash, *prefix;
-
- lang1 = (char *) g_array_index (array,char *, i);
-
- dash = strchr (lang1, '-');
- if (dash == NULL) continue;
-
- for (j = i + 1; j < (int) array->len; j++)
- {
- lang2 = (char *) g_array_index (array, char *, j);
- if (strchr (lang2, '-') == NULL &&
- g_str_has_prefix (lang1, lang2))
- {
- found = TRUE;
- }
- }
-
- if (found == FALSE)
- {
- prefix = g_strndup (lang1, dash - lang1);
- g_array_append_val (array, prefix);
- }
- }
-
- /* uniquify */
- for (i = 0; i < (int) array->len - 1; i++)
- {
- for (j = (int) array->len - 1; j > i; j--)
- {
- lang1 = (char *) g_array_index (array,char *, i);
- lang2 = (char *) g_array_index (array, char *, j);
-
- if (strcmp (lang1, lang2) == 0)
- {
- g_array_remove_index (array, j);
- g_free (lang2);
- }
- }
- }
-
- /* move 'xy' code behind all 'xy-ab' codes */
- for (i = (int) array->len - 2; i >= 0; i--)
- {
- for (j = (int) array->len - 1; j > i; j--)
- {
- lang1 = (char *) g_array_index (array, char *, i);
- lang2 = (char *) g_array_index (array, char *, j);
-
- if (strchr (lang1, '-') == NULL &&
- strchr (lang2, '-') != NULL &&
- g_str_has_prefix (lang2, lang1))
- {
- g_array_insert_val (array, j + 1, lang1);
- g_array_remove_index (array, i);
- break;
- }
- }
- }
+ char *lang1, *lang2;
+ int i, j;
+
+ /* if we have 'xy-ab' in list but not 'xy', append 'xy' */
+ for (i = 0; i < (int)array->len; i++) {
+ gboolean found = FALSE;
+ char *dash, *prefix;
+
+ lang1 = (char *)g_array_index (array, char *, i);
+
+ dash = strchr (lang1, '-');
+ if (dash == NULL) continue;
+
+ for (j = i + 1; j < (int)array->len; j++) {
+ lang2 = (char *)g_array_index (array, char *, j);
+ if (strchr (lang2, '-') == NULL &&
+ g_str_has_prefix (lang1, lang2)) {
+ found = TRUE;
+ }
+ }
+
+ if (found == FALSE) {
+ prefix = g_strndup (lang1, dash - lang1);
+ g_array_append_val (array, prefix);
+ }
+ }
+
+ /* uniquify */
+ for (i = 0; i < (int)array->len - 1; i++) {
+ for (j = (int)array->len - 1; j > i; j--) {
+ lang1 = (char *)g_array_index (array, char *, i);
+ lang2 = (char *)g_array_index (array, char *, j);
+
+ if (strcmp (lang1, lang2) == 0) {
+ g_array_remove_index (array, j);
+ g_free (lang2);
+ }
+ }
+ }
+
+ /* move 'xy' code behind all 'xy-ab' codes */
+ for (i = (int)array->len - 2; i >= 0; i--) {
+ for (j = (int)array->len - 1; j > i; j--) {
+ lang1 = (char *)g_array_index (array, char *, i);
+ lang2 = (char *)g_array_index (array, char *, j);
+
+ if (strchr (lang1, '-') == NULL &&
+ strchr (lang2, '-') != NULL &&
+ g_str_has_prefix (lang2, lang1)) {
+ g_array_insert_val (array, j + 1, lang1);
+ g_array_remove_index (array, i);
+ break;
+ }
+ }
+ }
}
void
ephy_langs_append_languages (GArray *array)
{
- const char * const * languages;
- char *lang;
- int i;
-
- languages = g_get_language_names ();
- g_return_if_fail (languages != NULL);
-
- /* FIXME: maybe just use the first, instead of all of them? */
- for (i = 0; languages[i] != NULL; i++)
- {
-
- if (strstr (languages[i], ".") == 0 &&
- strstr (languages[i], "@") == 0 &&
- strcmp (languages[i], "C") != 0)
- {
- /* change to lowercase and '_' to '-' */
- lang = g_strdelimit (g_ascii_strdown
- (languages[i], -1), "_", '-');
-
- g_array_append_val (array, lang);
- }
- }
-
- /* Fallback: add "en" if list is empty */
- if (array->len == 0)
- {
- lang = g_strdup ("en");
- g_array_append_val (array, lang);
- }
+ const char * const *languages;
+ char *lang;
+ int i;
+
+ languages = g_get_language_names ();
+ g_return_if_fail (languages != NULL);
+
+ /* FIXME: maybe just use the first, instead of all of them? */
+ for (i = 0; languages[i] != NULL; i++) {
+ if (strstr (languages[i], ".") == 0 &&
+ strstr (languages[i], "@") == 0 &&
+ strcmp (languages[i], "C") != 0) {
+ /* change to lowercase and '_' to '-' */
+ lang = g_strdelimit (g_ascii_strdown
+ (languages[i], -1), "_", '-');
+
+ g_array_append_val (array, lang);
+ }
+ }
+
+ /* Fallback: add "en" if list is empty */
+ if (array->len == 0) {
+ lang = g_strdup ("en");
+ g_array_append_val (array, lang);
+ }
}
char **
ephy_langs_get_languages (void)
{
- GArray *array;
+ GArray *array;
- array = g_array_new (TRUE, FALSE, sizeof (char *));
+ array = g_array_new (TRUE, FALSE, sizeof (char *));
- ephy_langs_append_languages (array);
+ ephy_langs_append_languages (array);
- ephy_langs_sanitise (array);
+ ephy_langs_sanitise (array);
- return (char **)(void *) g_array_free (array, FALSE);
+ return (char **)(void *)g_array_free (array, FALSE);
}
static void
ephy_langs_bind_iso_domains (void)
{
- static gboolean bound = FALSE;
+ static gboolean bound = FALSE;
- if (bound == FALSE)
- {
- bindtextdomain (ISO_639_DOMAIN, LOCALEDIR);
- bind_textdomain_codeset (ISO_639_DOMAIN, "UTF-8");
+ if (bound == FALSE) {
+ bindtextdomain (ISO_639_DOMAIN, LOCALEDIR);
+ bind_textdomain_codeset (ISO_639_DOMAIN, "UTF-8");
- bindtextdomain(ISO_3166_DOMAIN, LOCALEDIR);
- bind_textdomain_codeset (ISO_3166_DOMAIN, "UTF-8");
+ bindtextdomain (ISO_3166_DOMAIN, LOCALEDIR);
+ bind_textdomain_codeset (ISO_3166_DOMAIN, "UTF-8");
- bound = TRUE;
- }
+ bound = TRUE;
+ }
}
static void
read_iso_639_entry (xmlTextReaderPtr reader,
- GHashTable *table)
+ GHashTable *table)
{
- xmlChar *code, *name;
-
- code = xmlTextReaderGetAttribute (reader, (const xmlChar *) "iso_639_1_code");
- name = xmlTextReaderGetAttribute (reader, (const xmlChar *) "name");
-
- /* Get iso-639-2 code */
- if (code == NULL || code[0] == '\0')
- {
- xmlFree (code);
- /* FIXME: use the 2T or 2B code? */
- code = xmlTextReaderGetAttribute (reader, (const xmlChar *) "iso_639_2T_code");
- }
-
- if (code != NULL && code[0] != '\0' && name != NULL && name[0] != '\0')
- {
- g_hash_table_insert (table, code, name);
- }
- else
- {
- xmlFree (code);
- xmlFree (name);
- }
+ xmlChar *code, *name;
+
+ code = xmlTextReaderGetAttribute (reader, (const xmlChar *)"iso_639_1_code");
+ name = xmlTextReaderGetAttribute (reader, (const xmlChar *)"name");
+
+ /* Get iso-639-2 code */
+ if (code == NULL || code[0] == '\0') {
+ xmlFree (code);
+ /* FIXME: use the 2T or 2B code? */
+ code = xmlTextReaderGetAttribute (reader, (const xmlChar *)"iso_639_2T_code");
+ }
+
+ if (code != NULL && code[0] != '\0' && name != NULL && name[0] != '\0') {
+ g_hash_table_insert (table, code, name);
+ } else {
+ xmlFree (code);
+ xmlFree (name);
+ }
}
static void
read_iso_3166_entry (xmlTextReaderPtr reader,
- GHashTable *table)
+ GHashTable *table)
{
- xmlChar *code, *name;
+ xmlChar *code, *name;
- code = xmlTextReaderGetAttribute (reader, (const xmlChar *) "alpha_2_code");
- name = xmlTextReaderGetAttribute (reader, (const xmlChar *) "name");
+ code = xmlTextReaderGetAttribute (reader, (const xmlChar *)"alpha_2_code");
+ name = xmlTextReaderGetAttribute (reader, (const xmlChar *)"name");
- if (code != NULL && code[0] != '\0' && name != NULL && name[0] != '\0')
- {
- char *lcode;
+ if (code != NULL && code[0] != '\0' && name != NULL && name[0] != '\0') {
+ char *lcode;
- lcode = g_ascii_strdown ((char *) code, -1);
- xmlFree (code);
-
- g_hash_table_insert (table, lcode, name);
- }
- else
- {
- xmlFree (code);
- xmlFree (name);
- }
+ lcode = g_ascii_strdown ((char *)code, -1);
+ xmlFree (code);
+ g_hash_table_insert (table, lcode, name);
+ } else {
+ xmlFree (code);
+ xmlFree (name);
+ }
}
-typedef enum
-{
- STATE_START,
- STATE_STOP,
- STATE_ENTRIES,
+typedef enum {
+ STATE_START,
+ STATE_STOP,
+ STATE_ENTRIES,
} ParserState;
static void
-load_iso_entries (int iso,
- GFunc read_entry_func,
- gpointer user_data)
+load_iso_entries (int iso,
+ GFunc read_entry_func,
+ gpointer user_data)
{
- xmlTextReaderPtr reader;
- ParserState state = STATE_START;
- xmlChar iso_entries[32], iso_entry[32];
- char *filename;
- int ret = -1;
-
- LOG ("Loading ISO-%d codes", iso);
-
- START_PROFILER ("Loading ISO codes")
-
- filename = g_strdup_printf (ISO_CODES_PREFIX "/share/xml/iso-codes/iso_%d.xml", iso);
- reader = xmlNewTextReaderFilename (filename);
- if (reader == NULL) goto out;
-
- xmlStrPrintf (iso_entries, sizeof (iso_entries), (const xmlChar *)"iso_%d_entries", iso);
- xmlStrPrintf (iso_entry, sizeof (iso_entry), (const xmlChar *)"iso_%d_entry", iso);
-
- ret = xmlTextReaderRead (reader);
-
- while (ret == 1)
- {
- const xmlChar *tag;
- xmlReaderTypes type;
-
- tag = xmlTextReaderConstName (reader);
- type = xmlTextReaderNodeType (reader);
-
- if (state == STATE_ENTRIES &&
- type == XML_READER_TYPE_ELEMENT &&
- xmlStrEqual (tag, iso_entry))
- {
- read_entry_func (reader, user_data);
- }
- else if (state == STATE_START &&
- type == XML_READER_TYPE_ELEMENT &&
- xmlStrEqual (tag, iso_entries))
- {
- state = STATE_ENTRIES;
- }
- else if (state == STATE_ENTRIES &&
- type == XML_READER_TYPE_END_ELEMENT &&
- xmlStrEqual (tag, iso_entries))
- {
- state = STATE_STOP;
- }
- else if (type == XML_READER_TYPE_SIGNIFICANT_WHITESPACE ||
- type == XML_READER_TYPE_WHITESPACE ||
- type == XML_READER_TYPE_TEXT ||
- type == XML_READER_TYPE_COMMENT)
- {
- /* eat it */
- }
- else
- {
- /* ignore it */
- }
-
- ret = xmlTextReaderRead (reader);
- }
-
- xmlFreeTextReader (reader);
-
-out:
- if (ret < 0 || state != STATE_STOP)
- {
- g_warning ("Failed to load ISO-%d codes from %s!\n",
- iso, filename);
- }
-
- g_free (filename);
-
- STOP_PROFILER ("Loading ISO codes")
+ xmlTextReaderPtr reader;
+ ParserState state = STATE_START;
+ xmlChar iso_entries[32], iso_entry[32];
+ char *filename;
+ int ret = -1;
+
+ LOG ("Loading ISO-%d codes", iso);
+
+ START_PROFILER ("Loading ISO codes")
+
+ filename = g_strdup_printf (ISO_CODES_PREFIX "/share/xml/iso-codes/iso_%d.xml", iso);
+ reader = xmlNewTextReaderFilename (filename);
+ if (reader == NULL) goto out;
+
+ xmlStrPrintf (iso_entries, sizeof (iso_entries), (const xmlChar *)"iso_%d_entries", iso);
+ xmlStrPrintf (iso_entry, sizeof (iso_entry), (const xmlChar *)"iso_%d_entry", iso);
+
+ ret = xmlTextReaderRead (reader);
+
+ while (ret == 1) {
+ const xmlChar *tag;
+ xmlReaderTypes type;
+
+ tag = xmlTextReaderConstName (reader);
+ type = xmlTextReaderNodeType (reader);
+
+ if (state == STATE_ENTRIES &&
+ type == XML_READER_TYPE_ELEMENT &&
+ xmlStrEqual (tag, iso_entry)) {
+ read_entry_func (reader, user_data);
+ } else if (state == STATE_START &&
+ type == XML_READER_TYPE_ELEMENT &&
+ xmlStrEqual (tag, iso_entries)) {
+ state = STATE_ENTRIES;
+ } else if (state == STATE_ENTRIES &&
+ type == XML_READER_TYPE_END_ELEMENT &&
+ xmlStrEqual (tag, iso_entries)) {
+ state = STATE_STOP;
+ } else if (type == XML_READER_TYPE_SIGNIFICANT_WHITESPACE ||
+ type == XML_READER_TYPE_WHITESPACE ||
+ type == XML_READER_TYPE_TEXT ||
+ type == XML_READER_TYPE_COMMENT) {
+ /* eat it */
+ } else {
+ /* ignore it */
+ }
+
+ ret = xmlTextReaderRead (reader);
+ }
+
+ xmlFreeTextReader (reader);
+
+ out:
+ if (ret < 0 || state != STATE_STOP) {
+ g_warning ("Failed to load ISO-%d codes from %s!\n",
+ iso, filename);
+ }
+
+ g_free (filename);
+
+ STOP_PROFILER ("Loading ISO codes")
}
GHashTable *
ephy_langs_iso_639_table (void)
{
- GHashTable *table;
+ GHashTable *table;
- ephy_langs_bind_iso_domains ();
- table = g_hash_table_new_full (g_str_hash, g_str_equal,
- (GDestroyNotify) xmlFree,
- (GDestroyNotify) xmlFree);
+ ephy_langs_bind_iso_domains ();
+ table = g_hash_table_new_full (g_str_hash, g_str_equal,
+ (GDestroyNotify)xmlFree,
+ (GDestroyNotify)xmlFree);
- load_iso_entries (639, (GFunc) read_iso_639_entry, table);
+ load_iso_entries (639, (GFunc)read_iso_639_entry, table);
- return table;
+ return table;
}
GHashTable *
ephy_langs_iso_3166_table (void)
{
- GHashTable *table;
+ GHashTable *table;
+
+ ephy_langs_bind_iso_domains ();
+ table = g_hash_table_new_full (g_str_hash, g_str_equal,
+ (GDestroyNotify)g_free,
+ (GDestroyNotify)xmlFree);
- ephy_langs_bind_iso_domains ();
- table = g_hash_table_new_full (g_str_hash, g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) xmlFree);
-
- load_iso_entries (3166, (GFunc) read_iso_3166_entry, table);
+ load_iso_entries (3166, (GFunc)read_iso_3166_entry, table);
- return table;
+ return table;
}
diff --git a/lib/ephy-node-db.c b/lib/ephy-node-db.c
index 11a0c1271..7847724cf 100644
--- a/lib/ephy-node-db.c
+++ b/lib/ephy-node-db.c
@@ -32,99 +32,95 @@
/* FIXME I want to find a better way to deal with "root" nodes */
#define RESERVED_IDS 30
-enum
-{
- PROP_0,
- PROP_NAME,
- PROP_IMMUTABLE,
- LAST_PROP
+enum {
+ PROP_0,
+ PROP_NAME,
+ PROP_IMMUTABLE,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
-struct _EphyNodeDb
-{
- GObject parent_instance;
+struct _EphyNodeDb {
+ GObject parent_instance;
- char *name;
- gboolean immutable;
+ char *name;
+ gboolean immutable;
- guint id_factory;
+ guint id_factory;
- GPtrArray *id_to_node;
+ GPtrArray *id_to_node;
};
G_DEFINE_TYPE (EphyNodeDb, ephy_node_db, G_TYPE_OBJECT)
static void
-ephy_node_db_get_property (GObject *object,
- guint prop_id,
- GValue *value,
+ephy_node_db_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
GParamSpec *pspec)
{
- EphyNodeDb *db = EPHY_NODE_DB (object);
-
- switch (prop_id)
- {
- case PROP_NAME:
- g_value_set_string (value, db->name);
- break;
- case PROP_IMMUTABLE:
- g_value_set_boolean (value, ephy_node_db_is_immutable (db));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
+ EphyNodeDb *db = EPHY_NODE_DB (object);
+
+ switch (prop_id) {
+ case PROP_NAME:
+ g_value_set_string (value, db->name);
+ break;
+ case PROP_IMMUTABLE:
+ g_value_set_boolean (value, ephy_node_db_is_immutable (db));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
-ephy_node_db_set_property (GObject *object,
- guint prop_id,
+ephy_node_db_set_property (GObject *object,
+ guint prop_id,
const GValue *value,
- GParamSpec *pspec)
+ GParamSpec *pspec)
{
- EphyNodeDb *db = EPHY_NODE_DB (object);
-
- switch (prop_id)
- {
- case PROP_NAME:
- db->name = g_value_dup_string (value);
- break;
- case PROP_IMMUTABLE:
- ephy_node_db_set_immutable (db, g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
+ EphyNodeDb *db = EPHY_NODE_DB (object);
+
+ switch (prop_id) {
+ case PROP_NAME:
+ db->name = g_value_dup_string (value);
+ break;
+ case PROP_IMMUTABLE:
+ ephy_node_db_set_immutable (db, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
ephy_node_db_free_func (EphyNode *node)
{
- if (node)
- ephy_node_unref (node);
+ if (node)
+ ephy_node_unref (node);
}
static void
ephy_node_db_init (EphyNodeDb *db)
{
- /* id to node */
- db->id_to_node = g_ptr_array_new_with_free_func ((GDestroyNotify)ephy_node_db_free_func);
+ /* id to node */
+ db->id_to_node = g_ptr_array_new_with_free_func ((GDestroyNotify)ephy_node_db_free_func);
- /* id factory */
- db->id_factory = RESERVED_IDS;
+ /* id factory */
+ db->id_factory = RESERVED_IDS;
}
static void
ephy_node_db_finalize (GObject *object)
{
- EphyNodeDb *db = EPHY_NODE_DB (object);
+ EphyNodeDb *db = EPHY_NODE_DB (object);
- g_ptr_array_free (db->id_to_node, TRUE);
+ g_ptr_array_free (db->id_to_node, TRUE);
- g_free (db->name);
+ g_free (db->name);
- G_OBJECT_CLASS (ephy_node_db_parent_class)->finalize (object);
+ G_OBJECT_CLASS (ephy_node_db_parent_class)->finalize (object);
}
/**
@@ -138,24 +134,24 @@ ephy_node_db_finalize (GObject *object)
EphyNodeDb *
ephy_node_db_new (const char *name)
{
- EphyNodeDb *db;
+ EphyNodeDb *db;
- db = EPHY_NODE_DB (g_object_new (EPHY_TYPE_NODE_DB,
- "name", name,
- NULL));
+ db = EPHY_NODE_DB (g_object_new (EPHY_TYPE_NODE_DB,
+ "name", name,
+ NULL));
- return db;
+ return db;
}
static inline EphyNode *
node_from_id_real (EphyNodeDb *db, guint id)
{
- EphyNode *ret = NULL;
+ EphyNode *ret = NULL;
- if (id < db->id_to_node->len)
- ret = g_ptr_array_index (db->id_to_node, id);
+ if (id < db->id_to_node->len)
+ ret = g_ptr_array_index (db->id_to_node, id);
- return ret;
+ return ret;
}
/**
@@ -167,7 +163,7 @@ node_from_id_real (EphyNodeDb *db, guint id)
const char *
ephy_node_db_get_name (EphyNodeDb *db)
{
- return db->name;
+ return db->name;
}
/**
@@ -179,7 +175,7 @@ ephy_node_db_get_name (EphyNodeDb *db)
gboolean
ephy_node_db_is_immutable (EphyNodeDb *db)
{
- return db->immutable;
+ return db->immutable;
}
/**
@@ -193,9 +189,9 @@ ephy_node_db_is_immutable (EphyNodeDb *db)
void
ephy_node_db_set_immutable (EphyNodeDb *db, gboolean immutable)
{
- db->immutable = immutable;
+ db->immutable = immutable;
- g_object_notify_by_pspec (G_OBJECT (db), obj_properties[PROP_IMMUTABLE]);
+ g_object_notify_by_pspec (G_OBJECT (db), obj_properties[PROP_IMMUTABLE]);
}
/**
@@ -210,48 +206,47 @@ ephy_node_db_set_immutable (EphyNodeDb *db, gboolean immutable)
EphyNode *
ephy_node_db_get_node_from_id (EphyNodeDb *db, guint id)
{
- EphyNode *ret = NULL;
+ EphyNode *ret = NULL;
- ret = node_from_id_real (db, id);
+ ret = node_from_id_real (db, id);
- return ret;
+ return ret;
}
guint
_ephy_node_db_new_id (EphyNodeDb *db)
{
- guint ret;
+ guint ret;
- while (node_from_id_real (db, db->id_factory) != NULL)
- {
- db->id_factory++;
- }
+ while (node_from_id_real (db, db->id_factory) != NULL) {
+ db->id_factory++;
+ }
- ret = db->id_factory;
+ ret = db->id_factory;
- return ret;
+ return ret;
}
void
_ephy_node_db_add_id (EphyNodeDb *db,
- guint id,
- EphyNode *node)
+ guint id,
+ EphyNode *node)
{
- /* resize array if needed */
- if (id >= db->id_to_node->len)
- g_ptr_array_set_size (db->id_to_node, id + 1);
+ /* resize array if needed */
+ if (id >= db->id_to_node->len)
+ g_ptr_array_set_size (db->id_to_node, id + 1);
- g_ptr_array_index (db->id_to_node, id) = node;
+ g_ptr_array_index (db->id_to_node, id) = node;
}
void
_ephy_node_db_remove_id (EphyNodeDb *db,
- guint id)
+ guint id)
{
- g_ptr_array_index (db->id_to_node, id) = NULL;
+ g_ptr_array_index (db->id_to_node, id) = NULL;
- /* reset id factory so we use the freed node id */
- db->id_factory = RESERVED_IDS;
+ /* reset id factory so we use the freed node id */
+ db->id_factory = RESERVED_IDS;
}
/**
@@ -272,176 +267,163 @@ _ephy_node_db_remove_id (EphyNodeDb *db,
* Return value: %TRUE if successful
**/
gboolean
-ephy_node_db_load_from_file (EphyNodeDb *db,
- const char *xml_file,
- const xmlChar *xml_root,
- const xmlChar *xml_version)
+ephy_node_db_load_from_file (EphyNodeDb *db,
+ const char *xml_file,
+ const xmlChar *xml_root,
+ const xmlChar *xml_version)
{
- xmlTextReaderPtr reader;
- gboolean success = TRUE;
- gboolean was_immutable;
- int ret;
+ xmlTextReaderPtr reader;
+ gboolean success = TRUE;
+ gboolean was_immutable;
+ int ret;
- LOG ("ephy_node_db_load_from_file %s", xml_file);
+ LOG ("ephy_node_db_load_from_file %s", xml_file);
- START_PROFILER ("loading node db")
+ START_PROFILER ("loading node db")
- if (g_file_test (xml_file, G_FILE_TEST_EXISTS) == FALSE)
- {
- return FALSE;
- }
+ if (g_file_test (xml_file, G_FILE_TEST_EXISTS) == FALSE) {
+ return FALSE;
+ }
- reader = xmlNewTextReaderFilename (xml_file);
- if (reader == NULL)
- {
- return FALSE;
- }
+ reader = xmlNewTextReaderFilename (xml_file);
+ if (reader == NULL) {
+ return FALSE;
+ }
- was_immutable = db->immutable;
- db->immutable = FALSE;
+ was_immutable = db->immutable;
+ db->immutable = FALSE;
- ret = xmlTextReaderRead (reader);
- while (ret == 1)
- {
- const xmlChar *name;
- xmlReaderTypes type;
- gboolean skip = FALSE;
+ ret = xmlTextReaderRead (reader);
+ while (ret == 1) {
+ const xmlChar *name;
+ xmlReaderTypes type;
+ gboolean skip = FALSE;
- name = xmlTextReaderConstName (reader);
- type = xmlTextReaderNodeType (reader);
+ name = xmlTextReaderConstName (reader);
+ type = xmlTextReaderNodeType (reader);
- if (xmlStrEqual (name, (const xmlChar *)"node")
- && type == XML_READER_TYPE_ELEMENT)
- {
- xmlNodePtr subtree;
+ if (xmlStrEqual (name, (const xmlChar *)"node")
+ && type == XML_READER_TYPE_ELEMENT) {
+ xmlNodePtr subtree;
- /* grow the subtree and load the node from it */
- subtree = xmlTextReaderExpand (reader);
+ /* grow the subtree and load the node from it */
+ subtree = xmlTextReaderExpand (reader);
- if (subtree != NULL)
- {
- ephy_node_new_from_xml (db, subtree);
- }
+ if (subtree != NULL) {
+ ephy_node_new_from_xml (db, subtree);
+ }
- skip = TRUE;
- }
- else if (xmlStrEqual (name, xml_root)
- && type == XML_READER_TYPE_ELEMENT)
- {
- xmlChar *version;
+ skip = TRUE;
+ } else if (xmlStrEqual (name, xml_root)
+ && type == XML_READER_TYPE_ELEMENT) {
+ xmlChar *version;
- /* check version info */
- version = xmlTextReaderGetAttribute (reader, (const xmlChar *)"version");
- if (xmlStrEqual (version, xml_version) == FALSE)
- {
- success = FALSE;
- xmlFree (version);
+ /* check version info */
+ version = xmlTextReaderGetAttribute (reader, (const xmlChar *)"version");
+ if (xmlStrEqual (version, xml_version) == FALSE) {
+ success = FALSE;
+ xmlFree (version);
- break;
- }
+ break;
+ }
- xmlFree (version);
- }
+ xmlFree (version);
+ }
- /* next one, please */
- ret = skip ? xmlTextReaderNext (reader)
- : xmlTextReaderRead (reader);
- }
+ /* next one, please */
+ ret = skip ? xmlTextReaderNext (reader)
+ : xmlTextReaderRead (reader);
+ }
- xmlFreeTextReader (reader);
+ xmlFreeTextReader (reader);
- db->immutable = was_immutable;
+ db->immutable = was_immutable;
- STOP_PROFILER ("loading node db")
+ STOP_PROFILER ("loading node db")
- return (success && ret == 0);
+ return (success && ret == 0);
}
static int
-ephy_node_db_write_to_xml_valist (EphyNodeDb *db,
- xmlBuffer *buffer,
- const xmlChar *root,
- const xmlChar *version,
- const xmlChar *comment,
- EphyNode *first_node,
- va_list argptr)
+ephy_node_db_write_to_xml_valist (EphyNodeDb *db,
+ xmlBuffer *buffer,
+ const xmlChar *root,
+ const xmlChar *version,
+ const xmlChar *comment,
+ EphyNode *first_node,
+ va_list argptr)
{
- xmlTextWriterPtr writer;
- EphyNode *node;
- int ret;
+ xmlTextWriterPtr writer;
+ EphyNode *node;
+ int ret;
- START_PROFILER ("Saving node db")
+ START_PROFILER ("Saving node db")
- /* FIXME: do we want to turn compression on ? */
- writer = xmlNewTextWriterMemory (buffer, 0);
- if (writer == NULL)
- {
- return -1;
- }
+ /* FIXME: do we want to turn compression on ? */
+ writer = xmlNewTextWriterMemory (buffer, 0);
+ if (writer == NULL) {
+ return -1;
+ }
- ret = xmlTextWriterSetIndent (writer, 1);
- if (ret < 0) goto out;
+ ret = xmlTextWriterSetIndent (writer, 1);
+ if (ret < 0) goto out;
- ret = xmlTextWriterSetIndentString (writer, (const xmlChar *)" ");
- if (ret < 0) goto out;
+ ret = xmlTextWriterSetIndentString (writer, (const xmlChar *)" ");
+ if (ret < 0) goto out;
- ret = xmlTextWriterStartDocument (writer, "1.0", NULL, NULL);
- if (ret < 0) goto out;
+ ret = xmlTextWriterStartDocument (writer, "1.0", NULL, NULL);
+ if (ret < 0) goto out;
- ret = xmlTextWriterStartElement (writer, root);
- if (ret < 0) goto out;
+ ret = xmlTextWriterStartElement (writer, root);
+ if (ret < 0) goto out;
- ret = xmlTextWriterWriteAttribute (writer, (const xmlChar *)"version", version);
- if (ret < 0) goto out;
+ ret = xmlTextWriterWriteAttribute (writer, (const xmlChar *)"version", version);
+ if (ret < 0) goto out;
- if (comment != NULL)
- {
- ret = xmlTextWriterWriteComment (writer, comment);
- if (ret < 0) goto out;
- }
+ if (comment != NULL) {
+ ret = xmlTextWriterWriteComment (writer, comment);
+ if (ret < 0) goto out;
+ }
- node = first_node;
- while (node != NULL)
- {
- GPtrArray *children;
- EphyNodeFilterFunc filter;
- gpointer user_data;
- guint i;
+ node = first_node;
+ while (node != NULL) {
+ GPtrArray *children;
+ EphyNodeFilterFunc filter;
+ gpointer user_data;
+ guint i;
- filter = va_arg (argptr, EphyNodeFilterFunc);
- user_data = va_arg (argptr, gpointer);
+ filter = va_arg (argptr, EphyNodeFilterFunc);
+ user_data = va_arg (argptr, gpointer);
- children = ephy_node_get_children (node);
- for (i = 0; i < children->len; i++)
- {
- EphyNode *kid;
+ children = ephy_node_get_children (node);
+ for (i = 0; i < children->len; i++) {
+ EphyNode *kid;
- kid = g_ptr_array_index (children, i);
+ kid = g_ptr_array_index (children, i);
- if (!filter || filter (kid, user_data))
- {
- ret = ephy_node_write_to_xml (kid, writer);
- if (ret < 0) break;
- }
- }
- if (ret < 0) break;
+ if (!filter || filter (kid, user_data)) {
+ ret = ephy_node_write_to_xml (kid, writer);
+ if (ret < 0) break;
+ }
+ }
+ if (ret < 0) break;
- node = va_arg (argptr, EphyNode *);
- }
- if (ret < 0) goto out;
+ node = va_arg (argptr, EphyNode *);
+ }
+ if (ret < 0) goto out;
- ret = xmlTextWriterEndElement (writer); /* root */
- if (ret < 0) goto out;
+ ret = xmlTextWriterEndElement (writer); /* root */
+ if (ret < 0) goto out;
- ret = xmlTextWriterEndDocument (writer);
- if (ret < 0) goto out;
+ ret = xmlTextWriterEndDocument (writer);
+ if (ret < 0) goto out;
-out:
- xmlFreeTextWriter (writer);
+ out:
+ xmlFreeTextWriter (writer);
- STOP_PROFILER ("Saving node db")
+ STOP_PROFILER ("Saving node db")
- return ret >= 0 ? 0 : -1;
+ return ret >= 0 ? 0 : -1;
}
/**
@@ -453,7 +435,7 @@ out:
* @comment: a comment to place directly inside the @root element of @filename
* @node: The first node of data to write
* @Varargs: number of exceptions, list of their #EphyNodes, and more such
- * sequences, followed by %NULL
+ * sequences, followed by %NULL
*
* Writes @db's data to an XML file for storage. The data can be retrieved in
* the future using ephy_node_db_load_from_file().
@@ -479,68 +461,66 @@ out:
**/
int
ephy_node_db_write_to_xml_safe (EphyNodeDb *db,
- const xmlChar *filename,
- const xmlChar *root,
- const xmlChar *version,
- const xmlChar *comment,
- EphyNode *node, ...)
+ const xmlChar *filename,
+ const xmlChar *root,
+ const xmlChar *version,
+ const xmlChar *comment,
+ EphyNode *node, ...)
{
- va_list argptr;
- xmlBuffer *buffer;
- GError *error = NULL;
- int ret = 0;
+ va_list argptr;
+ xmlBuffer *buffer;
+ GError *error = NULL;
+ int ret = 0;
- LOG ("Saving node db to %s", filename);
+ LOG ("Saving node db to %s", filename);
- va_start (argptr, node);
+ va_start (argptr, node);
- buffer = xmlBufferCreate ();
- ret = ephy_node_db_write_to_xml_valist
- (db, buffer, root, version, comment, node, argptr);
+ buffer = xmlBufferCreate ();
+ ret = ephy_node_db_write_to_xml_valist
+ (db, buffer, root, version, comment, node, argptr);
- va_end (argptr);
+ va_end (argptr);
- if (ret < 0)
- {
- g_warning ("Failed to write XML data");
- goto failed;
- }
+ if (ret < 0) {
+ g_warning ("Failed to write XML data");
+ goto failed;
+ }
- if (g_file_set_contents ((const char *)filename, (const char *)buffer->content, buffer->use, &error) == FALSE)
- {
- g_warning ("Error saving EphyNodeDB as XML: %s", error->message);
- g_error_free (error);
- ret = -1;
- }
+ if (g_file_set_contents ((const char *)filename, (const char *)buffer->content, buffer->use, &error) == FALSE) {
+ g_warning ("Error saving EphyNodeDB as XML: %s", error->message);
+ g_error_free (error);
+ ret = -1;
+ }
-failed:
- xmlBufferFree (buffer);
+ failed:
+ xmlBufferFree (buffer);
- return ret;
+ return ret;
}
static void
ephy_node_db_class_init (EphyNodeDbClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = ephy_node_db_finalize;
- object_class->set_property = ephy_node_db_set_property;
- object_class->get_property = ephy_node_db_get_property;
-
- obj_properties[PROP_NAME] =
- g_param_spec_string ("name",
- "Name",
- "Name",
- NULL,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
-
- obj_properties[PROP_IMMUTABLE] =
- g_param_spec_boolean ("immutable",
- "Immutable",
- "Immutable",
- FALSE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = ephy_node_db_finalize;
+ object_class->set_property = ephy_node_db_set_property;
+ object_class->get_property = ephy_node_db_get_property;
+
+ obj_properties[PROP_NAME] =
+ g_param_spec_string ("name",
+ "Name",
+ "Name",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
+
+ obj_properties[PROP_IMMUTABLE] =
+ g_param_spec_boolean ("immutable",
+ "Immutable",
+ "Immutable",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
}
diff --git a/lib/ephy-node-filter.c b/lib/ephy-node-filter.c
index e981d7da6..3ba8bc395 100644
--- a/lib/ephy-node-filter.c
+++ b/lib/ephy-node-filter.c
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright © 2002 Olivier Martin <omartin@ifrance.com>
* (C) 2002 Jorn Baayen <jorn@nl.linux.org>
*
@@ -26,45 +26,38 @@
static void ephy_node_filter_finalize (GObject *object);
static gboolean ephy_node_filter_expression_evaluate (EphyNodeFilterExpression *expression,
- EphyNode *node);
+ EphyNode *node);
-enum
-{
- CHANGED,
- LAST_SIGNAL
+enum {
+ CHANGED,
+ LAST_SIGNAL
};
-struct _EphyNodeFilter
-{
- GObject parent_instance;
+struct _EphyNodeFilter {
+ GObject parent_instance;
- GPtrArray *levels;
+ GPtrArray *levels;
};
-struct _EphyNodeFilterExpression
-{
- EphyNodeFilterExpressionType type;
-
- union
- {
- struct
- {
- EphyNode *a;
- EphyNode *b;
- } node_args;
-
- struct
- {
- int prop_id;
-
- union
- {
- EphyNode *node;
- char *string;
- int number;
- } second_arg;
- } prop_args;
- } args;
+struct _EphyNodeFilterExpression {
+ EphyNodeFilterExpressionType type;
+
+ union {
+ struct {
+ EphyNode *a;
+ EphyNode *b;
+ } node_args;
+
+ struct {
+ int prop_id;
+
+ union {
+ EphyNode *node;
+ char *string;
+ int number;
+ } second_arg;
+ } prop_args;
+ } args;
};
static guint ephy_node_filter_signals[LAST_SIGNAL] = { 0 };
@@ -74,349 +67,342 @@ G_DEFINE_TYPE (EphyNodeFilter, ephy_node_filter, G_TYPE_OBJECT)
static void
ephy_node_filter_class_init (EphyNodeFilterClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = ephy_node_filter_finalize;
+ object_class->finalize = ephy_node_filter_finalize;
- ephy_node_filter_signals[CHANGED] =
- g_signal_new ("changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 0);
+ ephy_node_filter_signals[CHANGED] =
+ g_signal_new ("changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 0);
}
static void
ephy_node_filter_init (EphyNodeFilter *filter)
{
- filter->levels = g_ptr_array_new ();
+ filter->levels = g_ptr_array_new ();
}
static void
ephy_node_filter_finalize (GObject *object)
{
- EphyNodeFilter *filter = EPHY_NODE_FILTER (object);
+ EphyNodeFilter *filter = EPHY_NODE_FILTER (object);
- ephy_node_filter_empty (filter);
+ ephy_node_filter_empty (filter);
- g_ptr_array_free (filter->levels, TRUE);
+ g_ptr_array_free (filter->levels, TRUE);
- G_OBJECT_CLASS (ephy_node_filter_parent_class)->finalize (object);
+ G_OBJECT_CLASS (ephy_node_filter_parent_class)->finalize (object);
}
EphyNodeFilter *
ephy_node_filter_new (void)
{
- return EPHY_NODE_FILTER (g_object_new (EPHY_TYPE_NODE_FILTER, NULL));
+ return EPHY_NODE_FILTER (g_object_new (EPHY_TYPE_NODE_FILTER, NULL));
}
void
-ephy_node_filter_add_expression (EphyNodeFilter *filter,
- EphyNodeFilterExpression *exp,
- int level)
+ephy_node_filter_add_expression (EphyNodeFilter *filter,
+ EphyNodeFilterExpression *exp,
+ int level)
{
- while (level >= (int)filter->levels->len)
- g_ptr_array_add (filter->levels, NULL);
+ while (level >= (int)filter->levels->len)
+ g_ptr_array_add (filter->levels, NULL);
- /* FIXME bogosity! This only works because g_list_append (x, data) == x */
- g_ptr_array_index (filter->levels, level) =
- g_list_append (g_ptr_array_index (filter->levels, level), exp);
+ /* FIXME bogosity! This only works because g_list_append (x, data) == x */
+ g_ptr_array_index (filter->levels, level) =
+ g_list_append (g_ptr_array_index (filter->levels, level), exp);
}
void
ephy_node_filter_empty (EphyNodeFilter *filter)
{
- int i;
-
- for (i = filter->levels->len - 1; i >= 0; i--)
- {
- GList *list, *l;
+ int i;
+
+ for (i = filter->levels->len - 1; i >= 0; i--) {
+ GList *list, *l;
- list = g_ptr_array_index (filter->levels, i);
+ list = g_ptr_array_index (filter->levels, i);
- for (l = list; l != NULL; l = g_list_next (l))
- {
- EphyNodeFilterExpression *exp;
+ for (l = list; l != NULL; l = g_list_next (l)) {
+ EphyNodeFilterExpression *exp;
- exp = (EphyNodeFilterExpression *) l->data;
+ exp = (EphyNodeFilterExpression *)l->data;
- ephy_node_filter_expression_free (exp);
- }
+ ephy_node_filter_expression_free (exp);
+ }
- g_list_free (list);
+ g_list_free (list);
- g_ptr_array_remove_index (filter->levels, i);
- }
+ g_ptr_array_remove_index (filter->levels, i);
+ }
}
void
ephy_node_filter_done_changing (EphyNodeFilter *filter)
{
- g_signal_emit (G_OBJECT (filter), ephy_node_filter_signals[CHANGED], 0);
+ g_signal_emit (G_OBJECT (filter), ephy_node_filter_signals[CHANGED], 0);
}
/*
- * We go through each level evaluating the filter expressions.
+ * We go through each level evaluating the filter expressions.
* Every time we get a match we immediately do a break and jump
- * to the next level. We'll return FALSE if we arrive to a level
+ * to the next level. We'll return FALSE if we arrive to a level
* without matches, TRUE otherwise.
*/
gboolean
ephy_node_filter_evaluate (EphyNodeFilter *filter,
- EphyNode *node)
+ EphyNode *node)
{
- guint i;
+ guint i;
+
+ for (i = 0; i < filter->levels->len; i++) {
+ GList *l, *list;
+ gboolean handled;
- for (i = 0; i < filter->levels->len; i++) {
- GList *l, *list;
- gboolean handled;
+ handled = FALSE;
- handled = FALSE;
+ list = g_ptr_array_index (filter->levels, i);
- list = g_ptr_array_index (filter->levels, i);
+ for (l = list; l != NULL; l = g_list_next (l)) {
+ if (ephy_node_filter_expression_evaluate (l->data, node) == TRUE) {
+ handled = TRUE;
+ break;
+ }
+ }
- for (l = list; l != NULL; l = g_list_next (l)) {
- if (ephy_node_filter_expression_evaluate (l->data, node) == TRUE) {
- handled = TRUE;
- break;
- }
- }
+ if (list != NULL && handled == FALSE)
+ return FALSE;
+ }
- if (list != NULL && handled == FALSE)
- return FALSE;
- }
-
- return TRUE;
+ return TRUE;
}
EphyNodeFilterExpression *
ephy_node_filter_expression_new (EphyNodeFilterExpressionType type,
- ...)
+ ...)
{
- EphyNodeFilterExpression *exp;
- va_list valist;
-
- va_start (valist, type);
-
- exp = g_new0 (EphyNodeFilterExpression, 1);
-
- exp->type = type;
-
- switch (type)
- {
- case EPHY_NODE_FILTER_EXPRESSION_NODE_EQUALS:
- exp->args.node_args.a = va_arg (valist, EphyNode *);
- exp->args.node_args.b = va_arg (valist, EphyNode *);
- break;
- case EPHY_NODE_FILTER_EXPRESSION_EQUALS:
- case EPHY_NODE_FILTER_EXPRESSION_HAS_PARENT:
- case EPHY_NODE_FILTER_EXPRESSION_HAS_CHILD:
- exp->args.node_args.a = va_arg (valist, EphyNode *);
- break;
- case EPHY_NODE_FILTER_EXPRESSION_NODE_PROP_EQUALS:
- case EPHY_NODE_FILTER_EXPRESSION_CHILD_PROP_EQUALS:
- exp->args.prop_args.prop_id = va_arg (valist, int);
- exp->args.prop_args.second_arg.node = va_arg (valist, EphyNode *);
- break;
- case EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_CONTAINS:
- case EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_EQUALS:
- exp->args.prop_args.prop_id = va_arg (valist, int);
- exp->args.prop_args.second_arg.string = g_utf8_casefold (va_arg (valist, char *), -1);
- break;
- case EPHY_NODE_FILTER_EXPRESSION_KEY_PROP_CONTAINS:
- case EPHY_NODE_FILTER_EXPRESSION_KEY_PROP_EQUALS:
- {
- char *folded;
-
- exp->args.prop_args.prop_id = va_arg (valist, int);
-
- folded = g_utf8_casefold (va_arg (valist, char *), -1);
- exp->args.prop_args.second_arg.string = g_utf8_collate_key (folded, -1);
- g_free (folded);
- break;
- }
- case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_EQUALS:
- case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_BIGGER_THAN:
- case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_LESS_THAN:
- exp->args.prop_args.prop_id = va_arg (valist, int);
- exp->args.prop_args.second_arg.number = va_arg (valist, int);
- break;
- case EPHY_NODE_FILTER_EXPRESSION_ALWAYS_TRUE:
- default:
- break;
- }
-
- va_end (valist);
-
- return exp;
+ EphyNodeFilterExpression *exp;
+ va_list valist;
+
+ va_start (valist, type);
+
+ exp = g_new0 (EphyNodeFilterExpression, 1);
+
+ exp->type = type;
+
+ switch (type) {
+ case EPHY_NODE_FILTER_EXPRESSION_NODE_EQUALS:
+ exp->args.node_args.a = va_arg (valist, EphyNode *);
+ exp->args.node_args.b = va_arg (valist, EphyNode *);
+ break;
+ case EPHY_NODE_FILTER_EXPRESSION_EQUALS:
+ case EPHY_NODE_FILTER_EXPRESSION_HAS_PARENT:
+ case EPHY_NODE_FILTER_EXPRESSION_HAS_CHILD:
+ exp->args.node_args.a = va_arg (valist, EphyNode *);
+ break;
+ case EPHY_NODE_FILTER_EXPRESSION_NODE_PROP_EQUALS:
+ case EPHY_NODE_FILTER_EXPRESSION_CHILD_PROP_EQUALS:
+ exp->args.prop_args.prop_id = va_arg (valist, int);
+ exp->args.prop_args.second_arg.node = va_arg (valist, EphyNode *);
+ break;
+ case EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_CONTAINS:
+ case EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_EQUALS:
+ exp->args.prop_args.prop_id = va_arg (valist, int);
+ exp->args.prop_args.second_arg.string = g_utf8_casefold (va_arg (valist, char *), -1);
+ break;
+ case EPHY_NODE_FILTER_EXPRESSION_KEY_PROP_CONTAINS:
+ case EPHY_NODE_FILTER_EXPRESSION_KEY_PROP_EQUALS:
+ {
+ char *folded;
+
+ exp->args.prop_args.prop_id = va_arg (valist, int);
+
+ folded = g_utf8_casefold (va_arg (valist, char *), -1);
+ exp->args.prop_args.second_arg.string = g_utf8_collate_key (folded, -1);
+ g_free (folded);
+ break;
+ }
+ case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_EQUALS:
+ case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_BIGGER_THAN:
+ case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_LESS_THAN:
+ exp->args.prop_args.prop_id = va_arg (valist, int);
+ exp->args.prop_args.second_arg.number = va_arg (valist, int);
+ break;
+ case EPHY_NODE_FILTER_EXPRESSION_ALWAYS_TRUE:
+ default:
+ break;
+ }
+
+ va_end (valist);
+
+ return exp;
}
void
ephy_node_filter_expression_free (EphyNodeFilterExpression *exp)
{
- switch (exp->type)
- {
- case EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_CONTAINS:
- case EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_EQUALS:
- case EPHY_NODE_FILTER_EXPRESSION_KEY_PROP_CONTAINS:
- case EPHY_NODE_FILTER_EXPRESSION_KEY_PROP_EQUALS:
- g_free (exp->args.prop_args.second_arg.string);
- break;
- case EPHY_NODE_FILTER_EXPRESSION_ALWAYS_TRUE:
- case EPHY_NODE_FILTER_EXPRESSION_NODE_EQUALS:
- case EPHY_NODE_FILTER_EXPRESSION_EQUALS:
- case EPHY_NODE_FILTER_EXPRESSION_HAS_PARENT:
- case EPHY_NODE_FILTER_EXPRESSION_HAS_CHILD:
- case EPHY_NODE_FILTER_EXPRESSION_NODE_PROP_EQUALS:
- case EPHY_NODE_FILTER_EXPRESSION_CHILD_PROP_EQUALS:
- case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_EQUALS:
- case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_BIGGER_THAN:
- case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_LESS_THAN:
- default:
- break;
- }
-
- g_free (exp);
+ switch (exp->type) {
+ case EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_CONTAINS:
+ case EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_EQUALS:
+ case EPHY_NODE_FILTER_EXPRESSION_KEY_PROP_CONTAINS:
+ case EPHY_NODE_FILTER_EXPRESSION_KEY_PROP_EQUALS:
+ g_free (exp->args.prop_args.second_arg.string);
+ break;
+ case EPHY_NODE_FILTER_EXPRESSION_ALWAYS_TRUE:
+ case EPHY_NODE_FILTER_EXPRESSION_NODE_EQUALS:
+ case EPHY_NODE_FILTER_EXPRESSION_EQUALS:
+ case EPHY_NODE_FILTER_EXPRESSION_HAS_PARENT:
+ case EPHY_NODE_FILTER_EXPRESSION_HAS_CHILD:
+ case EPHY_NODE_FILTER_EXPRESSION_NODE_PROP_EQUALS:
+ case EPHY_NODE_FILTER_EXPRESSION_CHILD_PROP_EQUALS:
+ case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_EQUALS:
+ case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_BIGGER_THAN:
+ case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_LESS_THAN:
+ default:
+ break;
+ }
+
+ g_free (exp);
}
static gboolean
ephy_node_filter_expression_evaluate (EphyNodeFilterExpression *exp,
- EphyNode *node)
+ EphyNode *node)
{
- switch (exp->type)
- {
- case EPHY_NODE_FILTER_EXPRESSION_ALWAYS_TRUE:
- return TRUE;
- case EPHY_NODE_FILTER_EXPRESSION_NODE_EQUALS:
- return (exp->args.node_args.a == exp->args.node_args.b);
- case EPHY_NODE_FILTER_EXPRESSION_EQUALS:
- return (exp->args.node_args.a == node);
- case EPHY_NODE_FILTER_EXPRESSION_HAS_PARENT:
- return ephy_node_has_child (exp->args.node_args.a, node);
- case EPHY_NODE_FILTER_EXPRESSION_HAS_CHILD:
- return ephy_node_has_child (node, exp->args.node_args.a);
- case EPHY_NODE_FILTER_EXPRESSION_NODE_PROP_EQUALS:
- {
- EphyNode *prop;
-
- prop = ephy_node_get_property_node (node,
- exp->args.prop_args.prop_id);
-
- return (prop == exp->args.prop_args.second_arg.node);
- }
- case EPHY_NODE_FILTER_EXPRESSION_CHILD_PROP_EQUALS:
- {
- EphyNode *prop;
- GPtrArray *children;
- guint i;
-
- children = ephy_node_get_children (node);
- for (i = 0; i < children->len; i++)
- {
- EphyNode *child;
-
- child = g_ptr_array_index (children, i);
- prop = ephy_node_get_property_node
- (child, exp->args.prop_args.prop_id);
-
- if (prop == exp->args.prop_args.second_arg.node)
- {
- return TRUE;
- }
- }
-
- return FALSE;
- }
- case EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_CONTAINS:
- {
- const char *prop;
- char *folded_case;
- gboolean ret;
-
- prop = ephy_node_get_property_string (node,
- exp->args.prop_args.prop_id);
- if (prop == NULL)
- return FALSE;
-
- folded_case = g_utf8_casefold (prop, -1);
- ret = (strstr (folded_case, exp->args.prop_args.second_arg.string) != NULL);
- g_free (folded_case);
-
- return ret;
- }
- case EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_EQUALS:
- {
- const char *prop;
- char *folded_case;
- gboolean ret;
-
- prop = ephy_node_get_property_string (node,
- exp->args.prop_args.prop_id);
-
- if (prop == NULL)
- return FALSE;
-
- folded_case = g_utf8_casefold (prop, -1);
- ret = (strcmp (folded_case, exp->args.prop_args.second_arg.string) == 0);
- g_free (folded_case);
-
- return ret;
- }
- case EPHY_NODE_FILTER_EXPRESSION_KEY_PROP_CONTAINS:
- {
- const char *prop;
-
- prop = ephy_node_get_property_string (node,
- exp->args.prop_args.prop_id);
-
- if (prop == NULL)
- return FALSE;
-
- return (strstr (prop, exp->args.prop_args.second_arg.string) != NULL);
- }
- case EPHY_NODE_FILTER_EXPRESSION_KEY_PROP_EQUALS:
- {
- const char *prop;
-
- prop = ephy_node_get_property_string (node,
- exp->args.prop_args.prop_id);
-
- if (prop == NULL)
- return FALSE;
-
- return (strcmp (prop, exp->args.prop_args.second_arg.string) == 0);
- }
- case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_EQUALS:
- {
- int prop;
-
- prop = ephy_node_get_property_int (node,
- exp->args.prop_args.prop_id);
-
- return (prop == exp->args.prop_args.second_arg.number);
- }
- case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_BIGGER_THAN:
- {
- int prop;
-
- prop = ephy_node_get_property_int (node,
- exp->args.prop_args.prop_id);
-
- return (prop > exp->args.prop_args.second_arg.number);
- }
- case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_LESS_THAN:
- {
- int prop;
-
- prop = ephy_node_get_property_int (node,
- exp->args.prop_args.prop_id);
-
- return (prop < exp->args.prop_args.second_arg.number);
- }
- default:
- break;
- }
-
- return FALSE;
+ switch (exp->type) {
+ case EPHY_NODE_FILTER_EXPRESSION_ALWAYS_TRUE:
+ return TRUE;
+ case EPHY_NODE_FILTER_EXPRESSION_NODE_EQUALS:
+ return (exp->args.node_args.a == exp->args.node_args.b);
+ case EPHY_NODE_FILTER_EXPRESSION_EQUALS:
+ return (exp->args.node_args.a == node);
+ case EPHY_NODE_FILTER_EXPRESSION_HAS_PARENT:
+ return ephy_node_has_child (exp->args.node_args.a, node);
+ case EPHY_NODE_FILTER_EXPRESSION_HAS_CHILD:
+ return ephy_node_has_child (node, exp->args.node_args.a);
+ case EPHY_NODE_FILTER_EXPRESSION_NODE_PROP_EQUALS:
+ {
+ EphyNode *prop;
+
+ prop = ephy_node_get_property_node (node,
+ exp->args.prop_args.prop_id);
+
+ return (prop == exp->args.prop_args.second_arg.node);
+ }
+ case EPHY_NODE_FILTER_EXPRESSION_CHILD_PROP_EQUALS:
+ {
+ EphyNode *prop;
+ GPtrArray *children;
+ guint i;
+
+ children = ephy_node_get_children (node);
+ for (i = 0; i < children->len; i++) {
+ EphyNode *child;
+
+ child = g_ptr_array_index (children, i);
+ prop = ephy_node_get_property_node
+ (child, exp->args.prop_args.prop_id);
+
+ if (prop == exp->args.prop_args.second_arg.node) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+ }
+ case EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_CONTAINS:
+ {
+ const char *prop;
+ char *folded_case;
+ gboolean ret;
+
+ prop = ephy_node_get_property_string (node,
+ exp->args.prop_args.prop_id);
+ if (prop == NULL)
+ return FALSE;
+
+ folded_case = g_utf8_casefold (prop, -1);
+ ret = (strstr (folded_case, exp->args.prop_args.second_arg.string) != NULL);
+ g_free (folded_case);
+
+ return ret;
+ }
+ case EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_EQUALS:
+ {
+ const char *prop;
+ char *folded_case;
+ gboolean ret;
+
+ prop = ephy_node_get_property_string (node,
+ exp->args.prop_args.prop_id);
+
+ if (prop == NULL)
+ return FALSE;
+
+ folded_case = g_utf8_casefold (prop, -1);
+ ret = (strcmp (folded_case, exp->args.prop_args.second_arg.string) == 0);
+ g_free (folded_case);
+
+ return ret;
+ }
+ case EPHY_NODE_FILTER_EXPRESSION_KEY_PROP_CONTAINS:
+ {
+ const char *prop;
+
+ prop = ephy_node_get_property_string (node,
+ exp->args.prop_args.prop_id);
+
+ if (prop == NULL)
+ return FALSE;
+
+ return (strstr (prop, exp->args.prop_args.second_arg.string) != NULL);
+ }
+ case EPHY_NODE_FILTER_EXPRESSION_KEY_PROP_EQUALS:
+ {
+ const char *prop;
+
+ prop = ephy_node_get_property_string (node,
+ exp->args.prop_args.prop_id);
+
+ if (prop == NULL)
+ return FALSE;
+
+ return (strcmp (prop, exp->args.prop_args.second_arg.string) == 0);
+ }
+ case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_EQUALS:
+ {
+ int prop;
+
+ prop = ephy_node_get_property_int (node,
+ exp->args.prop_args.prop_id);
+
+ return (prop == exp->args.prop_args.second_arg.number);
+ }
+ case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_BIGGER_THAN:
+ {
+ int prop;
+
+ prop = ephy_node_get_property_int (node,
+ exp->args.prop_args.prop_id);
+
+ return (prop > exp->args.prop_args.second_arg.number);
+ }
+ case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_LESS_THAN:
+ {
+ int prop;
+
+ prop = ephy_node_get_property_int (node,
+ exp->args.prop_args.prop_id);
+
+ return (prop < exp->args.prop_args.second_arg.number);
+ }
+ default:
+ break;
+ }
+
+ return FALSE;
}
diff --git a/lib/ephy-node.c b/lib/ephy-node.c
index 9216a38c2..0303fdafd 100644
--- a/lib/ephy-node.c
+++ b/lib/ephy-node.c
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright © 2002 Jorn Baayen <jorn@nl.linux.org>
* Copyright © 2003 Marco Pesenti Gritti
* Copyright © 2003 Christian Persch
@@ -29,356 +29,348 @@
#include "ephy-node.h"
-typedef struct
-{
- EphyNode *node;
- int id;
- EphyNodeCallback callback;
- EphyNodeSignalType type;
- gpointer data;
- gboolean invalidated;
+typedef struct {
+ EphyNode *node;
+ int id;
+ EphyNodeCallback callback;
+ EphyNodeSignalType type;
+ gpointer data;
+ gboolean invalidated;
} EphyNodeSignalData;
-typedef struct
-{
- EphyNode *node;
- guint index;
+typedef struct {
+ EphyNode *node;
+ guint index;
} EphyNodeParent;
-typedef struct
-{
- EphyNode *node;
- guint property_id;
+typedef struct {
+ EphyNode *node;
+ guint property_id;
} EphyNodeChange;
-struct _EphyNode
-{
- int ref_count;
+struct _EphyNode {
+ int ref_count;
- guint id;
+ guint id;
- GPtrArray *properties;
+ GPtrArray *properties;
- GHashTable *parents;
- GPtrArray *children;
+ GHashTable *parents;
+ GPtrArray *children;
- GHashTable *signals;
- int signal_id;
- guint emissions;
- guint invalidated_signals;
- guint is_drag_source : 1;
- guint is_drag_dest : 1;
+ GHashTable *signals;
+ int signal_id;
+ guint emissions;
+ guint invalidated_signals;
+ guint is_drag_source : 1;
+ guint is_drag_dest : 1;
- EphyNodeDb *db;
+ EphyNodeDb *db;
};
-typedef struct
-{
- EphyNodeSignalType type;
- va_list valist;
+typedef struct {
+ EphyNodeSignalType type;
+ va_list valist;
} ENESCData;
static gboolean
int_equal (gconstpointer a,
- gconstpointer b)
+ gconstpointer b)
{
- return GPOINTER_TO_INT (a) == GPOINTER_TO_INT (b);
+ return GPOINTER_TO_INT (a) == GPOINTER_TO_INT (b);
}
static guint
int_hash (gconstpointer a)
{
- return GPOINTER_TO_INT (a);
+ return GPOINTER_TO_INT (a);
}
static void
callback (long id, EphyNodeSignalData *data, gpointer *dummy)
{
- ENESCData *user_data;
- va_list valist;
+ ENESCData *user_data;
+ va_list valist;
+
+ if (data->invalidated) return;
+
+ user_data = (ENESCData *)dummy;
- if (data->invalidated) return;
+ G_VA_COPY (valist, user_data->valist);
- user_data = (ENESCData *) dummy;
+ if (data->type != user_data->type) return;
- G_VA_COPY(valist, user_data->valist);
+ switch (data->type) {
+ case EPHY_NODE_DESTROY:
+ case EPHY_NODE_RESTORED:
+ data->callback (data->node, data->data);
+ break;
- if (data->type != user_data->type) return;
+ case EPHY_NODE_CHANGED:
+ {
+ guint property_id;
- switch (data->type)
- {
- case EPHY_NODE_DESTROY:
- case EPHY_NODE_RESTORED:
- data->callback (data->node, data->data);
- break;
+ property_id = va_arg (valist, guint);
- case EPHY_NODE_CHANGED:
- {
- guint property_id;
+ data->callback (data->node, property_id, data->data);
+ }
+ break;
- property_id = va_arg (valist, guint);
-
- data->callback (data->node, property_id, data->data);
- }
- break;
+ case EPHY_NODE_CHILD_ADDED:
+ {
+ EphyNode *node;
- case EPHY_NODE_CHILD_ADDED:
- {
- EphyNode *node;
+ node = va_arg (valist, EphyNode *);
- node = va_arg (valist, EphyNode *);
-
- data->callback (data->node, node, data->data);
- }
- break;
+ data->callback (data->node, node, data->data);
+ }
+ break;
- case EPHY_NODE_CHILD_CHANGED:
- {
- EphyNode *node;
- guint property_id;
+ case EPHY_NODE_CHILD_CHANGED:
+ {
+ EphyNode *node;
+ guint property_id;
- node = va_arg (valist, EphyNode *);
- property_id = va_arg (valist, guint);
-
- data->callback (data->node, node, property_id, data->data);
- }
- break;
+ node = va_arg (valist, EphyNode *);
+ property_id = va_arg (valist, guint);
- case EPHY_NODE_CHILD_REMOVED:
- {
- EphyNode *node;
- guint last_index;
+ data->callback (data->node, node, property_id, data->data);
+ }
+ break;
- node = va_arg (valist, EphyNode *);
- last_index = va_arg (valist, guint);
+ case EPHY_NODE_CHILD_REMOVED:
+ {
+ EphyNode *node;
+ guint last_index;
- data->callback (data->node, node, last_index, data->data);
- }
- break;
+ node = va_arg (valist, EphyNode *);
+ last_index = va_arg (valist, guint);
- case EPHY_NODE_CHILDREN_REORDERED:
- data->callback (data->node, va_arg (valist, int *), data->data);
- break;
+ data->callback (data->node, node, last_index, data->data);
+ }
+ break;
- default:
- break;
- }
+ case EPHY_NODE_CHILDREN_REORDERED:
+ data->callback (data->node, va_arg (valist, int *), data->data);
+ break;
- va_end(valist);
+ default:
+ break;
+ }
+
+ va_end (valist);
}
static gboolean
-remove_invalidated_signals (long id,
- EphyNodeSignalData *data,
- gpointer user_data)
+remove_invalidated_signals (long id,
+ EphyNodeSignalData *data,
+ gpointer user_data)
{
- return data->invalidated;
+ return data->invalidated;
}
static void
ephy_node_emit_signal (EphyNode *node, EphyNodeSignalType type, ...)
{
- ENESCData data;
+ ENESCData data;
- ++node->emissions;
+ ++node->emissions;
- va_start (data.valist, type);
+ va_start (data.valist, type);
- data.type = type;
+ data.type = type;
- g_hash_table_foreach (node->signals,
- (GHFunc) callback,
- &data);
+ g_hash_table_foreach (node->signals,
+ (GHFunc)callback,
+ &data);
- va_end (data.valist);
+ va_end (data.valist);
- if (G_UNLIKELY (--node->emissions == 0 && node->invalidated_signals))
- {
- guint removed;
+ if (G_UNLIKELY (--node->emissions == 0 && node->invalidated_signals)) {
+ guint removed;
- removed = g_hash_table_foreach_remove
- (node->signals,
- (GHRFunc) remove_invalidated_signals,
- NULL);
- g_assert (removed == node->invalidated_signals);
+ removed = g_hash_table_foreach_remove
+ (node->signals,
+ (GHRFunc)remove_invalidated_signals,
+ NULL);
+ g_assert (removed == node->invalidated_signals);
- node->invalidated_signals = 0;
- }
+ node->invalidated_signals = 0;
+ }
}
static inline void
real_remove_child (EphyNode *node,
- EphyNode *child,
- gboolean remove_from_parent,
- gboolean remove_from_child)
+ EphyNode *child,
+ gboolean remove_from_parent,
+ gboolean remove_from_child)
{
- EphyNodeParent *node_info;
+ EphyNodeParent *node_info;
- node_info = g_hash_table_lookup (child->parents,
- GINT_TO_POINTER (node->id));
+ node_info = g_hash_table_lookup (child->parents,
+ GINT_TO_POINTER (node->id));
- if (remove_from_parent) {
- guint i;
- guint old_index;
+ if (remove_from_parent) {
+ guint i;
+ guint old_index;
- old_index = node_info->index;
+ old_index = node_info->index;
- g_ptr_array_remove_index (node->children,
- node_info->index);
+ g_ptr_array_remove_index (node->children,
+ node_info->index);
- /* correct indices on kids */
- for (i = node_info->index; i < node->children->len; i++) {
- EphyNode *borked_node;
- EphyNodeParent *borked_node_info;
+ /* correct indices on kids */
+ for (i = node_info->index; i < node->children->len; i++) {
+ EphyNode *borked_node;
+ EphyNodeParent *borked_node_info;
- borked_node = g_ptr_array_index (node->children, i);
+ borked_node = g_ptr_array_index (node->children, i);
- borked_node_info = g_hash_table_lookup (borked_node->parents,
- GINT_TO_POINTER (node->id));
- borked_node_info->index--;
- }
+ borked_node_info = g_hash_table_lookup (borked_node->parents,
+ GINT_TO_POINTER (node->id));
+ borked_node_info->index--;
+ }
- ephy_node_emit_signal (node, EPHY_NODE_CHILD_REMOVED, child, old_index);
- }
+ ephy_node_emit_signal (node, EPHY_NODE_CHILD_REMOVED, child, old_index);
+ }
- if (remove_from_child) {
- g_hash_table_remove (child->parents,
- GINT_TO_POINTER (node->id));
- }
+ if (remove_from_child) {
+ g_hash_table_remove (child->parents,
+ GINT_TO_POINTER (node->id));
+ }
}
static void
-remove_child (long id,
- EphyNodeParent *node_info,
- EphyNode *node)
+remove_child (long id,
+ EphyNodeParent *node_info,
+ EphyNode *node)
{
- real_remove_child (node_info->node, node, TRUE, FALSE);
+ real_remove_child (node_info->node, node, TRUE, FALSE);
}
static void
signal_object_weak_notify (EphyNodeSignalData *signal_data,
- GObject *where_the_object_was)
+ GObject *where_the_object_was)
{
- signal_data->data = NULL;
- ephy_node_signal_disconnect (signal_data->node, signal_data->id);
+ signal_data->data = NULL;
+ ephy_node_signal_disconnect (signal_data->node, signal_data->id);
}
static void
destroy_signal_data (EphyNodeSignalData *signal_data)
{
- if (signal_data->data)
- {
- g_object_weak_unref (G_OBJECT (signal_data->data),
- (GWeakNotify)signal_object_weak_notify,
- signal_data);
- }
-
- g_slice_free (EphyNodeSignalData, signal_data);
+ if (signal_data->data) {
+ g_object_weak_unref (G_OBJECT (signal_data->data),
+ (GWeakNotify)signal_object_weak_notify,
+ signal_data);
+ }
+
+ g_slice_free (EphyNodeSignalData, signal_data);
}
static void
node_parent_free (EphyNodeParent *parent)
{
- g_slice_free (EphyNodeParent, parent);
+ g_slice_free (EphyNodeParent, parent);
}
static void
ephy_node_destroy (EphyNode *node)
{
- guint i;
+ guint i;
- ephy_node_emit_signal (node, EPHY_NODE_DESTROY);
+ ephy_node_emit_signal (node, EPHY_NODE_DESTROY);
- /* Remove from parents. */
- g_hash_table_foreach (node->parents,
- (GHFunc) remove_child,
- node);
- g_hash_table_destroy (node->parents);
+ /* Remove from parents. */
+ g_hash_table_foreach (node->parents,
+ (GHFunc)remove_child,
+ node);
+ g_hash_table_destroy (node->parents);
- /* Remove children. */
- for (i = 0; i < node->children->len; i++) {
- EphyNode *child;
+ /* Remove children. */
+ for (i = 0; i < node->children->len; i++) {
+ EphyNode *child;
- child = g_ptr_array_index (node->children, i);
+ child = g_ptr_array_index (node->children, i);
- real_remove_child (node, child, FALSE, TRUE);
- }
- g_ptr_array_free (node->children, TRUE);
-
- /* Remove signals. */
- g_hash_table_destroy (node->signals);
+ real_remove_child (node, child, FALSE, TRUE);
+ }
+ g_ptr_array_free (node->children, TRUE);
- /* Remove id. */
- _ephy_node_db_remove_id (node->db, node->id);
+ /* Remove signals. */
+ g_hash_table_destroy (node->signals);
- /* Remove properties. */
- for (i = 0; i < node->properties->len; i++) {
- GValue *val;
+ /* Remove id. */
+ _ephy_node_db_remove_id (node->db, node->id);
- val = g_ptr_array_index (node->properties, i);
+ /* Remove properties. */
+ for (i = 0; i < node->properties->len; i++) {
+ GValue *val;
- if (val != NULL) {
- g_value_unset (val);
- g_slice_free (GValue, val);
- }
- }
- g_ptr_array_free (node->properties, TRUE);
+ val = g_ptr_array_index (node->properties, i);
- g_slice_free (EphyNode, node);
+ if (val != NULL) {
+ g_value_unset (val);
+ g_slice_free (GValue, val);
+ }
+ }
+ g_ptr_array_free (node->properties, TRUE);
+
+ g_slice_free (EphyNode, node);
}
EphyNode *
ephy_node_new (EphyNodeDb *db)
{
- long id;
+ long id;
- g_return_val_if_fail (EPHY_IS_NODE_DB (db), NULL);
+ g_return_val_if_fail (EPHY_IS_NODE_DB (db), NULL);
- if (ephy_node_db_is_immutable (db)) return NULL;
+ if (ephy_node_db_is_immutable (db)) return NULL;
- id = _ephy_node_db_new_id (db);
+ id = _ephy_node_db_new_id (db);
- return ephy_node_new_with_id (db, id);
+ return ephy_node_new_with_id (db, id);
}
EphyNode *
ephy_node_new_with_id (EphyNodeDb *db, guint reserved_id)
{
- EphyNode *node;
+ EphyNode *node;
- g_return_val_if_fail (EPHY_IS_NODE_DB (db), NULL);
+ g_return_val_if_fail (EPHY_IS_NODE_DB (db), NULL);
- if (ephy_node_db_is_immutable (db)) return NULL;
+ if (ephy_node_db_is_immutable (db)) return NULL;
- node = g_slice_new0 (EphyNode);
+ node = g_slice_new0 (EphyNode);
- node->ref_count = 1;
+ node->ref_count = 1;
- node->id = reserved_id;
+ node->id = reserved_id;
- node->db = db;
+ node->db = db;
- node->properties = g_ptr_array_new ();
+ node->properties = g_ptr_array_new ();
- node->children = g_ptr_array_new ();
+ node->children = g_ptr_array_new ();
- node->parents = g_hash_table_new_full
- (int_hash, int_equal, NULL, (GDestroyNotify) node_parent_free);
+ node->parents = g_hash_table_new_full
+ (int_hash, int_equal, NULL, (GDestroyNotify)node_parent_free);
- node->signals = g_hash_table_new_full
- (int_hash, int_equal, NULL,
- (GDestroyNotify)destroy_signal_data);
+ node->signals = g_hash_table_new_full
+ (int_hash, int_equal, NULL,
+ (GDestroyNotify)destroy_signal_data);
- node->signal_id = 0;
- node->emissions = 0;
- node->invalidated_signals = 0;
- node->is_drag_source = TRUE;
- node->is_drag_dest = TRUE;
+ node->signal_id = 0;
+ node->emissions = 0;
+ node->invalidated_signals = 0;
+ node->is_drag_source = TRUE;
+ node->is_drag_dest = TRUE;
- _ephy_node_db_add_id (db, reserved_id, node);
+ _ephy_node_db_add_id (db, reserved_id, node);
- return node;
+ return node;
}
/**
@@ -389,108 +381,107 @@ ephy_node_new_with_id (EphyNodeDb *db, guint reserved_id)
EphyNodeDb *
ephy_node_get_db (EphyNode *node)
{
- g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
-
- return node->db;
+ g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
+
+ return node->db;
}
guint
ephy_node_get_id (EphyNode *node)
{
- long ret;
+ long ret;
- g_return_val_if_fail (EPHY_IS_NODE (node), G_MAXUINT);
+ g_return_val_if_fail (EPHY_IS_NODE (node), G_MAXUINT);
- ret = node->id;
+ ret = node->id;
- return ret;
+ return ret;
}
void
ephy_node_ref (EphyNode *node)
{
- g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (EPHY_IS_NODE (node));
- node->ref_count++;
+ node->ref_count++;
}
void
ephy_node_unref (EphyNode *node)
{
- g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (EPHY_IS_NODE (node));
- node->ref_count--;
+ node->ref_count--;
- if (node->ref_count <= 0) {
- ephy_node_destroy (node);
- }
+ if (node->ref_count <= 0) {
+ ephy_node_destroy (node);
+ }
}
static void
-child_changed (guint id,
- EphyNodeParent *node_info,
- EphyNodeChange *change)
+child_changed (guint id,
+ EphyNodeParent *node_info,
+ EphyNodeChange *change)
{
- ephy_node_emit_signal (node_info->node, EPHY_NODE_CHILD_CHANGED,
- change->node, change->property_id);
+ ephy_node_emit_signal (node_info->node, EPHY_NODE_CHILD_CHANGED,
+ change->node, change->property_id);
}
static inline void
real_set_property (EphyNode *node,
- guint property_id,
- GValue *value)
+ guint property_id,
+ GValue *value)
{
- GValue *old;
+ GValue *old;
- if (property_id >= node->properties->len) {
- g_ptr_array_set_size (node->properties, property_id + 1);
- }
+ if (property_id >= node->properties->len) {
+ g_ptr_array_set_size (node->properties, property_id + 1);
+ }
- old = g_ptr_array_index (node->properties, property_id);
- if (old != NULL) {
- g_value_unset (old);
- g_slice_free (GValue, old);
- }
+ old = g_ptr_array_index (node->properties, property_id);
+ if (old != NULL) {
+ g_value_unset (old);
+ g_slice_free (GValue, old);
+ }
- g_ptr_array_index (node->properties, property_id) = value;
+ g_ptr_array_index (node->properties, property_id) = value;
}
static inline void
ephy_node_set_property_internal (EphyNode *node,
- guint property_id,
- GValue *value)
+ guint property_id,
+ GValue *value)
{
- EphyNodeChange change;
+ EphyNodeChange change;
- real_set_property (node, property_id, value);
+ real_set_property (node, property_id, value);
- change.node = node;
- change.property_id = property_id;
- g_hash_table_foreach (node->parents,
- (GHFunc) child_changed,
- &change);
-
- ephy_node_emit_signal (node, EPHY_NODE_CHANGED, property_id);
+ change.node = node;
+ change.property_id = property_id;
+ g_hash_table_foreach (node->parents,
+ (GHFunc)child_changed,
+ &change);
+ ephy_node_emit_signal (node, EPHY_NODE_CHANGED, property_id);
}
void
-ephy_node_set_property (EphyNode *node,
- guint property_id,
- const GValue *value)
+ephy_node_set_property (EphyNode *node,
+ guint property_id,
+ const GValue *value)
{
- GValue *new;
+ GValue *new;
- g_return_if_fail (EPHY_IS_NODE (node));
- g_return_if_fail (value != NULL);
+ g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (value != NULL);
- if (ephy_node_db_is_immutable (node->db)) return;
+ if (ephy_node_db_is_immutable (node->db)) return;
- new = g_slice_new0 (GValue);
- g_value_init (new, G_VALUE_TYPE (value));
- g_value_copy (value, new);
+ new = g_slice_new0 (GValue);
+ g_value_init (new, G_VALUE_TYPE (value));
+ g_value_copy (value, new);
- ephy_node_set_property_internal (node, property_id, new);
+ ephy_node_set_property_internal (node, property_id, new);
}
/**
@@ -500,273 +491,273 @@ ephy_node_set_property (EphyNode *node,
*/
gboolean
ephy_node_get_property (EphyNode *node,
- guint property_id,
- GValue *value)
+ guint property_id,
+ GValue *value)
{
- GValue *ret;
+ GValue *ret;
- g_return_val_if_fail (EPHY_IS_NODE (node), FALSE);
- g_return_val_if_fail (value != NULL, FALSE);
+ g_return_val_if_fail (EPHY_IS_NODE (node), FALSE);
+ g_return_val_if_fail (value != NULL, FALSE);
- if (property_id >= node->properties->len) {
- return FALSE;
- }
+ if (property_id >= node->properties->len) {
+ return FALSE;
+ }
- ret = g_ptr_array_index (node->properties, property_id);
- if (ret == NULL) {
- return FALSE;
- }
+ ret = g_ptr_array_index (node->properties, property_id);
+ if (ret == NULL) {
+ return FALSE;
+ }
- g_value_init (value, G_VALUE_TYPE (ret));
- g_value_copy (ret, value);
+ g_value_init (value, G_VALUE_TYPE (ret));
+ g_value_copy (ret, value);
- return TRUE;
+ return TRUE;
}
void
-ephy_node_set_property_string (EphyNode *node,
- guint property_id,
- const char *value)
+ephy_node_set_property_string (EphyNode *node,
+ guint property_id,
+ const char *value)
{
- GValue *new;
+ GValue *new;
- g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (EPHY_IS_NODE (node));
- if (ephy_node_db_is_immutable (node->db)) return;
+ if (ephy_node_db_is_immutable (node->db)) return;
- new = g_slice_new0 (GValue);
- g_value_init (new, G_TYPE_STRING);
- g_value_set_string (new, value);
+ new = g_slice_new0 (GValue);
+ g_value_init (new, G_TYPE_STRING);
+ g_value_set_string (new, value);
- ephy_node_set_property_internal (node, property_id, new);
+ ephy_node_set_property_internal (node, property_id, new);
}
const char *
ephy_node_get_property_string (EphyNode *node,
- guint property_id)
+ guint property_id)
{
- GValue *ret;
- const char *retval;
+ GValue *ret;
+ const char *retval;
- g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
+ g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
- if (property_id >= node->properties->len) {
- return NULL;
- }
+ if (property_id >= node->properties->len) {
+ return NULL;
+ }
- ret = g_ptr_array_index (node->properties, property_id);
- if (ret == NULL) {
- return NULL;
- }
+ ret = g_ptr_array_index (node->properties, property_id);
+ if (ret == NULL) {
+ return NULL;
+ }
- retval = g_value_get_string (ret);
+ retval = g_value_get_string (ret);
- return retval;
+ return retval;
}
void
ephy_node_set_property_boolean (EphyNode *node,
- guint property_id,
- gboolean value)
+ guint property_id,
+ gboolean value)
{
- GValue *new;
+ GValue *new;
- g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (EPHY_IS_NODE (node));
- if (ephy_node_db_is_immutable (node->db)) return;
+ if (ephy_node_db_is_immutable (node->db)) return;
- new = g_slice_new0 (GValue);
- g_value_init (new, G_TYPE_BOOLEAN);
- g_value_set_boolean (new, value);
+ new = g_slice_new0 (GValue);
+ g_value_init (new, G_TYPE_BOOLEAN);
+ g_value_set_boolean (new, value);
- ephy_node_set_property_internal (node, property_id, new);
+ ephy_node_set_property_internal (node, property_id, new);
}
gboolean
ephy_node_get_property_boolean (EphyNode *node,
- guint property_id)
+ guint property_id)
{
- GValue *ret;
- gboolean retval;
+ GValue *ret;
+ gboolean retval;
- g_return_val_if_fail (EPHY_IS_NODE (node), FALSE);
+ g_return_val_if_fail (EPHY_IS_NODE (node), FALSE);
- if (property_id >= node->properties->len) {
- return FALSE;
- }
+ if (property_id >= node->properties->len) {
+ return FALSE;
+ }
- ret = g_ptr_array_index (node->properties, property_id);
- if (ret == NULL) {
- return FALSE;
- }
+ ret = g_ptr_array_index (node->properties, property_id);
+ if (ret == NULL) {
+ return FALSE;
+ }
- retval = g_value_get_boolean (ret);
+ retval = g_value_get_boolean (ret);
- return retval;
+ return retval;
}
void
ephy_node_set_property_long (EphyNode *node,
- guint property_id,
- long value)
+ guint property_id,
+ long value)
{
- GValue *new;
+ GValue *new;
- g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (EPHY_IS_NODE (node));
- if (ephy_node_db_is_immutable (node->db)) return;
+ if (ephy_node_db_is_immutable (node->db)) return;
- new = g_slice_new0 (GValue);
- g_value_init (new, G_TYPE_LONG);
- g_value_set_long (new, value);
+ new = g_slice_new0 (GValue);
+ g_value_init (new, G_TYPE_LONG);
+ g_value_set_long (new, value);
- ephy_node_set_property_internal (node, property_id, new);
+ ephy_node_set_property_internal (node, property_id, new);
}
long
ephy_node_get_property_long (EphyNode *node,
- guint property_id)
+ guint property_id)
{
- GValue *ret;
- long retval;
+ GValue *ret;
+ long retval;
- g_return_val_if_fail (EPHY_IS_NODE (node), -1);
+ g_return_val_if_fail (EPHY_IS_NODE (node), -1);
- if (property_id >= node->properties->len) {
- return -1;
- }
+ if (property_id >= node->properties->len) {
+ return -1;
+ }
- ret = g_ptr_array_index (node->properties, property_id);
- if (ret == NULL) {
- return -1;
- }
+ ret = g_ptr_array_index (node->properties, property_id);
+ if (ret == NULL) {
+ return -1;
+ }
- retval = g_value_get_long (ret);
+ retval = g_value_get_long (ret);
- return retval;
+ return retval;
}
void
ephy_node_set_property_int (EphyNode *node,
- guint property_id,
- int value)
+ guint property_id,
+ int value)
{
- GValue *new;
+ GValue *new;
- g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (EPHY_IS_NODE (node));
- if (ephy_node_db_is_immutable (node->db)) return;
+ if (ephy_node_db_is_immutable (node->db)) return;
- new = g_slice_new0 (GValue);
- g_value_init (new, G_TYPE_INT);
- g_value_set_int (new, value);
+ new = g_slice_new0 (GValue);
+ g_value_init (new, G_TYPE_INT);
+ g_value_set_int (new, value);
- ephy_node_set_property_internal (node, property_id, new);
+ ephy_node_set_property_internal (node, property_id, new);
}
int
ephy_node_get_property_int (EphyNode *node,
- guint property_id)
+ guint property_id)
{
- GValue *ret;
- int retval;
+ GValue *ret;
+ int retval;
- g_return_val_if_fail (EPHY_IS_NODE (node), -1);
+ g_return_val_if_fail (EPHY_IS_NODE (node), -1);
- if (property_id >= node->properties->len) {
- return -1;
- }
+ if (property_id >= node->properties->len) {
+ return -1;
+ }
- ret = g_ptr_array_index (node->properties, property_id);
- if (ret == NULL) {
- return -1;
- }
+ ret = g_ptr_array_index (node->properties, property_id);
+ if (ret == NULL) {
+ return -1;
+ }
- retval = g_value_get_int (ret);
+ retval = g_value_get_int (ret);
- return retval;
+ return retval;
}
void
ephy_node_set_property_double (EphyNode *node,
- guint property_id,
- double value)
+ guint property_id,
+ double value)
{
- GValue *new;
+ GValue *new;
- g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (EPHY_IS_NODE (node));
- if (ephy_node_db_is_immutable (node->db)) return;
+ if (ephy_node_db_is_immutable (node->db)) return;
- new = g_slice_new0 (GValue);
- g_value_init (new, G_TYPE_DOUBLE);
- g_value_set_double (new, value);
+ new = g_slice_new0 (GValue);
+ g_value_init (new, G_TYPE_DOUBLE);
+ g_value_set_double (new, value);
- ephy_node_set_property_internal (node, property_id, new);
+ ephy_node_set_property_internal (node, property_id, new);
}
double
ephy_node_get_property_double (EphyNode *node,
- guint property_id)
+ guint property_id)
{
- GValue *ret;
- double retval;
+ GValue *ret;
+ double retval;
- g_return_val_if_fail (EPHY_IS_NODE (node), -1);
+ g_return_val_if_fail (EPHY_IS_NODE (node), -1);
- if (property_id >= node->properties->len) {
- return -1;
- }
+ if (property_id >= node->properties->len) {
+ return -1;
+ }
- ret = g_ptr_array_index (node->properties, property_id);
- if (ret == NULL) {
- return -1;
- }
+ ret = g_ptr_array_index (node->properties, property_id);
+ if (ret == NULL) {
+ return -1;
+ }
- retval = g_value_get_double (ret);
+ retval = g_value_get_double (ret);
- return retval;
+ return retval;
}
void
ephy_node_set_property_float (EphyNode *node,
- guint property_id,
- float value)
+ guint property_id,
+ float value)
{
- GValue *new;
+ GValue *new;
- g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (EPHY_IS_NODE (node));
- if (ephy_node_db_is_immutable (node->db)) return;
+ if (ephy_node_db_is_immutable (node->db)) return;
- new = g_slice_new0 (GValue);
- g_value_init (new, G_TYPE_FLOAT);
- g_value_set_float (new, value);
+ new = g_slice_new0 (GValue);
+ g_value_init (new, G_TYPE_FLOAT);
+ g_value_set_float (new, value);
- ephy_node_set_property_internal (node, property_id, new);
+ ephy_node_set_property_internal (node, property_id, new);
}
float
ephy_node_get_property_float (EphyNode *node,
- guint property_id)
+ guint property_id)
{
- GValue *ret;
- float retval;
+ GValue *ret;
+ float retval;
- g_return_val_if_fail (EPHY_IS_NODE (node), -1);
+ g_return_val_if_fail (EPHY_IS_NODE (node), -1);
- if (property_id >= node->properties->len) {
- return -1;
- }
+ if (property_id >= node->properties->len) {
+ return -1;
+ }
- ret = g_ptr_array_index (node->properties, property_id);
- if (ret == NULL) {
- return -1;
- }
+ ret = g_ptr_array_index (node->properties, property_id);
+ if (ret == NULL) {
+ return -1;
+ }
- retval = g_value_get_float (ret);
+ retval = g_value_get_float (ret);
- return retval;
+ return retval;
}
/**
@@ -776,371 +767,351 @@ ephy_node_get_property_float (EphyNode *node,
**/
EphyNode *
ephy_node_get_property_node (EphyNode *node,
- guint property_id)
+ guint property_id)
{
- GValue *ret;
- EphyNode *retval;
+ GValue *ret;
+ EphyNode *retval;
- g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
+ g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
- if (property_id >= node->properties->len) {
- return NULL;
- }
+ if (property_id >= node->properties->len) {
+ return NULL;
+ }
- ret = g_ptr_array_index (node->properties, property_id);
- if (ret == NULL) {
- return NULL;
- }
+ ret = g_ptr_array_index (node->properties, property_id);
+ if (ret == NULL) {
+ return NULL;
+ }
- retval = g_value_get_pointer (ret);
+ retval = g_value_get_pointer (ret);
- return retval;
+ return retval;
}
-typedef struct
-{
- xmlTextWriterPtr writer;
- int ret;
+typedef struct {
+ xmlTextWriterPtr writer;
+ int ret;
} ForEachData;
static void
-write_parent (guint id,
- EphyNodeParent *node_info,
- ForEachData* data)
+write_parent (guint id,
+ EphyNodeParent *node_info,
+ ForEachData *data)
{
- xmlTextWriterPtr writer = data->writer;
+ xmlTextWriterPtr writer = data->writer;
- /* there already was an error, do nothing. this works around
- * the fact that g_hash_table_foreach cannot be cancelled.
- */
- if (data->ret < 0) return;
+ /* there already was an error, do nothing. this works around
+ * the fact that g_hash_table_foreach cannot be cancelled.
+ */
+ if (data->ret < 0) return;
- data->ret = xmlTextWriterStartElement (writer, (const xmlChar *)"parent");
- if (data->ret < 0) return;
+ data->ret = xmlTextWriterStartElement (writer, (const xmlChar *)"parent");
+ if (data->ret < 0) return;
- data->ret = xmlTextWriterWriteFormatAttribute
- (writer, (const xmlChar *)"id", "%d", node_info->node->id);
- if (data->ret < 0) return;
+ data->ret = xmlTextWriterWriteFormatAttribute
+ (writer, (const xmlChar *)"id", "%d", node_info->node->id);
+ if (data->ret < 0) return;
- data->ret = xmlTextWriterEndElement (writer); /* parent */
- if (data->ret < 0) return;
+ data->ret = xmlTextWriterEndElement (writer); /* parent */
+ if (data->ret < 0) return;
}
static inline int
safe_write_string (xmlTextWriterPtr writer,
- const xmlChar *string)
+ const xmlChar *string)
{
- int ret;
- xmlChar *copy, *p;
-
- if (!string)
- return 0;
-
- /* http://www.w3.org/TR/REC-xml/#sec-well-formed :
- Character Range
- [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] |
- [#xE000-#xFFFD] | [#x10000-#x10FFFF]
- any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
- */
-
- copy = xmlStrdup (string);
- for (p = copy; *p; p++)
- {
- xmlChar c = *p;
- if (G_UNLIKELY (c < 0x20 && c != 0xd && c != 0xa && c != 0x9)) {
- *p = 0x20;
- }
- }
-
- ret = xmlTextWriterWriteString (writer, copy);
- xmlFree (copy);
-
- return ret;
+ int ret;
+ xmlChar *copy, *p;
+
+ if (!string)
+ return 0;
+
+ /* http://www.w3.org/TR/REC-xml/#sec-well-formed :
+ Character Range
+ [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] |
+ [#xE000-#xFFFD] | [#x10000-#x10FFFF]
+ any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
+ */
+
+ copy = xmlStrdup (string);
+ for (p = copy; *p; p++) {
+ xmlChar c = *p;
+ if (G_UNLIKELY (c < 0x20 && c != 0xd && c != 0xa && c != 0x9)) {
+ *p = 0x20;
+ }
+ }
+
+ ret = xmlTextWriterWriteString (writer, copy);
+ xmlFree (copy);
+
+ return ret;
}
int
-ephy_node_write_to_xml(EphyNode *node,
- xmlTextWriterPtr writer)
-{
- xmlChar xml_buf[G_ASCII_DTOSTR_BUF_SIZE];
- guint i;
- int ret;
- ForEachData data;
-
- g_return_val_if_fail (EPHY_IS_NODE (node), -1);
- g_return_val_if_fail (writer != NULL, -1);
-
- /* start writing the node */
- ret = xmlTextWriterStartElement (writer, (const xmlChar *)"node");
- if (ret < 0) goto out;
-
- /* write node id */
- ret = xmlTextWriterWriteFormatAttribute (writer, (const xmlChar *)"id", "%d", node->id);
- if (ret < 0) goto out;
-
- /* write node properties */
- for (i = 0; i < node->properties->len; i++)
- {
- GValue *value;
-
- value = g_ptr_array_index (node->properties, i);
-
- if (value == NULL) continue;
- if (G_VALUE_TYPE (value) == G_TYPE_STRING &&
- g_value_get_string (value) == NULL) continue;
-
- ret = xmlTextWriterStartElement (writer, (const xmlChar *)"property");
- if (ret < 0) break;
-
- ret = xmlTextWriterWriteFormatAttribute (writer, (const xmlChar *)"id", "%d", i);
- if (ret < 0) break;
-
- ret = xmlTextWriterWriteAttribute
- (writer, (const xmlChar *)"value_type",
- (const xmlChar *)g_type_name (G_VALUE_TYPE (value)));
- if (ret < 0) break;
-
- switch (G_VALUE_TYPE (value))
- {
- case G_TYPE_STRING:
- ret = safe_write_string
- (writer, (const xmlChar *)g_value_get_string (value));
- break;
- case G_TYPE_BOOLEAN:
- ret = xmlTextWriterWriteFormatString
- (writer, "%d", g_value_get_boolean (value));
- break;
- case G_TYPE_INT:
- ret = xmlTextWriterWriteFormatString
- (writer, "%d", g_value_get_int (value));
- break;
- case G_TYPE_LONG:
- ret = xmlTextWriterWriteFormatString
- (writer, "%ld", g_value_get_long (value));
- break;
- case G_TYPE_FLOAT:
- g_ascii_dtostr ((gchar *)xml_buf, sizeof (xml_buf),
- g_value_get_float (value));
- ret = xmlTextWriterWriteString (writer, xml_buf);
- break;
- case G_TYPE_DOUBLE:
- g_ascii_dtostr ((gchar *)xml_buf, sizeof (xml_buf),
- g_value_get_double (value));
- ret = xmlTextWriterWriteString (writer, xml_buf);
- break;
- default:
- g_assert_not_reached ();
- break;
- }
- if (ret < 0) break;
-
- ret = xmlTextWriterEndElement (writer); /* property */
- if (ret < 0) break;
- }
- if (ret < 0) goto out;
-
- /* now write parent node ids */
- data.writer = writer;
- data.ret = 0;
-
- g_hash_table_foreach (node->parents,
- (GHFunc) write_parent,
- &data);
- ret = data.ret;
- if (ret < 0) goto out;
-
- ret = xmlTextWriterEndElement (writer); /* node */
- if (ret < 0) goto out;
-
-out:
- return ret >= 0 ? 0 : -1;
+ephy_node_write_to_xml (EphyNode *node,
+ xmlTextWriterPtr writer)
+{
+ xmlChar xml_buf[G_ASCII_DTOSTR_BUF_SIZE];
+ guint i;
+ int ret;
+ ForEachData data;
+
+ g_return_val_if_fail (EPHY_IS_NODE (node), -1);
+ g_return_val_if_fail (writer != NULL, -1);
+
+ /* start writing the node */
+ ret = xmlTextWriterStartElement (writer, (const xmlChar *)"node");
+ if (ret < 0) goto out;
+
+ /* write node id */
+ ret = xmlTextWriterWriteFormatAttribute (writer, (const xmlChar *)"id", "%d", node->id);
+ if (ret < 0) goto out;
+
+ /* write node properties */
+ for (i = 0; i < node->properties->len; i++) {
+ GValue *value;
+
+ value = g_ptr_array_index (node->properties, i);
+
+ if (value == NULL) continue;
+ if (G_VALUE_TYPE (value) == G_TYPE_STRING &&
+ g_value_get_string (value) == NULL) continue;
+
+ ret = xmlTextWriterStartElement (writer, (const xmlChar *)"property");
+ if (ret < 0) break;
+
+ ret = xmlTextWriterWriteFormatAttribute (writer, (const xmlChar *)"id", "%d", i);
+ if (ret < 0) break;
+
+ ret = xmlTextWriterWriteAttribute
+ (writer, (const xmlChar *)"value_type",
+ (const xmlChar *)g_type_name (G_VALUE_TYPE (value)));
+ if (ret < 0) break;
+
+ switch (G_VALUE_TYPE (value)) {
+ case G_TYPE_STRING:
+ ret = safe_write_string
+ (writer, (const xmlChar *)g_value_get_string (value));
+ break;
+ case G_TYPE_BOOLEAN:
+ ret = xmlTextWriterWriteFormatString
+ (writer, "%d", g_value_get_boolean (value));
+ break;
+ case G_TYPE_INT:
+ ret = xmlTextWriterWriteFormatString
+ (writer, "%d", g_value_get_int (value));
+ break;
+ case G_TYPE_LONG:
+ ret = xmlTextWriterWriteFormatString
+ (writer, "%ld", g_value_get_long (value));
+ break;
+ case G_TYPE_FLOAT:
+ g_ascii_dtostr ((gchar *)xml_buf, sizeof (xml_buf),
+ g_value_get_float (value));
+ ret = xmlTextWriterWriteString (writer, xml_buf);
+ break;
+ case G_TYPE_DOUBLE:
+ g_ascii_dtostr ((gchar *)xml_buf, sizeof (xml_buf),
+ g_value_get_double (value));
+ ret = xmlTextWriterWriteString (writer, xml_buf);
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+ if (ret < 0) break;
+
+ ret = xmlTextWriterEndElement (writer); /* property */
+ if (ret < 0) break;
+ }
+ if (ret < 0) goto out;
+
+ /* now write parent node ids */
+ data.writer = writer;
+ data.ret = 0;
+
+ g_hash_table_foreach (node->parents,
+ (GHFunc)write_parent,
+ &data);
+ ret = data.ret;
+ if (ret < 0) goto out;
+
+ ret = xmlTextWriterEndElement (writer); /* node */
+ if (ret < 0) goto out;
+
+ out:
+ return ret >= 0 ? 0 : -1;
}
static inline void
real_add_child (EphyNode *node,
- EphyNode *child)
+ EphyNode *child)
{
- EphyNodeParent *node_info;
+ EphyNodeParent *node_info;
- if (g_hash_table_lookup (child->parents,
- GINT_TO_POINTER (node->id)) != NULL) {
- return;
- }
+ if (g_hash_table_lookup (child->parents,
+ GINT_TO_POINTER (node->id)) != NULL) {
+ return;
+ }
- g_ptr_array_add (node->children, child);
+ g_ptr_array_add (node->children, child);
- node_info = g_slice_new0 (EphyNodeParent);
- node_info->node = node;
- node_info->index = node->children->len - 1;
+ node_info = g_slice_new0 (EphyNodeParent);
+ node_info->node = node;
+ node_info->index = node->children->len - 1;
- g_hash_table_insert (child->parents,
- GINT_TO_POINTER (node->id),
- node_info);
+ g_hash_table_insert (child->parents,
+ GINT_TO_POINTER (node->id),
+ node_info);
}
EphyNode *
ephy_node_new_from_xml (EphyNodeDb *db, xmlNodePtr xml_node)
{
- EphyNode *node;
- xmlNodePtr xml_child;
- xmlChar *xml;
- long id;
-
- g_return_val_if_fail (EPHY_IS_NODE_DB (db), NULL);
- g_return_val_if_fail (xml_node != NULL, NULL);
-
- if (ephy_node_db_is_immutable (db)) return NULL;
-
- xml = xmlGetProp (xml_node, (const xmlChar *)"id");
- if (xml == NULL)
- return NULL;
- id = atol ((const char *)xml);
- xmlFree (xml);
-
- node = ephy_node_new_with_id (db, id);
-
- for (xml_child = xml_node->children; xml_child != NULL; xml_child = xml_child->next) {
- if (strcmp ((const char *)xml_child->name, "parent") == 0) {
- EphyNode *parent;
- long parent_id;
-
- xml = xmlGetProp (xml_child, (const xmlChar *)"id");
- g_assert (xml != NULL);
- parent_id = atol ((const char *)xml);
- xmlFree (xml);
-
- parent = ephy_node_db_get_node_from_id (db, parent_id);
-
- if (parent != NULL)
- {
- real_add_child (parent, node);
-
- ephy_node_emit_signal (parent, EPHY_NODE_CHILD_ADDED, node);
- }
- } else if (strcmp ((const char *)xml_child->name, "property") == 0) {
- GValue *value;
- xmlChar *xmlType, *xmlValue;
- int property_id;
-
- xml = xmlGetProp (xml_child, (const xmlChar *)"id");
- property_id = atoi ((const char *)xml);
- xmlFree (xml);
-
- xmlType = xmlGetProp (xml_child, (const xmlChar *)"value_type");
- xmlValue = xmlNodeGetContent (xml_child);
-
- value = g_slice_new0 (GValue);
-
- if (xmlStrEqual (xmlType, (const xmlChar *) "gchararray"))
- {
- g_value_init (value, G_TYPE_STRING);
- g_value_set_string (value, (const gchar *)xmlValue);
- }
- else if (xmlStrEqual (xmlType, (const xmlChar *) "gint"))
- {
- g_value_init (value, G_TYPE_INT);
- g_value_set_int (value, atoi ((const char *)xmlValue));
- }
- else if (xmlStrEqual (xmlType, (const xmlChar *) "gboolean"))
- {
- g_value_init (value, G_TYPE_BOOLEAN);
- g_value_set_boolean (value, atoi ((const char *)xmlValue));
- }
- else if (xmlStrEqual (xmlType, (const xmlChar *) "glong"))
- {
- g_value_init (value, G_TYPE_LONG);
- g_value_set_long (value, atol ((const char *)xmlValue));
- }
- else if (xmlStrEqual (xmlType, (const xmlChar *) "gfloat"))
- {
- g_value_init (value, G_TYPE_FLOAT);
- g_value_set_float (value, g_ascii_strtod ((const gchar *)xmlValue, NULL));
- }
- else if (xmlStrEqual (xmlType, (const xmlChar *) "gdouble"))
- {
- g_value_init (value, G_TYPE_DOUBLE);
- g_value_set_double (value, g_ascii_strtod ((const gchar *)xmlValue, NULL));
- }
- else if (xmlStrEqual (xmlType, (const xmlChar *) "gpointer"))
- {
- EphyNode *property_node;
-
- property_node = ephy_node_db_get_node_from_id (db, atol ((const char *)xmlValue));
-
- g_value_set_pointer (value, property_node);
- break;
- }
- else
- {
- g_assert_not_reached ();
- }
-
- real_set_property (node, property_id, value);
-
- xmlFree (xmlValue);
- xmlFree (xmlType);
- }
- }
-
- ephy_node_emit_signal (node, EPHY_NODE_RESTORED);
-
- return node;
+ EphyNode *node;
+ xmlNodePtr xml_child;
+ xmlChar *xml;
+ long id;
+
+ g_return_val_if_fail (EPHY_IS_NODE_DB (db), NULL);
+ g_return_val_if_fail (xml_node != NULL, NULL);
+
+ if (ephy_node_db_is_immutable (db)) return NULL;
+
+ xml = xmlGetProp (xml_node, (const xmlChar *)"id");
+ if (xml == NULL)
+ return NULL;
+ id = atol ((const char *)xml);
+ xmlFree (xml);
+
+ node = ephy_node_new_with_id (db, id);
+
+ for (xml_child = xml_node->children; xml_child != NULL; xml_child = xml_child->next) {
+ if (strcmp ((const char *)xml_child->name, "parent") == 0) {
+ EphyNode *parent;
+ long parent_id;
+
+ xml = xmlGetProp (xml_child, (const xmlChar *)"id");
+ g_assert (xml != NULL);
+ parent_id = atol ((const char *)xml);
+ xmlFree (xml);
+
+ parent = ephy_node_db_get_node_from_id (db, parent_id);
+
+ if (parent != NULL) {
+ real_add_child (parent, node);
+
+ ephy_node_emit_signal (parent, EPHY_NODE_CHILD_ADDED, node);
+ }
+ } else if (strcmp ((const char *)xml_child->name, "property") == 0) {
+ GValue *value;
+ xmlChar *xmlType, *xmlValue;
+ int property_id;
+
+ xml = xmlGetProp (xml_child, (const xmlChar *)"id");
+ property_id = atoi ((const char *)xml);
+ xmlFree (xml);
+
+ xmlType = xmlGetProp (xml_child, (const xmlChar *)"value_type");
+ xmlValue = xmlNodeGetContent (xml_child);
+
+ value = g_slice_new0 (GValue);
+
+ if (xmlStrEqual (xmlType, (const xmlChar *)"gchararray")) {
+ g_value_init (value, G_TYPE_STRING);
+ g_value_set_string (value, (const gchar *)xmlValue);
+ } else if (xmlStrEqual (xmlType, (const xmlChar *)"gint")) {
+ g_value_init (value, G_TYPE_INT);
+ g_value_set_int (value, atoi ((const char *)xmlValue));
+ } else if (xmlStrEqual (xmlType, (const xmlChar *)"gboolean")) {
+ g_value_init (value, G_TYPE_BOOLEAN);
+ g_value_set_boolean (value, atoi ((const char *)xmlValue));
+ } else if (xmlStrEqual (xmlType, (const xmlChar *)"glong")) {
+ g_value_init (value, G_TYPE_LONG);
+ g_value_set_long (value, atol ((const char *)xmlValue));
+ } else if (xmlStrEqual (xmlType, (const xmlChar *)"gfloat")) {
+ g_value_init (value, G_TYPE_FLOAT);
+ g_value_set_float (value, g_ascii_strtod ((const gchar *)xmlValue, NULL));
+ } else if (xmlStrEqual (xmlType, (const xmlChar *)"gdouble")) {
+ g_value_init (value, G_TYPE_DOUBLE);
+ g_value_set_double (value, g_ascii_strtod ((const gchar *)xmlValue, NULL));
+ } else if (xmlStrEqual (xmlType, (const xmlChar *)"gpointer")) {
+ EphyNode *property_node;
+
+ property_node = ephy_node_db_get_node_from_id (db, atol ((const char *)xmlValue));
+
+ g_value_set_pointer (value, property_node);
+ break;
+ } else {
+ g_assert_not_reached ();
+ }
+
+ real_set_property (node, property_id, value);
+
+ xmlFree (xmlValue);
+ xmlFree (xmlType);
+ }
+ }
+
+ ephy_node_emit_signal (node, EPHY_NODE_RESTORED);
+
+ return node;
}
void
ephy_node_add_child (EphyNode *node,
- EphyNode *child)
+ EphyNode *child)
{
- g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (EPHY_IS_NODE (node));
- if (ephy_node_db_is_immutable (node->db)) return;
-
- real_add_child (node, child);
+ if (ephy_node_db_is_immutable (node->db)) return;
- ephy_node_emit_signal (node, EPHY_NODE_CHILD_ADDED, child);
+ real_add_child (node, child);
+
+ ephy_node_emit_signal (node, EPHY_NODE_CHILD_ADDED, child);
}
void
ephy_node_remove_child (EphyNode *node,
- EphyNode *child)
+ EphyNode *child)
{
- g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (EPHY_IS_NODE (node));
- if (ephy_node_db_is_immutable (node->db)) return;
+ if (ephy_node_db_is_immutable (node->db)) return;
- real_remove_child (node, child, TRUE, TRUE);
+ real_remove_child (node, child, TRUE, TRUE);
}
gboolean
ephy_node_has_child (EphyNode *node,
- EphyNode *child)
+ EphyNode *child)
{
- gboolean ret;
+ gboolean ret;
+
+ g_return_val_if_fail (EPHY_IS_NODE (node), FALSE);
- g_return_val_if_fail (EPHY_IS_NODE (node), FALSE);
-
- ret = (g_hash_table_lookup (child->parents,
- GINT_TO_POINTER (node->id)) != NULL);
+ ret = (g_hash_table_lookup (child->parents,
+ GINT_TO_POINTER (node->id)) != NULL);
- return ret;
+ return ret;
}
static int
ephy_node_real_get_child_index (EphyNode *node,
- EphyNode *child)
+ EphyNode *child)
{
- EphyNodeParent *node_info;
- int ret;
+ EphyNodeParent *node_info;
+ int ret;
- node_info = g_hash_table_lookup (child->parents,
- GINT_TO_POINTER (node->id));
+ node_info = g_hash_table_lookup (child->parents,
+ GINT_TO_POINTER (node->id));
- if (node_info == NULL)
- return -1;
+ if (node_info == NULL)
+ return -1;
- ret = node_info->index;
+ ret = node_info->index;
- return ret;
+ return ret;
}
/**
@@ -1152,83 +1123,81 @@ ephy_node_real_get_child_index (EphyNode *node,
*
**/
void
-ephy_node_sort_children (EphyNode *node,
- GCompareFunc compare_func)
+ephy_node_sort_children (EphyNode *node,
+ GCompareFunc compare_func)
{
- GPtrArray *newkids;
- guint i, *new_order;
+ GPtrArray *newkids;
+ guint i, *new_order;
- if (ephy_node_db_is_immutable (node->db)) return;
+ if (ephy_node_db_is_immutable (node->db)) return;
- g_return_if_fail (EPHY_IS_NODE (node));
- g_return_if_fail (compare_func != NULL);
+ g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (compare_func != NULL);
- newkids = g_ptr_array_new ();
- g_ptr_array_set_size (newkids, node->children->len);
+ newkids = g_ptr_array_new ();
+ g_ptr_array_set_size (newkids, node->children->len);
- /* dup the array */
- for (i = 0; i < node->children->len; i++)
- {
- g_ptr_array_index (newkids, i) = g_ptr_array_index (node->children, i);
- }
+ /* dup the array */
+ for (i = 0; i < node->children->len; i++) {
+ g_ptr_array_index (newkids, i) = g_ptr_array_index (node->children, i);
+ }
- g_ptr_array_sort (newkids, compare_func);
+ g_ptr_array_sort (newkids, compare_func);
- new_order = g_new (guint, newkids->len);
- memset (new_order, -1, sizeof (guint) * newkids->len);
+ new_order = g_new (guint, newkids->len);
+ memset (new_order, -1, sizeof (guint) * newkids->len);
- for (i = 0; i < newkids->len; i++)
- {
- EphyNodeParent *node_info;
- EphyNode *child;
+ for (i = 0; i < newkids->len; i++) {
+ EphyNodeParent *node_info;
+ EphyNode *child;
- child = g_ptr_array_index (newkids, i);
- new_order[ephy_node_real_get_child_index (node, child)] = i;
- node_info = g_hash_table_lookup (child->parents,
- GINT_TO_POINTER (node->id));
- node_info->index = i;
- }
+ child = g_ptr_array_index (newkids, i);
+ new_order[ephy_node_real_get_child_index (node, child)] = i;
+ node_info = g_hash_table_lookup (child->parents,
+ GINT_TO_POINTER (node->id));
+ node_info->index = i;
+ }
- g_ptr_array_free (node->children, FALSE);
- node->children = newkids;
+ g_ptr_array_free (node->children, FALSE);
+ node->children = newkids;
- ephy_node_emit_signal (node, EPHY_NODE_CHILDREN_REORDERED, new_order);
+ ephy_node_emit_signal (node, EPHY_NODE_CHILDREN_REORDERED, new_order);
- g_free (new_order);
+ g_free (new_order);
}
void
ephy_node_reorder_children (EphyNode *node,
- int *new_order)
+ int *new_order)
{
- GPtrArray *newkids;
- guint i;
+ GPtrArray *newkids;
+ guint i;
- g_return_if_fail (EPHY_IS_NODE (node));
- g_return_if_fail (new_order != NULL);
+ g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (new_order != NULL);
- if (ephy_node_db_is_immutable (node->db)) return;
+ if (ephy_node_db_is_immutable (node->db)) return;
- newkids = g_ptr_array_new ();
- g_ptr_array_set_size (newkids, node->children->len);
+ newkids = g_ptr_array_new ();
+ g_ptr_array_set_size (newkids, node->children->len);
- for (i = 0; i < node->children->len; i++) {
- EphyNode *child;
- EphyNodeParent *node_info;
+ for (i = 0; i < node->children->len; i++) {
+ EphyNode *child;
+ EphyNodeParent *node_info;
- child = g_ptr_array_index (node->children, i);
+ child = g_ptr_array_index (node->children, i);
- g_ptr_array_index (newkids, new_order[i]) = child;
+ g_ptr_array_index (newkids, new_order[i]) = child;
- node_info = g_hash_table_lookup (child->parents,
- GINT_TO_POINTER (node->id));
- node_info->index = new_order[i];
- }
+ node_info = g_hash_table_lookup (child->parents,
+ GINT_TO_POINTER (node->id));
+ node_info->index = new_order[i];
+ }
- g_ptr_array_free (node->children, FALSE);
- node->children = newkids;
+ g_ptr_array_free (node->children, FALSE);
+ node->children = newkids;
- ephy_node_emit_signal (node, EPHY_NODE_CHILDREN_REORDERED, new_order);
+ ephy_node_emit_signal (node, EPHY_NODE_CHILDREN_REORDERED, new_order);
}
/**
@@ -1239,21 +1208,21 @@ ephy_node_reorder_children (EphyNode *node,
GPtrArray *
ephy_node_get_children (EphyNode *node)
{
- g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
+ g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
- return node->children;
+ return node->children;
}
int
ephy_node_get_n_children (EphyNode *node)
{
- int ret;
+ int ret;
- g_return_val_if_fail (EPHY_IS_NODE (node), -1);
+ g_return_val_if_fail (EPHY_IS_NODE (node), -1);
- ret = node->children->len;
+ ret = node->children->len;
- return ret;
+ return ret;
}
/**
@@ -1263,49 +1232,49 @@ ephy_node_get_n_children (EphyNode *node)
**/
EphyNode *
ephy_node_get_nth_child (EphyNode *node,
- guint n)
+ guint n)
{
- EphyNode *ret;
+ EphyNode *ret;
- g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
+ g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
- if (n < node->children->len) {
- ret = g_ptr_array_index (node->children, n);
- } else {
- ret = NULL;
- }
+ if (n < node->children->len) {
+ ret = g_ptr_array_index (node->children, n);
+ } else {
+ ret = NULL;
+ }
- return ret;
+ return ret;
}
static inline int
get_child_index_real (EphyNode *node,
- EphyNode *child)
+ EphyNode *child)
{
- EphyNodeParent *node_info;
+ EphyNodeParent *node_info;
- node_info = g_hash_table_lookup (child->parents,
- GINT_TO_POINTER (node->id));
+ node_info = g_hash_table_lookup (child->parents,
+ GINT_TO_POINTER (node->id));
- if (node_info == NULL)
- return -1;
+ if (node_info == NULL)
+ return -1;
- return node_info->index;
+ return node_info->index;
}
int
ephy_node_get_child_index (EphyNode *node,
- EphyNode *child)
+ EphyNode *child)
{
- int ret;
+ int ret;
- g_return_val_if_fail (EPHY_IS_NODE (node), -1);
- g_return_val_if_fail (EPHY_IS_NODE (child), -1);
+ g_return_val_if_fail (EPHY_IS_NODE (node), -1);
+ g_return_val_if_fail (EPHY_IS_NODE (child), -1);
- ret = ephy_node_real_get_child_index (node, child);
+ ret = ephy_node_real_get_child_index (node, child);
- return ret;
+ return ret;
}
/**
@@ -1315,23 +1284,23 @@ ephy_node_get_child_index (EphyNode *node,
**/
EphyNode *
ephy_node_get_next_child (EphyNode *node,
- EphyNode *child)
+ EphyNode *child)
{
- EphyNode *ret;
- guint idx;
+ EphyNode *ret;
+ guint idx;
+
+ g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
+ g_return_val_if_fail (EPHY_IS_NODE (child), NULL);
- g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
- g_return_val_if_fail (EPHY_IS_NODE (child), NULL);
-
- idx = get_child_index_real (node, child);
+ idx = get_child_index_real (node, child);
- if ((idx + 1) < node->children->len) {
- ret = g_ptr_array_index (node->children, idx + 1);
- } else {
- ret = NULL;
- }
+ if ((idx + 1) < node->children->len) {
+ ret = g_ptr_array_index (node->children, idx + 1);
+ } else {
+ ret = NULL;
+ }
- return ret;
+ return ret;
}
/**
@@ -1341,23 +1310,23 @@ ephy_node_get_next_child (EphyNode *node,
**/
EphyNode *
ephy_node_get_previous_child (EphyNode *node,
- EphyNode *child)
+ EphyNode *child)
{
- EphyNode *ret;
- int idx;
+ EphyNode *ret;
+ int idx;
- g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
- g_return_val_if_fail (EPHY_IS_NODE (child), NULL);
-
- idx = get_child_index_real (node, child);
+ g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
+ g_return_val_if_fail (EPHY_IS_NODE (child), NULL);
- if ((idx - 1) >= 0) {
- ret = g_ptr_array_index (node->children, idx - 1);
- } else {
- ret = NULL;
- }
+ idx = get_child_index_real (node, child);
- return ret;
+ if ((idx - 1) >= 0) {
+ ret = g_ptr_array_index (node->children, idx - 1);
+ } else {
+ ret = NULL;
+ }
+
+ return ret;
}
/**
@@ -1372,64 +1341,62 @@ ephy_node_get_previous_child (EphyNode *node,
* Returns: an identifier for the connected signal
**/
int
-ephy_node_signal_connect_object (EphyNode *node,
- EphyNodeSignalType type,
- EphyNodeCallback cb,
- GObject *object)
-{
- EphyNodeSignalData *signal_data;
- int ret;
-
- g_return_val_if_fail (EPHY_IS_NODE (node), -1);
- /* FIXME: */
- g_return_val_if_fail (node->emissions == 0, -1);
-
- signal_data = g_slice_new0 (EphyNodeSignalData);
- signal_data->node = node;
- signal_data->id = node->signal_id;
- signal_data->callback = cb;
- signal_data->type = type;
- signal_data->data = object;
-
- g_hash_table_insert (node->signals,
- GINT_TO_POINTER (node->signal_id),
- signal_data);
- if (object)
- {
- g_object_weak_ref (object,
- (GWeakNotify)signal_object_weak_notify,
- signal_data);
- }
-
- ret = node->signal_id;
- node->signal_id++;
-
- return ret;
+ephy_node_signal_connect_object (EphyNode *node,
+ EphyNodeSignalType type,
+ EphyNodeCallback cb,
+ GObject *object)
+{
+ EphyNodeSignalData *signal_data;
+ int ret;
+
+ g_return_val_if_fail (EPHY_IS_NODE (node), -1);
+ /* FIXME: */
+ g_return_val_if_fail (node->emissions == 0, -1);
+
+ signal_data = g_slice_new0 (EphyNodeSignalData);
+ signal_data->node = node;
+ signal_data->id = node->signal_id;
+ signal_data->callback = cb;
+ signal_data->type = type;
+ signal_data->data = object;
+
+ g_hash_table_insert (node->signals,
+ GINT_TO_POINTER (node->signal_id),
+ signal_data);
+ if (object) {
+ g_object_weak_ref (object,
+ (GWeakNotify)signal_object_weak_notify,
+ signal_data);
+ }
+
+ ret = node->signal_id;
+ node->signal_id++;
+
+ return ret;
}
static gboolean
-remove_matching_signal_data (gpointer key,
- EphyNodeSignalData *signal_data,
- EphyNodeSignalData *user_data)
+remove_matching_signal_data (gpointer key,
+ EphyNodeSignalData *signal_data,
+ EphyNodeSignalData *user_data)
{
- return (user_data->data == signal_data->data &&
- user_data->type == signal_data->type &&
- user_data->callback == signal_data->callback);
+ return (user_data->data == signal_data->data &&
+ user_data->type == signal_data->type &&
+ user_data->callback == signal_data->callback);
}
static void
-invalidate_matching_signal_data (gpointer key,
- EphyNodeSignalData *signal_data,
- EphyNodeSignalData *user_data)
-{
- if (user_data->data == signal_data->data &&
- user_data->type == signal_data->type &&
- user_data->callback == signal_data->callback &&
- !signal_data->invalidated)
- {
- signal_data->invalidated = TRUE;
- ++signal_data->node->invalidated_signals;
- }
+invalidate_matching_signal_data (gpointer key,
+ EphyNodeSignalData *signal_data,
+ EphyNodeSignalData *user_data)
+{
+ if (user_data->data == signal_data->data &&
+ user_data->type == signal_data->type &&
+ user_data->callback == signal_data->callback &&
+ !signal_data->invalidated) {
+ signal_data->invalidated = TRUE;
+ ++signal_data->node->invalidated_signals;
+ }
}
/**
@@ -1445,97 +1412,90 @@ invalidate_matching_signal_data (gpointer key,
* Returns: the number of signal handlers removed
**/
guint
-ephy_node_signal_disconnect_object (EphyNode *node,
+ephy_node_signal_disconnect_object (EphyNode *node,
EphyNodeSignalType type,
- EphyNodeCallback cb,
- GObject *object)
-{
- EphyNodeSignalData user_data;
-
- g_return_val_if_fail (EPHY_IS_NODE (node), 0);
-
- user_data.callback = cb;
- user_data.type = type;
- user_data.data = object;
-
- if (G_LIKELY (node->emissions == 0))
- {
- return g_hash_table_foreach_remove (node->signals,
- (GHRFunc) remove_matching_signal_data,
- &user_data);
- }
- else
- {
- g_hash_table_foreach (node->signals,
- (GHFunc) invalidate_matching_signal_data,
- &user_data);
- return 0;
- }
+ EphyNodeCallback cb,
+ GObject *object)
+{
+ EphyNodeSignalData user_data;
+
+ g_return_val_if_fail (EPHY_IS_NODE (node), 0);
+
+ user_data.callback = cb;
+ user_data.type = type;
+ user_data.data = object;
+
+ if (G_LIKELY (node->emissions == 0)) {
+ return g_hash_table_foreach_remove (node->signals,
+ (GHRFunc)remove_matching_signal_data,
+ &user_data);
+ } else {
+ g_hash_table_foreach (node->signals,
+ (GHFunc)invalidate_matching_signal_data,
+ &user_data);
+ return 0;
+ }
}
void
ephy_node_signal_disconnect (EphyNode *node,
- int signal_id)
+ int signal_id)
{
- g_return_if_fail (EPHY_IS_NODE (node));
- g_return_if_fail (signal_id != -1);
-
- if (G_LIKELY (node->emissions == 0))
- {
- g_hash_table_remove (node->signals,
- GINT_TO_POINTER (signal_id));
- }
- else
- {
- EphyNodeSignalData *data;
-
- data = g_hash_table_lookup (node->signals,
- GINT_TO_POINTER (signal_id));
- g_return_if_fail (data != NULL);
- g_return_if_fail (!data->invalidated);
-
- data->invalidated = TRUE;
- node->invalidated_signals++;
- }
+ g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (signal_id != -1);
+
+ if (G_LIKELY (node->emissions == 0)) {
+ g_hash_table_remove (node->signals,
+ GINT_TO_POINTER (signal_id));
+ } else {
+ EphyNodeSignalData *data;
+
+ data = g_hash_table_lookup (node->signals,
+ GINT_TO_POINTER (signal_id));
+ g_return_if_fail (data != NULL);
+ g_return_if_fail (!data->invalidated);
+
+ data->invalidated = TRUE;
+ node->invalidated_signals++;
+ }
}
void
ephy_node_set_is_drag_source (EphyNode *node,
- gboolean allow)
+ gboolean allow)
{
- node->is_drag_source = allow != FALSE;
+ node->is_drag_source = allow != FALSE;
}
gboolean
ephy_node_get_is_drag_source (EphyNode *node)
{
- return node->is_drag_source;
+ return node->is_drag_source;
}
void
ephy_node_set_is_drag_dest (EphyNode *node,
- gboolean allow)
+ gboolean allow)
{
- node->is_drag_dest = allow != FALSE;
+ node->is_drag_dest = allow != FALSE;
}
gboolean
ephy_node_get_is_drag_dest (EphyNode *node)
{
- return node->is_drag_dest;
+ return node->is_drag_dest;
}
GType
ephy_node_get_type (void)
{
- static GType type = 0;
+ static GType type = 0;
- if (G_UNLIKELY (type == 0))
- {
- type = g_boxed_type_register_static ("EphyNode",
- (GBoxedCopyFunc) ephy_node_ref,
- (GBoxedFreeFunc) ephy_node_unref);
- }
+ if (G_UNLIKELY (type == 0)) {
+ type = g_boxed_type_register_static ("EphyNode",
+ (GBoxedCopyFunc)ephy_node_ref,
+ (GBoxedFreeFunc)ephy_node_unref);
+ }
- return type;
+ return type;
}
diff --git a/lib/ephy-nss-glue.c b/lib/ephy-nss-glue.c
index b9d01f5e6..70c9e184c 100644
--- a/lib/ephy-nss-glue.c
+++ b/lib/ephy-nss-glue.c
@@ -40,10 +40,10 @@
static gboolean nss_initialized = FALSE;
static PK11SlotInfo *db_slot = NULL;
-static char*
+static char *
ask_for_nss_password (PK11SlotInfo *slot,
- PRBool retry,
- void *arg)
+ PRBool retry,
+ void *arg)
{
GtkWidget *dialog;
GtkWidget *entry;
@@ -69,11 +69,11 @@ ask_for_nss_password (PK11SlotInfo *slot,
result = gtk_dialog_run (GTK_DIALOG (dialog));
switch (result) {
- case GTK_RESPONSE_OK:
- password = PL_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
- break;
- default:
- break;
+ case GTK_RESPONSE_OK:
+ password = PL_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
+ break;
+ default:
+ break;
}
gtk_widget_destroy (dialog);
@@ -127,8 +127,7 @@ void ephy_nss_glue_close (void)
nss_initialized = FALSE;
}
-typedef struct SDRResult
-{
+typedef struct SDRResult {
SECItem keyid;
SECAlgorithmID alg;
SECItem data;
@@ -136,15 +135,15 @@ typedef struct SDRResult
static SEC_ASN1Template g_template[] = {
{ SEC_ASN1_SEQUENCE, 0, NULL, sizeof (SDRResult) },
- { SEC_ASN1_OCTET_STRING, offsetof(SDRResult, keyid) },
- { SEC_ASN1_INLINE | SEC_ASN1_XTRN, offsetof(SDRResult, alg),
- SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) },
- { SEC_ASN1_OCTET_STRING, offsetof(SDRResult, data) },
+ { SEC_ASN1_OCTET_STRING, offsetof (SDRResult, keyid) },
+ { SEC_ASN1_INLINE | SEC_ASN1_XTRN, offsetof (SDRResult, alg),
+ SEC_ASN1_SUB (SECOID_AlgorithmIDTemplate) },
+ { SEC_ASN1_OCTET_STRING, offsetof (SDRResult, data) },
{ 0 }
};
static SECStatus
-unpadBlock(SECItem *data, int blockSize, SECItem *result)
+unpadBlock (SECItem *data, int blockSize, SECItem *result)
{
SECStatus rv = SECSuccess;
int padLength;
@@ -154,24 +153,30 @@ unpadBlock(SECItem *data, int blockSize, SECItem *result)
result->len = 0;
/* Remove the padding from the end if the input data */
- if (data->len == 0 || data->len % blockSize != 0) { rv = SECFailure; goto loser; }
+ if (data->len == 0 || data->len % blockSize != 0) {
+ rv = SECFailure; goto loser;
+ }
- padLength = data->data[data->len-1];
- if (padLength > blockSize) { rv = SECFailure; goto loser; }
+ padLength = data->data[data->len - 1];
+ if (padLength > blockSize) {
+ rv = SECFailure; goto loser;
+ }
/* verify padding */
- for (i=data->len - padLength; (uint32)i < data->len; i++) {
+ for (i = data->len - padLength; (uint32)i < data->len; i++) {
if (data->data[i] != padLength) {
- rv = SECFailure;
- goto loser;
+ rv = SECFailure;
+ goto loser;
}
}
result->len = data->len - padLength;
- result->data = (unsigned char *)PORT_Alloc(result->len);
- if (!result->data) { rv = SECFailure; goto loser; }
+ result->data = (unsigned char *)PORT_Alloc (result->len);
+ if (!result->data) {
+ rv = SECFailure; goto loser;
+ }
- PORT_Memcpy(result->data, data->data, result->len);
+ PORT_Memcpy (result->data, data->data, result->len);
if (padLength < 2) {
/* Chromium returns an error here, but it seems to be harmless and
@@ -180,13 +185,13 @@ unpadBlock(SECItem *data, int blockSize, SECItem *result)
/* return SECWouldBlock; */
}
-loser:
+ loser:
return rv;
}
static SECStatus
-pk11Decrypt (PK11SlotInfo *slot, PLArenaPool *arena,
- CK_MECHANISM_TYPE type, PK11SymKey *key,
+pk11Decrypt (PK11SlotInfo *slot, PLArenaPool *arena,
+ CK_MECHANISM_TYPE type, PK11SymKey *key,
SECItem *params, SECItem *in, SECItem *result)
{
PK11Context *ctx = 0;
@@ -203,22 +208,22 @@ pk11Decrypt (PK11SlotInfo *slot, PLArenaPool *arena,
}
paddedResult.len = in->len;
- paddedResult.data = (unsigned char*)PORT_ArenaAlloc (arena, paddedResult.len);
+ paddedResult.data = (unsigned char *)PORT_ArenaAlloc (arena, paddedResult.len);
- rv = PK11_CipherOp (ctx, paddedResult.data,
- (int*)&paddedResult.len, paddedResult.len,
+ rv = PK11_CipherOp (ctx, paddedResult.data,
+ (int *)&paddedResult.len, paddedResult.len,
in->data, in->len);
if (rv != SECSuccess)
goto loser;
- PK11_Finalize(ctx);
+ PK11_Finalize (ctx);
/* Remove the padding */
- rv = unpadBlock (&paddedResult, PK11_GetBlockSize(type, 0), result);
+ rv = unpadBlock (&paddedResult, PK11_GetBlockSize (type, 0), result);
if (rv)
goto loser;
-loser:
+ loser:
if (ctx)
PK11_DestroyContext (ctx, PR_TRUE);
@@ -258,10 +263,10 @@ PK11SDR_DecryptWithSlot (PK11SlotInfo *slot, SECItem *data, SECItem *result, voi
/* Use triple-DES (Should look up the algorithm) */
type = CKM_DES3_CBC;
key = PK11_FindFixedKey (slot, type, &sdrResult.keyid, cx);
- if (!key) {
- rv = SECFailure;
+ if (!key) {
+ rv = SECFailure;
} else {
- rv = pk11Decrypt (slot, arena, type, key, params,
+ rv = pk11Decrypt (slot, arena, type, key, params,
&sdrResult.data, result);
}
@@ -270,18 +275,18 @@ PK11SDR_DecryptWithSlot (PK11SlotInfo *slot, SECItem *data, SECItem *result, voi
PORT_FreeArena (arena, PR_TRUE);
if (key)
- PK11_FreeSymKey(key);
+ PK11_FreeSymKey (key);
if (params)
- SECITEM_ZfreeItem(params, PR_TRUE);
+ SECITEM_ZfreeItem (params, PR_TRUE);
if (possibleResult.data)
- SECITEM_ZfreeItem(&possibleResult, PR_FALSE);
+ SECITEM_ZfreeItem (&possibleResult, PR_FALSE);
return rv;
}
-char * ephy_nss_glue_decrypt (const unsigned char *data, gsize length)
+char *ephy_nss_glue_decrypt (const unsigned char *data, gsize length)
{
char *plain = NULL;
SECItem request, reply;
@@ -291,14 +296,14 @@ char * ephy_nss_glue_decrypt (const unsigned char *data, gsize length)
if (result != SECSuccess)
return NULL;
- request.data = (unsigned char*)data;
+ request.data = (unsigned char *)data;
request.len = length;
reply.data = NULL;
reply.len = 0;
result = PK11SDR_DecryptWithSlot (db_slot, &request, &reply, NULL);
if (result == SECSuccess)
- plain = g_strndup ((const char*)reply.data, reply.len);
+ plain = g_strndup ((const char *)reply.data, reply.len);
SECITEM_FreeItem (&reply, PR_FALSE);
diff --git a/lib/ephy-profile-migrator.c b/lib/ephy-profile-migrator.c
index 96dfa119b..b613f793e 100644
--- a/lib/ephy-profile-migrator.c
+++ b/lib/ephy-profile-migrator.c
@@ -110,7 +110,7 @@ migrate_cookies (void)
cookies = soup_cookie_jar_all_cookies (txt);
for (p = cookies; p; p = p->next) {
- SoupCookie *cookie = (SoupCookie*)p->data;
+ SoupCookie *cookie = (SoupCookie *)p->data;
/* Cookie is stolen, so we won't free it */
soup_cookie_jar_add_cookie (sqlite, cookie);
}
@@ -127,7 +127,7 @@ migrate_cookies (void)
}
#ifdef ENABLE_NSS
-static char*
+static char *
decrypt (const char *data)
{
unsigned char *plain;
@@ -142,15 +142,15 @@ decrypt (const char *data)
decrypted = ephy_nss_glue_decrypt (plain, out_len);
g_free (plain);
- plain = (unsigned char*)decrypted;
+ plain = (unsigned char *)decrypted;
}
- return (char*)plain;
+ return (char *)plain;
}
static void
parse_and_decrypt_signons (const char *signons,
- gboolean handle_forms)
+ gboolean handle_forms)
{
int version;
gchar **lines;
@@ -224,7 +224,7 @@ parse_and_decrypt_signons (const char *signons,
g_free (url);
start += strlen (realmBracketBegin);
- end_ptr = g_strstr_len (full_url, -1, realmBracketEnd) -1;
+ end_ptr = g_strstr_len (full_url, -1, realmBracketEnd) - 1;
ending = g_utf8_pointer_to_offset (full_url, end_ptr);
realm = g_utf8_substring (full_url, start, ending);
@@ -297,7 +297,7 @@ parse_and_decrypt_signons (const char *signons,
/* We skip the '*' at the beginning of form_password. */
ephy_form_auth_data_store (u,
form_username,
- form_password+1,
+ form_password + 1,
username,
password,
NULL, NULL);
@@ -470,7 +470,7 @@ history_parse_text (GMarkupParseContext *context,
{
HistoryParseData *parse_data = user_data;
- if (!parse_data || ! parse_data->current)
+ if (!parse_data || !parse_data->current)
return;
if (g_str_equal (parse_data->current, "2")) {
@@ -691,7 +691,7 @@ migrate_profile_gnome2_to_xdg (void)
static char *
fix_desktop_file_and_return_new_location (const char *dir)
{
- GRegex * regex;
+ GRegex *regex;
char *result, *old_profile_dir, *replacement, *contents, *new_contents;
gsize length;
@@ -729,40 +729,40 @@ migrate_web_app_links (void)
apps = ephy_web_application_get_application_list ();
for (p = apps; p; p = p->next) {
char *desktop_file, *app_link;
- EphyWebApplication *app = (EphyWebApplication*)p->data;
+ EphyWebApplication *app = (EphyWebApplication *)p->data;
desktop_file = app->desktop_file;
/* Update the link in applications. */
app_link = g_build_filename (g_get_user_data_dir (), "applications", desktop_file, NULL);
if (g_file_test (app_link, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_SYMLINK)) {
- /* Change the link to point to the new profile dir. */
- GFileInfo *info;
- const char *target;
- GFile *file = g_file_new_for_path (app_link);
-
- info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET,
- 0, NULL, NULL);
- if (info) {
- char *new_target;
-
- target = g_file_info_get_symlink_target (info);
- new_target = fix_desktop_file_and_return_new_location (target);
-
- /* FIXME: Updating the file info and setting it again should
- * work, but it does not? Just delete and create the link
- * again. */
- g_file_delete (file, 0, 0);
- g_object_unref (file);
-
- file = g_file_new_for_path (app_link);
- g_file_make_symbolic_link (file, new_target, NULL, NULL);
-
- g_object_unref (info);
- g_free (new_target);
- }
-
+ /* Change the link to point to the new profile dir. */
+ GFileInfo *info;
+ const char *target;
+ GFile *file = g_file_new_for_path (app_link);
+
+ info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET,
+ 0, NULL, NULL);
+ if (info) {
+ char *new_target;
+
+ target = g_file_info_get_symlink_target (info);
+ new_target = fix_desktop_file_and_return_new_location (target);
+
+ /* FIXME: Updating the file info and setting it again should
+ * work, but it does not? Just delete and create the link
+ * again. */
+ g_file_delete (file, 0, 0);
g_object_unref (file);
+
+ file = g_file_new_for_path (app_link);
+ g_file_make_symbolic_link (file, new_target, NULL, NULL);
+
+ g_object_unref (info);
+ g_free (new_target);
+ }
+
+ g_object_unref (file);
}
g_free (app_link);
@@ -821,8 +821,8 @@ static int form_passwords_migrating = 0;
static void
password_cleared_cb (SecretService *service,
- GAsyncResult *res,
- gpointer userdata)
+ GAsyncResult *res,
+ gpointer userdata)
{
secret_service_clear_finish (service, res, NULL);
@@ -831,9 +831,9 @@ password_cleared_cb (SecretService *service,
}
static void
-store_form_auth_data_cb (GObject *object,
+store_form_auth_data_cb (GObject *object,
GAsyncResult *res,
- GHashTable *attributes)
+ GHashTable *attributes)
{
GError *error = NULL;
@@ -848,7 +848,7 @@ store_form_auth_data_cb (GObject *object,
attributes, NULL, (GAsyncReadyCallback)password_cleared_cb,
NULL);
-out:
+ out:
if (g_atomic_int_dec_and_test (&form_passwords_migrating))
g_main_loop_quit (loop);
@@ -857,8 +857,8 @@ out:
static void
load_collection_items_cb (SecretCollection *collection,
- GAsyncResult *res,
- gpointer data)
+ GAsyncResult *res,
+ gpointer data)
{
SecretItem *item;
SecretValue *secret;
@@ -880,7 +880,7 @@ load_collection_items_cb (SecretCollection *collection,
items = secret_collection_get_items (collection);
for (l = items; l; l = l->next) {
- item = (SecretItem*)l->data;
+ item = (SecretItem *)l->data;
attributes = secret_item_get_attributes (item);
server = g_hash_table_lookup (attributes, "server");
@@ -940,7 +940,7 @@ migrate_form_passwords_to_libsecret (void)
for (c = collections; c; c = c->next) {
g_atomic_int_inc (&form_passwords_migrating);
- secret_collection_load_items ((SecretCollection*)c->data, NULL, (GAsyncReadyCallback)load_collection_items_cb,
+ secret_collection_load_items ((SecretCollection *)c->data, NULL, (GAsyncReadyCallback)load_collection_items_cb,
NULL);
}
@@ -959,7 +959,7 @@ migrate_app_desktop_file_categories (void)
web_apps = ephy_web_application_get_application_list ();
for (l = web_apps; l; l = l->next) {
- EphyWebApplication *app = (EphyWebApplication *) l->data;
+ EphyWebApplication *app = (EphyWebApplication *)l->data;
GKeyFile *file;
char *data = NULL;
char *app_path;
@@ -989,8 +989,8 @@ migrate_app_desktop_file_categories (void)
const EphyProfileMigrator migrators[] = {
migrate_cookies,
migrate_passwords,
- /* Yes, again! Version 2 had some bugs, so we need to run
- migrate_passwords again to possibly migrate more passwords*/
+ /* Yes, again! Version 2 had some bugs, so we need to run
+ migrate_passwords again to possibly migrate more passwords*/
migrate_passwords,
/* Very similar to migrate_passwords, but this migrates
* login/passwords for page forms, which we previously ignored */
@@ -1025,7 +1025,7 @@ ephy_migrator (void)
LOG ("Running only migrator: %d", do_step_n);
m = migrators[do_step_n];
- m();
+ m ();
return TRUE;
}
@@ -1046,7 +1046,7 @@ ephy_migrator (void)
continue;
m = migrators[i];
- m();
+ m ();
}
if (ephy_profile_utils_set_migration_version (EPHY_PROFILE_MIGRATION_VERSION) != TRUE) {
@@ -1099,13 +1099,13 @@ main (int argc, char *argv[])
return 1;
}
-
+
g_option_context_free (option_context);
if (migration_version != -1 && migration_version != EPHY_PROFILE_MIGRATION_VERSION) {
g_print ("Version mismatch, version %d requested but our version is %d\n",
migration_version, EPHY_PROFILE_MIGRATION_VERSION);
-
+
return 1;
}
@@ -1113,7 +1113,7 @@ main (int argc, char *argv[])
if (profile_dir != NULL)
file_helpers_flags = EPHY_FILE_HELPERS_PRIVATE_PROFILE |
- EPHY_FILE_HELPERS_KEEP_DIR;
+ EPHY_FILE_HELPERS_KEEP_DIR;
if (!ephy_file_helpers_init (profile_dir, file_helpers_flags, NULL)) {
LOG ("Something wrong happened with ephy_file_helpers_init()");
diff --git a/lib/ephy-profile-utils.c b/lib/ephy-profile-utils.c
index 20b05a5de..b5dbb08f5 100644
--- a/lib/ephy-profile-utils.c
+++ b/lib/ephy-profile-utils.c
@@ -41,7 +41,7 @@ ephy_profile_utils_get_migration_version (void)
g_file_get_contents (migrated_file, &contents, &size, NULL);
if (contents != NULL)
- result = sscanf(contents, "%d", &latest);
+ result = sscanf (contents, "%d", &latest);
g_free (contents);
@@ -126,7 +126,7 @@ ephy_profile_utils_do_migration (const char *profile_directory, int test_to_run,
argv[i++] = NULL;
if (debug)
- argv[0] = ABS_TOP_BUILD_DIR"/lib/"EPHY_PROFILE_MIGRATOR;
+ argv[0] = ABS_TOP_BUILD_DIR "/lib/"EPHY_PROFILE_MIGRATOR;
ret = g_spawn_sync (NULL, (char **)argv, envp, G_SPAWN_SEARCH_PATH,
NULL, NULL, NULL, NULL,
@@ -134,7 +134,7 @@ ephy_profile_utils_do_migration (const char *profile_directory, int test_to_run,
g_free (index);
g_free (version);
g_strfreev (envp);
-
+
if (error) {
LOG ("Failed to run migrator: %s", error->message);
g_error_free (error);
diff --git a/lib/ephy-security-levels.c b/lib/ephy-security-levels.c
index 37c4fec51..8782fb5c9 100644
--- a/lib/ephy-security-levels.c
+++ b/lib/ephy-security-levels.c
@@ -33,20 +33,20 @@ ephy_security_level_to_icon_name (EphySecurityLevel level)
const char *result;
switch (level) {
- case EPHY_SECURITY_LEVEL_LOCAL_PAGE:
- case EPHY_SECURITY_LEVEL_TO_BE_DETERMINED:
- result = NULL;
- break;
- case EPHY_SECURITY_LEVEL_NO_SECURITY:
- case EPHY_SECURITY_LEVEL_MIXED_CONTENT:
- case EPHY_SECURITY_LEVEL_UNACCEPTABLE_CERTIFICATE:
- result = "channel-insecure-symbolic";
- break;
- case EPHY_SECURITY_LEVEL_STRONG_SECURITY:
- result = "channel-secure-symbolic";
- break;
- default:
- g_assert_not_reached ();
+ case EPHY_SECURITY_LEVEL_LOCAL_PAGE:
+ case EPHY_SECURITY_LEVEL_TO_BE_DETERMINED:
+ result = NULL;
+ break;
+ case EPHY_SECURITY_LEVEL_NO_SECURITY:
+ case EPHY_SECURITY_LEVEL_MIXED_CONTENT:
+ case EPHY_SECURITY_LEVEL_UNACCEPTABLE_CERTIFICATE:
+ result = "channel-insecure-symbolic";
+ break;
+ case EPHY_SECURITY_LEVEL_STRONG_SECURITY:
+ result = "channel-secure-symbolic";
+ break;
+ default:
+ g_assert_not_reached ();
}
return result;
diff --git a/lib/ephy-signal-accumulator.c b/lib/ephy-signal-accumulator.c
index fc2a3b670..17831fbfe 100644
--- a/lib/ephy-signal-accumulator.c
+++ b/lib/ephy-signal-accumulator.c
@@ -1,58 +1,55 @@
/*
-* Copyright © 2004 Christian Persch
-*
-* 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, see <http://www.gnu.org/licenses/>.
-*/
+ * Copyright © 2004 Christian Persch
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
#include "config.h"
#include "ephy-signal-accumulator.h"
-typedef GType (* GetTypeFunc) (void);
+typedef GType (*GetTypeFunc) (void);
gboolean
ephy_signal_accumulator_object (GSignalInvocationHint *ihint,
- GValue *return_accu,
- const GValue *handler_return,
- gpointer accu_data)
+ GValue *return_accu,
+ const GValue *handler_return,
+ gpointer accu_data)
{
- GObject *object;
- GetTypeFunc get_type = (GetTypeFunc) accu_data;
-
- object = g_value_get_object (handler_return);
- if (object != NULL &&
- G_TYPE_CHECK_INSTANCE_TYPE (object, get_type ()))
- {
- g_value_set_object (return_accu, object);
-
- return FALSE;
- }
- else if (object != NULL)
- {
- g_return_val_if_reached (TRUE);
- }
-
- return TRUE;
+ GObject *object;
+ GetTypeFunc get_type = (GetTypeFunc)accu_data;
+
+ object = g_value_get_object (handler_return);
+ if (object != NULL &&
+ G_TYPE_CHECK_INSTANCE_TYPE (object, get_type ())) {
+ g_value_set_object (return_accu, object);
+
+ return FALSE;
+ } else if (object != NULL) {
+ g_return_val_if_reached (TRUE);
+ }
+
+ return TRUE;
}
gboolean
ephy_signal_accumulator_string (GSignalInvocationHint *ihint,
- GValue *return_accu,
- const GValue *handler_return,
- gpointer accu_data)
+ GValue *return_accu,
+ const GValue *handler_return,
+ gpointer accu_data)
{
- g_value_copy (handler_return, return_accu);
-
- return g_value_get_string (handler_return) == NULL;
+ g_value_copy (handler_return, return_accu);
+
+ return g_value_get_string (handler_return) == NULL;
}
diff --git a/lib/ephy-smaps.c b/lib/ephy-smaps.c
index 9f1536359..fbf4439b5 100644
--- a/lib/ephy-smaps.c
+++ b/lib/ephy-smaps.c
@@ -69,21 +69,21 @@ typedef enum {
static const char *get_ephy_process_name (EphyProcess process)
{
switch (process) {
- case EPHY_PROCESS_EPIPHANY:
- return "Browser";
- case EPHY_PROCESS_WEB:
- return "Web Process";
- case EPHY_PROCESS_PLUGIN:
- return "Plugin Process";
- case EPHY_PROCESS_OTHER:
- default:
- g_assert_not_reached ();
+ case EPHY_PROCESS_EPIPHANY:
+ return "Browser";
+ case EPHY_PROCESS_WEB:
+ return "Web Process";
+ case EPHY_PROCESS_PLUGIN:
+ return "Plugin Process";
+ case EPHY_PROCESS_OTHER:
+ default:
+ g_assert_not_reached ();
}
return NULL;
}
-static void vma_free (VMA_t* vma)
+static void vma_free (VMA_t *vma)
{
g_free (vma->start);
g_free (vma->end);
@@ -207,7 +207,7 @@ static void ephy_smaps_pid_to_html (EphySMaps *smaps, GString *str, pid_t pid, E
stream = g_file_read (file, NULL, &error);
g_object_unref (file);
- if (error && error->code == G_IO_ERROR_NOT_FOUND ) {
+ if (error && error->code == G_IO_ERROR_NOT_FOUND) {
/* This is not GNU/Linux, do nothing. */
g_error_free (error);
return;
@@ -238,7 +238,7 @@ static void ephy_smaps_pid_to_html (EphySMaps *smaps, GString *str, pid_t pid, E
vma->inode = g_match_info_fetch (match_info, 7);
vma->filename = g_match_info_fetch (match_info, 8);
}
-
+
g_match_info_free (match_info);
if (matched)
@@ -271,7 +271,7 @@ static void ephy_smaps_pid_to_html (EphySMaps *smaps, GString *str, pid_t pid, E
}
g_match_info_free (match_info);
- out:
+ out:
g_free (line);
}
@@ -292,7 +292,7 @@ static void ephy_smaps_pid_to_html (EphySMaps *smaps, GString *str, pid_t pid, E
(GDestroyNotify)perm_entry_free);
for (p = vma_entries; p; p = p->next) {
- VMA_t *entry = (VMA_t*)p->data;
+ VMA_t *entry = (VMA_t *)p->data;
if (g_strcmp0 (entry->major, "00") && g_strcmp0 (entry->minor, "00"))
add_to_perm_entry (anon_hash, entry);
@@ -438,7 +438,7 @@ static void ephy_smaps_pid_children_to_html (EphySMaps *smaps, GString *str, pid
g_dir_close (proc);
}
-char* ephy_smaps_to_html (EphySMaps *smaps)
+char *ephy_smaps_to_html (EphySMaps *smaps)
{
GString *str = g_string_new ("");
pid_t pid = getpid ();
diff --git a/lib/ephy-snapshot-service.c b/lib/ephy-snapshot-service.c
index ac176eb34..dd2103bd4 100644
--- a/lib/ephy-snapshot-service.c
+++ b/lib/ephy-snapshot-service.c
@@ -30,8 +30,7 @@
/* Update snapshots after one week. */
#define SNAPSHOT_UPDATE_THRESHOLD (60 * 60 * 24 * 7)
-struct _EphySnapshotService
-{
+struct _EphySnapshotService {
GObject parent_instance;
GnomeDesktopThumbnailFactory *factory;
GHashTable *cache;
@@ -103,7 +102,7 @@ ephy_snapshot_service_prepare_snapshot (cairo_surface_t *surface,
x_offset = 6;
if (favicon) {
- GdkPixbuf* fav_pixbuf;
+ GdkPixbuf *fav_pixbuf;
int favicon_size = 16;
int y_offset = gdk_pixbuf_get_height (scaled) - favicon_size - x_offset;
@@ -129,7 +128,7 @@ typedef struct {
static SnapshotAsyncData *
snapshot_async_data_new (WebKitWebView *web_view,
- time_t mtime)
+ time_t mtime)
{
SnapshotAsyncData *data;
@@ -144,7 +143,7 @@ snapshot_async_data_new (WebKitWebView *web_view,
static SnapshotAsyncData *
snapshot_async_data_new_for_snapshot (WebKitWebView *web_view,
- time_t mtime)
+ time_t mtime)
{
SnapshotAsyncData *data = snapshot_async_data_new (web_view, mtime);
@@ -158,7 +157,7 @@ snapshot_async_data_free (SnapshotAsyncData *data)
{
if (data->web_view)
g_object_remove_weak_pointer (G_OBJECT (data->web_view), (gpointer *)&data->web_view);
- g_clear_object(&data->snapshot);
+ g_clear_object (&data->snapshot);
g_free (data->path);
g_slice_free (SnapshotAsyncData, data);
@@ -166,8 +165,8 @@ snapshot_async_data_free (SnapshotAsyncData *data)
static void
snapshot_saved (EphySnapshotService *service,
- GAsyncResult *result,
- GTask *task)
+ GAsyncResult *result,
+ GTask *task)
{
SnapshotAsyncData *data = g_task_get_task_data (task);
char *path;
@@ -184,7 +183,7 @@ snapshot_saved (EphySnapshotService *service,
static void
save_snapshot (cairo_surface_t *surface,
- GTask *task)
+ GTask *task)
{
SnapshotAsyncData *data = g_task_get_task_data (task);
@@ -202,8 +201,8 @@ save_snapshot (cairo_surface_t *surface,
static void
on_snapshot_ready (WebKitWebView *web_view,
- GAsyncResult *result,
- GTask *task)
+ GAsyncResult *result,
+ GTask *task)
{
cairo_surface_t *surface;
GError *error = NULL;
@@ -244,7 +243,7 @@ retrieve_snapshot_from_web_view (GTask *task)
static void
webview_destroyed_cb (GtkWidget *web_view,
- GTask *task)
+ GTask *task)
{
g_task_return_new_error (task,
EPHY_SNAPSHOT_SERVICE_ERROR,
@@ -254,16 +253,16 @@ webview_destroyed_cb (GtkWidget *web_view,
}
static void
-webview_load_changed_cb (WebKitWebView *web_view,
+webview_load_changed_cb (WebKitWebView *web_view,
WebKitLoadEvent load_event,
- GTask *task)
+ GTask *task)
{
if (load_event != WEBKIT_LOAD_FINISHED)
return;
/* Load finished doesn't ensure that we actually have visible content yet,
so hold a bit before retrieving the snapshot. */
- g_idle_add ((GSourceFunc) retrieve_snapshot_from_web_view, task);
+ g_idle_add ((GSourceFunc)retrieve_snapshot_from_web_view, task);
/* Some pages might end up causing this condition to happen twice, so remove
the handler in order to avoid calling the above idle function twice. */
@@ -272,11 +271,11 @@ webview_load_changed_cb (WebKitWebView *web_view,
}
static gboolean
-webview_load_failed_cb (WebKitWebView *web_view,
+webview_load_failed_cb (WebKitWebView *web_view,
WebKitLoadEvent load_event,
- const char failing_uri,
- GError *error,
- GTask *task)
+ const char failing_uri,
+ GError *error,
+ GTask *task)
{
g_signal_handlers_disconnect_by_func (web_view, webview_load_changed_cb, task);
g_signal_handlers_disconnect_by_func (web_view, webview_load_failed_cb, task);
@@ -356,7 +355,7 @@ typedef struct {
static SnapshotForURLAsyncData *
snapshot_for_url_async_data_new (const char *url,
- time_t mtime)
+ time_t mtime)
{
SnapshotForURLAsyncData *data;
@@ -385,7 +384,7 @@ typedef struct {
static gboolean
idle_cache_snapshot_path (gpointer user_data)
{
- CacheData* data = (CacheData*)user_data;
+ CacheData *data = (CacheData *)user_data;
g_hash_table_insert (data->cache, data->url, data->path);
g_hash_table_unref (data->cache);
g_free (data);
@@ -394,10 +393,10 @@ idle_cache_snapshot_path (gpointer user_data)
}
static void
-get_snapshot_for_url_thread (GTask *task,
- EphySnapshotService *service,
+get_snapshot_for_url_thread (GTask *task,
+ EphySnapshotService *service,
SnapshotForURLAsyncData *data,
- GCancellable *cancellable)
+ GCancellable *cancellable)
{
GdkPixbuf *snapshot;
GError *error = NULL;
@@ -445,11 +444,11 @@ get_snapshot_for_url_thread (GTask *task,
**/
void
ephy_snapshot_service_get_snapshot_for_url_async (EphySnapshotService *service,
- const char *url,
- const time_t mtime,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+ const char *url,
+ const time_t mtime,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
GTask *task;
@@ -479,9 +478,9 @@ ephy_snapshot_service_get_snapshot_for_url_async (EphySnapshotService *service,
**/
GdkPixbuf *
ephy_snapshot_service_get_snapshot_for_url_finish (EphySnapshotService *service,
- GAsyncResult *result,
- gchar **path,
- GError **error)
+ GAsyncResult *result,
+ gchar **path,
+ GError **error)
{
GTask *task = G_TASK (result);
GdkPixbuf *snapshot;
@@ -505,8 +504,8 @@ ephy_snapshot_service_get_snapshot_for_url_finish (EphySnapshotService *service,
static void
got_snapshot_for_url (EphySnapshotService *service,
- GAsyncResult *result,
- GTask *task)
+ GAsyncResult *result,
+ GTask *task)
{
GdkPixbuf *snapshot;
SnapshotAsyncData *data;
@@ -537,11 +536,11 @@ got_snapshot_for_url (EphySnapshotService *service,
**/
void
ephy_snapshot_service_get_snapshot_async (EphySnapshotService *service,
- WebKitWebView *web_view,
- const time_t mtime,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+ WebKitWebView *web_view,
+ const time_t mtime,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
GTask *task;
const char *uri;
@@ -580,9 +579,9 @@ ephy_snapshot_service_get_snapshot_async (EphySnapshotService *service,
**/
GdkPixbuf *
ephy_snapshot_service_get_snapshot_finish (EphySnapshotService *service,
- GAsyncResult *result,
- gchar **path,
- GError **error)
+ GAsyncResult *result,
+ gchar **path,
+ GError **error)
{
GTask *task = G_TASK (result);
GdkPixbuf *snapshot;
@@ -611,9 +610,9 @@ typedef struct {
} SaveSnapshotAsyncData;
static SaveSnapshotAsyncData *
-save_snapshot_async_data_new (GdkPixbuf *snapshot,
+save_snapshot_async_data_new (GdkPixbuf *snapshot,
const char *url,
- time_t mtime)
+ time_t mtime)
{
SaveSnapshotAsyncData *data;
@@ -635,10 +634,10 @@ save_snapshot_async_data_free (SaveSnapshotAsyncData *data)
}
static void
-save_snapshot_thread (GTask *task,
- EphySnapshotService *service,
+save_snapshot_thread (GTask *task,
+ EphySnapshotService *service,
SaveSnapshotAsyncData *data,
- GCancellable *cancellable)
+ GCancellable *cancellable)
{
char *path;
CacheData *cache_data;
@@ -661,12 +660,12 @@ save_snapshot_thread (GTask *task,
void
ephy_snapshot_service_save_snapshot_async (EphySnapshotService *service,
- GdkPixbuf *snapshot,
- const char *url,
- time_t mtime,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+ GdkPixbuf *snapshot,
+ const char *url,
+ time_t mtime,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
GTask *task;
@@ -685,8 +684,8 @@ ephy_snapshot_service_save_snapshot_async (EphySnapshotService *service,
char *
ephy_snapshot_service_save_snapshot_finish (EphySnapshotService *service,
- GAsyncResult *result,
- GError **error)
+ GAsyncResult *result,
+ GError **error)
{
g_return_val_if_fail (g_task_is_valid (result, service), NULL);
@@ -695,7 +694,7 @@ ephy_snapshot_service_save_snapshot_finish (EphySnapshotService *service,
const char *
ephy_snapshot_service_lookup_snapshot_path (EphySnapshotService *service,
- const char *url)
+ const char *url)
{
g_return_val_if_fail (EPHY_IS_SNAPSHOT_SERVICE (service), NULL);
@@ -703,10 +702,10 @@ ephy_snapshot_service_lookup_snapshot_path (EphySnapshotService *service,
}
static void
-get_snapshot_path_for_url_thread (GTask *task,
- EphySnapshotService *service,
+get_snapshot_path_for_url_thread (GTask *task,
+ EphySnapshotService *service,
SnapshotForURLAsyncData *data,
- GCancellable *cancellable)
+ GCancellable *cancellable)
{
char *path;
CacheData *cache_data;
@@ -731,11 +730,11 @@ get_snapshot_path_for_url_thread (GTask *task,
void
ephy_snapshot_service_get_snapshot_path_for_url_async (EphySnapshotService *service,
- const char *url,
- const time_t mtime,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+ const char *url,
+ const time_t mtime,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
GTask *task;
const char *path;
@@ -762,8 +761,8 @@ ephy_snapshot_service_get_snapshot_path_for_url_async (EphySnapshotService *serv
char *
ephy_snapshot_service_get_snapshot_path_for_url_finish (EphySnapshotService *service,
- GAsyncResult *result,
- GError **error)
+ GAsyncResult *result,
+ GError **error)
{
g_return_val_if_fail (g_task_is_valid (result, service), NULL);
@@ -772,8 +771,8 @@ ephy_snapshot_service_get_snapshot_path_for_url_finish (EphySnapshotService *ser
static void
got_snapshot_path_for_url (EphySnapshotService *service,
- GAsyncResult *result,
- GTask *task)
+ GAsyncResult *result,
+ GTask *task)
{
char *path;
@@ -788,11 +787,11 @@ got_snapshot_path_for_url (EphySnapshotService *service,
void
ephy_snapshot_service_get_snapshot_path_async (EphySnapshotService *service,
- WebKitWebView *web_view,
- const time_t mtime,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+ WebKitWebView *web_view,
+ const time_t mtime,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
GTask *task;
const char *uri;
@@ -829,8 +828,8 @@ ephy_snapshot_service_get_snapshot_path_async (EphySnapshotService *service,
char *
ephy_snapshot_service_get_snapshot_path_finish (EphySnapshotService *service,
- GAsyncResult *result,
- GError **error)
+ GAsyncResult *result,
+ GError **error)
{
g_return_val_if_fail (g_task_is_valid (result, service), NULL);
diff --git a/lib/ephy-sqlite-connection.c b/lib/ephy-sqlite-connection.c
index 10bc5d6e1..90266a447 100644
--- a/lib/ephy-sqlite-connection.c
+++ b/lib/ephy-sqlite-connection.c
@@ -53,7 +53,7 @@ static GQuark get_ephy_sqlite_quark (void)
}
static void
-set_error_from_string (const char* string, GError **error)
+set_error_from_string (const char *string, GError **error)
{
if (error)
*error = g_error_new_literal (get_ephy_sqlite_quark (), 0, string);
@@ -72,7 +72,7 @@ ephy_sqlite_connection_open (EphySQLiteConnection *self, const gchar *filename,
set_error_from_string ("Connection already open.", error);
return FALSE;
}
-
+
if (sqlite3_open (filename, &self->database) != SQLITE_OK) {
ephy_sqlite_connection_get_error (self, error);
self->database = NULL;
@@ -105,7 +105,7 @@ ephy_sqlite_connection_execute (EphySQLiteConnection *self, const char *sql, GEr
set_error_from_string ("Connection not open.", error);
return FALSE;
}
-
+
return sqlite3_exec (self->database, sql, NULL, NULL, NULL) == SQLITE_OK;
}
@@ -161,7 +161,7 @@ ephy_sqlite_connection_table_exists (EphySQLiteConnection *self, const char *tab
gboolean table_exists = FALSE;
EphySQLiteStatement *statement = ephy_sqlite_connection_create_statement (self,
- "SELECT COUNT(type) FROM sqlite_master WHERE type='table' and name=?", &error);
+ "SELECT COUNT(type) FROM sqlite_master WHERE type='table' and name=?", &error);
if (error) {
g_warning ("Could not detect table existence: %s", error->message);
g_error_free (error);
diff --git a/lib/ephy-sqlite-statement.c b/lib/ephy-sqlite-statement.c
index 795887977..41f274860 100644
--- a/lib/ephy-sqlite-statement.c
+++ b/lib/ephy-sqlite-statement.c
@@ -21,8 +21,7 @@
#include "ephy-sqlite-connection.h"
#include <sqlite3.h>
-enum
-{
+enum {
PROP_0,
PROP_PREPARED_STATEMENT,
PROP_CONNECTION,
@@ -236,13 +235,13 @@ ephy_sqlite_statement_get_column_as_double (EphySQLiteStatement *self, int colum
return sqlite3_column_double (self->prepared_statement, column);
}
-const char*
+const char *
ephy_sqlite_statement_get_column_as_string (EphySQLiteStatement *self, int column)
{
- return (const char*) sqlite3_column_text (self->prepared_statement, column);
+ return (const char *)sqlite3_column_text (self->prepared_statement, column);
}
-const void*
+const void *
ephy_sqlite_statement_get_column_as_blob (EphySQLiteStatement *self, int column)
{
return sqlite3_column_blob (self->prepared_statement, column);
diff --git a/lib/ephy-string.c b/lib/ephy-string.c
index 5e866cf27..57e2d509f 100644
--- a/lib/ephy-string.c
+++ b/lib/ephy-string.c
@@ -68,7 +68,7 @@ ephy_string_blank_chr (char *source)
p = source;
while (*p != '\0') {
- if ((guchar) *p < 0x20)
+ if ((guchar) * p < 0x20)
*p = ' ';
p++;
@@ -81,10 +81,10 @@ ephy_string_blank_chr (char *source)
* ephy_string_shorten: shortens a string
* @str: the string to shorten, in UTF-8
* @target_length: the length of the shortened string (in characters)
- *
+ *
* If @str is already short enough, it is returned. Otherwise a new string
* is allocated and @str is consumed.
- *
+ *
* Return value: a newly allocated string, not longer than target_length
* characters.
*/
@@ -105,23 +105,23 @@ ephy_string_shorten (char *str,
* it can still split a sequence of combining characters.
*/
actual_length = g_utf8_strlen (str, -1);
-
+
/* if the string is already short enough, or if it's too short for
* us to shorten it, return a new copy */
if ((gsize)actual_length <= target_length)
return str;
-
+
/* create string */
bytes = GPOINTER_TO_UINT (g_utf8_offset_to_pointer (str, target_length - 1) - str);
-
- new_str = g_new (gchar, bytes + strlen(ELLIPSIS) + 1);
-
+
+ new_str = g_new (gchar, bytes + strlen (ELLIPSIS) + 1);
+
strncpy (new_str, str, bytes);
strncpy (new_str + bytes, ELLIPSIS, strlen (ELLIPSIS));
new_str[bytes + strlen (ELLIPSIS)] = '\0';
-
+
g_free (str);
-
+
return new_str;
}
@@ -136,12 +136,12 @@ ephy_string_shorten (char *str,
* ephy_string_collate_key_for_domain:
* @host:
* @len: the length of @host, or -1 to use the entire null-terminated @host string
- *
+ *
* Return value: a collation key for @host.
*/
-char*
+char *
ephy_string_collate_key_for_domain (const char *str,
- gssize len)
+ gssize len)
{
GString *result;
const char *dot;
@@ -176,7 +176,7 @@ ephy_string_get_host_name (const char *url)
{
SoupURI *uri;
char *ret;
-
+
if (url == NULL ||
g_str_has_prefix (url, "file://") ||
g_str_has_prefix (url, "about:") ||
@@ -188,9 +188,9 @@ ephy_string_get_host_name (const char *url)
* something without a scheme, let's try to prepend
* 'http://' */
if (uri == NULL) {
- char *effective_url = g_strconcat ("http://", url, NULL);
- uri = soup_uri_new (effective_url);
- g_free (effective_url);
+ char *effective_url = g_strconcat ("http://", url, NULL);
+ uri = soup_uri_new (effective_url);
+ g_free (effective_url);
}
if (uri == NULL) return NULL;
@@ -229,7 +229,7 @@ ephy_string_commandline_args_to_uris (char **arguments, GError **error)
args[i] = g_file_get_uri (file);
} else {
args[i] = g_locale_to_utf8 (arguments [i], -1,
- NULL, NULL, error);
+ NULL, NULL, error);
if (error && *error) {
g_strfreev (args);
return NULL;
diff --git a/lib/ephy-time-helpers.c b/lib/ephy-time-helpers.c
index dc3fe7422..85863309b 100644
--- a/lib/ephy-time-helpers.c
+++ b/lib/ephy-time-helpers.c
@@ -64,223 +64,223 @@
char *
eel_strdup_strftime (const char *format, struct tm *time_pieces)
{
- GString *string;
- const char *remainder, *percent;
- char code[4], buffer[512];
- char *piece, *result, *converted;
- size_t string_length;
- gboolean strip_leading_zeros, turn_leading_zeros_to_spaces;
- char modifier;
- int i;
+ GString *string;
+ const char *remainder, *percent;
+ char code[4], buffer[512];
+ char *piece, *result, *converted;
+ size_t string_length;
+ gboolean strip_leading_zeros, turn_leading_zeros_to_spaces;
+ char modifier;
+ int i;
- /* Format could be translated, and contain UTF-8 chars,
- * so convert to locale encoding which strftime uses */
- converted = g_locale_from_utf8 (format, -1, NULL, NULL, NULL);
- g_return_val_if_fail (converted != NULL, NULL);
+ /* Format could be translated, and contain UTF-8 chars,
+ * so convert to locale encoding which strftime uses */
+ converted = g_locale_from_utf8 (format, -1, NULL, NULL, NULL);
+ g_return_val_if_fail (converted != NULL, NULL);
- string = g_string_new ("");
- remainder = converted;
+ string = g_string_new ("");
+ remainder = converted;
- /* Walk from % character to % character. */
- for (;;) {
- percent = strchr (remainder, '%');
- if (percent == NULL) {
- g_string_append (string, remainder);
- break;
- }
- g_string_append_len (string, remainder,
- percent - remainder);
+ /* Walk from % character to % character. */
+ for (;; ) {
+ percent = strchr (remainder, '%');
+ if (percent == NULL) {
+ g_string_append (string, remainder);
+ break;
+ }
+ g_string_append_len (string, remainder,
+ percent - remainder);
- /* Handle the "%" character. */
- remainder = percent + 1;
- switch (*remainder) {
- case '-':
- strip_leading_zeros = TRUE;
- turn_leading_zeros_to_spaces = FALSE;
- remainder++;
- break;
- case '_':
- strip_leading_zeros = FALSE;
- turn_leading_zeros_to_spaces = TRUE;
- remainder++;
- break;
- case '%':
- g_string_append_c (string, '%');
- remainder++;
- continue;
- case '\0':
- g_warning ("Trailing %% passed to eel_strdup_strftime");
- g_string_append_c (string, '%');
- continue;
- default:
- strip_leading_zeros = FALSE;
- turn_leading_zeros_to_spaces = FALSE;
- break;
- }
+ /* Handle the "%" character. */
+ remainder = percent + 1;
+ switch (*remainder) {
+ case '-':
+ strip_leading_zeros = TRUE;
+ turn_leading_zeros_to_spaces = FALSE;
+ remainder++;
+ break;
+ case '_':
+ strip_leading_zeros = FALSE;
+ turn_leading_zeros_to_spaces = TRUE;
+ remainder++;
+ break;
+ case '%':
+ g_string_append_c (string, '%');
+ remainder++;
+ continue;
+ case '\0':
+ g_warning ("Trailing %% passed to eel_strdup_strftime");
+ g_string_append_c (string, '%');
+ continue;
+ default:
+ strip_leading_zeros = FALSE;
+ turn_leading_zeros_to_spaces = FALSE;
+ break;
+ }
- modifier = 0;
- if (strchr (SUS_EXTENDED_STRFTIME_MODIFIERS, *remainder) != NULL) {
- modifier = *remainder;
- remainder++;
+ modifier = 0;
+ if (strchr (SUS_EXTENDED_STRFTIME_MODIFIERS, *remainder) != NULL) {
+ modifier = *remainder;
+ remainder++;
- if (*remainder == 0) {
- g_warning ("Unfinished %%%c modifier passed to eel_strdup_strftime", modifier);
- break;
- }
- }
+ if (*remainder == 0) {
+ g_warning ("Unfinished %%%c modifier passed to eel_strdup_strftime", modifier);
+ break;
+ }
+ }
- if (strchr (C_STANDARD_STRFTIME_CHARACTERS, *remainder) == NULL) {
- g_warning ("eel_strdup_strftime does not support "
- "non-standard escape code %%%c",
- *remainder);
- }
+ if (strchr (C_STANDARD_STRFTIME_CHARACTERS, *remainder) == NULL) {
+ g_warning ("eel_strdup_strftime does not support "
+ "non-standard escape code %%%c",
+ *remainder);
+ }
- /* Convert code to strftime format. We have a fixed
- * limit here that each code can expand to a maximum
- * of 512 bytes, which is probably OK. There's no
- * limit on the total size of the result string.
- */
- i = 0;
- code[i++] = '%';
- if (modifier != 0) {
+ /* Convert code to strftime format. We have a fixed
+ * limit here that each code can expand to a maximum
+ * of 512 bytes, which is probably OK. There's no
+ * limit on the total size of the result string.
+ */
+ i = 0;
+ code[i++] = '%';
+ if (modifier != 0) {
#ifdef HAVE_STRFTIME_EXTENSION
- code[i++] = modifier;
+ code[i++] = modifier;
#endif
- }
- code[i++] = *remainder;
- code[i++] = '\0';
+ }
+ code[i++] = *remainder;
+ code[i++] = '\0';
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
- /* Format string under control of caller, since this is a wrapper for strftime. */
- string_length = strftime (buffer, sizeof (buffer),
- code, time_pieces);
+ /* Format string under control of caller, since this is a wrapper for strftime. */
+ string_length = strftime (buffer, sizeof (buffer),
+ code, time_pieces);
#pragma GCC diagnostic pop
- if (string_length == 0) {
- /* We could put a warning here, but there's no
- * way to tell a successful conversion to
- * empty string from a failure.
- */
- buffer[0] = '\0';
- }
+ if (string_length == 0) {
+ /* We could put a warning here, but there's no
+ * way to tell a successful conversion to
+ * empty string from a failure.
+ */
+ buffer[0] = '\0';
+ }
- /* Strip leading zeros if requested. */
- piece = buffer;
- if (strip_leading_zeros || turn_leading_zeros_to_spaces) {
- if (strchr (C_STANDARD_NUMERIC_STRFTIME_CHARACTERS, *remainder) == NULL) {
- g_warning ("eel_strdup_strftime does not support "
- "modifier for non-numeric escape code %%%c%c",
- remainder[-1],
- *remainder);
- }
- if (*piece == '0') {
- do {
- piece++;
- } while (*piece == '0');
- if (!g_ascii_isdigit (*piece)) {
- piece--;
- }
- }
- if (turn_leading_zeros_to_spaces) {
- memset (buffer, ' ', piece - buffer);
- piece = buffer;
- }
- }
- remainder++;
+ /* Strip leading zeros if requested. */
+ piece = buffer;
+ if (strip_leading_zeros || turn_leading_zeros_to_spaces) {
+ if (strchr (C_STANDARD_NUMERIC_STRFTIME_CHARACTERS, *remainder) == NULL) {
+ g_warning ("eel_strdup_strftime does not support "
+ "modifier for non-numeric escape code %%%c%c",
+ remainder[-1],
+ *remainder);
+ }
+ if (*piece == '0') {
+ do {
+ piece++;
+ } while (*piece == '0');
+ if (!g_ascii_isdigit (*piece)) {
+ piece--;
+ }
+ }
+ if (turn_leading_zeros_to_spaces) {
+ memset (buffer, ' ', piece - buffer);
+ piece = buffer;
+ }
+ }
+ remainder++;
- /* Add this piece. */
- g_string_append (string, piece);
- }
+ /* Add this piece. */
+ g_string_append (string, piece);
+ }
- /* Convert the string back into utf-8. */
- result = g_locale_to_utf8 (string->str, -1, NULL, NULL, NULL);
+ /* Convert the string back into utf-8. */
+ result = g_locale_to_utf8 (string->str, -1, NULL, NULL, NULL);
- g_string_free (string, TRUE);
- g_free (converted);
+ g_string_free (string, TRUE);
+ g_free (converted);
- return result;
+ return result;
}
/* Based on evolution/mail/message-list.c:filter_date() */
char *
ephy_time_helpers_utf_friendly_time (time_t date)
{
- time_t nowdate;
- time_t yesdate;
- struct tm then, now, yesterday;
- const char *format = NULL;
- char *str = NULL;
- gboolean done = FALSE;
+ time_t nowdate;
+ time_t yesdate;
+ struct tm then, now, yesterday;
+ const char *format = NULL;
+ char *str = NULL;
+ gboolean done = FALSE;
- nowdate = time (NULL);
+ nowdate = time (NULL);
- if (date == 0)
- return NULL;
+ if (date == 0)
+ return NULL;
- localtime_r (&date, &then);
- localtime_r (&nowdate, &now);
+ localtime_r (&date, &then);
+ localtime_r (&nowdate, &now);
- if (then.tm_mday == now.tm_mday &&
- then.tm_mon == now.tm_mon &&
- then.tm_year == now.tm_year) {
- /* Translators: "friendly time" string for the current day, strftime format. like "Today 12:34 am" */
- format = _("Today %I:%M %p");
- done = TRUE;
- }
+ if (then.tm_mday == now.tm_mday &&
+ then.tm_mon == now.tm_mon &&
+ then.tm_year == now.tm_year) {
+ /* Translators: "friendly time" string for the current day, strftime format. like "Today 12:34 am" */
+ format = _("Today %I:%M %p");
+ done = TRUE;
+ }
- if (! done) {
- yesdate = nowdate - 60 * 60 * 24;
- localtime_r (&yesdate, &yesterday);
- if (then.tm_mday == yesterday.tm_mday &&
- then.tm_mon == yesterday.tm_mon &&
- then.tm_year == yesterday.tm_year) {
- /* Translators: "friendly time" string for the previous day,
- * strftime format. e.g. "Yesterday 12:34 am"
- */
- format = _("Yesterday %I:%M %p");
- done = TRUE;
- }
- }
+ if (!done) {
+ yesdate = nowdate - 60 * 60 * 24;
+ localtime_r (&yesdate, &yesterday);
+ if (then.tm_mday == yesterday.tm_mday &&
+ then.tm_mon == yesterday.tm_mon &&
+ then.tm_year == yesterday.tm_year) {
+ /* Translators: "friendly time" string for the previous day,
+ * strftime format. e.g. "Yesterday 12:34 am"
+ */
+ format = _("Yesterday %I:%M %p");
+ done = TRUE;
+ }
+ }
- if (! done) {
- int i;
- for (i = 2; i < 7; i++) {
- yesdate = nowdate - 60 * 60 * 24 * i;
- localtime_r (&yesdate, &yesterday);
- if (then.tm_mday == yesterday.tm_mday &&
- then.tm_mon == yesterday.tm_mon &&
- then.tm_year == yesterday.tm_year) {
- /* Translators: "friendly time" string for a day in the current week,
- * strftime format. e.g. "Wed 12:34 am"
- */
- format = _("%a %I:%M %p");
- done = TRUE;
- break;
- }
- }
- }
+ if (!done) {
+ int i;
+ for (i = 2; i < 7; i++) {
+ yesdate = nowdate - 60 * 60 * 24 * i;
+ localtime_r (&yesdate, &yesterday);
+ if (then.tm_mday == yesterday.tm_mday &&
+ then.tm_mon == yesterday.tm_mon &&
+ then.tm_year == yesterday.tm_year) {
+ /* Translators: "friendly time" string for a day in the current week,
+ * strftime format. e.g. "Wed 12:34 am"
+ */
+ format = _("%a %I:%M %p");
+ done = TRUE;
+ break;
+ }
+ }
+ }
- if (! done) {
- if (then.tm_year == now.tm_year) {
- /* Translators: "friendly time" string for a day in the current year,
- * strftime format. e.g. "Feb 12 12:34 am"
- */
- format = _("%b %d %I:%M %p");
- } else {
- /* Translators: "friendly time" string for a day in a different year,
- * strftime format. e.g. "Feb 12 1997"
- */
- format = _("%b %d %Y");
- }
- }
+ if (!done) {
+ if (then.tm_year == now.tm_year) {
+ /* Translators: "friendly time" string for a day in the current year,
+ * strftime format. e.g. "Feb 12 12:34 am"
+ */
+ format = _("%b %d %I:%M %p");
+ } else {
+ /* Translators: "friendly time" string for a day in a different year,
+ * strftime format. e.g. "Feb 12 1997"
+ */
+ format = _("%b %d %Y");
+ }
+ }
- if (format != NULL) {
- str = eel_strdup_strftime (format, &then);
- }
+ if (format != NULL) {
+ str = eel_strdup_strftime (format, &then);
+ }
- if (str == NULL) {
- /* impossible time or broken locale settings */
- str = g_strdup (_("Unknown"));
- }
+ if (str == NULL) {
+ /* impossible time or broken locale settings */
+ str = g_strdup (_("Unknown"));
+ }
- return str;
+ return str;
}
diff --git a/lib/ephy-uri-helpers.c b/lib/ephy-uri-helpers.c
index 95b258f9e..f7c3503d4 100644
--- a/lib/ephy-uri-helpers.c
+++ b/lib/ephy-uri-helpers.c
@@ -127,7 +127,7 @@ query_concat (GList *items)
}
g_ptr_array_add (array, NULL);
- ret = g_strjoinv ("&", (char **) array->pdata);
+ ret = g_strjoinv ("&", (char **)array->pdata);
g_ptr_array_free (array, TRUE);
return ret;
@@ -142,31 +142,31 @@ is_garbage (const char *name,
const char *host;
} const fields[] = {
/* analytics.google.com */
- { "utm_source", NULL },
- { "utm_medium", NULL },
- { "utm_term", NULL },
- { "utm_content", NULL },
- { "utm_campaign", NULL },
- { "utm_reader", NULL },
+ { "utm_source", NULL },
+ { "utm_medium", NULL },
+ { "utm_term", NULL },
+ { "utm_content", NULL },
+ { "utm_campaign", NULL },
+ { "utm_reader", NULL },
/* metrika.yandex.ru */
- { "yclid", NULL },
+ { "yclid", NULL },
/* youtube.com */
- { "feature", "youtube.com" },
+ { "feature", "youtube.com" },
/* facebook.com */
- { "fb_action_ids", NULL},
- { "fb_action_types", NULL },
- { "fb_ref", NULL },
- { "fb_source", NULL },
- { "action_object_map", NULL },
- { "action_type_map", NULL },
- { "action_ref_map", NULL },
- { "ref", "facebook.com" },
- { "fref", "facebook.com" },
- { "hc_location", "facebook.com" },
+ { "fb_action_ids", NULL },
+ { "fb_action_types", NULL },
+ { "fb_ref", NULL },
+ { "fb_source", NULL },
+ { "action_object_map", NULL },
+ { "action_type_map", NULL },
+ { "action_ref_map", NULL },
+ { "ref", "facebook.com" },
+ { "fref", "facebook.com" },
+ { "hc_location", "facebook.com" },
/* imdb.com */
- { "ref_", "imdb.com" },
+ { "ref_", "imdb.com" },
/* addons.mozilla.org */
- { "src", "addons.mozilla.org" }
+ { "src", "addons.mozilla.org" }
};
guint i;
@@ -239,10 +239,10 @@ ephy_remove_tracking_from_uri (const char *uri_string)
ret = soup_uri_to_string (uri, FALSE);
}
- g_list_free_full (items, (GDestroyNotify) query_item_free);
+ g_list_free_full (items, (GDestroyNotify)query_item_free);
g_list_free (new_items);
-bail:
+ bail:
soup_uri_free (uri);
return ret;
}
diff --git a/lib/ephy-web-app-utils.c b/lib/ephy-web-app-utils.c
index 37b6be7f4..aaf1f7c2f 100644
--- a/lib/ephy-web-app-utils.c
+++ b/lib/ephy-web-app-utils.c
@@ -111,10 +111,10 @@ ephy_web_application_get_profile_directory (const char *name)
/**
* ephy_web_application_delete:
* @name: the name of the web application do delete
- *
+ *
* Deletes all the data associated with a Web Application created by
* Epiphany.
- *
+ *
* Returns: %TRUE if the web app was succesfully deleted, %FALSE otherwise
**/
gboolean
@@ -158,7 +158,7 @@ ephy_web_application_delete (const char *name)
}
return_value = TRUE;
-out:
+ out:
g_free (profile_dir);
@@ -174,7 +174,7 @@ static char *
create_desktop_file (const char *address,
const char *profile_dir,
const char *title,
- GdkPixbuf *icon)
+ GdkPixbuf *icon)
{
GKeyFile *file = NULL;
char *exec_string;
@@ -213,7 +213,7 @@ create_desktop_file (const char *address,
path = g_build_filename (profile_dir, EPHY_WEB_APP_ICON_NAME, NULL);
image = g_file_new_for_path (path);
- stream = (GOutputStream*)g_file_create (image, 0, NULL, NULL);
+ stream = (GOutputStream *)g_file_create (image, 0, NULL, NULL);
gdk_pixbuf_save_to_stream (icon, stream, "png", NULL, NULL, NULL);
g_key_file_set_value (file, "Desktop Entry", "Icon", path);
@@ -248,7 +248,7 @@ create_desktop_file (const char *address,
g_free (apps_path);
g_free (filename);
-out:
+ out:
g_free (wm_class);
g_free (data);
g_key_file_free (file);
@@ -268,7 +268,7 @@ static SoupCookieJar *get_current_cookie_jar (void)
*/
dot_dir = !ephy_dot_dir_is_default () ? ephy_default_dot_dir () : NULL;
filename = g_build_filename (dot_dir ? dot_dir : ephy_dot_dir (), "cookies.sqlite", NULL);
- jar = (SoupCookieJar*)soup_cookie_jar_db_new (filename, TRUE);
+ jar = (SoupCookieJar *)soup_cookie_jar_db_new (filename, TRUE);
g_free (filename);
g_free (dot_dir);
@@ -285,7 +285,7 @@ create_cookie_jar_for_domain (const char *address, const char *directory)
/* Create the new cookie jar */
filename = g_build_filename (directory, "cookies.sqlite", NULL);
- new_jar = (SoupCookieJar*)soup_cookie_jar_db_new (filename, FALSE);
+ new_jar = (SoupCookieJar *)soup_cookie_jar_db_new (filename, FALSE);
g_free (filename);
/* The app domain for the current view */
@@ -302,7 +302,7 @@ create_cookie_jar_for_domain (const char *address, const char *directory)
cookies = soup_cookie_jar_all_cookies (current_jar);
for (p = cookies; p; p = p->next) {
- SoupCookie *cookie = (SoupCookie*)p->data;
+ SoupCookie *cookie = (SoupCookie *)p->data;
if (soup_cookie_domain_matches (cookie, domain))
soup_cookie_jar_add_cookie (new_jar, cookie);
@@ -321,9 +321,9 @@ create_cookie_jar_for_domain (const char *address, const char *directory)
* @address: the address of the new web application
* @name: the name for the new web application
* @icon: the icon for the new web application
- *
+ *
* Creates a new Web Application for @address.
- *
+ *
* Returns: (transfer-full): the path to the desktop file representing the new application
**/
char *
@@ -349,13 +349,13 @@ ephy_web_application_create (const char *address, const char *name, GdkPixbuf *i
/* Things we need in a WebApp's profile:
- Our own cookies file, copying the relevant cookies for the
app's domain.
- */
+ */
create_cookie_jar_for_domain (address, profile_dir);
/* Create the deskop file. */
desktop_file_path = create_desktop_file (address, profile_dir, name, icon);
-out:
+ out:
if (profile_dir)
g_free (profile_dir);
@@ -458,7 +458,7 @@ ephy_web_application_setup_from_desktop_file (GDesktopAppInfo *desktop_info)
}
g_clear_object (&file);
} else if (G_IS_THEMED_ICON (icon)) {
- const char *const *names = g_themed_icon_get_names (G_THEMED_ICON (icon));
+ const char * const *names = g_themed_icon_get_names (G_THEMED_ICON (icon));
if (names)
gtk_window_set_default_icon_name (names[0]);
}
@@ -597,7 +597,7 @@ ephy_web_application_free_application_list (GList *list)
GList *p;
for (p = list; p; p = p->next)
- ephy_web_application_free ((EphyWebApplication*)p->data);
+ ephy_web_application_free ((EphyWebApplication *)p->data);
g_list_free (list);
}
diff --git a/lib/ephy-zoom.c b/lib/ephy-zoom.c
index c2c678027..6b77f61ed 100644
--- a/lib/ephy-zoom.c
+++ b/lib/ephy-zoom.c
@@ -48,7 +48,7 @@ ephy_zoom_get_changed_zoom_level (float level, int steps)
int index;
index = ephy_zoom_get_zoom_level_index (level);
- return zoom_levels[CLAMP(index + steps, 0, (int) n_zoom_levels - 1)].level;
+ return zoom_levels[CLAMP (index + steps, 0, (int)n_zoom_levels - 1)].level;
}
float
diff --git a/lib/history/ephy-history-service-hosts-table.c b/lib/history/ephy-history-service-hosts-table.c
index 2cfeeaa9f..ad27403e2 100644
--- a/lib/history/ephy-history-service-hosts-table.c
+++ b/lib/history/ephy-history-service-hosts-table.c
@@ -33,12 +33,12 @@ ephy_history_service_initialize_hosts_table (EphyHistoryService *self)
return TRUE;
}
ephy_sqlite_connection_execute (self->history_database,
- "CREATE TABLE hosts ("
- "id INTEGER PRIMARY KEY,"
- "url LONGVARCAR,"
- "title LONGVARCAR,"
- "visit_count INTEGER DEFAULT 0 NOT NULL,"
- "zoom_level REAL DEFAULT 1.0)", &error);
+ "CREATE TABLE hosts ("
+ "id INTEGER PRIMARY KEY,"
+ "url LONGVARCAR,"
+ "title LONGVARCAR,"
+ "visit_count INTEGER DEFAULT 0 NOT NULL,"
+ "zoom_level REAL DEFAULT 1.0)", &error);
if (error) {
g_warning ("Could not create hosts table: %s", error->message);
@@ -59,8 +59,8 @@ ephy_history_service_add_host_row (EphyHistoryService *self, EphyHistoryHost *ho
g_assert (self->history_database != NULL);
statement = ephy_sqlite_connection_create_statement (self->history_database,
- "INSERT INTO hosts (url, title, visit_count, zoom_level) "
- "VALUES (?, ?, ?, ?)", &error);
+ "INSERT INTO hosts (url, title, visit_count, zoom_level) "
+ "VALUES (?, ?, ?, ?)", &error);
if (error) {
g_warning ("Could not build hosts table addition statement: %s", error->message);
@@ -99,8 +99,8 @@ ephy_history_service_update_host_row (EphyHistoryService *self, EphyHistoryHost
g_assert (self->history_database != NULL);
statement = ephy_sqlite_connection_create_statement (self->history_database,
- "UPDATE hosts SET url=?, title=?, visit_count=?, zoom_level=?"
- "WHERE id=?", &error);
+ "UPDATE hosts SET url=?, title=?, visit_count=?, zoom_level=?"
+ "WHERE id=?", &error);
if (error) {
g_warning ("Could not build hosts table modification statement: %s", error->message);
g_error_free (error);
@@ -126,7 +126,7 @@ ephy_history_service_update_host_row (EphyHistoryService *self, EphyHistoryHost
g_object_unref (statement);
}
-EphyHistoryHost*
+EphyHistoryHost *
ephy_history_service_get_host_row (EphyHistoryService *self, const gchar *host_string, EphyHistoryHost *host)
{
EphySQLiteStatement *statement = NULL;
@@ -138,16 +138,16 @@ ephy_history_service_get_host_row (EphyHistoryService *self, const gchar *host_s
if (host_string == NULL && host != NULL)
host_string = host->url;
- g_assert (host_string || host->id !=-1);
+ g_assert (host_string || host->id != -1);
if (host != NULL && host->id != -1) {
statement = ephy_sqlite_connection_create_statement (self->history_database,
- "SELECT id, url, title, visit_count, zoom_level FROM hosts "
- "WHERE id=?", &error);
+ "SELECT id, url, title, visit_count, zoom_level FROM hosts "
+ "WHERE id=?", &error);
} else {
statement = ephy_sqlite_connection_create_statement (self->history_database,
- "SELECT id, url, title, visit_count, zoom_level FROM hosts "
- "WHERE url=?", &error);
+ "SELECT id, url, title, visit_count, zoom_level FROM hosts "
+ "WHERE url=?", &error);
}
if (error) {
@@ -194,7 +194,7 @@ ephy_history_service_get_host_row (EphyHistoryService *self, const gchar *host_s
return host;
}
-static EphyHistoryHost*
+static EphyHistoryHost *
create_host_from_statement (EphySQLiteStatement *statement)
{
EphyHistoryHost *host =
@@ -207,7 +207,7 @@ create_host_from_statement (EphySQLiteStatement *statement)
return host;
}
-GList*
+GList *
ephy_history_service_get_all_hosts (EphyHistoryService *self)
{
EphySQLiteStatement *statement = NULL;
@@ -218,7 +218,7 @@ ephy_history_service_get_all_hosts (EphyHistoryService *self)
g_assert (self->history_database != NULL);
statement = ephy_sqlite_connection_create_statement (self->history_database,
- "SELECT id, url, title, visit_count, zoom_level FROM hosts", &error);
+ "SELECT id, url, title, visit_count, zoom_level FROM hosts", &error);
if (error) {
g_warning ("Could not build hosts query statement: %s", error->message);
@@ -240,7 +240,7 @@ ephy_history_service_get_all_hosts (EphyHistoryService *self)
return hosts;
}
-GList*
+GList *
ephy_history_service_find_host_rows (EphyHistoryService *self, EphyHistoryQuery *query)
{
EphySQLiteStatement *statement = NULL;
@@ -249,14 +249,14 @@ ephy_history_service_find_host_rows (EphyHistoryService *self, EphyHistoryQuery
GList *hosts = NULL;
GError *error = NULL;
const char *base_statement = ""
- "SELECT "
- "DISTINCT hosts.id, "
- "hosts.url, "
- "hosts.title, "
- "hosts.visit_count, "
- "hosts.zoom_level "
- "FROM "
- "hosts ";
+ "SELECT "
+ "DISTINCT hosts.id, "
+ "hosts.url, "
+ "hosts.title, "
+ "hosts.visit_count, "
+ "hosts.zoom_level "
+ "FROM "
+ "hosts ";
int i = 0;
@@ -267,7 +267,7 @@ ephy_history_service_find_host_rows (EphyHistoryService *self, EphyHistoryQuery
/* In either of these cases we need to at least join with the urls table. */
if (query->substring_list || query->from > 0 || query->to > 0)
- statement_str = g_string_append (statement_str, "JOIN urls on hosts.id = urls.host ");
+ statement_str = g_string_append (statement_str, "JOIN urls on hosts.id = urls.host ");
/* In these cases, we additionally need to join with the visits table. */
if (query->from > 0 || query->to > 0) {
@@ -287,7 +287,7 @@ ephy_history_service_find_host_rows (EphyHistoryService *self, EphyHistoryQuery
statement_str = g_string_append (statement_str, "1 ");
statement = ephy_sqlite_connection_create_statement (self->history_database,
- statement_str->str, &error);
+ statement_str->str, &error);
g_string_free (statement_str, TRUE);
if (error) {
@@ -316,7 +316,7 @@ ephy_history_service_find_host_rows (EphyHistoryService *self, EphyHistoryQuery
char *string = ephy_sqlite_create_match_pattern (substring->data);
while (j--)
/* The bitwise operation ensures we only skip two characters for titles. */
- if (ephy_sqlite_statement_bind_string (statement, i++, string + 2*((j+1) & 1), &error) == FALSE) {
+ if (ephy_sqlite_statement_bind_string (statement, i++, string + 2 * ((j + 1) & 1), &error) == FALSE) {
g_warning ("Could not build hosts table query statement: %s", error->message);
g_error_free (error);
g_object_unref (statement);
@@ -344,13 +344,13 @@ ephy_history_service_find_host_rows (EphyHistoryService *self, EphyHistoryQuery
static GList *
get_hostname_and_locations (const gchar *url, gchar **hostname)
{
- GList *host_locations = NULL;
- char *scheme = NULL;
+ GList *host_locations = NULL;
+ char *scheme = NULL;
if (url) {
- scheme = g_uri_parse_scheme (url);
- *hostname = ephy_string_get_host_name (url);
- }
+ scheme = g_uri_parse_scheme (url);
+ *hostname = ephy_string_get_host_name (url);
+ }
/* Build an host name */
if (scheme == NULL || *hostname == NULL) {
*hostname = g_strdup (_("Others"));
@@ -391,9 +391,9 @@ get_hostname_and_locations (const gchar *url, gchar **hostname)
return host_locations;
}
-EphyHistoryHost*
+EphyHistoryHost *
ephy_history_service_get_host_row_from_url (EphyHistoryService *self,
- const gchar *url)
+ const gchar *url)
{
GList *host_locations, *l;
char *hostname;
@@ -413,14 +413,14 @@ ephy_history_service_get_host_row_from_url (EphyHistoryService *self,
}
g_free (hostname);
- g_list_free_full (host_locations, (GDestroyNotify) g_free);
+ g_list_free_full (host_locations, (GDestroyNotify)g_free);
return host;
}
void
ephy_history_service_delete_host_row (EphyHistoryService *self,
- EphyHistoryHost *host)
+ EphyHistoryHost *host)
{
EphySQLiteStatement *statement = NULL;
gchar *sql_statement;
diff --git a/lib/history/ephy-history-service-urls-table.c b/lib/history/ephy-history-service-urls-table.c
index ead8475b3..56675bd68 100644
--- a/lib/history/ephy-history-service-urls-table.c
+++ b/lib/history/ephy-history-service-urls-table.c
@@ -31,16 +31,16 @@ ephy_history_service_initialize_urls_table (EphyHistoryService *self)
return TRUE;
}
ephy_sqlite_connection_execute (self->history_database,
- "CREATE TABLE urls ("
- "id INTEGER PRIMARY KEY,"
- "host INTEGER NOT NULL REFERENCES hosts(id) ON DELETE CASCADE,"
- "url LONGVARCAR,"
- "title LONGVARCAR,"
- "visit_count INTEGER DEFAULT 0 NOT NULL,"
- "typed_count INTEGER DEFAULT 0 NOT NULL,"
- "last_visit_time INTEGER,"
- "thumbnail_update_time INTEGER DEFAULT 0,"
- "hidden_from_overview INTEGER DEFAULT 0)", &error);
+ "CREATE TABLE urls ("
+ "id INTEGER PRIMARY KEY,"
+ "host INTEGER NOT NULL REFERENCES hosts(id) ON DELETE CASCADE,"
+ "url LONGVARCAR,"
+ "title LONGVARCAR,"
+ "visit_count INTEGER DEFAULT 0 NOT NULL,"
+ "typed_count INTEGER DEFAULT 0 NOT NULL,"
+ "last_visit_time INTEGER,"
+ "thumbnail_update_time INTEGER DEFAULT 0,"
+ "hidden_from_overview INTEGER DEFAULT 0)", &error);
if (error) {
g_warning ("Could not create urls table: %s", error->message);
@@ -54,7 +54,7 @@ ephy_history_service_initialize_urls_table (EphyHistoryService *self)
EphyHistoryURL *
ephy_history_service_get_url_row (EphyHistoryService *self, const char *url_string, EphyHistoryURL *url)
{
- EphySQLiteStatement *statement = NULL;
+ EphySQLiteStatement *statement = NULL;
GError *error = NULL;
g_assert (self->history_thread == g_thread_self ());
@@ -67,12 +67,12 @@ ephy_history_service_get_url_row (EphyHistoryService *self, const char *url_stri
if (url != NULL && url->id != -1) {
statement = ephy_sqlite_connection_create_statement (self->history_database,
- "SELECT id, url, title, visit_count, typed_count, last_visit_time, hidden_from_overview, thumbnail_update_time FROM urls "
- "WHERE id=?", &error);
+ "SELECT id, url, title, visit_count, typed_count, last_visit_time, hidden_from_overview, thumbnail_update_time FROM urls "
+ "WHERE id=?", &error);
} else {
statement = ephy_sqlite_connection_create_statement (self->history_database,
- "SELECT id, url, title, visit_count, typed_count, last_visit_time, hidden_from_overview, thumbnail_update_time FROM urls "
- "WHERE url=?", &error);
+ "SELECT id, url, title, visit_count, typed_count, last_visit_time, hidden_from_overview, thumbnail_update_time FROM urls "
+ "WHERE url=?", &error);
}
if (error) {
@@ -124,15 +124,15 @@ ephy_history_service_get_url_row (EphyHistoryService *self, const char *url_stri
void
ephy_history_service_add_url_row (EphyHistoryService *self, EphyHistoryURL *url)
{
- EphySQLiteStatement *statement = NULL;
+ EphySQLiteStatement *statement = NULL;
GError *error = NULL;
g_assert (self->history_thread == g_thread_self ());
g_assert (self->history_database != NULL);
statement = ephy_sqlite_connection_create_statement (self->history_database,
- "INSERT INTO urls (url, title, visit_count, typed_count, last_visit_time, host) "
- " VALUES (?, ?, ?, ?, ?, ?)", &error);
+ "INSERT INTO urls (url, title, visit_count, typed_count, last_visit_time, host) "
+ " VALUES (?, ?, ?, ?, ?, ?)", &error);
if (error) {
g_warning ("Could not build urls table addition statement: %s", error->message);
g_error_free (error);
@@ -140,7 +140,7 @@ ephy_history_service_add_url_row (EphyHistoryService *self, EphyHistoryURL *url)
}
if (ephy_sqlite_statement_bind_string (statement, 0, url->url, &error) == FALSE ||
- ephy_sqlite_statement_bind_string (statement, 1, url->title, &error) == FALSE ||
+ ephy_sqlite_statement_bind_string (statement, 1, url->title, &error) == FALSE ||
ephy_sqlite_statement_bind_int (statement, 2, url->visit_count, &error) == FALSE ||
ephy_sqlite_statement_bind_int (statement, 3, url->typed_count, &error) == FALSE ||
ephy_sqlite_statement_bind_int (statement, 4, url->last_visit_time, &error) == FALSE ||
@@ -172,15 +172,15 @@ ephy_history_service_update_url_row (EphyHistoryService *self, EphyHistoryURL *u
g_assert (self->history_database != NULL);
statement = ephy_sqlite_connection_create_statement (self->history_database,
- "UPDATE urls SET title=?, visit_count=?, typed_count=?, last_visit_time=?, hidden_from_overview=?, thumbnail_update_time=? "
- "WHERE id=?", &error);
+ "UPDATE urls SET title=?, visit_count=?, typed_count=?, last_visit_time=?, hidden_from_overview=?, thumbnail_update_time=? "
+ "WHERE id=?", &error);
if (error) {
g_warning ("Could not build urls table modification statement: %s", error->message);
g_error_free (error);
return;
}
- if (ephy_sqlite_statement_bind_string (statement, 0, url->title, &error) == FALSE ||
+ if (ephy_sqlite_statement_bind_string (statement, 0, url->title, &error) == FALSE ||
ephy_sqlite_statement_bind_int (statement, 1, url->visit_count, &error) == FALSE ||
ephy_sqlite_statement_bind_int (statement, 2, url->typed_count, &error) == FALSE ||
ephy_sqlite_statement_bind_int (statement, 3, url->last_visit_time, &error) == FALSE ||
@@ -228,18 +228,18 @@ ephy_history_service_find_url_rows (EphyHistoryService *self, EphyHistoryQuery *
GList *urls = NULL;
GError *error = NULL;
const char *base_statement = ""
- "SELECT "
- "DISTINCT urls.id, "
- "urls.url, "
- "urls.title, "
- "urls.visit_count, "
- "urls.typed_count, "
- "urls.last_visit_time, "
- "urls.hidden_from_overview, "
- "urls.thumbnail_update_time, "
- "urls.host "
- "FROM "
- "urls ";
+ "SELECT "
+ "DISTINCT urls.id, "
+ "urls.url, "
+ "urls.title, "
+ "urls.visit_count, "
+ "urls.typed_count, "
+ "urls.last_visit_time, "
+ "urls.hidden_from_overview, "
+ "urls.thumbnail_update_time, "
+ "urls.host "
+ "FROM "
+ "urls ";
int i = 0;
@@ -273,33 +273,33 @@ ephy_history_service_find_url_rows (EphyHistoryService *self, EphyHistoryQuery *
statement_str = g_string_append (statement_str, "1 ");
switch (query->sort_type) {
- case EPHY_HISTORY_SORT_MOST_VISITED:
- statement_str = g_string_append (statement_str, "ORDER BY urls.visit_count DESC ");
- break;
- case EPHY_HISTORY_SORT_LEAST_VISITED:
- statement_str = g_string_append (statement_str, "ORDER BY urls.visit_count ");
- break;
- case EPHY_HISTORY_SORT_MOST_RECENTLY_VISITED:
- statement_str = g_string_append (statement_str, "ORDER BY urls.last_visit_time DESC ");
- break;
- case EPHY_HISTORY_SORT_LEAST_RECENTLY_VISITED:
- statement_str = g_string_append (statement_str, "ORDER BY urls.last_visit_time ");
- break;
- case EPHY_HISTORY_SORT_TITLE_ASCENDING:
- statement_str = g_string_append (statement_str, "ORDER BY LOWER(urls.title) ");
- break;
- case EPHY_HISTORY_SORT_TITLE_DESCENDING:
- statement_str = g_string_append (statement_str, "ORDER BY LOWER(urls.title) DESC ");
- break;
- case EPHY_HISTORY_SORT_URL_ASCENDING:
- statement_str = g_string_append (statement_str, "ORDER BY LOWER(urls.url) ");
- break;
- case EPHY_HISTORY_SORT_URL_DESCENDING:
- statement_str = g_string_append (statement_str, "ORDER BY LOWER(urls.url) DESC ");
- break;
- case EPHY_HISTORY_SORT_NONE:
- default:
- g_warning ("We don't support this sorting method yet.");
+ case EPHY_HISTORY_SORT_MOST_VISITED:
+ statement_str = g_string_append (statement_str, "ORDER BY urls.visit_count DESC ");
+ break;
+ case EPHY_HISTORY_SORT_LEAST_VISITED:
+ statement_str = g_string_append (statement_str, "ORDER BY urls.visit_count ");
+ break;
+ case EPHY_HISTORY_SORT_MOST_RECENTLY_VISITED:
+ statement_str = g_string_append (statement_str, "ORDER BY urls.last_visit_time DESC ");
+ break;
+ case EPHY_HISTORY_SORT_LEAST_RECENTLY_VISITED:
+ statement_str = g_string_append (statement_str, "ORDER BY urls.last_visit_time ");
+ break;
+ case EPHY_HISTORY_SORT_TITLE_ASCENDING:
+ statement_str = g_string_append (statement_str, "ORDER BY LOWER(urls.title) ");
+ break;
+ case EPHY_HISTORY_SORT_TITLE_DESCENDING:
+ statement_str = g_string_append (statement_str, "ORDER BY LOWER(urls.title) DESC ");
+ break;
+ case EPHY_HISTORY_SORT_URL_ASCENDING:
+ statement_str = g_string_append (statement_str, "ORDER BY LOWER(urls.url) ");
+ break;
+ case EPHY_HISTORY_SORT_URL_DESCENDING:
+ statement_str = g_string_append (statement_str, "ORDER BY LOWER(urls.url) DESC ");
+ break;
+ case EPHY_HISTORY_SORT_NONE:
+ default:
+ g_warning ("We don't support this sorting method yet.");
}
if (query->limit) {
@@ -307,7 +307,7 @@ ephy_history_service_find_url_rows (EphyHistoryService *self, EphyHistoryQuery *
}
statement = ephy_sqlite_connection_create_statement (self->history_database,
- statement_str->str, &error);
+ statement_str->str, &error);
g_string_free (statement_str, TRUE);
if (error) {
diff --git a/lib/history/ephy-history-service-visits-table.c b/lib/history/ephy-history-service-visits-table.c
index 5438ffce3..75c052b1b 100644
--- a/lib/history/ephy-history-service-visits-table.c
+++ b/lib/history/ephy-history-service-visits-table.c
@@ -29,12 +29,12 @@ ephy_history_service_initialize_visits_table (EphyHistoryService *self)
return TRUE;
ephy_sqlite_connection_execute (self->history_database,
- "CREATE TABLE visits ("
- "id INTEGER PRIMARY KEY,"
- "url INTEGER NOT NULL REFERENCES urls(id) ON DELETE CASCADE,"
- "visit_time INTEGER NOT NULL,"
- "visit_type INTEGER NOT NULL,"
- "referring_visit INTEGER)", &error);
+ "CREATE TABLE visits ("
+ "id INTEGER PRIMARY KEY,"
+ "url INTEGER NOT NULL REFERENCES urls(id) ON DELETE CASCADE,"
+ "visit_time INTEGER NOT NULL,"
+ "visit_type INTEGER NOT NULL,"
+ "referring_visit INTEGER)", &error);
if (error) {
g_warning ("Could not create visits table: %s", error->message);
@@ -66,7 +66,7 @@ ephy_history_service_add_visit_row (EphyHistoryService *self, EphyHistoryPageVis
if (ephy_sqlite_statement_bind_int (statement, 0, visit->url->id, &error) == FALSE ||
ephy_sqlite_statement_bind_int (statement, 1, visit->visit_time, &error) == FALSE ||
- ephy_sqlite_statement_bind_int (statement, 2, visit->visit_type, &error) == FALSE ) {
+ ephy_sqlite_statement_bind_int (statement, 2, visit->visit_type, &error) == FALSE) {
g_warning ("Could not build visits table addition statement: %s", error->message);
g_error_free (error);
g_object_unref (statement);
@@ -88,7 +88,7 @@ ephy_history_service_add_visit_row (EphyHistoryService *self, EphyHistoryPageVis
static EphyHistoryPageVisit *
create_page_visit_from_statement (EphySQLiteStatement *statement)
{
- EphyHistoryPageVisit *visit =
+ EphyHistoryPageVisit *visit =
ephy_history_page_visit_new (NULL,
ephy_sqlite_statement_get_column_as_int (statement, 1),
ephy_sqlite_statement_get_column_as_int (statement, 2));
@@ -105,16 +105,16 @@ ephy_history_service_find_visit_rows (EphyHistoryService *self, EphyHistoryQuery
GList *visits = NULL;
GError *error = NULL;
const char *base_statement = ""
- "SELECT "
- "visits.url, "
- "visits.visit_time, "
- "visits.visit_type ";
+ "SELECT "
+ "visits.url, "
+ "visits.visit_time, "
+ "visits.visit_type ";
const char *from_join_statement = ""
- "FROM "
- "visits JOIN urls ON visits.url = urls.id ";
+ "FROM "
+ "visits JOIN urls ON visits.url = urls.id ";
const char *from_visits_statement = ""
- "FROM "
- "visits ";
+ "FROM "
+ "visits ";
int i = 0;
@@ -145,7 +145,7 @@ ephy_history_service_find_visit_rows (EphyHistoryService *self, EphyHistoryQuery
statement_str = g_string_append (statement_str, "1");
statement = ephy_sqlite_connection_create_statement (self->history_database,
- statement_str->str, &error);
+ statement_str->str, &error);
g_string_free (statement_str, TRUE);
if (error) {
diff --git a/lib/history/ephy-history-service.c b/lib/history/ephy-history-service.c
index ea72a6684..276f2640c 100644
--- a/lib/history/ephy-history-service.c
+++ b/lib/history/ephy-history-service.c
@@ -71,10 +71,10 @@ typedef struct _EphyHistoryServiceMessage {
EphyHistoryJobCallback callback;
} EphyHistoryServiceMessage;
-static gpointer run_history_service_thread (EphyHistoryService *self);
-static void ephy_history_service_process_message (EphyHistoryService *self, EphyHistoryServiceMessage *message);
+static gpointer run_history_service_thread (EphyHistoryService *self);
+static void ephy_history_service_process_message (EphyHistoryService *self, EphyHistoryServiceMessage *message);
static gboolean ephy_history_service_execute_quit (EphyHistoryService *self, gpointer data, gpointer *result);
-static void ephy_history_service_quit (EphyHistoryService *self, EphyHistoryJobCallback callback, gpointer user_data);
+static void ephy_history_service_quit (EphyHistoryService *self, EphyHistoryJobCallback callback, gpointer user_data);
enum {
PROP_0,
@@ -173,7 +173,7 @@ ephy_history_service_class_init (EphyHistoryServiceClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = ephy_history_service_finalize;
- gobject_class->dispose = ephy_history_service_dispose;
+ gobject_class->dispose = ephy_history_service_dispose;
gobject_class->get_property = ephy_history_service_get_property;
gobject_class->set_property = ephy_history_service_set_property;
@@ -261,13 +261,13 @@ ephy_history_service_class_init (EphyHistoryServiceClass *klass)
static void
ephy_history_service_init (EphyHistoryService *self)
{
- self->history_thread = g_thread_new ("EphyHistoryService", (GThreadFunc) run_history_service_thread, self);
+ self->history_thread = g_thread_new ("EphyHistoryService", (GThreadFunc)run_history_service_thread, self);
self->queue = g_async_queue_new ();
}
EphyHistoryService *
ephy_history_service_new (const char *history_filename,
- gboolean read_only)
+ gboolean read_only)
{
return EPHY_HISTORY_SERVICE (g_object_new (EPHY_TYPE_HISTORY_SERVICE,
"history-filename", history_filename,
@@ -276,19 +276,19 @@ ephy_history_service_new (const char *history_filename,
}
static gint
-sort_messages (EphyHistoryServiceMessage* a, EphyHistoryServiceMessage* b, gpointer user_data)
+sort_messages (EphyHistoryServiceMessage *a, EphyHistoryServiceMessage *b, gpointer user_data)
{
return a->type > b->type ? 1 : a->type == b->type ? 0 : -1;
}
static EphyHistoryServiceMessage *
-ephy_history_service_message_new (EphyHistoryService *service,
+ephy_history_service_message_new (EphyHistoryService *service,
EphyHistoryServiceMessageType type,
- gpointer method_argument,
- GDestroyNotify method_argument_cleanup,
- GCancellable *cancellable,
- EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer method_argument,
+ GDestroyNotify method_argument_cleanup,
+ GCancellable *cancellable,
+ EphyHistoryJobCallback callback,
+ gpointer user_data)
{
EphyHistoryServiceMessage *message = g_slice_alloc0 (sizeof (EphyHistoryServiceMessage));
@@ -426,7 +426,7 @@ ephy_history_service_clear_all (EphyHistoryService *self)
"DELETE FROM hosts;", &error);
if (error) {
g_warning ("Couldn't clear history database: %s", error->message);
- g_error_free(error);
+ g_error_free (error);
}
}
@@ -487,7 +487,6 @@ run_history_service_thread (EphyHistoryService *self)
/* Process item. */
ephy_history_service_process_message (self, message);
-
} while (!ephy_history_service_is_scheduled_to_quit (self));
ephy_history_service_close_database_connections (self);
@@ -498,7 +497,7 @@ run_history_service_thread (EphyHistoryService *self)
static gboolean
ephy_history_service_execute_job_callback (gpointer data)
{
- EphyHistoryServiceMessage *message = (EphyHistoryServiceMessage*) data;
+ EphyHistoryServiceMessage *message = (EphyHistoryServiceMessage *)data;
g_assert (message->callback || message->type == CLEAR);
@@ -535,8 +534,8 @@ signal_emission_context_free (SignalEmissionContext *ctx)
static SignalEmissionContext *
signal_emission_context_new (EphyHistoryService *service,
- gpointer user_data,
- GDestroyNotify destroy_func)
+ gpointer user_data,
+ GDestroyNotify destroy_func)
{
SignalEmissionContext *ctx = g_slice_new0 (SignalEmissionContext);
@@ -576,7 +575,6 @@ ephy_history_service_execute_add_visit_helper (EphyHistoryService *self, EphyHis
g_warning ("Adding visit failed after failed URL addition.");
return FALSE;
}
-
} else {
visit->url->visit_count++;
@@ -613,7 +611,7 @@ ephy_history_service_execute_add_visits (EphyHistoryService *self, GList *visits
return FALSE;
while (visits) {
- success = success && ephy_history_service_execute_add_visit_helper (self, (EphyHistoryPageVisit *) visits->data);
+ success = success && ephy_history_service_execute_add_visit_helper (self, (EphyHistoryPageVisit *)visits->data);
visits = visits->next;
}
@@ -630,7 +628,7 @@ ephy_history_service_execute_find_visits (EphyHistoryService *self, EphyHistoryQ
/* FIXME: We don't have a good way to tell the difference between failures and empty returns */
while (current) {
- EphyHistoryPageVisit *visit = (EphyHistoryPageVisit *) current->data;
+ EphyHistoryPageVisit *visit = (EphyHistoryPageVisit *)current->data;
if (NULL == ephy_history_service_get_url_row (self, NULL, visit->url)) {
ephy_history_page_visit_list_free (visits);
g_warning ("Tried to process an orphaned page visit");
@@ -678,7 +676,7 @@ ephy_history_service_add_visit (EphyHistoryService *self, EphyHistoryPageVisit *
message = ephy_history_service_message_new (self, ADD_VISIT,
ephy_history_page_visit_copy (visit),
- (GDestroyNotify) ephy_history_page_visit_free,
+ (GDestroyNotify)ephy_history_page_visit_free,
cancellable, callback, user_data);
ephy_history_service_send_message (self, message);
}
@@ -693,7 +691,7 @@ ephy_history_service_add_visits (EphyHistoryService *self, GList *visits, GCance
message = ephy_history_service_message_new (self, ADD_VISITS,
ephy_history_page_visit_list_copy (visits),
- (GDestroyNotify) ephy_history_page_visit_list_free,
+ (GDestroyNotify)ephy_history_page_visit_list_free,
cancellable, callback, user_data);
ephy_history_service_send_message (self, message);
}
@@ -722,7 +720,7 @@ ephy_history_service_query_visits (EphyHistoryService *self, EphyHistoryQuery *q
g_return_if_fail (query != NULL);
message = ephy_history_service_message_new (self, QUERY_VISITS,
- ephy_history_query_copy (query), (GDestroyNotify) ephy_history_query_free, cancellable, callback, user_data);
+ ephy_history_query_copy (query), (GDestroyNotify)ephy_history_query_free, cancellable, callback, user_data);
ephy_history_service_send_message (self, message);
}
@@ -745,16 +743,16 @@ ephy_history_service_query_urls (EphyHistoryService *self, EphyHistoryQuery *que
g_return_if_fail (query != NULL);
message = ephy_history_service_message_new (self, QUERY_URLS,
- ephy_history_query_copy (query), (GDestroyNotify) ephy_history_query_free,
+ ephy_history_query_copy (query), (GDestroyNotify)ephy_history_query_free,
cancellable, callback, user_data);
ephy_history_service_send_message (self, message);
}
void
-ephy_history_service_get_hosts (EphyHistoryService *self,
- GCancellable *cancellable,
+ephy_history_service_get_hosts (EphyHistoryService *self,
+ GCancellable *cancellable,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
EphyHistoryServiceMessage *message;
@@ -767,11 +765,11 @@ ephy_history_service_get_hosts (EphyHistoryService *self,
}
void
-ephy_history_service_query_hosts (EphyHistoryService *self,
- EphyHistoryQuery *query,
- GCancellable *cancellable,
+ephy_history_service_query_hosts (EphyHistoryService *self,
+ EphyHistoryQuery *query,
+ GCancellable *cancellable,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
EphyHistoryServiceMessage *message;
@@ -779,7 +777,7 @@ ephy_history_service_query_hosts (EphyHistoryService *self,
message = ephy_history_service_message_new (self, QUERY_HOSTS,
ephy_history_query_copy (query),
- (GDestroyNotify) ephy_history_query_free,
+ (GDestroyNotify)ephy_history_query_free,
cancellable, callback, user_data);
ephy_history_service_send_message (self, message);
}
@@ -796,8 +794,8 @@ set_url_title_signal_emit (SignalEmissionContext *ctx)
static gboolean
ephy_history_service_execute_set_url_title (EphyHistoryService *self,
- EphyHistoryURL *url,
- gpointer *result)
+ EphyHistoryURL *url,
+ gpointer *result)
{
char *title = g_strdup (url->title);
@@ -827,12 +825,12 @@ ephy_history_service_execute_set_url_title (EphyHistoryService *self,
}
void
-ephy_history_service_set_url_title (EphyHistoryService *self,
- const char *orig_url,
- const char *title,
- GCancellable *cancellable,
+ephy_history_service_set_url_title (EphyHistoryService *self,
+ const char *orig_url,
+ const char *title,
+ GCancellable *cancellable,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
EphyHistoryURL *url;
EphyHistoryServiceMessage *message;
@@ -844,15 +842,15 @@ ephy_history_service_set_url_title (EphyHistoryService *self,
url = ephy_history_url_new (orig_url, title, 0, 0, 0);
message = ephy_history_service_message_new (self, SET_URL_TITLE,
- url, (GDestroyNotify) ephy_history_url_free,
+ url, (GDestroyNotify)ephy_history_url_free,
cancellable, callback, user_data);
ephy_history_service_send_message (self, message);
}
static gboolean
ephy_history_service_execute_set_url_zoom_level (EphyHistoryService *self,
- GVariant *variant,
- gpointer *result)
+ GVariant *variant,
+ gpointer *result)
{
char *url_string;
double zoom_level;
@@ -876,12 +874,12 @@ ephy_history_service_execute_set_url_zoom_level (EphyHistoryService *self,
}
void
-ephy_history_service_set_url_zoom_level (EphyHistoryService *self,
- const char *url,
- const double zoom_level,
- GCancellable *cancellable,
+ephy_history_service_set_url_zoom_level (EphyHistoryService *self,
+ const char *url,
+ const double zoom_level,
+ GCancellable *cancellable,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
EphyHistoryServiceMessage *message;
GVariant *variant;
@@ -899,8 +897,8 @@ ephy_history_service_set_url_zoom_level (EphyHistoryService *self,
static gboolean
ephy_history_service_execute_set_url_hidden (EphyHistoryService *self,
- EphyHistoryURL *url,
- gpointer *result)
+ EphyHistoryURL *url,
+ gpointer *result)
{
gboolean hidden;
@@ -921,12 +919,12 @@ ephy_history_service_execute_set_url_hidden (EphyHistoryService *self,
}
void
-ephy_history_service_set_url_hidden (EphyHistoryService *self,
- const char *orig_url,
- gboolean hidden,
- GCancellable *cancellable,
+ephy_history_service_set_url_hidden (EphyHistoryService *self,
+ const char *orig_url,
+ gboolean hidden,
+ GCancellable *cancellable,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
EphyHistoryServiceMessage *message;
EphyHistoryURL *url;
@@ -945,8 +943,8 @@ ephy_history_service_set_url_hidden (EphyHistoryService *self,
static gboolean
ephy_history_service_execute_set_url_thumbnail_time (EphyHistoryService *self,
- EphyHistoryURL *url,
- gpointer *result)
+ EphyHistoryURL *url,
+ gpointer *result)
{
int thumbnail_time;
@@ -966,12 +964,12 @@ ephy_history_service_execute_set_url_thumbnail_time (EphyHistoryService *self,
}
void
-ephy_history_service_set_url_thumbnail_time (EphyHistoryService *self,
- const char *orig_url,
- int thumbnail_time,
- GCancellable *cancellable,
+ephy_history_service_set_url_thumbnail_time (EphyHistoryService *self,
+ const char *orig_url,
+ int thumbnail_time,
+ GCancellable *cancellable,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
EphyHistoryURL *url;
EphyHistoryServiceMessage *message;
@@ -982,15 +980,15 @@ ephy_history_service_set_url_thumbnail_time (EphyHistoryService *self,
url = ephy_history_url_new (orig_url, NULL, 0, 0, 0);
url->thumbnail_time = thumbnail_time;
message = ephy_history_service_message_new (self, SET_URL_THUMBNAIL_TIME,
- url, (GDestroyNotify) ephy_history_url_free,
+ url, (GDestroyNotify)ephy_history_url_free,
cancellable, callback, user_data);
ephy_history_service_send_message (self, message);
}
static gboolean
ephy_history_service_execute_get_url (EphyHistoryService *self,
- const gchar *orig_url,
- gpointer *result)
+ const gchar *orig_url,
+ gpointer *result)
{
EphyHistoryURL *url;
@@ -1002,27 +1000,27 @@ ephy_history_service_execute_get_url (EphyHistoryService *self,
}
void
-ephy_history_service_get_url (EphyHistoryService *self,
- const char *url,
- GCancellable *cancellable,
+ephy_history_service_get_url (EphyHistoryService *self,
+ const char *url,
+ GCancellable *cancellable,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
EphyHistoryServiceMessage *message;
g_return_if_fail (EPHY_IS_HISTORY_SERVICE (self));
g_return_if_fail (url != NULL);
- message = ephy_history_service_message_new (self, GET_URL,
- g_strdup (url), g_free,
- cancellable, callback, user_data);
+ message = ephy_history_service_message_new (self, GET_URL,
+ g_strdup (url), g_free,
+ cancellable, callback, user_data);
ephy_history_service_send_message (self, message);
}
static gboolean
ephy_history_service_execute_get_host_for_url (EphyHistoryService *self,
- const gchar *url,
- gpointer *result)
+ const gchar *url,
+ gpointer *result)
{
EphyHistoryHost *host;
@@ -1035,11 +1033,11 @@ ephy_history_service_execute_get_host_for_url (EphyHistoryService *self,
}
void
-ephy_history_service_get_host_for_url (EphyHistoryService *self,
- const char *url,
- GCancellable *cancellable,
+ephy_history_service_get_host_for_url (EphyHistoryService *self,
+ const char *url,
+ GCancellable *cancellable,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
EphyHistoryServiceMessage *message;
@@ -1064,8 +1062,8 @@ delete_urls_signal_emit (SignalEmissionContext *ctx)
static gboolean
ephy_history_service_execute_delete_urls (EphyHistoryService *self,
- GList *urls,
- gpointer *result)
+ GList *urls,
+ gpointer *result)
{
GList *l;
EphyHistoryURL *url;
@@ -1079,7 +1077,7 @@ ephy_history_service_execute_delete_urls (EphyHistoryService *self,
ephy_history_service_delete_url (self, url);
ctx = signal_emission_context_new (self, g_strdup (url->url),
- (GDestroyNotify) g_free);
+ (GDestroyNotify)g_free);
g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
(GSourceFunc)delete_urls_signal_emit,
ctx,
@@ -1103,10 +1101,10 @@ delete_host_signal_emit (SignalEmissionContext *ctx)
}
static gboolean
-ephy_history_service_execute_delete_host (EphyHistoryService *self,
- EphyHistoryHost *host,
+ephy_history_service_execute_delete_host (EphyHistoryService *self,
+ EphyHistoryHost *host,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
SignalEmissionContext *ctx;
@@ -1119,17 +1117,17 @@ ephy_history_service_execute_delete_host (EphyHistoryService *self,
ctx = signal_emission_context_new (self, g_strdup (host->url),
(GDestroyNotify)g_free);
g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
- (GSourceFunc) delete_host_signal_emit,
+ (GSourceFunc)delete_host_signal_emit,
ctx,
- (GDestroyNotify) signal_emission_context_free);
+ (GDestroyNotify)signal_emission_context_free);
return TRUE;
}
static gboolean
ephy_history_service_execute_clear (EphyHistoryService *self,
- gpointer pointer,
- gpointer *result)
+ gpointer pointer,
+ gpointer *result)
{
if (self->read_only)
return FALSE;
@@ -1141,11 +1139,11 @@ ephy_history_service_execute_clear (EphyHistoryService *self,
}
void
-ephy_history_service_delete_urls (EphyHistoryService *self,
- GList *urls,
- GCancellable *cancellable,
+ephy_history_service_delete_urls (EphyHistoryService *self,
+ GList *urls,
+ GCancellable *cancellable,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
EphyHistoryServiceMessage *message;
@@ -1159,11 +1157,11 @@ ephy_history_service_delete_urls (EphyHistoryService *self,
}
void
-ephy_history_service_delete_host (EphyHistoryService *self,
- EphyHistoryHost *host,
- GCancellable *cancellable,
+ephy_history_service_delete_host (EphyHistoryService *self,
+ EphyHistoryHost *host,
+ GCancellable *cancellable,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
EphyHistoryServiceMessage *message =
ephy_history_service_message_new (self, DELETE_HOST,
@@ -1173,10 +1171,10 @@ ephy_history_service_delete_host (EphyHistoryService *self,
}
void
-ephy_history_service_clear (EphyHistoryService *self,
- GCancellable *cancellable,
+ephy_history_service_clear (EphyHistoryService *self,
+ GCancellable *cancellable,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
EphyHistoryServiceMessage *message;
@@ -1189,9 +1187,9 @@ ephy_history_service_clear (EphyHistoryService *self,
}
static void
-ephy_history_service_quit (EphyHistoryService *self,
+ephy_history_service_quit (EphyHistoryService *self,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
EphyHistoryServiceMessage *message =
ephy_history_service_message_new (self, QUIT,
@@ -1226,7 +1224,7 @@ ephy_history_service_message_is_write (EphyHistoryServiceMessage *message)
}
static void
-ephy_history_service_process_message (EphyHistoryService *self,
+ephy_history_service_process_message (EphyHistoryService *self,
EphyHistoryServiceMessage *message)
{
EphyHistoryServiceMethod method;
@@ -1287,8 +1285,8 @@ ephy_history_service_find_urls (EphyHistoryService *self,
}
void
-ephy_history_service_visit_url (EphyHistoryService *self,
- const char *url,
+ephy_history_service_visit_url (EphyHistoryService *self,
+ const char *url,
EphyHistoryPageVisitType visit_type)
{
EphyHistoryPageVisit *visit;
diff --git a/lib/history/ephy-history-types.c b/lib/history/ephy-history-types.c
index af7821c65..693052c75 100644
--- a/lib/history/ephy-history-types.c
+++ b/lib/history/ephy-history-types.c
@@ -64,7 +64,7 @@ ephy_history_page_visit_list_copy (GList *original)
GList *new = g_list_copy (original);
GList *current = new;
while (current) {
- current->data = ephy_history_page_visit_copy ((EphyHistoryPageVisit *) current->data);
+ current->data = ephy_history_page_visit_copy ((EphyHistoryPageVisit *)current->data);
current = current->next;
}
return new;
@@ -73,7 +73,7 @@ ephy_history_page_visit_list_copy (GList *original)
void
ephy_history_page_visit_list_free (GList *list)
{
- g_list_free_full (list, (GDestroyNotify) ephy_history_page_visit_free);
+ g_list_free_full (list, (GDestroyNotify)ephy_history_page_visit_free);
}
EphyHistoryHost *
@@ -187,13 +187,13 @@ ephy_history_url_list_copy (GList *original)
void
ephy_history_url_list_free (GList *list)
{
- g_list_free_full (list, (GDestroyNotify) ephy_history_url_free);
+ g_list_free_full (list, (GDestroyNotify)ephy_history_url_free);
}
EphyHistoryQuery *
ephy_history_query_new (void)
{
- return (EphyHistoryQuery*) g_slice_alloc0 (sizeof (EphyHistoryQuery));
+ return (EphyHistoryQuery *)g_slice_alloc0 (sizeof (EphyHistoryQuery));
}
void
diff --git a/lib/widgets/ephy-certificate-dialog.c b/lib/widgets/ephy-certificate-dialog.c
index 5e038b8a5..ab21ae15c 100644
--- a/lib/widgets/ephy-certificate-dialog.c
+++ b/lib/widgets/ephy-certificate-dialog.c
@@ -32,8 +32,7 @@
* #EphyCertificateDialog shows information about SSL certificates.
*/
-enum
-{
+enum {
PROP_0,
PROP_ADDRESS,
PROP_CERTIFICATE,
@@ -44,8 +43,7 @@ enum
static GParamSpec *obj_properties[LAST_PROP];
-struct _EphyCertificateDialog
-{
+struct _EphyCertificateDialog {
GtkDialog parent_object;
GtkWidget *icon;
@@ -60,7 +58,7 @@ G_DEFINE_TYPE (EphyCertificateDialog, ephy_certificate_dialog, GTK_TYPE_DIALOG)
static void
ephy_certificate_dialog_set_address (EphyCertificateDialog *dialog,
- const char *address)
+ const char *address)
{
SoupURI *uri;
@@ -71,7 +69,7 @@ ephy_certificate_dialog_set_address (EphyCertificateDialog *dialog,
static void
ephy_certificate_dialog_set_certificate (EphyCertificateDialog *dialog,
- GTlsCertificate *certificate)
+ GTlsCertificate *certificate)
{
GcrCertificate *simple_certificate;
GByteArray *certificate_data;
@@ -80,7 +78,7 @@ ephy_certificate_dialog_set_certificate (EphyCertificateDialog *dialog,
g_object_get (certificate, "certificate", &certificate_data, NULL);
simple_certificate = gcr_simple_certificate_new ((const guchar *)certificate_data->data,
- certificate_data->len);
+ certificate_data->len);
g_byte_array_unref (certificate_data);
certificate_widget = GTK_WIDGET (gcr_certificate_widget_new (simple_certificate));
@@ -126,9 +124,9 @@ get_error_messages_from_tls_errors (GTlsCertificateFlags tls_errors)
for (i = 0; i < errors->len; i++) {
g_string_append_printf (message, "• %s",
- (char *)g_ptr_array_index (errors, i));
+ (char *)g_ptr_array_index (errors, i));
if (i < errors->len - 1)
- g_string_append_c (message, '\n');
+ g_string_append_c (message, '\n');
}
retval = g_string_free (message, FALSE);
@@ -157,9 +155,9 @@ ephy_certificate_dialog_constructed (GObject *object)
}
markup = g_strdup_printf ("<span weight=\"bold\" size=\"large\">%s</span>",
- dialog->tls_errors == 0 ?
- _("The identity of this website has been verified.") :
- _("The identity of this website has not been verified."));
+ dialog->tls_errors == 0 ?
+ _("The identity of this website has been verified.") :
+ _("The identity of this website has not been verified."));
gtk_label_set_markup (GTK_LABEL (dialog->title), markup);
g_free (markup);
@@ -169,48 +167,48 @@ ephy_certificate_dialog_constructed (GObject *object)
g_free (text);
} else {
switch (dialog->security_level) {
- case EPHY_SECURITY_LEVEL_STRONG_SECURITY:
- /* Message on certificte dialog ertificate dialog */
- gtk_label_set_text (GTK_LABEL (dialog->text), _("No problems have been detected with your connection."));
- break;
- case EPHY_SECURITY_LEVEL_MIXED_CONTENT:
- gtk_label_set_text (GTK_LABEL (dialog->text), _("This certificate is valid. However, "
- "resources on this page were sent insecurely."));
- break;
- case EPHY_SECURITY_LEVEL_TO_BE_DETERMINED:
- case EPHY_SECURITY_LEVEL_NO_SECURITY:
- case EPHY_SECURITY_LEVEL_UNACCEPTABLE_CERTIFICATE:
- case EPHY_SECURITY_LEVEL_LOCAL_PAGE:
- default:
- g_assert_not_reached ();
+ case EPHY_SECURITY_LEVEL_STRONG_SECURITY:
+ /* Message on certificte dialog ertificate dialog */
+ gtk_label_set_text (GTK_LABEL (dialog->text), _("No problems have been detected with your connection."));
+ break;
+ case EPHY_SECURITY_LEVEL_MIXED_CONTENT:
+ gtk_label_set_text (GTK_LABEL (dialog->text), _("This certificate is valid. However, "
+ "resources on this page were sent insecurely."));
+ break;
+ case EPHY_SECURITY_LEVEL_TO_BE_DETERMINED:
+ case EPHY_SECURITY_LEVEL_NO_SECURITY:
+ case EPHY_SECURITY_LEVEL_UNACCEPTABLE_CERTIFICATE:
+ case EPHY_SECURITY_LEVEL_LOCAL_PAGE:
+ default:
+ g_assert_not_reached ();
}
}
gtk_widget_show (dialog->text);
}
static void
-ephy_certificate_dialog_set_property (GObject *object,
- guint prop_id,
+ephy_certificate_dialog_set_property (GObject *object,
+ guint prop_id,
const GValue *value,
- GParamSpec *pspec)
+ GParamSpec *pspec)
{
EphyCertificateDialog *dialog = EPHY_CERTIFICATE_DIALOG (object);
switch (prop_id) {
- case PROP_ADDRESS:
- ephy_certificate_dialog_set_address (dialog, g_value_get_string (value));
- break;
- case PROP_CERTIFICATE:
- ephy_certificate_dialog_set_certificate (dialog, g_value_get_object (value));
- break;
- case PROP_SECURITY_LEVEL:
- dialog->security_level = g_value_get_enum (value);
- break;
- case PROP_TLS_ERRORS:
- dialog->tls_errors = g_value_get_flags (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ case PROP_ADDRESS:
+ ephy_certificate_dialog_set_address (dialog, g_value_get_string (value));
+ break;
+ case PROP_CERTIFICATE:
+ ephy_certificate_dialog_set_certificate (dialog, g_value_get_object (value));
+ break;
+ case PROP_SECURITY_LEVEL:
+ dialog->security_level = g_value_get_enum (value);
+ break;
+ case PROP_TLS_ERRORS:
+ dialog->tls_errors = g_value_get_flags (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
@@ -299,7 +297,7 @@ ephy_certificate_dialog_init (EphyCertificateDialog *dialog)
dialog->title = gtk_label_new (NULL);
gtk_label_set_use_markup (GTK_LABEL (dialog->title), TRUE);
- gtk_label_set_line_wrap (GTK_LABEL (dialog->title), TRUE);
+ gtk_label_set_line_wrap (GTK_LABEL (dialog->title), TRUE);
gtk_label_set_selectable (GTK_LABEL (dialog->title), TRUE);
gtk_widget_set_halign (dialog->title, GTK_ALIGN_START);
gtk_widget_set_valign (dialog->title, GTK_ALIGN_CENTER);
@@ -310,7 +308,7 @@ ephy_certificate_dialog_init (EphyCertificateDialog *dialog)
gtk_widget_show (dialog->title);
dialog->text = gtk_label_new (NULL);
- gtk_label_set_line_wrap (GTK_LABEL (dialog->text), TRUE);
+ gtk_label_set_line_wrap (GTK_LABEL (dialog->text), TRUE);
gtk_label_set_selectable (GTK_LABEL (dialog->text), TRUE);
gtk_widget_set_halign (dialog->text, GTK_ALIGN_START);
gtk_widget_set_valign (dialog->text, GTK_ALIGN_START);
@@ -326,11 +324,11 @@ ephy_certificate_dialog_init (EphyCertificateDialog *dialog)
}
GtkWidget *
-ephy_certificate_dialog_new (GtkWindow *parent,
- const char *address,
- GTlsCertificate *certificate,
+ephy_certificate_dialog_new (GtkWindow *parent,
+ const char *address,
+ GTlsCertificate *certificate,
GTlsCertificateFlags tls_errors,
- EphySecurityLevel security_level)
+ EphySecurityLevel security_level)
{
GtkWidget *dialog;
@@ -338,13 +336,13 @@ ephy_certificate_dialog_new (GtkWindow *parent,
g_return_val_if_fail (G_IS_TLS_CERTIFICATE (certificate), NULL);
dialog = GTK_WIDGET (g_object_new (EPHY_TYPE_CERTIFICATE_DIALOG,
- "address", address,
- "certificate", certificate,
- "security-level", security_level,
- "tls-errors", tls_errors,
+ "address", address,
+ "certificate", certificate,
+ "security-level", security_level,
+ "tls-errors", tls_errors,
"modal", TRUE,
"use-header-bar", TRUE,
- NULL));
+ NULL));
if (parent)
gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
diff --git a/lib/widgets/ephy-download-widget.c b/lib/widgets/ephy-download-widget.c
index ed11528e2..5ad18cdf6 100644
--- a/lib/widgets/ephy-download-widget.c
+++ b/lib/widgets/ephy-download-widget.c
@@ -31,8 +31,7 @@
#include <glib/gi18n.h>
#include <webkit2/webkit2.h>
-struct _EphyDownloadWidget
-{
+struct _EphyDownloadWidget {
GtkGrid parent_instance;
EphyDownload *download;
@@ -46,8 +45,7 @@ struct _EphyDownloadWidget
G_DEFINE_TYPE (EphyDownloadWidget, ephy_download_widget, GTK_TYPE_GRID)
-enum
-{
+enum {
PROP_0,
PROP_DOWNLOAD,
LAST_PROP
@@ -79,41 +77,30 @@ get_destination_basename_from_download (EphyDownload *ephy_download)
static gchar *
duration_to_string (guint seconds)
{
- if (seconds < 60)
- {
- return g_strdup_printf (ngettext ("%d second left",
- "%d seconds left", seconds), seconds);
- }
- else if (seconds < (60 * 60))
- {
- seconds /= 60;
- return g_strdup_printf (ngettext ("%d minute left",
- "%d minutes left", seconds), seconds);
- }
- else if (seconds < (60 * 60 * 24))
- {
- seconds /= 60 * 60;
- return g_strdup_printf (ngettext ("%d hour left",
- "%d hours left", seconds), seconds);
- }
- else if (seconds < (60 * 60 * 24 * 7))
- {
- seconds /= 60 * 60 * 24;
- return g_strdup_printf (ngettext ("%d day left",
- "%d days left", seconds), seconds);
- }
- else if (seconds < (60 * 60 * 24 * 30))
- {
- seconds /= 60 * 60 * 24 * 7;
- return g_strdup_printf (ngettext ("%d week left",
- "%d weeks left", seconds), seconds);
- }
- else
- {
- seconds /= 60 * 60 * 24 * 30;
- return g_strdup_printf (ngettext ("%d month left",
- "%d months left", seconds), seconds);
- }
+ if (seconds < 60) {
+ return g_strdup_printf (ngettext ("%d second left",
+ "%d seconds left", seconds), seconds);
+ } else if (seconds < (60 * 60)) {
+ seconds /= 60;
+ return g_strdup_printf (ngettext ("%d minute left",
+ "%d minutes left", seconds), seconds);
+ } else if (seconds < (60 * 60 * 24)) {
+ seconds /= 60 * 60;
+ return g_strdup_printf (ngettext ("%d hour left",
+ "%d hours left", seconds), seconds);
+ } else if (seconds < (60 * 60 * 24 * 7)) {
+ seconds /= 60 * 60 * 24;
+ return g_strdup_printf (ngettext ("%d day left",
+ "%d days left", seconds), seconds);
+ } else if (seconds < (60 * 60 * 24 * 30)) {
+ seconds /= 60 * 60 * 24 * 7;
+ return g_strdup_printf (ngettext ("%d week left",
+ "%d weeks left", seconds), seconds);
+ } else {
+ seconds /= 60 * 60 * 24 * 30;
+ return g_strdup_printf (ngettext ("%d month left",
+ "%d months left", seconds), seconds);
+ }
}
static gdouble
@@ -171,7 +158,7 @@ update_download_destination (EphyDownloadWidget *widget)
static void
update_status_label (EphyDownloadWidget *widget,
- const char *download_label)
+ const char *download_label)
{
char *markup;
@@ -181,8 +168,8 @@ update_status_label (EphyDownloadWidget *widget,
}
static void
-download_progress_cb (WebKitDownload *download,
- GParamSpec *pspec,
+download_progress_cb (WebKitDownload *download,
+ GParamSpec *pspec,
EphyDownloadWidget *widget)
{
gdouble progress;
@@ -200,24 +187,24 @@ download_progress_cb (WebKitDownload *download,
received_length = webkit_download_get_received_data_length (download);
if (content_length > 0 && received_length > 0) {
- gdouble time;
- char *remaining;
- char *received;
- char *total;
-
- received = g_format_size (received_length);
- total = g_format_size (content_length);
-
- time = get_remaining_time (content_length, received_length,
- webkit_download_get_elapsed_time (download));
- remaining = duration_to_string ((guint)time);
- download_label = g_strdup_printf ("%s / %s — %s", received, total, remaining);
- g_free (received);
- g_free (total);
- g_free (remaining);
-
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (widget->progress),
- progress);
+ gdouble time;
+ char *remaining;
+ char *received;
+ char *total;
+
+ received = g_format_size (received_length);
+ total = g_format_size (content_length);
+
+ time = get_remaining_time (content_length, received_length,
+ webkit_download_get_elapsed_time (download));
+ remaining = duration_to_string ((guint)time);
+ download_label = g_strdup_printf ("%s / %s — %s", received, total, remaining);
+ g_free (received);
+ g_free (total);
+ g_free (remaining);
+
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (widget->progress),
+ progress);
} else if (received_length > 0) {
download_label = g_format_size (received_length);
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (widget->progress));
@@ -230,7 +217,7 @@ download_progress_cb (WebKitDownload *download,
}
static void
-download_finished_cb (EphyDownload *download,
+download_finished_cb (EphyDownload *download,
EphyDownloadWidget *widget)
{
gtk_widget_hide (widget->progress);
@@ -241,8 +228,8 @@ download_finished_cb (EphyDownload *download,
}
static void
-download_failed_cb (EphyDownload *download,
- GError *error,
+download_failed_cb (EphyDownload *download,
+ GError *error,
EphyDownloadWidget *widget)
{
char *error_msg;
@@ -260,8 +247,8 @@ download_failed_cb (EphyDownload *download,
}
static void
-download_content_type_changed_cb (EphyDownload *download,
- GParamSpec *spec,
+download_content_type_changed_cb (EphyDownload *download,
+ GParamSpec *spec,
EphyDownloadWidget *widget)
{
update_download_icon (widget);
@@ -294,8 +281,8 @@ widget_action_button_clicked_cb (EphyDownloadWidget *widget)
}
static void
-download_destination_changed_cb (WebKitDownload *download,
- GParamSpec *pspec,
+download_destination_changed_cb (WebKitDownload *download,
+ GParamSpec *pspec,
EphyDownloadWidget *widget)
{
update_download_destination (widget);
@@ -402,7 +389,7 @@ ephy_download_widget_constructed (GObject *object)
gtk_progress_bar_set_pulse_step (GTK_PROGRESS_BAR (widget->progress), 0.05);
gtk_grid_attach (GTK_GRID (widget), widget->progress, 0, 1, 2, 1);
if (ephy_download_is_active (widget->download))
- gtk_widget_show (widget->progress);
+ gtk_widget_show (widget->progress);
widget->status = gtk_label_new (NULL);
gtk_widget_set_valign (widget->status, GTK_ALIGN_CENTER);
@@ -411,15 +398,15 @@ ephy_download_widget_constructed (GObject *object)
gtk_label_set_max_width_chars (GTK_LABEL (widget->status), 30);
gtk_label_set_ellipsize (GTK_LABEL (widget->status), PANGO_ELLIPSIZE_END);
if (ephy_download_failed (widget->download, &error)) {
- char *error_msg;
+ char *error_msg;
- error_msg = g_strdup_printf (_("Error downloading: %s"), error->message);
- update_status_label (widget, error_msg);
- g_free (error_msg);
+ error_msg = g_strdup_printf (_("Error downloading: %s"), error->message);
+ update_status_label (widget, error_msg);
+ g_free (error_msg);
} else if (ephy_download_succeeded (widget->download)) {
- update_status_label (widget, _("Finished"));
+ update_status_label (widget, _("Finished"));
} else {
- update_status_label (widget, _("Starting…"));
+ update_status_label (widget, _("Starting…"));
}
gtk_grid_attach (GTK_GRID (widget), widget->status, 0, 2, 2, 1);
gtk_widget_show (widget->status);
diff --git a/lib/widgets/ephy-downloads-popover.c b/lib/widgets/ephy-downloads-popover.c
index 65d151657..a0f1e4ece 100644
--- a/lib/widgets/ephy-downloads-popover.c
+++ b/lib/widgets/ephy-downloads-popover.c
@@ -26,8 +26,7 @@
#include <glib/gi18n.h>
-struct _EphyDownloadsPopover
-{
+struct _EphyDownloadsPopover {
GtkPopover parent_instance;
GtkWidget *downloads_box;
diff --git a/lib/widgets/ephy-downloads-progress-icon.c b/lib/widgets/ephy-downloads-progress-icon.c
index 05c87c89d..0957c5196 100644
--- a/lib/widgets/ephy-downloads-progress-icon.c
+++ b/lib/widgets/ephy-downloads-progress-icon.c
@@ -23,8 +23,7 @@
#include "ephy-downloads-manager.h"
#include "ephy-embed-shell.h"
-struct _EphyDownloadsProgressIcon
-{
+struct _EphyDownloadsProgressIcon {
GtkDrawingArea parent_instance;
GtkWidget *downloads_box;
diff --git a/lib/widgets/ephy-file-chooser.c b/lib/widgets/ephy-file-chooser.c
index add180613..b34cc940c 100644
--- a/lib/widgets/ephy-file-chooser.c
+++ b/lib/widgets/ephy-file-chooser.c
@@ -28,15 +28,14 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
-static void ephy_file_chooser_image_preview (GtkFileChooser *file_chooser,
- gpointer user_data);
+static void ephy_file_chooser_image_preview (GtkFileChooser *file_chooser,
+ gpointer user_data);
#define PREVIEW_WIDTH 150
#define PREVIEW_HEIGHT 150
-struct _EphyFileChooser
-{
- GtkFileChooserDialog parent_instance;
+struct _EphyFileChooser {
+ GtkFileChooserDialog parent_instance;
};
G_DEFINE_TYPE (EphyFileChooser, ephy_file_chooser, GTK_TYPE_FILE_CHOOSER_DIALOG)
@@ -47,215 +46,207 @@ ephy_file_chooser_init (EphyFileChooser *dialog)
}
static GObject *
-ephy_file_chooser_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_params)
+ephy_file_chooser_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_params)
{
- GObject *object;
- char *downloads_dir;
+ GObject *object;
+ char *downloads_dir;
- object = G_OBJECT_CLASS (ephy_file_chooser_parent_class)->constructor (type, n_construct_properties,
- construct_params);
+ object = G_OBJECT_CLASS (ephy_file_chooser_parent_class)->constructor (type, n_construct_properties,
+ construct_params);
- downloads_dir = ephy_file_get_downloads_dir ();
- gtk_file_chooser_add_shortcut_folder
- (GTK_FILE_CHOOSER (object), downloads_dir, NULL);
- g_free (downloads_dir);
+ downloads_dir = ephy_file_get_downloads_dir ();
+ gtk_file_chooser_add_shortcut_folder
+ (GTK_FILE_CHOOSER (object), downloads_dir, NULL);
+ g_free (downloads_dir);
- return object;
+ return object;
}
GtkFileFilter *
ephy_file_chooser_add_pattern_filter (EphyFileChooser *dialog,
- const char *title,
- const char *first_pattern,
- ...)
+ const char *title,
+ const char *first_pattern,
+ ...)
{
- GtkFileFilter *filth;
- va_list args;
- const char *pattern;
+ GtkFileFilter *filth;
+ va_list args;
+ const char *pattern;
- filth = gtk_file_filter_new ();
+ filth = gtk_file_filter_new ();
- va_start (args, first_pattern);
+ va_start (args, first_pattern);
- pattern = first_pattern;
- while (pattern != NULL)
- {
- gtk_file_filter_add_pattern (filth, pattern);
- pattern = va_arg (args, const char *);
- }
- va_end (args);
+ pattern = first_pattern;
+ while (pattern != NULL) {
+ gtk_file_filter_add_pattern (filth, pattern);
+ pattern = va_arg (args, const char *);
+ }
+ va_end (args);
- gtk_file_filter_set_name (filth, title);
+ gtk_file_filter_set_name (filth, title);
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filth);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filth);
- return filth;
+ return filth;
}
GtkFileFilter *
ephy_file_chooser_add_mime_filter (EphyFileChooser *dialog,
- const char *title,
- const char *first_mimetype,
- ...)
+ const char *title,
+ const char *first_mimetype,
+ ...)
{
- GtkFileFilter *filth;
- va_list args;
- const char *mimetype;
+ GtkFileFilter *filth;
+ va_list args;
+ const char *mimetype;
- filth = gtk_file_filter_new ();
+ filth = gtk_file_filter_new ();
- va_start (args, first_mimetype);
+ va_start (args, first_mimetype);
- mimetype = first_mimetype;
- while (mimetype != NULL)
- {
- gtk_file_filter_add_mime_type (filth, mimetype);
- mimetype = va_arg (args, const char *);
- }
- va_end (args);
+ mimetype = first_mimetype;
+ while (mimetype != NULL) {
+ gtk_file_filter_add_mime_type (filth, mimetype);
+ mimetype = va_arg (args, const char *);
+ }
+ va_end (args);
- gtk_file_filter_set_name (filth, title);
+ gtk_file_filter_set_name (filth, title);
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filth);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filth);
- return filth;
+ return filth;
}
static void
ephy_file_chooser_class_init (EphyFileChooserClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->constructor = ephy_file_chooser_constructor;
+ object_class->constructor = ephy_file_chooser_constructor;
}
static void
-ephy_file_chooser_image_preview (GtkFileChooser *file_chooser,
- gpointer user_data)
+ephy_file_chooser_image_preview (GtkFileChooser *file_chooser,
+ gpointer user_data)
{
- char *filename;
- GtkWidget *preview;
- GdkPixbuf *pixbuf;
- gboolean have_preview;
-
- pixbuf = NULL;
- preview = GTK_WIDGET (user_data);
- filename = gtk_file_chooser_get_preview_filename (file_chooser);
-
- if (filename)
- pixbuf = gdk_pixbuf_new_from_file_at_size (filename,
- PREVIEW_WIDTH, PREVIEW_HEIGHT, NULL);
- g_free (filename);
-
- have_preview = (pixbuf != NULL);
- gtk_image_set_from_pixbuf (GTK_IMAGE (preview), pixbuf);
-
- if (pixbuf)
- g_object_unref (pixbuf);
-
- gtk_file_chooser_set_preview_widget_active (file_chooser, have_preview);
-
+ char *filename;
+ GtkWidget *preview;
+ GdkPixbuf *pixbuf;
+ gboolean have_preview;
+
+ pixbuf = NULL;
+ preview = GTK_WIDGET (user_data);
+ filename = gtk_file_chooser_get_preview_filename (file_chooser);
+
+ if (filename)
+ pixbuf = gdk_pixbuf_new_from_file_at_size (filename,
+ PREVIEW_WIDTH, PREVIEW_HEIGHT, NULL);
+ g_free (filename);
+
+ have_preview = (pixbuf != NULL);
+ gtk_image_set_from_pixbuf (GTK_IMAGE (preview), pixbuf);
+
+ if (pixbuf)
+ g_object_unref (pixbuf);
+
+ gtk_file_chooser_set_preview_widget_active (file_chooser, have_preview);
}
-EphyFileChooser *
-ephy_file_chooser_new (const char *title,
- GtkWidget *parent,
- GtkFileChooserAction action,
- EphyFileFilterDefault default_filter)
+EphyFileChooser *
+ephy_file_chooser_new (const char *title,
+ GtkWidget *parent,
+ GtkFileChooserAction action,
+ EphyFileFilterDefault default_filter)
{
- EphyFileChooser *dialog;
- GtkFileFilter *filter[EPHY_FILE_FILTER_LAST];
- GtkWidget *preview;
-
- g_return_val_if_fail (default_filter >= 0 && default_filter <= EPHY_FILE_FILTER_LAST, NULL);
-
- dialog = EPHY_FILE_CHOOSER (g_object_new (EPHY_TYPE_FILE_CHOOSER,
- "title", title,
- "action", action,
- NULL));
-
- if (action == GTK_FILE_CHOOSER_ACTION_OPEN ||
- action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
- action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
- {
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- _("_Cancel"), GTK_RESPONSE_CANCEL,
- _("_Open"), GTK_RESPONSE_ACCEPT,
- NULL);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog),
- GTK_RESPONSE_ACCEPT);
- }
- else if (action == GTK_FILE_CHOOSER_ACTION_SAVE)
- {
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- _("_Cancel"), GTK_RESPONSE_CANCEL,
- _("_Save"), GTK_RESPONSE_ACCEPT,
- NULL);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog),
- GTK_RESPONSE_ACCEPT);
- }
-
- preview = gtk_image_new ();
- gtk_file_chooser_set_preview_widget (GTK_FILE_CHOOSER (dialog), preview);
- gtk_file_chooser_set_preview_widget_active (GTK_FILE_CHOOSER (dialog), FALSE);
- g_signal_connect (dialog, "update-preview", G_CALLBACK (ephy_file_chooser_image_preview), preview);
-
- if (default_filter != EPHY_FILE_FILTER_NONE)
- {
- filter[EPHY_FILE_FILTER_ALL_SUPPORTED] =
- ephy_file_chooser_add_mime_filter
- (dialog,
- _("All supported types"),
- "text/html",
- "application/xhtml+xml",
- "text/xml",
- "message/rfc822", /* MHTML */
- "multipart/related", /* MHTML */
- "application/x-mimearchive", /* MHTML */
- "image/png",
- "image/jpeg",
- "image/gif",
- NULL);
-
- filter[EPHY_FILE_FILTER_WEBPAGES] =
- ephy_file_chooser_add_mime_filter
- (dialog, _("Web pages"),
- "text/html",
- "application/xhtml+xml",
- "text/xml",
- "message/rfc822", /* MHTML */
- "multipart/related", /* MHTML */
- "application/x-mimearchive", /* MHTML */
- NULL);
-
- filter[EPHY_FILE_FILTER_IMAGES] =
- ephy_file_chooser_add_mime_filter
- (dialog, _("Images"),
- "image/png",
- "image/jpeg",
- "image/gif",
- NULL);
-
- filter[EPHY_FILE_FILTER_ALL] =
- ephy_file_chooser_add_pattern_filter
- (dialog, _("All files"), "*", NULL);
-
- gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog),
- filter[default_filter]);
- }
-
- if (parent != NULL)
- {
- gtk_window_set_transient_for (GTK_WINDOW (dialog),
- GTK_WINDOW (parent));
- gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
- gtk_window_group_add_window (ephy_gui_ensure_window_group (GTK_WINDOW (parent)),
- GTK_WINDOW (dialog));
- gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
- }
-
- return dialog;
+ EphyFileChooser *dialog;
+ GtkFileFilter *filter[EPHY_FILE_FILTER_LAST];
+ GtkWidget *preview;
+
+ g_return_val_if_fail (default_filter >= 0 && default_filter <= EPHY_FILE_FILTER_LAST, NULL);
+
+ dialog = EPHY_FILE_CHOOSER (g_object_new (EPHY_TYPE_FILE_CHOOSER,
+ "title", title,
+ "action", action,
+ NULL));
+
+ if (action == GTK_FILE_CHOOSER_ACTION_OPEN ||
+ action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
+ action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER) {
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ _("_Cancel"), GTK_RESPONSE_CANCEL,
+ _("_Open"), GTK_RESPONSE_ACCEPT,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog),
+ GTK_RESPONSE_ACCEPT);
+ } else if (action == GTK_FILE_CHOOSER_ACTION_SAVE) {
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ _("_Cancel"), GTK_RESPONSE_CANCEL,
+ _("_Save"), GTK_RESPONSE_ACCEPT,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog),
+ GTK_RESPONSE_ACCEPT);
+ }
+
+ preview = gtk_image_new ();
+ gtk_file_chooser_set_preview_widget (GTK_FILE_CHOOSER (dialog), preview);
+ gtk_file_chooser_set_preview_widget_active (GTK_FILE_CHOOSER (dialog), FALSE);
+ g_signal_connect (dialog, "update-preview", G_CALLBACK (ephy_file_chooser_image_preview), preview);
+
+ if (default_filter != EPHY_FILE_FILTER_NONE) {
+ filter[EPHY_FILE_FILTER_ALL_SUPPORTED] =
+ ephy_file_chooser_add_mime_filter
+ (dialog,
+ _("All supported types"),
+ "text/html",
+ "application/xhtml+xml",
+ "text/xml",
+ "message/rfc822", /* MHTML */
+ "multipart/related", /* MHTML */
+ "application/x-mimearchive", /* MHTML */
+ "image/png",
+ "image/jpeg",
+ "image/gif",
+ NULL);
+
+ filter[EPHY_FILE_FILTER_WEBPAGES] =
+ ephy_file_chooser_add_mime_filter
+ (dialog, _("Web pages"),
+ "text/html",
+ "application/xhtml+xml",
+ "text/xml",
+ "message/rfc822", /* MHTML */
+ "multipart/related", /* MHTML */
+ "application/x-mimearchive", /* MHTML */
+ NULL);
+
+ filter[EPHY_FILE_FILTER_IMAGES] =
+ ephy_file_chooser_add_mime_filter
+ (dialog, _("Images"),
+ "image/png",
+ "image/jpeg",
+ "image/gif",
+ NULL);
+
+ filter[EPHY_FILE_FILTER_ALL] =
+ ephy_file_chooser_add_pattern_filter
+ (dialog, _("All files"), "*", NULL);
+
+ gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog),
+ filter[default_filter]);
+ }
+
+ if (parent != NULL) {
+ gtk_window_set_transient_for (GTK_WINDOW (dialog),
+ GTK_WINDOW (parent));
+ gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+ gtk_window_group_add_window (ephy_gui_ensure_window_group (GTK_WINDOW (parent)),
+ GTK_WINDOW (dialog));
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
+ }
+
+ return dialog;
}
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c
index ff77c0af9..8ddeb15fd 100644
--- a/lib/widgets/ephy-location-entry.c
+++ b/lib/widgets/ephy-location-entry.c
@@ -50,1037 +50,1003 @@
* #EphyLocationEntry implements the location bar in the main Epiphany window.
*/
-struct _EphyLocationEntry
-{
- GtkEntry parent_instance;
+struct _EphyLocationEntry {
+ GtkEntry parent_instance;
- GdkPixbuf *favicon;
- GtkTreeModel *model;
+ GdkPixbuf *favicon;
+ GtkTreeModel *model;
- GSList *search_terms;
+ GSList *search_terms;
- char *before_completion;
- char *saved_text;
+ char *before_completion;
+ char *saved_text;
- guint text_col;
- guint action_col;
- guint keywords_col;
- guint relevance_col;
- guint url_col;
- guint extra_col;
- guint favicon_col;
+ guint text_col;
+ guint action_col;
+ guint keywords_col;
+ guint relevance_col;
+ guint url_col;
+ guint extra_col;
+ guint favicon_col;
- guint hash;
+ guint hash;
- gulong dns_prefetch_handler;
+ gulong dns_prefetch_handler;
- guint user_changed : 1;
- guint can_redo : 1;
- guint block_update : 1;
- guint original_address : 1;
- guint apply_colors : 1;
- guint needs_reset : 1;
- guint show_favicon : 1;
+ guint user_changed : 1;
+ guint can_redo : 1;
+ guint block_update : 1;
+ guint original_address : 1;
+ guint apply_colors : 1;
+ guint needs_reset : 1;
+ guint show_favicon : 1;
- GtkTargetList *drag_targets;
- GdkDragAction drag_actions;
+ GtkTargetList *drag_targets;
+ GdkDragAction drag_actions;
};
static const GtkTargetEntry url_drag_types [] =
{
- { (char *)EPHY_DND_URL_TYPE, 0, 0 },
- { (char *)EPHY_DND_URI_LIST_TYPE, 0, 1 },
- { (char *)EPHY_DND_TEXT_TYPE, 0, 2 }
+ { (char *)EPHY_DND_URL_TYPE, 0, 0 },
+ { (char *)EPHY_DND_URI_LIST_TYPE, 0, 1 },
+ { (char *)EPHY_DND_TEXT_TYPE, 0, 2 }
};
static gboolean ephy_location_entry_reset_internal (EphyLocationEntry *, gboolean);
-static void extracell_data_func (GtkCellLayout *cell_layout,
- GtkCellRenderer *cell,
- GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- gpointer data);
-
-enum
-{
- PROP_0,
- PROP_LOCATION,
- PROP_FAVICON,
- PROP_SECURITY_LEVEL,
- PROP_SHOW_FAVICON,
- LAST_PROP
+static void extracell_data_func (GtkCellLayout *cell_layout,
+ GtkCellRenderer *cell,
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ gpointer data);
+
+enum {
+ PROP_0,
+ PROP_LOCATION,
+ PROP_FAVICON,
+ PROP_SECURITY_LEVEL,
+ PROP_SHOW_FAVICON,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
-enum signalsEnum
-{
- USER_CHANGED,
- LOCK_CLICKED,
- GET_LOCATION,
- GET_TITLE,
- LAST_SIGNAL
+enum signalsEnum {
+ USER_CHANGED,
+ LOCK_CLICKED,
+ GET_LOCATION,
+ GET_TITLE,
+ LAST_SIGNAL
};
static gint signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (EphyLocationEntry, ephy_location_entry, GTK_TYPE_ENTRY)
static void
-ephy_location_entry_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ephy_location_entry_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (object);
-
- switch (prop_id)
- {
- case PROP_LOCATION:
- ephy_location_entry_set_location (entry,
- g_value_get_string (value));
- break;
- case PROP_FAVICON:
- ephy_location_entry_set_favicon (entry,
- g_value_get_object (value));
- break;
- case PROP_SECURITY_LEVEL:
- ephy_location_entry_set_security_level (entry,
- g_value_get_enum (value));
- break;
- case PROP_SHOW_FAVICON:
- ephy_location_entry_set_show_favicon (entry,
- g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id,pspec);
- }
+ EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (object);
+
+ switch (prop_id) {
+ case PROP_LOCATION:
+ ephy_location_entry_set_location (entry,
+ g_value_get_string (value));
+ break;
+ case PROP_FAVICON:
+ ephy_location_entry_set_favicon (entry,
+ g_value_get_object (value));
+ break;
+ case PROP_SECURITY_LEVEL:
+ ephy_location_entry_set_security_level (entry,
+ g_value_get_enum (value));
+ break;
+ case PROP_SHOW_FAVICON:
+ ephy_location_entry_set_show_favicon (entry,
+ g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
-ephy_location_entry_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ephy_location_entry_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (object);
-
- switch (prop_id)
- {
- case PROP_LOCATION:
- g_value_set_string (value, ephy_location_entry_get_location (entry));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id,pspec);
- }
+ EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (object);
+
+ switch (prop_id) {
+ case PROP_LOCATION:
+ g_value_set_string (value, ephy_location_entry_get_location (entry));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
ephy_location_entry_finalize (GObject *object)
{
- EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (object);
+ EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (object);
- g_free (entry->saved_text);
+ g_free (entry->saved_text);
- if (entry->drag_targets != NULL)
- {
- gtk_target_list_unref (entry->drag_targets);
- }
+ if (entry->drag_targets != NULL) {
+ gtk_target_list_unref (entry->drag_targets);
+ }
- if (entry->favicon != NULL)
- {
- g_object_unref (entry->favicon);
- }
+ if (entry->favicon != NULL) {
+ g_object_unref (entry->favicon);
+ }
- G_OBJECT_CLASS (ephy_location_entry_parent_class)->finalize (object);
+ G_OBJECT_CLASS (ephy_location_entry_parent_class)->finalize (object);
}
static void
-ephy_location_entry_get_preferred_width (GtkWidget *widget,
- gint *minimum_width,
- gint *natural_width)
+ephy_location_entry_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width)
{
- if (minimum_width)
- *minimum_width = -1;
+ if (minimum_width)
+ *minimum_width = -1;
- if (natural_width)
- *natural_width = 848;
+ if (natural_width)
+ *natural_width = 848;
}
static void
ephy_location_entry_copy_clipboard (GtkEntry *entry)
{
- char *text;
- gint start;
- gint end;
-
- if (!gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start, &end))
- return;
-
- text = gtk_editable_get_chars (GTK_EDITABLE (entry), start, end);
-
- if (start == 0)
- {
- char *tmp = text;
- text = ephy_uri_normalize (tmp);
- g_free (tmp);
- }
-
- gtk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (entry),
- GDK_SELECTION_CLIPBOARD),
- text, -1);
- g_free (text);
+ char *text;
+ gint start;
+ gint end;
+
+ if (!gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start, &end))
+ return;
+
+ text = gtk_editable_get_chars (GTK_EDITABLE (entry), start, end);
+
+ if (start == 0) {
+ char *tmp = text;
+ text = ephy_uri_normalize (tmp);
+ g_free (tmp);
+ }
+
+ gtk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (entry),
+ GDK_SELECTION_CLIPBOARD),
+ text, -1);
+ g_free (text);
}
static void
ephy_location_entry_cut_clipboard (GtkEntry *entry)
{
- if (!gtk_editable_get_editable (GTK_EDITABLE (entry)))
- {
- gtk_widget_error_bell (GTK_WIDGET (entry));
- return;
- }
-
- ephy_location_entry_copy_clipboard (entry);
- gtk_editable_delete_selection (GTK_EDITABLE (entry));
+ if (!gtk_editable_get_editable (GTK_EDITABLE (entry))) {
+ gtk_widget_error_bell (GTK_WIDGET (entry));
+ return;
+ }
+
+ ephy_location_entry_copy_clipboard (entry);
+ gtk_editable_delete_selection (GTK_EDITABLE (entry));
}
static void
ephy_location_entry_class_init (EphyLocationEntryClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- GtkEntryClass *entry_class = GTK_ENTRY_CLASS (klass);
-
- object_class->get_property = ephy_location_entry_get_property;
- object_class->set_property = ephy_location_entry_set_property;
- object_class->finalize = ephy_location_entry_finalize;
- widget_class->get_preferred_width = ephy_location_entry_get_preferred_width;
- entry_class->copy_clipboard = ephy_location_entry_copy_clipboard;
- entry_class->cut_clipboard = ephy_location_entry_cut_clipboard;
-
- /**
- * EphyLocationEntry:location:
- *
- * The current location.
- */
- obj_properties[PROP_LOCATION] =
- g_param_spec_string ("location",
- "Location",
- "The current location",
- "",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- /**
- * EphyLocationEntry:favicon:
- *
- * The icon corresponding to the current location.
- */
- obj_properties[PROP_FAVICON] =
- g_param_spec_object ("favicon",
- "Favicon",
- "The icon corresponding to the current location",
- GDK_TYPE_PIXBUF,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
-
- /**
- * EphyLocationEntry:security-level:
- *
- * State of the security icon.
- */
- obj_properties[PROP_SECURITY_LEVEL] =
- g_param_spec_enum ("security-level",
- "Security level",
- "State of the security icon",
- EPHY_TYPE_SECURITY_LEVEL,
- EPHY_SECURITY_LEVEL_TO_BE_DETERMINED,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
-
- obj_properties[PROP_SHOW_FAVICON] =
- g_param_spec_boolean ("show-favicon",
- "Show Favicon",
- "Whether to show the favicon",
- TRUE,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
-
- /**
- * EphyLocationEntry::user-changed:
- * @entry: the object on which the signal is emitted
- *
- * Emitted when the user changes the contents of the internal #GtkEntry
- *
- */
- signals[USER_CHANGED] = g_signal_new (
- "user_changed", G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 0,
- G_TYPE_NONE);
-
- /**
- * EphyLocationEntry::lock-clicked:
- * @entry: the object on which the signal is emitted
- *
- * Emitted when the user clicks the security icon inside the
- * #EphyLocationEntry.
- *
- */
- signals[LOCK_CLICKED] = g_signal_new (
- "lock-clicked",
- EPHY_TYPE_LOCATION_ENTRY,
- G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 0);
-
- /**
- * EphyLocationEntry::get-location:
- * @entry: the object on which the signal is emitted
- * Returns: the current page address as a string
- *
- * For drag and drop purposes, the location bar will request you the
- * real address of where it is pointing to. The signal handler for this
- * function should return the address of the currently loaded site.
- *
- */
- signals[GET_LOCATION] = g_signal_new (
- "get-location", G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
- 0, ephy_signal_accumulator_string,
- NULL, NULL,
- G_TYPE_STRING,
- 0,
- G_TYPE_NONE);
-
- /**
- * EphyLocationEntry::get-title:
- * @entry: the object on which the signal is emitted
- * Returns: the current page title as a string
- *
- * For drag and drop purposes, the location bar will request you the
- * title of where it is pointing to. The signal handler for this
- * function should return the title of the currently loaded site.
- *
- */
- signals[GET_TITLE] = g_signal_new (
- "get-title", G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
- 0, ephy_signal_accumulator_string,
- NULL, NULL,
- G_TYPE_STRING,
- 0,
- G_TYPE_NONE);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GtkEntryClass *entry_class = GTK_ENTRY_CLASS (klass);
+
+ object_class->get_property = ephy_location_entry_get_property;
+ object_class->set_property = ephy_location_entry_set_property;
+ object_class->finalize = ephy_location_entry_finalize;
+ widget_class->get_preferred_width = ephy_location_entry_get_preferred_width;
+ entry_class->copy_clipboard = ephy_location_entry_copy_clipboard;
+ entry_class->cut_clipboard = ephy_location_entry_cut_clipboard;
+
+ /**
+ * EphyLocationEntry:location:
+ *
+ * The current location.
+ */
+ obj_properties[PROP_LOCATION] =
+ g_param_spec_string ("location",
+ "Location",
+ "The current location",
+ "",
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ /**
+ * EphyLocationEntry:favicon:
+ *
+ * The icon corresponding to the current location.
+ */
+ obj_properties[PROP_FAVICON] =
+ g_param_spec_object ("favicon",
+ "Favicon",
+ "The icon corresponding to the current location",
+ GDK_TYPE_PIXBUF,
+ G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
+
+ /**
+ * EphyLocationEntry:security-level:
+ *
+ * State of the security icon.
+ */
+ obj_properties[PROP_SECURITY_LEVEL] =
+ g_param_spec_enum ("security-level",
+ "Security level",
+ "State of the security icon",
+ EPHY_TYPE_SECURITY_LEVEL,
+ EPHY_SECURITY_LEVEL_TO_BE_DETERMINED,
+ G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
+
+ obj_properties[PROP_SHOW_FAVICON] =
+ g_param_spec_boolean ("show-favicon",
+ "Show Favicon",
+ "Whether to show the favicon",
+ TRUE,
+ G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+
+ /**
+ * EphyLocationEntry::user-changed:
+ * @entry: the object on which the signal is emitted
+ *
+ * Emitted when the user changes the contents of the internal #GtkEntry
+ *
+ */
+ signals[USER_CHANGED] = g_signal_new (
+ "user_changed", G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 0,
+ G_TYPE_NONE);
+
+ /**
+ * EphyLocationEntry::lock-clicked:
+ * @entry: the object on which the signal is emitted
+ *
+ * Emitted when the user clicks the security icon inside the
+ * #EphyLocationEntry.
+ *
+ */
+ signals[LOCK_CLICKED] = g_signal_new (
+ "lock-clicked",
+ EPHY_TYPE_LOCATION_ENTRY,
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 0);
+
+ /**
+ * EphyLocationEntry::get-location:
+ * @entry: the object on which the signal is emitted
+ * Returns: the current page address as a string
+ *
+ * For drag and drop purposes, the location bar will request you the
+ * real address of where it is pointing to. The signal handler for this
+ * function should return the address of the currently loaded site.
+ *
+ */
+ signals[GET_LOCATION] = g_signal_new (
+ "get-location", G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
+ 0, ephy_signal_accumulator_string,
+ NULL, NULL,
+ G_TYPE_STRING,
+ 0,
+ G_TYPE_NONE);
+
+ /**
+ * EphyLocationEntry::get-title:
+ * @entry: the object on which the signal is emitted
+ * Returns: the current page title as a string
+ *
+ * For drag and drop purposes, the location bar will request you the
+ * title of where it is pointing to. The signal handler for this
+ * function should return the title of the currently loaded site.
+ *
+ */
+ signals[GET_TITLE] = g_signal_new (
+ "get-title", G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
+ 0, ephy_signal_accumulator_string,
+ NULL, NULL,
+ G_TYPE_STRING,
+ 0,
+ G_TYPE_NONE);
}
static void
update_address_state (EphyLocationEntry *entry)
{
- const char *text;
+ const char *text;
- text = gtk_entry_get_text (GTK_ENTRY (entry));
- entry->original_address = text != NULL &&
- g_str_hash (text) == entry->hash;
+ text = gtk_entry_get_text (GTK_ENTRY (entry));
+ entry->original_address = text != NULL &&
+ g_str_hash (text) == entry->hash;
}
static void
update_favicon (EphyLocationEntry *lentry)
{
- GtkEntry *entry = GTK_ENTRY (lentry);
-
- /* Only show the favicon if the entry's text is the
- * address of the current page.
- */
- if (lentry->show_favicon && lentry->favicon != NULL && lentry->original_address)
- {
- gtk_entry_set_icon_from_pixbuf (entry,
- GTK_ENTRY_ICON_PRIMARY,
- lentry->favicon);
- }
- else if (lentry->show_favicon)
- {
- const char *icon_name;
-
- /* Here we could consider using fallback favicon that matches
- * the page MIME type, though text/html should be good enough
- * most of the time. See #337140
- */
- if (gtk_entry_get_text_length (entry) > 0)
- icon_name = "text-x-generic-symbolic";
- else
- icon_name = "edit-find-symbolic";
-
- gtk_entry_set_icon_from_icon_name (entry,
- GTK_ENTRY_ICON_PRIMARY,
- icon_name);
- }
- else
- {
- gtk_entry_set_icon_from_icon_name (entry,
- GTK_ENTRY_ICON_PRIMARY,
- NULL);
- }
+ GtkEntry *entry = GTK_ENTRY (lentry);
+
+ /* Only show the favicon if the entry's text is the
+ * address of the current page.
+ */
+ if (lentry->show_favicon && lentry->favicon != NULL && lentry->original_address) {
+ gtk_entry_set_icon_from_pixbuf (entry,
+ GTK_ENTRY_ICON_PRIMARY,
+ lentry->favicon);
+ } else if (lentry->show_favicon) {
+ const char *icon_name;
+
+ /* Here we could consider using fallback favicon that matches
+ * the page MIME type, though text/html should be good enough
+ * most of the time. See #337140
+ */
+ if (gtk_entry_get_text_length (entry) > 0)
+ icon_name = "text-x-generic-symbolic";
+ else
+ icon_name = "edit-find-symbolic";
+
+ gtk_entry_set_icon_from_icon_name (entry,
+ GTK_ENTRY_ICON_PRIMARY,
+ icon_name);
+ } else {
+ gtk_entry_set_icon_from_icon_name (entry,
+ GTK_ENTRY_ICON_PRIMARY,
+ NULL);
+ }
}
static void
-editable_changed_cb (GtkEditable *editable,
- EphyLocationEntry *entry)
+editable_changed_cb (GtkEditable *editable,
+ EphyLocationEntry *entry)
{
- update_address_state (entry);
+ update_address_state (entry);
- if (entry->block_update == TRUE)
- return;
- else
- {
- entry->user_changed = TRUE;
- entry->can_redo = FALSE;
- }
+ if (entry->block_update == TRUE)
+ return;
+ else {
+ entry->user_changed = TRUE;
+ entry->can_redo = FALSE;
+ }
- g_signal_emit (entry, signals[USER_CHANGED], 0);
+ g_signal_emit (entry, signals[USER_CHANGED], 0);
}
static gboolean
-entry_key_press_cb (GtkEntry *entry,
- GdkEventKey *event,
- EphyLocationEntry *location_entry)
+entry_key_press_cb (GtkEntry *entry,
+ GdkEventKey *event,
+ EphyLocationEntry *location_entry)
{
- guint state = event->state & gtk_accelerator_get_default_mod_mask ();
+ guint state = event->state & gtk_accelerator_get_default_mod_mask ();
- if (event->keyval == GDK_KEY_Escape && state == 0)
- {
- ephy_location_entry_reset_internal (location_entry, TRUE);
- /* don't return TRUE since we want to cancel the autocompletion popup too */
- }
+ if (event->keyval == GDK_KEY_Escape && state == 0) {
+ ephy_location_entry_reset_internal (location_entry, TRUE);
+ /* don't return TRUE since we want to cancel the autocompletion popup too */
+ }
- if (event->keyval == GDK_KEY_l && state == GDK_CONTROL_MASK)
- {
- /* Make sure the location is activated on CTRL+l even when the
- * completion popup is shown and have an active keyboard grab.
- */
- ephy_location_entry_activate (location_entry);
- }
+ if (event->keyval == GDK_KEY_l && state == GDK_CONTROL_MASK) {
+ /* Make sure the location is activated on CTRL+l even when the
+ * completion popup is shown and have an active keyboard grab.
+ */
+ ephy_location_entry_activate (location_entry);
+ }
- return FALSE;
+ return FALSE;
}
static gboolean
-entry_key_press_after_cb (GtkEntry *entry,
- GdkEventKey *event,
- EphyLocationEntry *lentry)
+entry_key_press_after_cb (GtkEntry *entry,
+ GdkEventKey *event,
+ EphyLocationEntry *lentry)
{
- guint state = event->state & gtk_accelerator_get_default_mod_mask ();
-
- if ((event->keyval == GDK_KEY_Return ||
- event->keyval == GDK_KEY_KP_Enter ||
- event->keyval == GDK_KEY_ISO_Enter) &&
- (state == GDK_CONTROL_MASK ||
- state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK)))
- {
- //gtk_im_context_reset (entry->im_context);
-
- lentry->needs_reset = TRUE;
- g_signal_emit_by_name (entry, "activate");
-
- return TRUE;
- }
-
- if ((event->keyval == GDK_KEY_Down || event->keyval == GDK_KEY_KP_Down)
- && state == 0)
- {
- /* If we are focusing the entry, with the cursor at the end of it
- * we emit the changed signal, so that the completion popup appears */
- const char *string;
-
- string = gtk_entry_get_text (entry);
- if (gtk_editable_get_position (GTK_EDITABLE (entry)) == (int)strlen (string))
- {
- g_signal_emit_by_name (entry, "changed", 0);
- return TRUE;
- }
- }
-
- return FALSE;
+ guint state = event->state & gtk_accelerator_get_default_mod_mask ();
+
+ if ((event->keyval == GDK_KEY_Return ||
+ event->keyval == GDK_KEY_KP_Enter ||
+ event->keyval == GDK_KEY_ISO_Enter) &&
+ (state == GDK_CONTROL_MASK ||
+ state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK))) {
+ /* gtk_im_context_reset (entry->im_context); */
+
+ lentry->needs_reset = TRUE;
+ g_signal_emit_by_name (entry, "activate");
+
+ return TRUE;
+ }
+
+ if ((event->keyval == GDK_KEY_Down || event->keyval == GDK_KEY_KP_Down)
+ && state == 0) {
+ /* If we are focusing the entry, with the cursor at the end of it
+ * we emit the changed signal, so that the completion popup appears */
+ const char *string;
+
+ string = gtk_entry_get_text (entry);
+ if (gtk_editable_get_position (GTK_EDITABLE (entry)) == (int)strlen (string)) {
+ g_signal_emit_by_name (entry, "changed", 0);
+ return TRUE;
+ }
+ }
+
+ return FALSE;
}
static void
-entry_activate_after_cb (GtkEntry *entry,
- EphyLocationEntry *lentry)
+entry_activate_after_cb (GtkEntry *entry,
+ EphyLocationEntry *lentry)
{
- lentry->user_changed = FALSE;
+ lentry->user_changed = FALSE;
- if (lentry->needs_reset)
- {
- ephy_location_entry_reset_internal (lentry, TRUE);
- lentry->needs_reset = FALSE;
- }
+ if (lentry->needs_reset) {
+ ephy_location_entry_reset_internal (lentry, TRUE);
+ lentry->needs_reset = FALSE;
+ }
}
static gboolean
match_selected_cb (GtkEntryCompletion *completion,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- EphyLocationEntry *entry)
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ EphyLocationEntry *entry)
{
- char *item = NULL;
- guint state;
+ char *item = NULL;
+ guint state;
- gtk_tree_model_get (model, iter,
- entry->action_col, &item, -1);
- if (item == NULL) return FALSE;
+ gtk_tree_model_get (model, iter,
+ entry->action_col, &item, -1);
+ if (item == NULL) return FALSE;
- ephy_gui_get_current_event (NULL, &state, NULL);
+ ephy_gui_get_current_event (NULL, &state, NULL);
- entry->needs_reset = (state == GDK_CONTROL_MASK ||
- state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK));
+ entry->needs_reset = (state == GDK_CONTROL_MASK ||
+ state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK));
- ephy_location_entry_set_location (entry, item);
- //gtk_im_context_reset (GTK_ENTRY (entry)->im_context);
- g_signal_emit_by_name (entry, "activate");
+ ephy_location_entry_set_location (entry, item);
+ /* gtk_im_context_reset (GTK_ENTRY (entry)->im_context); */
+ g_signal_emit_by_name (entry, "activate");
- g_free (item);
+ g_free (item);
- return TRUE;
+ return TRUE;
}
static void
action_activated_after_cb (GtkEntryCompletion *completion,
- gint index,
- EphyLocationEntry *lentry)
+ gint index,
+ EphyLocationEntry *lentry)
{
- guint state, button;
-
- ephy_gui_get_current_event (NULL, &state, &button);
- if ((state == GDK_CONTROL_MASK ||
- state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) ||
- button == 2)
- {
- ephy_location_entry_reset_internal (lentry, TRUE);
- }
+ guint state, button;
+
+ ephy_gui_get_current_event (NULL, &state, &button);
+ if ((state == GDK_CONTROL_MASK ||
+ state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) ||
+ button == 2) {
+ ephy_location_entry_reset_internal (lentry, TRUE);
+ }
}
static gboolean
-entry_drag_motion_cb (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
+entry_drag_motion_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint time)
{
- return FALSE;
+ return FALSE;
}
static gboolean
-entry_drag_drop_cb (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
+entry_drag_drop_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint time)
{
- return FALSE;
+ return FALSE;
}
static void
-entry_clear_activate_cb (GtkMenuItem *item,
- EphyLocationEntry *entry)
+entry_clear_activate_cb (GtkMenuItem *item,
+ EphyLocationEntry *entry)
{
- entry->block_update = TRUE;
- gtk_entry_set_text (GTK_ENTRY (entry), "");
- entry->block_update = FALSE;
- entry->user_changed = TRUE;
+ entry->block_update = TRUE;
+ gtk_entry_set_text (GTK_ENTRY (entry), "");
+ entry->block_update = FALSE;
+ entry->user_changed = TRUE;
}
static void
-entry_redo_activate_cb (GtkMenuItem *item,
- EphyLocationEntry *entry)
+entry_redo_activate_cb (GtkMenuItem *item,
+ EphyLocationEntry *entry)
{
- ephy_location_entry_undo_reset (entry);
+ ephy_location_entry_undo_reset (entry);
}
static void
-entry_undo_activate_cb (GtkMenuItem *item,
- EphyLocationEntry *entry)
+entry_undo_activate_cb (GtkMenuItem *item,
+ EphyLocationEntry *entry)
{
- ephy_location_entry_reset_internal (entry, FALSE);
+ ephy_location_entry_reset_internal (entry, FALSE);
}
static void
-entry_populate_popup_cb (GtkEntry *entry,
- GtkMenu *menu,
- EphyLocationEntry *lentry)
+entry_populate_popup_cb (GtkEntry *entry,
+ GtkMenu *menu,
+ EphyLocationEntry *lentry)
{
- GtkWidget *clear_menuitem, *undo_menuitem, *redo_menuitem, *separator;
- GList *children, *item;
- int pos = 0, sep = 0;
- gboolean is_editable;
-
- /* Translators: the mnemonic shouldn't conflict with any of the
- * standard items in the GtkEntry context menu (Cut, Copy, Paste, Delete,
- * Select All, Input Methods and Insert Unicode control character.)
- */
- clear_menuitem = gtk_menu_item_new_with_mnemonic (_("Cl_ear"));
- g_signal_connect (clear_menuitem , "activate",
- G_CALLBACK (entry_clear_activate_cb), lentry);
- is_editable = gtk_editable_get_editable (GTK_EDITABLE (entry));
- gtk_widget_set_sensitive (clear_menuitem, is_editable);
- gtk_widget_show (clear_menuitem);
-
- /* search for the 2nd separator (the one after Select All) in the context
- * menu, and insert this menu item before it.
- * It's a bit of a hack, but there seems to be no better way to do it :/
- */
- children = gtk_container_get_children (GTK_CONTAINER (menu));
- for (item = children; item != NULL && sep < 2; item = item->next, pos++)
- {
- if (GTK_IS_SEPARATOR_MENU_ITEM (item->data)) sep++;
- }
-
- gtk_menu_shell_insert (GTK_MENU_SHELL (menu), clear_menuitem, pos - 1);
-
- undo_menuitem = gtk_menu_item_new_with_mnemonic (_("_Undo"));
- gtk_widget_set_sensitive (undo_menuitem, lentry->user_changed);
- g_signal_connect (undo_menuitem, "activate",
- G_CALLBACK (entry_undo_activate_cb), lentry);
- gtk_widget_show (undo_menuitem);
- gtk_menu_shell_insert (GTK_MENU_SHELL (menu), undo_menuitem, 0);
-
- redo_menuitem = gtk_menu_item_new_with_mnemonic (_("_Redo"));
- gtk_widget_set_sensitive (redo_menuitem, lentry->can_redo);
- g_signal_connect (redo_menuitem, "activate",
- G_CALLBACK (entry_redo_activate_cb), lentry);
- gtk_widget_show (redo_menuitem);
- gtk_menu_shell_insert (GTK_MENU_SHELL (menu), redo_menuitem, 1);
-
- separator = gtk_separator_menu_item_new ();
- gtk_widget_show (separator);
- gtk_menu_shell_insert (GTK_MENU_SHELL (menu), separator, 2);
+ GtkWidget *clear_menuitem, *undo_menuitem, *redo_menuitem, *separator;
+ GList *children, *item;
+ int pos = 0, sep = 0;
+ gboolean is_editable;
+
+ /* Translators: the mnemonic shouldn't conflict with any of the
+ * standard items in the GtkEntry context menu (Cut, Copy, Paste, Delete,
+ * Select All, Input Methods and Insert Unicode control character.)
+ */
+ clear_menuitem = gtk_menu_item_new_with_mnemonic (_("Cl_ear"));
+ g_signal_connect (clear_menuitem, "activate",
+ G_CALLBACK (entry_clear_activate_cb), lentry);
+ is_editable = gtk_editable_get_editable (GTK_EDITABLE (entry));
+ gtk_widget_set_sensitive (clear_menuitem, is_editable);
+ gtk_widget_show (clear_menuitem);
+
+ /* search for the 2nd separator (the one after Select All) in the context
+ * menu, and insert this menu item before it.
+ * It's a bit of a hack, but there seems to be no better way to do it :/
+ */
+ children = gtk_container_get_children (GTK_CONTAINER (menu));
+ for (item = children; item != NULL && sep < 2; item = item->next, pos++) {
+ if (GTK_IS_SEPARATOR_MENU_ITEM (item->data)) sep++;
+ }
+
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menu), clear_menuitem, pos - 1);
+
+ undo_menuitem = gtk_menu_item_new_with_mnemonic (_("_Undo"));
+ gtk_widget_set_sensitive (undo_menuitem, lentry->user_changed);
+ g_signal_connect (undo_menuitem, "activate",
+ G_CALLBACK (entry_undo_activate_cb), lentry);
+ gtk_widget_show (undo_menuitem);
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menu), undo_menuitem, 0);
+
+ redo_menuitem = gtk_menu_item_new_with_mnemonic (_("_Redo"));
+ gtk_widget_set_sensitive (redo_menuitem, lentry->can_redo);
+ g_signal_connect (redo_menuitem, "activate",
+ G_CALLBACK (entry_redo_activate_cb), lentry);
+ gtk_widget_show (redo_menuitem);
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menu), redo_menuitem, 1);
+
+ separator = gtk_separator_menu_item_new ();
+ gtk_widget_show (separator);
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menu), separator, 2);
}
static void
each_url_get_data_binder (EphyDragEachSelectedItemDataGet iteratee,
- gpointer iterator_context,
- gpointer return_data)
+ gpointer iterator_context,
+ gpointer return_data)
{
- EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (iterator_context);
- char *title = NULL, *address = NULL;
+ EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (iterator_context);
+ char *title = NULL, *address = NULL;
- g_signal_emit (entry, signals[GET_LOCATION], 0, &address);
- g_signal_emit (entry, signals[GET_TITLE], 0, &title);
- g_return_if_fail (address != NULL && title != NULL);
+ g_signal_emit (entry, signals[GET_LOCATION], 0, &address);
+ g_signal_emit (entry, signals[GET_TITLE], 0, &title);
+ g_return_if_fail (address != NULL && title != NULL);
- iteratee (address, title, return_data);
+ iteratee (address, title, return_data);
- g_free (address);
- g_free (title);
+ g_free (address);
+ g_free (title);
}
static void
sanitize_location (char **url)
{
- char *str;
-
- /* Do not show internal ephy-about: protocol to users */
- if (g_str_has_prefix (*url, EPHY_ABOUT_SCHEME)) {
- str = g_strdup_printf ("about:%s", *url + strlen (EPHY_ABOUT_SCHEME) + 1);
- g_free (*url);
- *url = str;
- }
+ char *str;
+
+ /* Do not show internal ephy-about: protocol to users */
+ if (g_str_has_prefix (*url, EPHY_ABOUT_SCHEME)) {
+ str = g_strdup_printf ("about:%s", *url + strlen (EPHY_ABOUT_SCHEME) + 1);
+ g_free (*url);
+ *url = str;
+ }
}
-#define DRAG_ICON_LAYOUT_PADDING 5
-#define DRAG_ICON_ICON_PADDING 10
-#define DRAG_ICON_MAX_WIDTH_CHARS 32
+#define DRAG_ICON_LAYOUT_PADDING 5
+#define DRAG_ICON_ICON_PADDING 10
+#define DRAG_ICON_MAX_WIDTH_CHARS 32
static cairo_surface_t *
favicon_create_drag_surface (EphyLocationEntry *entry,
- GtkWidget *widget)
+ GtkWidget *widget)
{
- char *title = NULL, *address = NULL;
- GString *text;
- GtkStyleContext *style;
- const PangoFontDescription *font_desc;
- cairo_surface_t *surface;
- PangoContext *context;
- PangoLayout *layout;
- PangoFontMetrics *metrics;
- int surface_height, surface_width;
- int layout_width, layout_height;
- int icon_width = 0, icon_height = 0, favicon_offset_x = 0;
- int char_width;
- cairo_t *cr;
- GtkStateFlags state;
- GdkRGBA color;
- GdkPixbuf *favicon;
-
- g_signal_emit (entry, signals[GET_LOCATION], 0, &address);
- sanitize_location (&address);
- g_signal_emit (entry, signals[GET_TITLE], 0, &title);
- if (address == NULL || title == NULL) return NULL;
-
- /* Compute text */
- title = g_strstrip (title);
-
- text = g_string_sized_new (strlen (address) + strlen (title) + 2);
- if (title[0] != '\0')
- {
- g_string_append (text, title);
- g_string_append (text, "\n");
- }
-
- if (address[0] != '\0')
- {
- g_string_append (text, address);
- }
-
- if (entry->favicon != NULL)
- favicon = g_object_ref (entry->favicon);
- else
- favicon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
- "text-x-generic-symbolic",
- 16,
- 0, NULL);
- if (favicon != NULL)
- {
- icon_width = gdk_pixbuf_get_width (favicon);
- icon_height = gdk_pixbuf_get_height (favicon);
- }
-
- context = gtk_widget_get_pango_context (widget);
- layout = pango_layout_new (context);
-
- style = gtk_widget_get_style_context (GTK_WIDGET (entry));
- state = gtk_style_context_get_state (style);
-
- gtk_style_context_save (style);
- gtk_style_context_set_state (style, GTK_STATE_FLAG_NORMAL);
- gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL,
- "font", &font_desc, NULL);
- gtk_style_context_restore (style);
-
- metrics = pango_context_get_metrics (context,
- font_desc,
- pango_context_get_language (context));
-
- char_width = pango_font_metrics_get_approximate_digit_width (metrics);
- pango_font_metrics_unref (metrics);
-
- pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);
- pango_layout_set_width (layout, char_width * DRAG_ICON_MAX_WIDTH_CHARS);
- pango_layout_set_text (layout, text->str, text->len);
-
- pango_layout_get_pixel_size (layout, &layout_width, &layout_height);
-
- if (favicon != NULL)
- {
- favicon_offset_x = icon_width + (2 * DRAG_ICON_ICON_PADDING);
- }
-
- surface_width = layout_width + favicon_offset_x +
- (DRAG_ICON_LAYOUT_PADDING * 3);
- surface_height = MAX (layout_height, icon_height) +
- (DRAG_ICON_LAYOUT_PADDING * 2);
-
- surface = gdk_window_create_similar_surface (gtk_widget_get_window (widget),
- CAIRO_CONTENT_COLOR,
- surface_width + 2,
- surface_height + 2);
- cr = cairo_create (surface);
-
- cairo_rectangle (cr, 1, 1, surface_width, surface_height);
- cairo_set_line_width (cr, 1.0);
-
- cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
- cairo_stroke_preserve (cr);
-
- gtk_style_context_get_background_color (style, state, &color);
- gdk_cairo_set_source_rgba (cr, &color);
- cairo_fill (cr);
-
- if (favicon != NULL)
- {
- double x;
- double y;
-
- x = 1 + DRAG_ICON_LAYOUT_PADDING + DRAG_ICON_ICON_PADDING;
- y = (surface_height - icon_height) / 2;
- gdk_cairo_set_source_pixbuf (cr, favicon, x, y);
- cairo_rectangle (cr, x, y, icon_width, icon_height);
- cairo_fill (cr);
- }
-
- cairo_move_to (cr,
- 1 + DRAG_ICON_LAYOUT_PADDING + favicon_offset_x,
- 1 + DRAG_ICON_LAYOUT_PADDING);
- gtk_style_context_get_color (style, state, &color);
- gdk_cairo_set_source_rgba (cr, &color);
- pango_cairo_show_layout (cr, layout);
-
- cairo_destroy (cr);
- g_object_unref (layout);
-
- g_free (address);
- g_free (title);
- g_string_free (text, TRUE);
- g_clear_object (&favicon);
-
- return surface;
+ char *title = NULL, *address = NULL;
+ GString *text;
+ GtkStyleContext *style;
+ const PangoFontDescription *font_desc;
+ cairo_surface_t *surface;
+ PangoContext *context;
+ PangoLayout *layout;
+ PangoFontMetrics *metrics;
+ int surface_height, surface_width;
+ int layout_width, layout_height;
+ int icon_width = 0, icon_height = 0, favicon_offset_x = 0;
+ int char_width;
+ cairo_t *cr;
+ GtkStateFlags state;
+ GdkRGBA color;
+ GdkPixbuf *favicon;
+
+ g_signal_emit (entry, signals[GET_LOCATION], 0, &address);
+ sanitize_location (&address);
+ g_signal_emit (entry, signals[GET_TITLE], 0, &title);
+ if (address == NULL || title == NULL) return NULL;
+
+ /* Compute text */
+ title = g_strstrip (title);
+
+ text = g_string_sized_new (strlen (address) + strlen (title) + 2);
+ if (title[0] != '\0') {
+ g_string_append (text, title);
+ g_string_append (text, "\n");
+ }
+
+ if (address[0] != '\0') {
+ g_string_append (text, address);
+ }
+
+ if (entry->favicon != NULL)
+ favicon = g_object_ref (entry->favicon);
+ else
+ favicon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+ "text-x-generic-symbolic",
+ 16,
+ 0, NULL);
+ if (favicon != NULL) {
+ icon_width = gdk_pixbuf_get_width (favicon);
+ icon_height = gdk_pixbuf_get_height (favicon);
+ }
+
+ context = gtk_widget_get_pango_context (widget);
+ layout = pango_layout_new (context);
+
+ style = gtk_widget_get_style_context (GTK_WIDGET (entry));
+ state = gtk_style_context_get_state (style);
+
+ gtk_style_context_save (style);
+ gtk_style_context_set_state (style, GTK_STATE_FLAG_NORMAL);
+ gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL,
+ "font", &font_desc, NULL);
+ gtk_style_context_restore (style);
+
+ metrics = pango_context_get_metrics (context,
+ font_desc,
+ pango_context_get_language (context));
+
+ char_width = pango_font_metrics_get_approximate_digit_width (metrics);
+ pango_font_metrics_unref (metrics);
+
+ pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);
+ pango_layout_set_width (layout, char_width * DRAG_ICON_MAX_WIDTH_CHARS);
+ pango_layout_set_text (layout, text->str, text->len);
+
+ pango_layout_get_pixel_size (layout, &layout_width, &layout_height);
+
+ if (favicon != NULL) {
+ favicon_offset_x = icon_width + (2 * DRAG_ICON_ICON_PADDING);
+ }
+
+ surface_width = layout_width + favicon_offset_x +
+ (DRAG_ICON_LAYOUT_PADDING * 3);
+ surface_height = MAX (layout_height, icon_height) +
+ (DRAG_ICON_LAYOUT_PADDING * 2);
+
+ surface = gdk_window_create_similar_surface (gtk_widget_get_window (widget),
+ CAIRO_CONTENT_COLOR,
+ surface_width + 2,
+ surface_height + 2);
+ cr = cairo_create (surface);
+
+ cairo_rectangle (cr, 1, 1, surface_width, surface_height);
+ cairo_set_line_width (cr, 1.0);
+
+ cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
+ cairo_stroke_preserve (cr);
+
+ gtk_style_context_get_background_color (style, state, &color);
+ gdk_cairo_set_source_rgba (cr, &color);
+ cairo_fill (cr);
+
+ if (favicon != NULL) {
+ double x;
+ double y;
+
+ x = 1 + DRAG_ICON_LAYOUT_PADDING + DRAG_ICON_ICON_PADDING;
+ y = (surface_height - icon_height) / 2;
+ gdk_cairo_set_source_pixbuf (cr, favicon, x, y);
+ cairo_rectangle (cr, x, y, icon_width, icon_height);
+ cairo_fill (cr);
+ }
+
+ cairo_move_to (cr,
+ 1 + DRAG_ICON_LAYOUT_PADDING + favicon_offset_x,
+ 1 + DRAG_ICON_LAYOUT_PADDING);
+ gtk_style_context_get_color (style, state, &color);
+ gdk_cairo_set_source_rgba (cr, &color);
+ pango_cairo_show_layout (cr, layout);
+
+ cairo_destroy (cr);
+ g_object_unref (layout);
+
+ g_free (address);
+ g_free (title);
+ g_string_free (text, TRUE);
+ g_clear_object (&favicon);
+
+ return surface;
}
static void
-favicon_drag_begin_cb (GtkWidget *widget,
- GdkDragContext *context,
- EphyLocationEntry *lentry)
+favicon_drag_begin_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ EphyLocationEntry *lentry)
{
- cairo_surface_t *surface;
- GtkEntry *entry;
- gint index;
+ cairo_surface_t *surface;
+ GtkEntry *entry;
+ gint index;
- entry = GTK_ENTRY (widget);
+ entry = GTK_ENTRY (widget);
- index = gtk_entry_get_current_icon_drag_source (entry);
- if (index != GTK_ENTRY_ICON_PRIMARY)
- return;
+ index = gtk_entry_get_current_icon_drag_source (entry);
+ if (index != GTK_ENTRY_ICON_PRIMARY)
+ return;
- surface = favicon_create_drag_surface (lentry, widget);
+ surface = favicon_create_drag_surface (lentry, widget);
- if (surface != NULL)
- {
- gtk_drag_set_icon_surface (context, surface);
- cairo_surface_destroy (surface);
- }
+ if (surface != NULL) {
+ gtk_drag_set_icon_surface (context, surface);
+ cairo_surface_destroy (surface);
+ }
}
static void
-favicon_drag_data_get_cb (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint info,
- guint32 time,
- EphyLocationEntry *lentry)
+favicon_drag_data_get_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint32 time,
+ EphyLocationEntry *lentry)
{
- gint index;
- GtkEntry *entry;
+ gint index;
+ GtkEntry *entry;
- g_assert (widget != NULL);
- g_return_if_fail (context != NULL);
+ g_assert (widget != NULL);
+ g_return_if_fail (context != NULL);
- entry = GTK_ENTRY (widget);
+ entry = GTK_ENTRY (widget);
- index = gtk_entry_get_current_icon_drag_source (entry);
- if (index == GTK_ENTRY_ICON_PRIMARY)
- {
- ephy_dnd_drag_data_get (widget, context, selection_data,
- time, lentry, each_url_get_data_binder);
- }
+ index = gtk_entry_get_current_icon_drag_source (entry);
+ if (index == GTK_ENTRY_ICON_PRIMARY) {
+ ephy_dnd_drag_data_get (widget, context, selection_data,
+ time, lentry, each_url_get_data_binder);
+ }
}
static gboolean
-icon_button_press_event_cb (GtkWidget *entry,
- GtkEntryIconPosition position,
- GdkEventButton *event,
- EphyLocationEntry *lentry)
+icon_button_press_event_cb (GtkWidget *entry,
+ GtkEntryIconPosition position,
+ GdkEventButton *event,
+ EphyLocationEntry *lentry)
{
- guint state = event->state & gtk_accelerator_get_default_mod_mask ();
-
- if (event->type == GDK_BUTTON_PRESS &&
- event->button == 1 &&
- state == 0 /* left */)
- {
- if (position == GTK_ENTRY_ICON_PRIMARY)
- {
- GtkWidget *toplevel;
-
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (entry));
- gtk_window_set_focus (GTK_WINDOW (toplevel), entry);
-
- gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
- }
- else
- {
- g_signal_emit (lentry, signals[LOCK_CLICKED], 0);
- }
-
- return TRUE;
- }
-
- return FALSE;
+ guint state = event->state & gtk_accelerator_get_default_mod_mask ();
+
+ if (event->type == GDK_BUTTON_PRESS &&
+ event->button == 1 &&
+ state == 0 /* left */) {
+ if (position == GTK_ENTRY_ICON_PRIMARY) {
+ GtkWidget *toplevel;
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (entry));
+ gtk_window_set_focus (GTK_WINDOW (toplevel), entry);
+
+ gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
+ } else {
+ g_signal_emit (lentry, signals[LOCK_CLICKED], 0);
+ }
+
+ return TRUE;
+ }
+
+ return FALSE;
}
static void
ephy_location_entry_construct_contents (EphyLocationEntry *lentry)
{
- GtkWidget *entry = GTK_WIDGET (lentry);
-
- LOG ("EphyLocationEntry constructing contents %p", lentry);
-
- /* Favicon */
- lentry->drag_targets = gtk_target_list_new (url_drag_types,
- G_N_ELEMENTS (url_drag_types));
- lentry->drag_actions = GDK_ACTION_ASK | GDK_ACTION_COPY | GDK_ACTION_LINK;
-
- gtk_entry_set_icon_drag_source (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_PRIMARY,
- lentry->drag_targets,
- lentry->drag_actions);
-
- gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_PRIMARY,
- _("Drag and drop this icon to create a link to this page"));
-
- gtk_drag_dest_set (entry,
- GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
- url_drag_types,
- G_N_ELEMENTS (url_drag_types),
- GDK_ACTION_MOVE | GDK_ACTION_COPY);
-
- g_object_connect (entry,
- "signal::icon-press", G_CALLBACK (icon_button_press_event_cb), lentry,
- "signal::populate-popup", G_CALLBACK (entry_populate_popup_cb), lentry,
- "signal::key-press-event", G_CALLBACK (entry_key_press_cb), lentry,
- "signal::changed", G_CALLBACK (editable_changed_cb), lentry,
- "signal::drag-motion", G_CALLBACK (entry_drag_motion_cb), lentry,
- "signal::drag-drop", G_CALLBACK (entry_drag_drop_cb), lentry,
- "signal::drag-data-get", G_CALLBACK (favicon_drag_data_get_cb), lentry,
- NULL);
-
- g_signal_connect_after (entry, "key-press-event",
- G_CALLBACK (entry_key_press_after_cb), lentry);
- g_signal_connect_after (entry, "activate",
- G_CALLBACK (entry_activate_after_cb), lentry);
- g_signal_connect_after (entry, "drag-begin",
- G_CALLBACK (favicon_drag_begin_cb), lentry);
+ GtkWidget *entry = GTK_WIDGET (lentry);
+
+ LOG ("EphyLocationEntry constructing contents %p", lentry);
+
+ /* Favicon */
+ lentry->drag_targets = gtk_target_list_new (url_drag_types,
+ G_N_ELEMENTS (url_drag_types));
+ lentry->drag_actions = GDK_ACTION_ASK | GDK_ACTION_COPY | GDK_ACTION_LINK;
+
+ gtk_entry_set_icon_drag_source (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_PRIMARY,
+ lentry->drag_targets,
+ lentry->drag_actions);
+
+ gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_PRIMARY,
+ _("Drag and drop this icon to create a link to this page"));
+
+ gtk_drag_dest_set (entry,
+ GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
+ url_drag_types,
+ G_N_ELEMENTS (url_drag_types),
+ GDK_ACTION_MOVE | GDK_ACTION_COPY);
+
+ g_object_connect (entry,
+ "signal::icon-press", G_CALLBACK (icon_button_press_event_cb), lentry,
+ "signal::populate-popup", G_CALLBACK (entry_populate_popup_cb), lentry,
+ "signal::key-press-event", G_CALLBACK (entry_key_press_cb), lentry,
+ "signal::changed", G_CALLBACK (editable_changed_cb), lentry,
+ "signal::drag-motion", G_CALLBACK (entry_drag_motion_cb), lentry,
+ "signal::drag-drop", G_CALLBACK (entry_drag_drop_cb), lentry,
+ "signal::drag-data-get", G_CALLBACK (favicon_drag_data_get_cb), lentry,
+ NULL);
+
+ g_signal_connect_after (entry, "key-press-event",
+ G_CALLBACK (entry_key_press_after_cb), lentry);
+ g_signal_connect_after (entry, "activate",
+ G_CALLBACK (entry_activate_after_cb), lentry);
+ g_signal_connect_after (entry, "drag-begin",
+ G_CALLBACK (favicon_drag_begin_cb), lentry);
}
static void
ephy_location_entry_init (EphyLocationEntry *le)
{
- LOG ("EphyLocationEntry initialising %p", le);
+ LOG ("EphyLocationEntry initialising %p", le);
- le->user_changed = FALSE;
- le->block_update = FALSE;
- le->saved_text = NULL;
- le->show_favicon = TRUE;
- le->dns_prefetch_handler = 0;
+ le->user_changed = FALSE;
+ le->block_update = FALSE;
+ le->saved_text = NULL;
+ le->show_favicon = TRUE;
+ le->dns_prefetch_handler = 0;
- ephy_location_entry_construct_contents (le);
+ ephy_location_entry_construct_contents (le);
}
GtkWidget *
ephy_location_entry_new (void)
{
- return GTK_WIDGET (g_object_new (EPHY_TYPE_LOCATION_ENTRY, NULL));
+ return GTK_WIDGET (g_object_new (EPHY_TYPE_LOCATION_ENTRY, NULL));
}
#if 0
/* FIXME: Refactor the DNS prefetch, this is a layering violation */
typedef struct {
- SoupURI *uri;
- EphyLocationEntry *entry;
+ SoupURI *uri;
+ EphyLocationEntry *entry;
} PrefetchHelper;
static void
free_prefetch_helper (PrefetchHelper *helper)
{
- soup_uri_free (helper->uri);
- g_object_unref (helper->entry);
- g_slice_free (PrefetchHelper, helper);
+ soup_uri_free (helper->uri);
+ g_object_unref (helper->entry);
+ g_slice_free (PrefetchHelper, helper);
}
static gboolean
do_dns_prefetch (PrefetchHelper *helper)
{
- EphyEmbedShell *shell = ephy_embed_shell_get_default ();
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
- if (helper->uri)
- webkit_web_context_prefetch_dns (ephy_embed_shell_get_web_context (shell), helper->uri->host);
+ if (helper->uri)
+ webkit_web_context_prefetch_dns (ephy_embed_shell_get_web_context (shell), helper->uri->host);
- helper->entry->dns_prefetch_handler = 0;
+ helper->entry->dns_prefetch_handler = 0;
- return FALSE;
+ return FALSE;
}
static void
schedule_dns_prefetch (EphyLocationEntry *entry, guint interval, const gchar *url)
{
- PrefetchHelper *helper;
- SoupURI *uri;
-
- uri = soup_uri_new (url);
- if (!uri || !uri->host) {
- soup_uri_free (uri);
- return;
- }
-
- if (entry->dns_prefetch_handler)
- g_source_remove (entry->dns_prefetch_handler);
-
- helper = g_slice_new0 (PrefetchHelper);
- helper->entry = g_object_ref (entry);
- helper->uri = uri;
-
- entry->dns_prefetch_handler =
- g_timeout_add_full (G_PRIORITY_DEFAULT, interval,
- (GSourceFunc) do_dns_prefetch, helper,
- (GDestroyNotify) free_prefetch_helper);
- g_source_set_name_by_id (entry->dns_prefetch_handler, "[epiphany] do_dns_prefetch");
+ PrefetchHelper *helper;
+ SoupURI *uri;
+
+ uri = soup_uri_new (url);
+ if (!uri || !uri->host) {
+ soup_uri_free (uri);
+ return;
+ }
+
+ if (entry->dns_prefetch_handler)
+ g_source_remove (entry->dns_prefetch_handler);
+
+ helper = g_slice_new0 (PrefetchHelper);
+ helper->entry = g_object_ref (entry);
+ helper->uri = uri;
+
+ entry->dns_prefetch_handler =
+ g_timeout_add_full (G_PRIORITY_DEFAULT, interval,
+ (GSourceFunc)do_dns_prefetch, helper,
+ (GDestroyNotify)free_prefetch_helper);
+ g_source_set_name_by_id (entry->dns_prefetch_handler, "[epiphany] do_dns_prefetch");
}
#endif
static gboolean
-cursor_on_match_cb (GtkEntryCompletion *completion,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- EphyLocationEntry *le)
+cursor_on_match_cb (GtkEntryCompletion *completion,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ EphyLocationEntry *le)
{
- char *url = NULL;
- GtkWidget *entry;
-
- gtk_tree_model_get (model, iter,
- le->url_col,
- &url, -1);
- entry = gtk_entry_completion_get_entry (completion);
-
- /* Prevent the update so we keep the highlight from our input.
- * See textcell_data_func().
- */
- le->block_update = TRUE;
- gtk_entry_set_text (GTK_ENTRY (entry), url);
- gtk_editable_set_position (GTK_EDITABLE (entry), -1);
- le->block_update = FALSE;
+ char *url = NULL;
+ GtkWidget *entry;
+
+ gtk_tree_model_get (model, iter,
+ le->url_col,
+ &url, -1);
+ entry = gtk_entry_completion_get_entry (completion);
+
+ /* Prevent the update so we keep the highlight from our input.
+ * See textcell_data_func().
+ */
+ le->block_update = TRUE;
+ gtk_entry_set_text (GTK_ENTRY (entry), url);
+ gtk_editable_set_position (GTK_EDITABLE (entry), -1);
+ le->block_update = FALSE;
#if 0
/* FIXME: Refactor the DNS prefetch, this is a layering violation */
- schedule_dns_prefetch (le, 250, (const gchar*) url);
+ schedule_dns_prefetch (le, 250, (const gchar *)url);
#endif
- g_free (url);
+ g_free (url);
- return TRUE;
+ return TRUE;
}
static void
-extracell_data_func (GtkCellLayout *cell_layout,
- GtkCellRenderer *cell,
- GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- gpointer data)
+extracell_data_func (GtkCellLayout *cell_layout,
+ GtkCellRenderer *cell,
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ gpointer data)
{
- EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (data);
- gboolean is_bookmark = FALSE;
- GValue visible = { 0, };
-
- gtk_tree_model_get (tree_model, iter,
- entry->extra_col, &is_bookmark,
- -1);
-
- if (is_bookmark)
- g_object_set (cell,
- "icon-name", "user-bookmarks-symbolic",
- NULL);
-
- g_value_init (&visible, G_TYPE_BOOLEAN);
- g_value_set_boolean (&visible, is_bookmark);
- g_object_set_property (G_OBJECT (cell), "visible", &visible);
- g_value_unset (&visible);
+ EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (data);
+ gboolean is_bookmark = FALSE;
+ GValue visible = { 0, };
+
+ gtk_tree_model_get (tree_model, iter,
+ entry->extra_col, &is_bookmark,
+ -1);
+
+ if (is_bookmark)
+ g_object_set (cell,
+ "icon-name", "user-bookmarks-symbolic",
+ NULL);
+
+ g_value_init (&visible, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&visible, is_bookmark);
+ g_object_set_property (G_OBJECT (cell), "visible", &visible);
+ g_value_unset (&visible);
}
/**
@@ -1095,15 +1061,15 @@ extracell_data_func (GtkCellLayout *cell_layout,
*
**/
void
-ephy_location_entry_set_match_func (EphyLocationEntry *entry,
- GtkEntryCompletionMatchFunc match_func,
- gpointer user_data,
- GDestroyNotify notify)
+ephy_location_entry_set_match_func (EphyLocationEntry *entry,
+ GtkEntryCompletionMatchFunc match_func,
+ gpointer user_data,
+ GDestroyNotify notify)
{
- GtkEntryCompletion *completion;
+ GtkEntryCompletion *completion;
- completion = gtk_entry_get_completion (GTK_ENTRY (entry));
- gtk_entry_completion_set_match_func (completion, match_func, user_data, notify);
+ completion = gtk_entry_get_completion (GTK_ENTRY (entry));
+ gtk_entry_completion_set_match_func (completion, match_func, user_data, notify);
}
/**
@@ -1126,64 +1092,64 @@ ephy_location_entry_set_match_func (EphyLocationEntry *entry,
**/
void
ephy_location_entry_set_completion (EphyLocationEntry *entry,
- GtkTreeModel *model,
- guint text_col,
- guint action_col,
- guint keywords_col,
- guint relevance_col,
- guint url_col,
- guint extra_col,
- guint favicon_col)
+ GtkTreeModel *model,
+ guint text_col,
+ guint action_col,
+ guint keywords_col,
+ guint relevance_col,
+ guint url_col,
+ guint extra_col,
+ guint favicon_col)
{
- GtkEntryCompletion *completion;
- GtkCellRenderer *cell;
-
- entry->text_col = text_col;
- entry->action_col = action_col;
- entry->keywords_col = keywords_col;
- entry->relevance_col = relevance_col;
- entry->url_col = url_col;
- entry->extra_col = extra_col;
- entry->favicon_col = favicon_col;
-
- completion = gtk_entry_completion_new ();
- gtk_entry_completion_set_model (completion, model);
- g_signal_connect (completion, "match-selected",
- G_CALLBACK (match_selected_cb), entry);
- g_signal_connect_after (completion, "action-activated",
- G_CALLBACK (action_activated_after_cb), entry);
-
- cell = gtk_cell_renderer_pixbuf_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion),
- cell, FALSE);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion),
- cell, "pixbuf", favicon_col);
-
- /* Pixel-perfect aligment with the location entry favicon
- * (16x16). Consider that this /might/ depend on the theme.
- *
- * The GtkEntryCompletion can not be themed so we work-around
- * that with padding and fixed sizes.
- * For the first cell, this is:
- *
- * ___+++++iiiiiiiiiiiiiiii++__ttt...bbb++++++__
- *
- * _ = widget spacing, can not be handled (3 px)
- * + = padding (5 px) (ICON_PADDING_LEFT)
- * i = the icon (16 px) (ICON_CONTENT_WIDTH)
- * + = padding (2 px) (ICON_PADDING_RIGHT) (cut by the fixed_size)
- * _ = spacing between cells, can not be handled (2 px)
- * t = the text (expands)
- * b = bookmark icon (16 px)
- * + = padding (6 px) (BKMK_PADDING_RIGHT)
- * _ = widget spacing, can not be handled (2 px)
- *
- * Each character is a pixel.
- *
- * The text cell and the bookmark icon cell are much more
- * flexible in its aligment, because they do not have to align
- * with anything in the entry.
- */
+ GtkEntryCompletion *completion;
+ GtkCellRenderer *cell;
+
+ entry->text_col = text_col;
+ entry->action_col = action_col;
+ entry->keywords_col = keywords_col;
+ entry->relevance_col = relevance_col;
+ entry->url_col = url_col;
+ entry->extra_col = extra_col;
+ entry->favicon_col = favicon_col;
+
+ completion = gtk_entry_completion_new ();
+ gtk_entry_completion_set_model (completion, model);
+ g_signal_connect (completion, "match-selected",
+ G_CALLBACK (match_selected_cb), entry);
+ g_signal_connect_after (completion, "action-activated",
+ G_CALLBACK (action_activated_after_cb), entry);
+
+ cell = gtk_cell_renderer_pixbuf_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion),
+ cell, FALSE);
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion),
+ cell, "pixbuf", favicon_col);
+
+ /* Pixel-perfect aligment with the location entry favicon
+ * (16x16). Consider that this /might/ depend on the theme.
+ *
+ * The GtkEntryCompletion can not be themed so we work-around
+ * that with padding and fixed sizes.
+ * For the first cell, this is:
+ *
+ * ___+++++iiiiiiiiiiiiiiii++__ttt...bbb++++++__
+ *
+ * _ = widget spacing, can not be handled (3 px)
+ * + = padding (5 px) (ICON_PADDING_LEFT)
+ * i = the icon (16 px) (ICON_CONTENT_WIDTH)
+ * + = padding (2 px) (ICON_PADDING_RIGHT) (cut by the fixed_size)
+ * _ = spacing between cells, can not be handled (2 px)
+ * t = the text (expands)
+ * b = bookmark icon (16 px)
+ * + = padding (6 px) (BKMK_PADDING_RIGHT)
+ * _ = widget spacing, can not be handled (2 px)
+ *
+ * Each character is a pixel.
+ *
+ * The text cell and the bookmark icon cell are much more
+ * flexible in its aligment, because they do not have to align
+ * with anything in the entry.
+ */
#define ROW_PADDING_VERT 4
@@ -1197,64 +1163,64 @@ ephy_location_entry_set_completion (EphyLocationEntry *entry,
#define BKMK_PADDING_RIGHT 6
- gtk_cell_renderer_set_padding
- (cell, ICON_PADDING_LEFT, ROW_PADDING_VERT);
- gtk_cell_renderer_set_fixed_size
- (cell,
- (ICON_PADDING_LEFT + ICON_CONTENT_WIDTH + ICON_PADDING_RIGHT),
- ICON_CONTENT_HEIGHT);
- gtk_cell_renderer_set_alignment (cell, 0.0, 0.5);
-
- cell = gd_two_lines_renderer_new ();
- g_object_set (cell,
- "ellipsize", PANGO_ELLIPSIZE_END,
- "text-lines", 2,
- NULL);
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion),
- cell, TRUE);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion),
- cell, "text", text_col);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion),
- cell, "line-two", url_col);
-
- /* Pixel-perfect aligment with the text in the location entry.
- * See above.
- */
- gtk_cell_renderer_set_padding
- (cell, TEXT_PADDING_LEFT, ROW_PADDING_VERT);
- gtk_cell_renderer_set_alignment (cell, 0.0, 0.5);
-
- /*
- * As the width of the entry completion is known in advance
- * (as big as the entry you are completing on), we can set
- * any fixed width (the 1 is just this random number here)
- * Since the height is known too, we avoid computing the actual
- * sizes of the cells, which takes a lot of CPU time and does
- * not get used anyway.
- */
- gtk_cell_renderer_set_fixed_size (cell, 1, -1);
- gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (cell), 2);
-
- cell = gtk_cell_renderer_pixbuf_new ();
- g_object_set (cell, "follow-state", TRUE, NULL);
- gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (completion),
- cell, FALSE);
- gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (completion),
- cell, extracell_data_func,
- entry,
- NULL);
-
- /* Pixel-perfect aligment. This just keeps the same margin from
- * the border than the favicon on the other side. See above. */
- gtk_cell_renderer_set_padding
- (cell, BKMK_PADDING_RIGHT, ROW_PADDING_VERT);
-
- g_object_set (completion, "inline-selection", TRUE, NULL);
- g_signal_connect (completion, "cursor-on-match",
- G_CALLBACK (cursor_on_match_cb), entry);
-
- gtk_entry_set_completion (GTK_ENTRY (entry), completion);
- g_object_unref (completion);
+ gtk_cell_renderer_set_padding
+ (cell, ICON_PADDING_LEFT, ROW_PADDING_VERT);
+ gtk_cell_renderer_set_fixed_size
+ (cell,
+ (ICON_PADDING_LEFT + ICON_CONTENT_WIDTH + ICON_PADDING_RIGHT),
+ ICON_CONTENT_HEIGHT);
+ gtk_cell_renderer_set_alignment (cell, 0.0, 0.5);
+
+ cell = gd_two_lines_renderer_new ();
+ g_object_set (cell,
+ "ellipsize", PANGO_ELLIPSIZE_END,
+ "text-lines", 2,
+ NULL);
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion),
+ cell, TRUE);
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion),
+ cell, "text", text_col);
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion),
+ cell, "line-two", url_col);
+
+ /* Pixel-perfect aligment with the text in the location entry.
+ * See above.
+ */
+ gtk_cell_renderer_set_padding
+ (cell, TEXT_PADDING_LEFT, ROW_PADDING_VERT);
+ gtk_cell_renderer_set_alignment (cell, 0.0, 0.5);
+
+ /*
+ * As the width of the entry completion is known in advance
+ * (as big as the entry you are completing on), we can set
+ * any fixed width (the 1 is just this random number here)
+ * Since the height is known too, we avoid computing the actual
+ * sizes of the cells, which takes a lot of CPU time and does
+ * not get used anyway.
+ */
+ gtk_cell_renderer_set_fixed_size (cell, 1, -1);
+ gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (cell), 2);
+
+ cell = gtk_cell_renderer_pixbuf_new ();
+ g_object_set (cell, "follow-state", TRUE, NULL);
+ gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (completion),
+ cell, FALSE);
+ gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (completion),
+ cell, extracell_data_func,
+ entry,
+ NULL);
+
+ /* Pixel-perfect aligment. This just keeps the same margin from
+ * the border than the favicon on the other side. See above. */
+ gtk_cell_renderer_set_padding
+ (cell, BKMK_PADDING_RIGHT, ROW_PADDING_VERT);
+
+ g_object_set (completion, "inline-selection", TRUE, NULL);
+ g_signal_connect (completion, "cursor-on-match",
+ G_CALLBACK (cursor_on_match_cb), entry);
+
+ gtk_entry_set_completion (GTK_ENTRY (entry), completion);
+ g_object_unref (completion);
}
/**
@@ -1266,76 +1232,70 @@ ephy_location_entry_set_completion (EphyLocationEntry *entry,
**/
void
ephy_location_entry_set_location (EphyLocationEntry *entry,
- const char *address)
+ const char *address)
{
- GtkWidget *widget = GTK_WIDGET (entry);
- GtkClipboard *clipboard;
- const char *text;
- char *effective_text = NULL, *selection = NULL;
- int start, end;
-
- /* Setting a new text will clear the clipboard. This makes it impossible
- * to copy&paste from the location entry of one tab into another tab, see
- * bug #155824. So we save the selection iff the clipboard was owned by
- * the location entry.
- */
- if (gtk_widget_get_realized (widget))
- {
- clipboard = gtk_widget_get_clipboard (widget,
- GDK_SELECTION_PRIMARY);
- g_return_if_fail (clipboard != NULL);
-
- if (gtk_clipboard_get_owner (clipboard) == G_OBJECT (widget) &&
- gtk_editable_get_selection_bounds (GTK_EDITABLE (widget),
- &start, &end))
- {
- selection = gtk_editable_get_chars (GTK_EDITABLE (widget),
- start, end);
- }
- }
-
- if (address != NULL)
- {
- if (g_str_has_prefix (address, EPHY_ABOUT_SCHEME))
- effective_text = g_strdup_printf ("about:%s",
- address + strlen (EPHY_ABOUT_SCHEME) + 1);
- text = address;
- gtk_entry_set_icon_drag_source (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_PRIMARY,
- entry->drag_targets,
- entry->drag_actions);
- }
- else
- {
- text = "";
- gtk_entry_set_icon_drag_source (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_PRIMARY,
- NULL,
- GDK_ACTION_DEFAULT);
- }
-
- /* First record the new hash, then update the entry text */
- entry->hash = g_str_hash (effective_text ? effective_text : text);
-
- entry->block_update = TRUE;
- gtk_entry_set_text (GTK_ENTRY (widget), effective_text ? effective_text : text);
- entry->block_update = FALSE;
- g_free (effective_text);
-
- /* We need to call update_address_state() here, as the 'changed' signal
- * may not get called if the user has typed in the exact correct url */
- update_address_state (entry);
- update_favicon (entry);
-
- /* Now restore the selection.
- * Note that it's not owned by the entry anymore!
- */
- if (selection != NULL)
- {
- gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_PRIMARY),
- selection, strlen (selection));
- g_free (selection);
- }
+ GtkWidget *widget = GTK_WIDGET (entry);
+ GtkClipboard *clipboard;
+ const char *text;
+ char *effective_text = NULL, *selection = NULL;
+ int start, end;
+
+ /* Setting a new text will clear the clipboard. This makes it impossible
+ * to copy&paste from the location entry of one tab into another tab, see
+ * bug #155824. So we save the selection iff the clipboard was owned by
+ * the location entry.
+ */
+ if (gtk_widget_get_realized (widget)) {
+ clipboard = gtk_widget_get_clipboard (widget,
+ GDK_SELECTION_PRIMARY);
+ g_return_if_fail (clipboard != NULL);
+
+ if (gtk_clipboard_get_owner (clipboard) == G_OBJECT (widget) &&
+ gtk_editable_get_selection_bounds (GTK_EDITABLE (widget),
+ &start, &end)) {
+ selection = gtk_editable_get_chars (GTK_EDITABLE (widget),
+ start, end);
+ }
+ }
+
+ if (address != NULL) {
+ if (g_str_has_prefix (address, EPHY_ABOUT_SCHEME))
+ effective_text = g_strdup_printf ("about:%s",
+ address + strlen (EPHY_ABOUT_SCHEME) + 1);
+ text = address;
+ gtk_entry_set_icon_drag_source (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_PRIMARY,
+ entry->drag_targets,
+ entry->drag_actions);
+ } else {
+ text = "";
+ gtk_entry_set_icon_drag_source (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_PRIMARY,
+ NULL,
+ GDK_ACTION_DEFAULT);
+ }
+
+ /* First record the new hash, then update the entry text */
+ entry->hash = g_str_hash (effective_text ? effective_text : text);
+
+ entry->block_update = TRUE;
+ gtk_entry_set_text (GTK_ENTRY (widget), effective_text ? effective_text : text);
+ entry->block_update = FALSE;
+ g_free (effective_text);
+
+ /* We need to call update_address_state() here, as the 'changed' signal
+ * may not get called if the user has typed in the exact correct url */
+ update_address_state (entry);
+ update_favicon (entry);
+
+ /* Now restore the selection.
+ * Note that it's not owned by the entry anymore!
+ */
+ if (selection != NULL) {
+ gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_PRIMARY),
+ selection, strlen (selection));
+ g_free (selection);
+ }
}
/**
@@ -1351,7 +1311,7 @@ ephy_location_entry_set_location (EphyLocationEntry *entry,
gboolean
ephy_location_entry_get_can_undo (EphyLocationEntry *entry)
{
- return entry->user_changed;
+ return entry->user_changed;
}
/**
@@ -1367,7 +1327,7 @@ ephy_location_entry_get_can_undo (EphyLocationEntry *entry)
gboolean
ephy_location_entry_get_can_redo (EphyLocationEntry *entry)
{
- return entry->can_redo;
+ return entry->can_redo;
}
/**
@@ -1383,39 +1343,38 @@ ephy_location_entry_get_can_redo (EphyLocationEntry *entry)
const char *
ephy_location_entry_get_location (EphyLocationEntry *entry)
{
- return gtk_entry_get_text (GTK_ENTRY (entry));
+ return gtk_entry_get_text (GTK_ENTRY (entry));
}
static gboolean
ephy_location_entry_reset_internal (EphyLocationEntry *entry,
- gboolean notify)
+ gboolean notify)
{
- const char *text, *old_text;
- char *url = NULL;
- gboolean retval;
+ const char *text, *old_text;
+ char *url = NULL;
+ gboolean retval;
- g_signal_emit (entry, signals[GET_LOCATION], 0, &url);
- text = url != NULL ? url : "";
- old_text = gtk_entry_get_text (GTK_ENTRY (entry));
- old_text = old_text != NULL ? old_text : "";
+ g_signal_emit (entry, signals[GET_LOCATION], 0, &url);
+ text = url != NULL ? url : "";
+ old_text = gtk_entry_get_text (GTK_ENTRY (entry));
+ old_text = old_text != NULL ? old_text : "";
- g_free (entry->saved_text);
- entry->saved_text = g_strdup (old_text);
- entry->can_redo = TRUE;
+ g_free (entry->saved_text);
+ entry->saved_text = g_strdup (old_text);
+ entry->can_redo = TRUE;
- retval = g_str_hash (text) != g_str_hash (old_text);
+ retval = g_str_hash (text) != g_str_hash (old_text);
- ephy_location_entry_set_location (entry, text);
- g_free (url);
+ ephy_location_entry_set_location (entry, text);
+ g_free (url);
- if (notify)
- {
- g_signal_emit (entry, signals[USER_CHANGED], 0);
- }
+ if (notify) {
+ g_signal_emit (entry, signals[USER_CHANGED], 0);
+ }
- entry->user_changed = FALSE;
+ entry->user_changed = FALSE;
- return retval;
+ return retval;
}
/**
@@ -1428,9 +1387,9 @@ ephy_location_entry_reset_internal (EphyLocationEntry *entry,
void
ephy_location_entry_undo_reset (EphyLocationEntry *entry)
{
- gtk_entry_set_text (GTK_ENTRY (entry), entry->saved_text);
- entry->can_redo = FALSE;
- entry->user_changed = TRUE;
+ gtk_entry_set_text (GTK_ENTRY (entry), entry->saved_text);
+ entry->can_redo = FALSE;
+ entry->user_changed = TRUE;
}
/**
@@ -1447,7 +1406,7 @@ ephy_location_entry_undo_reset (EphyLocationEntry *entry)
gboolean
ephy_location_entry_reset (EphyLocationEntry *entry)
{
- return ephy_location_entry_reset_internal (entry, FALSE);
+ return ephy_location_entry_reset_internal (entry, FALSE);
}
/**
@@ -1461,14 +1420,14 @@ ephy_location_entry_reset (EphyLocationEntry *entry)
void
ephy_location_entry_activate (EphyLocationEntry *entry)
{
- GtkWidget *toplevel, *widget = GTK_WIDGET (entry);
+ GtkWidget *toplevel, *widget = GTK_WIDGET (entry);
- toplevel = gtk_widget_get_toplevel (widget);
+ toplevel = gtk_widget_get_toplevel (widget);
- gtk_editable_select_region (GTK_EDITABLE (entry),
- 0, -1);
- gtk_window_set_focus (GTK_WINDOW (toplevel),
- widget);
+ gtk_editable_select_region (GTK_EDITABLE (entry),
+ 0, -1);
+ gtk_window_set_focus (GTK_WINDOW (toplevel),
+ widget);
}
/**
@@ -1481,27 +1440,26 @@ ephy_location_entry_activate (EphyLocationEntry *entry)
**/
void
ephy_location_entry_set_favicon (EphyLocationEntry *entry,
- GdkPixbuf *pixbuf)
+ GdkPixbuf *pixbuf)
{
- if (entry->favicon != NULL)
- {
- g_object_unref (entry->favicon);
- }
+ if (entry->favicon != NULL) {
+ g_object_unref (entry->favicon);
+ }
- entry->favicon = pixbuf ? g_object_ref (pixbuf) : NULL;
+ entry->favicon = pixbuf ? g_object_ref (pixbuf) : NULL;
- update_favicon (entry);
+ update_favicon (entry);
}
void
ephy_location_entry_set_show_favicon (EphyLocationEntry *entry,
- gboolean show_favicon)
+ gboolean show_favicon)
{
- g_return_if_fail (EPHY_IS_LOCATION_ENTRY (entry));
+ g_return_if_fail (EPHY_IS_LOCATION_ENTRY (entry));
- entry->show_favicon = show_favicon != FALSE;
+ entry->show_favicon = show_favicon != FALSE;
- update_favicon (entry);
+ update_favicon (entry);
}
/**
@@ -1514,17 +1472,17 @@ ephy_location_entry_set_show_favicon (EphyLocationEntry *entry,
**/
void
ephy_location_entry_set_security_level (EphyLocationEntry *entry,
- EphySecurityLevel security_level)
+ EphySecurityLevel security_level)
{
- const char *icon_name;
+ const char *icon_name;
- g_return_if_fail (EPHY_IS_LOCATION_ENTRY (entry));
+ g_return_if_fail (EPHY_IS_LOCATION_ENTRY (entry));
- icon_name = ephy_security_level_to_icon_name (security_level);
- gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_SECONDARY,
- icon_name);
+ icon_name = ephy_security_level_to_icon_name (security_level);
+ gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ icon_name);
}
/**
@@ -1537,11 +1495,11 @@ ephy_location_entry_set_security_level (EphyLocationEntry *entry,
**/
void
ephy_location_entry_set_lock_tooltip (EphyLocationEntry *entry,
- const char *tooltip)
+ const char *tooltip)
{
- gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_SECONDARY,
- tooltip);
+ gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ tooltip);
}
/**
@@ -1557,5 +1515,5 @@ ephy_location_entry_set_lock_tooltip (EphyLocationEntry *entry,
GSList *
ephy_location_entry_get_search_terms (EphyLocationEntry *entry)
{
- return entry->search_terms;
+ return entry->search_terms;
}
diff --git a/lib/widgets/ephy-middle-clickable-button.c b/lib/widgets/ephy-middle-clickable-button.c
index aa7ad5526..c9bf47807 100644
--- a/lib/widgets/ephy-middle-clickable-button.c
+++ b/lib/widgets/ephy-middle-clickable-button.c
@@ -20,16 +20,15 @@
#include "config.h"
#include "ephy-middle-clickable-button.h"
-struct _EphyMiddleClickableButton
-{
+struct _EphyMiddleClickableButton {
GtkButton parent_instance;
};
G_DEFINE_TYPE (EphyMiddleClickableButton, ephy_middle_clickable_button, GTK_TYPE_BUTTON)
-static gboolean
-ephy_middle_clickable_button_handle_event (GtkWidget * widget,
- GdkEventButton * event)
+static gboolean
+ephy_middle_clickable_button_handle_event (GtkWidget *widget,
+ GdkEventButton *event)
{
gboolean ret;
int actual_button;
@@ -44,7 +43,7 @@ ephy_middle_clickable_button_handle_event (GtkWidget * widget,
ret = widget_class->button_press_event (widget, event);
else
ret = widget_class->button_release_event (widget, event);
-
+
event->button = actual_button;
return ret;
diff --git a/lib/widgets/ephy-node-view.c b/lib/widgets/ephy-node-view.c
index efc2213f3..f9361f5dc 100644
--- a/lib/widgets/ephy-node-view.c
+++ b/lib/widgets/ephy-node-view.c
@@ -1,5 +1,5 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* Copyright © 2002 Jorn Baayen <jorn@nl.linux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -36,63 +36,60 @@
* elements. It implements drag and dropping.
*/
-struct _EphyNodeView
-{
- GtkTreeView parent_instance;
+struct _EphyNodeView {
+ GtkTreeView parent_instance;
- EphyNode *root;
+ EphyNode *root;
- EphyTreeModelNode *nodemodel;
- GtkTreeModel *filtermodel;
- GtkTreeModel *sortmodel;
- GtkCellRenderer *editable_renderer;
- GtkTreeViewColumn *editable_column;
- int editable_node_column;
- int toggle_column;
+ EphyTreeModelNode *nodemodel;
+ GtkTreeModel *filtermodel;
+ GtkTreeModel *sortmodel;
+ GtkCellRenderer *editable_renderer;
+ GtkTreeViewColumn *editable_column;
+ int editable_node_column;
+ int toggle_column;
- EphyNodeFilter *filter;
+ EphyNodeFilter *filter;
- GtkTargetList *drag_targets;
+ GtkTargetList *drag_targets;
- int sort_column;
- GtkSortType sort_type;
- guint priority_prop_id;
- int priority_column;
+ int sort_column;
+ GtkSortType sort_type;
+ guint priority_prop_id;
+ int priority_column;
- EphyNode *edited_node;
- gboolean remove_if_cancelled;
- int editable_property;
+ EphyNode *edited_node;
+ gboolean remove_if_cancelled;
+ int editable_property;
- gboolean drag_started;
- int drag_button;
- int drag_x;
- int drag_y;
- GtkTargetList *source_target_list;
+ gboolean drag_started;
+ int drag_button;
+ int drag_x;
+ int drag_y;
+ GtkTargetList *source_target_list;
- gboolean drop_occurred;
- gboolean have_drag_data;
- GtkSelectionData *drag_data;
- guint scroll_id;
+ gboolean drop_occurred;
+ gboolean have_drag_data;
+ GtkSelectionData *drag_data;
+ guint scroll_id;
- guint changing_selection : 1;
+ guint changing_selection : 1;
};
-enum
-{
- NODE_TOGGLED,
- NODE_ACTIVATED,
- NODE_SELECTED,
- NODE_DROPPED,
- NODE_MIDDLE_CLICKED,
- LAST_SIGNAL
+enum {
+ NODE_TOGGLED,
+ NODE_ACTIVATED,
+ NODE_SELECTED,
+ NODE_DROPPED,
+ NODE_MIDDLE_CLICKED,
+ LAST_SIGNAL
};
-enum
-{
- PROP_0,
- PROP_ROOT,
- PROP_FILTER,
- LAST_PROP
+enum {
+ PROP_0,
+ PROP_ROOT,
+ PROP_FILTER,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
@@ -106,321 +103,297 @@ G_DEFINE_TYPE (EphyNodeView, ephy_node_view, GTK_TYPE_TREE_VIEW)
static void
ephy_node_view_finalize (GObject *object)
{
- EphyNodeView *view = EPHY_NODE_VIEW (object);
+ EphyNodeView *view = EPHY_NODE_VIEW (object);
- g_object_unref (view->sortmodel);
- g_object_unref (view->filtermodel);
- g_object_unref (view->nodemodel);
+ g_object_unref (view->sortmodel);
+ g_object_unref (view->filtermodel);
+ g_object_unref (view->nodemodel);
- if (view->source_target_list)
- {
- gtk_target_list_unref (view->source_target_list);
- }
+ if (view->source_target_list) {
+ gtk_target_list_unref (view->source_target_list);
+ }
- if (view->drag_targets)
- {
- gtk_target_list_unref (view->drag_targets);
- }
+ if (view->drag_targets) {
+ gtk_target_list_unref (view->drag_targets);
+ }
- G_OBJECT_CLASS (ephy_node_view_parent_class)->finalize (object);
+ G_OBJECT_CLASS (ephy_node_view_parent_class)->finalize (object);
}
static EphyNode *
get_node_from_path (EphyNodeView *view, GtkTreePath *path)
{
- EphyNode *node;
- GtkTreeIter iter, iter2, iter3;
+ EphyNode *node;
+ GtkTreeIter iter, iter2, iter3;
- if (path == NULL) return NULL;
+ if (path == NULL) return NULL;
- gtk_tree_model_get_iter (view->sortmodel, &iter, path);
- gtk_tree_model_sort_convert_iter_to_child_iter
- (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
+ gtk_tree_model_get_iter (view->sortmodel, &iter, path);
+ gtk_tree_model_sort_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
- if (iter2.stamp == 0) {
- return NULL;
- }
- gtk_tree_model_filter_convert_iter_to_child_iter
- (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter3, &iter2);
+ if (iter2.stamp == 0) {
+ return NULL;
+ }
+ gtk_tree_model_filter_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter3, &iter2);
- node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter3);
+ node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter3);
- return node;
+ return node;
}
static void
gtk_tree_view_vertical_autoscroll (GtkTreeView *tree_view)
{
- GdkRectangle visible_rect;
- GtkAdjustment *vadjustment;
- GdkWindow *window;
- int y;
- int offset;
- float value;
-
- window = gtk_tree_view_get_bin_window (tree_view);
- vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (tree_view));
-
- gdk_window_get_device_position (window,
- gdk_device_manager_get_client_pointer (
- gdk_display_get_device_manager (
- gtk_widget_get_display (GTK_WIDGET (tree_view)))),
- NULL, &y, NULL);
-
- y += gtk_adjustment_get_value (vadjustment);
-
- gtk_tree_view_get_visible_rect (tree_view, &visible_rect);
-
- offset = y - (visible_rect.y + 2 * AUTO_SCROLL_MARGIN);
- if (offset > 0)
- {
- offset = y - (visible_rect.y + visible_rect.height - 2 * AUTO_SCROLL_MARGIN);
- if (offset < 0)
- {
- return;
- }
- }
-
- value = CLAMP (gtk_adjustment_get_value (vadjustment) + offset, 0.0,
- gtk_adjustment_get_upper (vadjustment) - gtk_adjustment_get_page_size (vadjustment));
- gtk_adjustment_set_value (vadjustment, value);
+ GdkRectangle visible_rect;
+ GtkAdjustment *vadjustment;
+ GdkWindow *window;
+ int y;
+ int offset;
+ float value;
+
+ window = gtk_tree_view_get_bin_window (tree_view);
+ vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (tree_view));
+
+ gdk_window_get_device_position (window,
+ gdk_device_manager_get_client_pointer (
+ gdk_display_get_device_manager (
+ gtk_widget_get_display (GTK_WIDGET (tree_view)))),
+ NULL, &y, NULL);
+
+ y += gtk_adjustment_get_value (vadjustment);
+
+ gtk_tree_view_get_visible_rect (tree_view, &visible_rect);
+
+ offset = y - (visible_rect.y + 2 * AUTO_SCROLL_MARGIN);
+ if (offset > 0) {
+ offset = y - (visible_rect.y + visible_rect.height - 2 * AUTO_SCROLL_MARGIN);
+ if (offset < 0) {
+ return;
+ }
+ }
+
+ value = CLAMP (gtk_adjustment_get_value (vadjustment) + offset, 0.0,
+ gtk_adjustment_get_upper (vadjustment) - gtk_adjustment_get_page_size (vadjustment));
+ gtk_adjustment_set_value (vadjustment, value);
}
static int
scroll_timeout (gpointer data)
{
- GtkTreeView *tree_view = GTK_TREE_VIEW (data);
+ GtkTreeView *tree_view = GTK_TREE_VIEW (data);
- gtk_tree_view_vertical_autoscroll (tree_view);
+ gtk_tree_view_vertical_autoscroll (tree_view);
- return TRUE;
+ return TRUE;
}
static void
remove_scroll_timeout (EphyNodeView *view)
{
- if (view->scroll_id)
- {
- g_source_remove (view->scroll_id);
- view->scroll_id = 0;
- }
+ if (view->scroll_id) {
+ g_source_remove (view->scroll_id);
+ view->scroll_id = 0;
+ }
}
static void
set_drag_dest_row (EphyNodeView *view,
- GtkTreePath *path)
-{
- if (path)
- {
- gtk_tree_view_set_drag_dest_row
- (GTK_TREE_VIEW (view),
- path,
- GTK_TREE_VIEW_DROP_INTO_OR_BEFORE);
- }
- else
- {
- gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (view),
- NULL,
- 0);
- }
+ GtkTreePath *path)
+{
+ if (path) {
+ gtk_tree_view_set_drag_dest_row
+ (GTK_TREE_VIEW (view),
+ path,
+ GTK_TREE_VIEW_DROP_INTO_OR_BEFORE);
+ } else {
+ gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (view),
+ NULL,
+ 0);
+ }
}
static void
clear_drag_dest_row (EphyNodeView *view)
{
- gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (view), NULL, 0);
+ gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (view), NULL, 0);
}
static void
-get_drag_data (EphyNodeView *view,
- GdkDragContext *context,
- guint32 time)
+get_drag_data (EphyNodeView *view,
+ GdkDragContext *context,
+ guint32 time)
{
- GdkAtom target;
+ GdkAtom target;
- target = gtk_drag_dest_find_target (GTK_WIDGET (view),
- context,
- NULL);
+ target = gtk_drag_dest_find_target (GTK_WIDGET (view),
+ context,
+ NULL);
- gtk_drag_get_data (GTK_WIDGET (view),
- context, target, time);
+ gtk_drag_get_data (GTK_WIDGET (view),
+ context, target, time);
}
static void
free_drag_data (EphyNodeView *view)
{
- view->have_drag_data = FALSE;
+ view->have_drag_data = FALSE;
- if (view->drag_data)
- {
- gtk_selection_data_free (view->drag_data);
- view->drag_data = NULL;
- }
+ if (view->drag_data) {
+ gtk_selection_data_free (view->drag_data);
+ view->drag_data = NULL;
+ }
}
static gboolean
-drag_motion_cb (GtkWidget *widget,
- GdkDragContext *context,
- int x,
- int y,
- guint32 time,
- EphyNodeView *view)
-{
- EphyNode *node;
- GdkAtom target;
- GtkTreePath *path;
- GtkTreeViewDropPosition pos;
- guint action = 0;
- int priority;
-
- gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget),
- x, y, &path, &pos);
-
- if (!view->have_drag_data)
- {
- get_drag_data (view, context, time);
- }
-
- target = gtk_drag_dest_find_target (widget, context, NULL);
- node = get_node_from_path (view, path);
-
- if (target != GDK_NONE && node != NULL)
- {
- priority = ephy_node_get_property_int (node, view->priority_prop_id);
-
- if (priority != EPHY_NODE_VIEW_ALL_PRIORITY &&
- priority != EPHY_NODE_VIEW_SPECIAL_PRIORITY &&
- ephy_node_get_is_drag_source (node))
- {
- action = gdk_drag_context_get_suggested_action (context);
- }
- }
-
- if (action)
- {
- set_drag_dest_row (view, path);
- }
- else
- {
- clear_drag_dest_row (view);
- }
-
- if (path)
- {
- gtk_tree_path_free (path);
- }
-
- if (view->scroll_id == 0)
- {
- view->scroll_id =
- g_timeout_add (150,
- scroll_timeout,
- GTK_TREE_VIEW (view));
- g_source_set_name_by_id (view->scroll_id, "[epiphany] scroll_timeout");
- }
-
- gdk_drag_status (context, action, time);
-
- return TRUE;
+drag_motion_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ int x,
+ int y,
+ guint32 time,
+ EphyNodeView *view)
+{
+ EphyNode *node;
+ GdkAtom target;
+ GtkTreePath *path;
+ GtkTreeViewDropPosition pos;
+ guint action = 0;
+ int priority;
+
+ gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget),
+ x, y, &path, &pos);
+
+ if (!view->have_drag_data) {
+ get_drag_data (view, context, time);
+ }
+
+ target = gtk_drag_dest_find_target (widget, context, NULL);
+ node = get_node_from_path (view, path);
+
+ if (target != GDK_NONE && node != NULL) {
+ priority = ephy_node_get_property_int (node, view->priority_prop_id);
+
+ if (priority != EPHY_NODE_VIEW_ALL_PRIORITY &&
+ priority != EPHY_NODE_VIEW_SPECIAL_PRIORITY &&
+ ephy_node_get_is_drag_source (node)) {
+ action = gdk_drag_context_get_suggested_action (context);
+ }
+ }
+
+ if (action) {
+ set_drag_dest_row (view, path);
+ } else {
+ clear_drag_dest_row (view);
+ }
+
+ if (path) {
+ gtk_tree_path_free (path);
+ }
+
+ if (view->scroll_id == 0) {
+ view->scroll_id =
+ g_timeout_add (150,
+ scroll_timeout,
+ GTK_TREE_VIEW (view));
+ g_source_set_name_by_id (view->scroll_id, "[epiphany] scroll_timeout");
+ }
+
+ gdk_drag_status (context, action, time);
+
+ return TRUE;
}
static void
-drag_leave_cb (GtkWidget *widget,
- GdkDragContext *context,
- guint32 time,
- EphyNodeView *view)
+drag_leave_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ guint32 time,
+ EphyNodeView *view)
{
- clear_drag_dest_row (view);
+ clear_drag_dest_row (view);
- free_drag_data (view);
+ free_drag_data (view);
- remove_scroll_timeout (view);
+ remove_scroll_timeout (view);
}
static void
-drag_data_received_cb (GtkWidget *widget,
- GdkDragContext *context,
- int x,
- int y,
- GtkSelectionData *selection_data,
- guint info,
- guint32 time,
- EphyNodeView *view)
-{
- GtkTreeViewDropPosition pos;
-
- /* x and y here are valid only on drop ! */
-
- if ((gtk_selection_data_get_length (selection_data) <= 0) ||
- (gtk_selection_data_get_data (selection_data) == NULL))
- {
- return;
- }
-
- /* appease GtkTreeView by preventing its drag_data_receive
- * from being called */
- g_signal_stop_emission_by_name (view, "drag_data_received");
-
- if (!view->have_drag_data)
- {
- view->have_drag_data = TRUE;
- view->drag_data = gtk_selection_data_copy (selection_data);
- }
-
- if (view->drop_occurred)
- {
- EphyNode *node;
- char **uris;
- gboolean success = FALSE;
- GtkTreePath *path;
-
- if (gtk_tree_view_get_dest_row_at_pos
- (GTK_TREE_VIEW (widget), x, y, &path, &pos) == FALSE)
- {
- return;
- }
-
- node = get_node_from_path (view, path);
- if (node == NULL) return;
-
- uris = gtk_selection_data_get_uris (selection_data);
-
- if (uris != NULL && ephy_node_get_is_drag_dest (node))
- {
- /* FIXME fill success */
- g_signal_emit (G_OBJECT (view),
- ephy_node_view_signals[NODE_DROPPED], 0,
- node, uris);
- g_strfreev (uris);
-
- }
-
- view->drop_occurred = FALSE;
- free_drag_data (view);
- gtk_drag_finish (context, success, FALSE, time);
-
- if (path)
- {
- gtk_tree_path_free (path);
- }
- }
+drag_data_received_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ int x,
+ int y,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint32 time,
+ EphyNodeView *view)
+{
+ GtkTreeViewDropPosition pos;
+
+ /* x and y here are valid only on drop ! */
+
+ if ((gtk_selection_data_get_length (selection_data) <= 0) ||
+ (gtk_selection_data_get_data (selection_data) == NULL)) {
+ return;
+ }
+
+ /* appease GtkTreeView by preventing its drag_data_receive
+ * from being called */
+ g_signal_stop_emission_by_name (view, "drag_data_received");
+
+ if (!view->have_drag_data) {
+ view->have_drag_data = TRUE;
+ view->drag_data = gtk_selection_data_copy (selection_data);
+ }
+
+ if (view->drop_occurred) {
+ EphyNode *node;
+ char **uris;
+ gboolean success = FALSE;
+ GtkTreePath *path;
+
+ if (gtk_tree_view_get_dest_row_at_pos
+ (GTK_TREE_VIEW (widget), x, y, &path, &pos) == FALSE) {
+ return;
+ }
+
+ node = get_node_from_path (view, path);
+ if (node == NULL) return;
+
+ uris = gtk_selection_data_get_uris (selection_data);
+
+ if (uris != NULL && ephy_node_get_is_drag_dest (node)) {
+ /* FIXME fill success */
+ g_signal_emit (G_OBJECT (view),
+ ephy_node_view_signals[NODE_DROPPED], 0,
+ node, uris);
+ g_strfreev (uris);
+ }
+
+ view->drop_occurred = FALSE;
+ free_drag_data (view);
+ gtk_drag_finish (context, success, FALSE, time);
+
+ if (path) {
+ gtk_tree_path_free (path);
+ }
+ }
}
static gboolean
-drag_drop_cb (GtkWidget *widget,
- GdkDragContext *context,
- int x,
- int y,
- guint32 time,
- EphyNodeView *view)
+drag_drop_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ int x,
+ int y,
+ guint32 time,
+ EphyNodeView *view)
{
- view->drop_occurred = TRUE;
+ view->drop_occurred = TRUE;
- get_drag_data (view, context, time);
- remove_scroll_timeout (view);
- clear_drag_dest_row (view);
+ get_drag_data (view, context, time);
+ remove_scroll_timeout (view);
+ clear_drag_dest_row (view);
- return TRUE;
+ return TRUE;
}
/**
@@ -433,526 +406,490 @@ drag_drop_cb (GtkWidget *widget,
*
**/
void
-ephy_node_view_enable_drag_dest (EphyNodeView *view,
- const GtkTargetEntry *types,
- int n_types)
+ephy_node_view_enable_drag_dest (EphyNodeView *view,
+ const GtkTargetEntry *types,
+ int n_types)
{
- GtkWidget *treeview;
+ GtkWidget *treeview;
- g_return_if_fail (view != NULL);
+ g_return_if_fail (view != NULL);
- treeview = GTK_WIDGET (view);
+ treeview = GTK_WIDGET (view);
- gtk_drag_dest_set (GTK_WIDGET (treeview),
- 0, types, n_types,
- GDK_ACTION_COPY);
- view->drag_targets = gtk_target_list_new (types, n_types);
+ gtk_drag_dest_set (GTK_WIDGET (treeview),
+ 0, types, n_types,
+ GDK_ACTION_COPY);
+ view->drag_targets = gtk_target_list_new (types, n_types);
- g_signal_connect (treeview, "drag_data_received",
- G_CALLBACK (drag_data_received_cb), view);
- g_signal_connect (treeview, "drag_drop",
- G_CALLBACK (drag_drop_cb), view);
- g_signal_connect (treeview, "drag_motion",
- G_CALLBACK (drag_motion_cb), view);
- g_signal_connect (treeview, "drag_leave",
- G_CALLBACK (drag_leave_cb), view);
+ g_signal_connect (treeview, "drag_data_received",
+ G_CALLBACK (drag_data_received_cb), view);
+ g_signal_connect (treeview, "drag_drop",
+ G_CALLBACK (drag_drop_cb), view);
+ g_signal_connect (treeview, "drag_motion",
+ G_CALLBACK (drag_motion_cb), view);
+ g_signal_connect (treeview, "drag_leave",
+ G_CALLBACK (drag_leave_cb), view);
}
static void
filter_changed_cb (EphyNodeFilter *filter,
- EphyNodeView *view)
+ EphyNodeView *view)
{
- GtkWidget *window;
- GdkWindow *gdk_window;
+ GtkWidget *window;
+ GdkWindow *gdk_window;
- g_return_if_fail (EPHY_IS_NODE_VIEW (view));
+ g_return_if_fail (EPHY_IS_NODE_VIEW (view));
- window = gtk_widget_get_toplevel (GTK_WIDGET (view));
- gdk_window = gtk_widget_get_window (window);
+ window = gtk_widget_get_toplevel (GTK_WIDGET (view));
+ gdk_window = gtk_widget_get_window (window);
- if (window != NULL && gdk_window != NULL)
- {
- /* nice busy cursor */
- GdkCursor *cursor;
+ if (window != NULL && gdk_window != NULL) {
+ /* nice busy cursor */
+ GdkCursor *cursor;
- cursor = gdk_cursor_new (GDK_WATCH);
- gdk_window_set_cursor (gdk_window, cursor);
- g_object_unref (cursor);
+ cursor = gdk_cursor_new (GDK_WATCH);
+ gdk_window_set_cursor (gdk_window, cursor);
+ g_object_unref (cursor);
- gdk_flush ();
+ gdk_flush ();
- gdk_window_set_cursor (gdk_window, NULL);
+ gdk_window_set_cursor (gdk_window, NULL);
- /* no flush: this will cause the cursor to be reset
- * only when the UI is free again */
- }
+ /* no flush: this will cause the cursor to be reset
+ * only when the UI is free again */
+ }
- gtk_tree_model_filter_refilter
- (GTK_TREE_MODEL_FILTER (view->filtermodel));
+ gtk_tree_model_filter_refilter
+ (GTK_TREE_MODEL_FILTER (view->filtermodel));
}
static void
ephy_node_view_selection_changed_cb (GtkTreeSelection *selection,
- EphyNodeView *view)
+ EphyNodeView *view)
{
- GList *list;
- EphyNode *node = NULL;
+ GList *list;
+ EphyNode *node = NULL;
- /* Work around bug #346662 */
- if (view->changing_selection) return;
+ /* Work around bug #346662 */
+ if (view->changing_selection) return;
- list = ephy_node_view_get_selection (view);
- if (list)
- {
- node = list->data;
- }
- g_list_free (list);
+ list = ephy_node_view_get_selection (view);
+ if (list) {
+ node = list->data;
+ }
+ g_list_free (list);
- g_signal_emit (G_OBJECT (view), ephy_node_view_signals[NODE_SELECTED], 0, node);
+ g_signal_emit (G_OBJECT (view), ephy_node_view_signals[NODE_SELECTED], 0, node);
}
static void
-ephy_node_view_row_activated_cb (GtkTreeView *treeview,
- GtkTreePath *path,
- GtkTreeViewColumn *column,
- EphyNodeView *view)
+ephy_node_view_row_activated_cb (GtkTreeView *treeview,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ EphyNodeView *view)
{
- GtkTreeIter iter, iter2;
- EphyNode *node;
+ GtkTreeIter iter, iter2;
+ EphyNode *node;
- gtk_tree_model_get_iter (view->sortmodel, &iter, path);
- gtk_tree_model_sort_convert_iter_to_child_iter
- (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
- gtk_tree_model_filter_convert_iter_to_child_iter
- (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter, &iter2);
+ gtk_tree_model_get_iter (view->sortmodel, &iter, path);
+ gtk_tree_model_sort_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
+ gtk_tree_model_filter_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter, &iter2);
- node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter);
+ node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter);
- g_signal_emit (G_OBJECT (view), ephy_node_view_signals[NODE_ACTIVATED], 0, node);
+ g_signal_emit (G_OBJECT (view), ephy_node_view_signals[NODE_ACTIVATED], 0, node);
}
static void
path_toggled (GtkTreeModel *dummy_model, GtkTreePath *path,
- GtkTreeIter *dummy, gpointer data)
-{
- EphyNodeView *view = EPHY_NODE_VIEW (data);
- gboolean checked;
- EphyNode *node;
- GtkTreeIter iter, iter2;
- GValue value = {0, };
-
- gtk_tree_model_get_iter (view->sortmodel, &iter, path);
- gtk_tree_model_sort_convert_iter_to_child_iter
- (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
- gtk_tree_model_filter_convert_iter_to_child_iter
- (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter, &iter2);
-
- node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter);
- gtk_tree_model_get_value (GTK_TREE_MODEL (view->nodemodel), &iter,
- view->toggle_column, &value);
- checked = !g_value_get_boolean (&value);
-
- g_signal_emit (G_OBJECT (view), ephy_node_view_signals[NODE_TOGGLED], 0,
- node, checked);
+ GtkTreeIter *dummy, gpointer data)
+{
+ EphyNodeView *view = EPHY_NODE_VIEW (data);
+ gboolean checked;
+ EphyNode *node;
+ GtkTreeIter iter, iter2;
+ GValue value = { 0, };
+
+ gtk_tree_model_get_iter (view->sortmodel, &iter, path);
+ gtk_tree_model_sort_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
+ gtk_tree_model_filter_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter, &iter2);
+
+ node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter);
+ gtk_tree_model_get_value (GTK_TREE_MODEL (view->nodemodel), &iter,
+ view->toggle_column, &value);
+ checked = !g_value_get_boolean (&value);
+
+ g_signal_emit (G_OBJECT (view), ephy_node_view_signals[NODE_TOGGLED], 0,
+ node, checked);
}
static EphyNode *
-process_middle_click (GtkTreePath *path,
- EphyNodeView *view)
+process_middle_click (GtkTreePath *path,
+ EphyNodeView *view)
{
- EphyNode *node;
- GtkTreeIter iter, iter2;
+ EphyNode *node;
+ GtkTreeIter iter, iter2;
- gtk_tree_model_get_iter (view->sortmodel, &iter, path);
- gtk_tree_model_sort_convert_iter_to_child_iter
- (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
- gtk_tree_model_filter_convert_iter_to_child_iter
- (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter, &iter2);
+ gtk_tree_model_get_iter (view->sortmodel, &iter, path);
+ gtk_tree_model_sort_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
+ gtk_tree_model_filter_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter, &iter2);
- node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter);
+ node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter);
- return node;
+ return node;
}
static gboolean
-ephy_node_view_key_press_cb (GtkTreeView *treeview,
- GdkEventKey *event,
- EphyNodeView *view)
-{
- gboolean handled = FALSE;
-
- if (event->keyval == GDK_KEY_space ||
- event->keyval == GDK_KEY_Return ||
- event->keyval == GDK_KEY_KP_Enter ||
- event->keyval == GDK_KEY_ISO_Enter)
- {
- if (view->toggle_column >= 0)
- {
- GtkTreeSelection *selection;
-
- selection = gtk_tree_view_get_selection (treeview);
- gtk_tree_selection_selected_foreach (selection, path_toggled, view);
- handled = TRUE;
- }
- }
-
- return handled;
+ephy_node_view_key_press_cb (GtkTreeView *treeview,
+ GdkEventKey *event,
+ EphyNodeView *view)
+{
+ gboolean handled = FALSE;
+
+ if (event->keyval == GDK_KEY_space ||
+ event->keyval == GDK_KEY_Return ||
+ event->keyval == GDK_KEY_KP_Enter ||
+ event->keyval == GDK_KEY_ISO_Enter) {
+ if (view->toggle_column >= 0) {
+ GtkTreeSelection *selection;
+
+ selection = gtk_tree_view_get_selection (treeview);
+ gtk_tree_selection_selected_foreach (selection, path_toggled, view);
+ handled = TRUE;
+ }
+ }
+
+ return handled;
}
static void
selection_foreach (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer data)
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer data)
{
- GList **list;
+ GList **list;
- list = (GList**)data;
+ list = (GList **)data;
- *list = g_list_prepend (*list, gtk_tree_row_reference_new (model, path));
+ *list = g_list_prepend (*list, gtk_tree_row_reference_new (model, path));
}
static GList *
get_selection_refs (GtkTreeView *tree_view)
{
- GtkTreeSelection *selection;
- GList *ref_list = NULL;
-
- selection = gtk_tree_view_get_selection (tree_view);
- gtk_tree_selection_selected_foreach (selection,
- selection_foreach,
- &ref_list);
- ref_list = g_list_reverse (ref_list);
- return ref_list;
+ GtkTreeSelection *selection;
+ GList *ref_list = NULL;
+
+ selection = gtk_tree_view_get_selection (tree_view);
+ gtk_tree_selection_selected_foreach (selection,
+ selection_foreach,
+ &ref_list);
+ ref_list = g_list_reverse (ref_list);
+ return ref_list;
}
static void
ref_list_free (GList *ref_list)
{
- g_list_foreach (ref_list, (GFunc) gtk_tree_row_reference_free, NULL);
- g_list_free (ref_list);
+ g_list_foreach (ref_list, (GFunc)gtk_tree_row_reference_free, NULL);
+ g_list_free (ref_list);
}
static void
stop_drag_check (EphyNodeView *view)
{
- view->drag_button = 0;
+ view->drag_button = 0;
}
static gboolean
button_event_modifies_selection (GdkEventButton *event)
{
- return (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) != 0;
+ return (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) != 0;
}
static void
-did_not_drag (EphyNodeView *view,
- GdkEventButton *event)
-{
- GtkTreeView *tree_view;
- GtkTreeSelection *selection;
- GtkTreePath *path;
-
- tree_view = GTK_TREE_VIEW (view);
- selection = gtk_tree_view_get_selection (tree_view);
-
- if (gtk_tree_view_get_path_at_pos (tree_view, event->x, event->y,
- &path, NULL, NULL, NULL))
- {
- if((event->button == 1 || event->button == 2) &&
- gtk_tree_selection_path_is_selected (selection, path) &&
- !button_event_modifies_selection (event))
- {
- if (gtk_tree_selection_get_mode (selection) == GTK_SELECTION_MULTIPLE)
- {
- gtk_tree_selection_unselect_all (selection);
- }
-
- gtk_tree_selection_select_path (selection, path);
- }
-
- gtk_tree_path_free (path);
- }
+did_not_drag (EphyNodeView *view,
+ GdkEventButton *event)
+{
+ GtkTreeView *tree_view;
+ GtkTreeSelection *selection;
+ GtkTreePath *path;
+
+ tree_view = GTK_TREE_VIEW (view);
+ selection = gtk_tree_view_get_selection (tree_view);
+
+ if (gtk_tree_view_get_path_at_pos (tree_view, event->x, event->y,
+ &path, NULL, NULL, NULL)) {
+ if ((event->button == 1 || event->button == 2) &&
+ gtk_tree_selection_path_is_selected (selection, path) &&
+ !button_event_modifies_selection (event)) {
+ if (gtk_tree_selection_get_mode (selection) == GTK_SELECTION_MULTIPLE) {
+ gtk_tree_selection_unselect_all (selection);
+ }
+
+ gtk_tree_selection_select_path (selection, path);
+ }
+
+ gtk_tree_path_free (path);
+ }
}
-typedef struct
-{
- EphyNodeView *view;
- gboolean result;
+typedef struct {
+ EphyNodeView *view;
+ gboolean result;
}
ForeachData;
static void
check_node_is_drag_source (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- ForeachData *data)
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ ForeachData *data)
{
- EphyNode *node;
+ EphyNode *node;
- node = get_node_from_path (data->view, path);
- data->result = data->result &&
- node != NULL &&
- ephy_node_get_is_drag_source (node);
+ node = get_node_from_path (data->view, path);
+ data->result = data->result &&
+ node != NULL &&
+ ephy_node_get_is_drag_source (node);
}
static gboolean
can_drag_selection (EphyNodeView *view)
{
- GtkTreeView *tree_view = GTK_TREE_VIEW (view);
- GtkTreeSelection *selection;
- ForeachData data = { view, TRUE };
+ GtkTreeView *tree_view = GTK_TREE_VIEW (view);
+ GtkTreeSelection *selection;
+ ForeachData data = { view, TRUE };
- selection = gtk_tree_view_get_selection (tree_view);
- gtk_tree_selection_selected_foreach (selection,
- (GtkTreeSelectionForeachFunc) check_node_is_drag_source,
- &data);
+ selection = gtk_tree_view_get_selection (tree_view);
+ gtk_tree_selection_selected_foreach (selection,
+ (GtkTreeSelectionForeachFunc)check_node_is_drag_source,
+ &data);
- return data.result;
+ return data.result;
}
static void
-drag_data_get_cb (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint info,
- guint time)
+drag_data_get_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint time)
{
- GtkTreeView *tree_view;
- GtkTreeModel *model;
- GList *ref_list;
+ GtkTreeView *tree_view;
+ GtkTreeModel *model;
+ GList *ref_list;
- tree_view = GTK_TREE_VIEW (widget);
+ tree_view = GTK_TREE_VIEW (widget);
- model = gtk_tree_view_get_model (tree_view);
- g_return_if_fail (model != NULL);
+ model = gtk_tree_view_get_model (tree_view);
+ g_return_if_fail (model != NULL);
- ref_list = g_object_get_data (G_OBJECT (context), "drag-info");
+ ref_list = g_object_get_data (G_OBJECT (context), "drag-info");
- if (ref_list == NULL)
- {
- return;
- }
+ if (ref_list == NULL) {
+ return;
+ }
- if (EGG_IS_TREE_MULTI_DRAG_SOURCE (model))
- {
- egg_tree_multi_drag_source_drag_data_get (EGG_TREE_MULTI_DRAG_SOURCE (model),
- ref_list,
- selection_data);
- }
+ if (EGG_IS_TREE_MULTI_DRAG_SOURCE (model)) {
+ egg_tree_multi_drag_source_drag_data_get (EGG_TREE_MULTI_DRAG_SOURCE (model),
+ ref_list,
+ selection_data);
+ }
}
static gboolean
-button_release_cb (GtkWidget *widget,
- GdkEventButton *event,
- EphyNodeView *view)
-{
- if ((int)event->button == view->drag_button)
- {
- stop_drag_check (view);
- if (!view->drag_started)
- {
- did_not_drag (view, event);
- return TRUE;
- }
- view->drag_started = FALSE;
- }
- return FALSE;
+button_release_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ EphyNodeView *view)
+{
+ if ((int)event->button == view->drag_button) {
+ stop_drag_check (view);
+ if (!view->drag_started) {
+ did_not_drag (view, event);
+ return TRUE;
+ }
+ view->drag_started = FALSE;
+ }
+ return FALSE;
}
static gboolean
-motion_notify_cb (GtkWidget *widget,
- GdkEventMotion *event,
- EphyNodeView *view)
-{
- GdkDragContext *context;
- GList *ref_list;
-
- if (event->window != gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget)))
- {
- return FALSE;
- }
- if (view->drag_button != 0)
- {
- if (gtk_drag_check_threshold (widget, view->drag_x,
- view->drag_y, event->x,
- event->y)
- && can_drag_selection (view))
- {
- context = gtk_drag_begin
- (widget, view->source_target_list,
- GDK_ACTION_ASK | GDK_ACTION_COPY | GDK_ACTION_LINK,
- view->drag_button,
- (GdkEvent*)event);
-
- stop_drag_check (view);
- view->drag_started = TRUE;
-
- ref_list = get_selection_refs (GTK_TREE_VIEW (widget));
- g_object_set_data_full (G_OBJECT (context),
- "drag-info",
- ref_list,
- (GDestroyNotify)ref_list_free);
-
- gtk_drag_set_icon_default (context);
- }
- }
-
- return TRUE;
+motion_notify_cb (GtkWidget *widget,
+ GdkEventMotion *event,
+ EphyNodeView *view)
+{
+ GdkDragContext *context;
+ GList *ref_list;
+
+ if (event->window != gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget))) {
+ return FALSE;
+ }
+ if (view->drag_button != 0) {
+ if (gtk_drag_check_threshold (widget, view->drag_x,
+ view->drag_y, event->x,
+ event->y)
+ && can_drag_selection (view)) {
+ context = gtk_drag_begin
+ (widget, view->source_target_list,
+ GDK_ACTION_ASK | GDK_ACTION_COPY | GDK_ACTION_LINK,
+ view->drag_button,
+ (GdkEvent *)event);
+
+ stop_drag_check (view);
+ view->drag_started = TRUE;
+
+ ref_list = get_selection_refs (GTK_TREE_VIEW (widget));
+ g_object_set_data_full (G_OBJECT (context),
+ "drag-info",
+ ref_list,
+ (GDestroyNotify)ref_list_free);
+
+ gtk_drag_set_icon_default (context);
+ }
+ }
+
+ return TRUE;
}
static gboolean
-ephy_node_view_button_press_cb (GtkWidget *treeview,
- GdkEventButton *event,
- EphyNodeView *view)
-{
- GtkTreePath *path = NULL;
- GtkTreeSelection *selection;
- gboolean call_parent = TRUE, path_is_selected;
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
-
- if (event->window != gtk_tree_view_get_bin_window (GTK_TREE_VIEW (treeview)))
- {
- return GTK_WIDGET_CLASS (ephy_node_view_parent_class)->button_press_event (treeview, event);
- }
-
- if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (treeview),
- event->x,
- event->y,
- &path,
- NULL, NULL, NULL))
- {
- path_is_selected = gtk_tree_selection_path_is_selected (selection, path);
-
- if (!gtk_widget_is_focus (GTK_WIDGET (treeview)))
- {
- gtk_widget_grab_focus (GTK_WIDGET (treeview));
- }
-
- if (event->button == 3 && path_is_selected)
- {
- call_parent = FALSE;
- }
-
- if(!button_event_modifies_selection (event) &&
- event->button == 1 && path_is_selected &&
- gtk_tree_selection_count_selected_rows (selection) > 1)
- {
- call_parent = FALSE;
- }
-
- if (call_parent)
- {
- GTK_WIDGET_CLASS (ephy_node_view_parent_class)->button_press_event (treeview, event);
- }
-
- if (event->button == 3)
- {
- gboolean retval;
-
- g_signal_emit_by_name (view, "popup_menu", &retval);
- }
- else if (event->button == 2)
- {
- EphyNode *clicked_node;
-
- clicked_node = process_middle_click (path, view);
- g_signal_emit (G_OBJECT (view),
- ephy_node_view_signals[NODE_MIDDLE_CLICKED], 0, clicked_node);
- }
- else if (event->button == 1)
- {
- if (view->toggle_column >= 0)
- {
- path_toggled (NULL, path, NULL, view);
- }
- else
- {
- view->drag_started = FALSE;
- view->drag_button = event->button;
- view->drag_x = event->x;
- view->drag_y = event->y;
- }
- }
-
- gtk_tree_path_free (path);
- }
- else
- {
- gtk_tree_selection_unselect_all (selection);
- }
-
- return TRUE;
+ephy_node_view_button_press_cb (GtkWidget *treeview,
+ GdkEventButton *event,
+ EphyNodeView *view)
+{
+ GtkTreePath *path = NULL;
+ GtkTreeSelection *selection;
+ gboolean call_parent = TRUE, path_is_selected;
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
+
+ if (event->window != gtk_tree_view_get_bin_window (GTK_TREE_VIEW (treeview))) {
+ return GTK_WIDGET_CLASS (ephy_node_view_parent_class)->button_press_event (treeview, event);
+ }
+
+ if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (treeview),
+ event->x,
+ event->y,
+ &path,
+ NULL, NULL, NULL)) {
+ path_is_selected = gtk_tree_selection_path_is_selected (selection, path);
+
+ if (!gtk_widget_is_focus (GTK_WIDGET (treeview))) {
+ gtk_widget_grab_focus (GTK_WIDGET (treeview));
+ }
+
+ if (event->button == 3 && path_is_selected) {
+ call_parent = FALSE;
+ }
+
+ if (!button_event_modifies_selection (event) &&
+ event->button == 1 && path_is_selected &&
+ gtk_tree_selection_count_selected_rows (selection) > 1) {
+ call_parent = FALSE;
+ }
+
+ if (call_parent) {
+ GTK_WIDGET_CLASS (ephy_node_view_parent_class)->button_press_event (treeview, event);
+ }
+
+ if (event->button == 3) {
+ gboolean retval;
+
+ g_signal_emit_by_name (view, "popup_menu", &retval);
+ } else if (event->button == 2) {
+ EphyNode *clicked_node;
+
+ clicked_node = process_middle_click (path, view);
+ g_signal_emit (G_OBJECT (view),
+ ephy_node_view_signals[NODE_MIDDLE_CLICKED], 0, clicked_node);
+ } else if (event->button == 1) {
+ if (view->toggle_column >= 0) {
+ path_toggled (NULL, path, NULL, view);
+ } else {
+ view->drag_started = FALSE;
+ view->drag_button = event->button;
+ view->drag_x = event->x;
+ view->drag_y = event->y;
+ }
+ }
+
+ gtk_tree_path_free (path);
+ } else {
+ gtk_tree_selection_unselect_all (selection);
+ }
+
+ return TRUE;
}
static void
ephy_node_view_set_filter (EphyNodeView *view, EphyNodeFilter *filter)
{
- gboolean refilter = FALSE;
-
- if (view->filter)
- {
- g_object_unref (view->filter);
- refilter = TRUE;
- }
-
- if (filter)
- {
- view->filter = g_object_ref (filter);
- g_signal_connect_object (G_OBJECT (view->filter),
- "changed", G_CALLBACK (filter_changed_cb),
- G_OBJECT (view), 0);
- }
-
- if (refilter)
- {
- gtk_tree_model_filter_refilter
- (GTK_TREE_MODEL_FILTER (view->filtermodel));
- }
+ gboolean refilter = FALSE;
+
+ if (view->filter) {
+ g_object_unref (view->filter);
+ refilter = TRUE;
+ }
+
+ if (filter) {
+ view->filter = g_object_ref (filter);
+ g_signal_connect_object (G_OBJECT (view->filter),
+ "changed", G_CALLBACK (filter_changed_cb),
+ G_OBJECT (view), 0);
+ }
+
+ if (refilter) {
+ gtk_tree_model_filter_refilter
+ (GTK_TREE_MODEL_FILTER (view->filtermodel));
+ }
}
static void
-ephy_node_view_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EphyNodeView *view = EPHY_NODE_VIEW (object);
-
- switch (prop_id)
- {
- case PROP_ROOT:
- view->root = g_value_get_pointer (value);
- break;
- case PROP_FILTER:
- ephy_node_view_set_filter (view, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ephy_node_view_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EphyNodeView *view = EPHY_NODE_VIEW (object);
+
+ switch (prop_id) {
+ case PROP_ROOT:
+ view->root = g_value_get_pointer (value);
+ break;
+ case PROP_FILTER:
+ ephy_node_view_set_filter (view, g_value_get_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-ephy_node_view_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EphyNodeView *view = EPHY_NODE_VIEW (object);
-
- switch (prop_id)
- {
- case PROP_ROOT:
- g_value_set_pointer (value, view->root);
- break;
- case PROP_FILTER:
- g_value_set_object (value, view->filter);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ephy_node_view_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EphyNodeView *view = EPHY_NODE_VIEW (object);
+
+ switch (prop_id) {
+ case PROP_ROOT:
+ g_value_set_pointer (value, view->root);
+ break;
+ case PROP_FILTER:
+ g_value_set_object (value, view->filter);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
/**
@@ -966,232 +903,201 @@ ephy_node_view_get_property (GObject *object,
* Returns: a new #EphyNodeView as a #GtkWidget
**/
GtkWidget *
-ephy_node_view_new (EphyNode *root,
- EphyNodeFilter *filter)
+ephy_node_view_new (EphyNode *root,
+ EphyNodeFilter *filter)
{
- EphyNodeView *view;
+ EphyNodeView *view;
- view = EPHY_NODE_VIEW (g_object_new (EPHY_TYPE_NODE_VIEW,
- "filter", filter,
- "root", root,
- NULL));
+ view = EPHY_NODE_VIEW (g_object_new (EPHY_TYPE_NODE_VIEW,
+ "filter", filter,
+ "root", root,
+ NULL));
- return GTK_WIDGET (view);
+ return GTK_WIDGET (view);
}
static void
cell_renderer_edited (GtkCellRendererText *cell,
- const char *path_str,
- const char *new_text,
- EphyNodeView *view)
+ const char *path_str,
+ const char *new_text,
+ EphyNodeView *view)
{
- GtkTreePath *path;
- GtkTreeIter iter, iter2;
- EphyNode *node;
+ GtkTreePath *path;
+ GtkTreeIter iter, iter2;
+ EphyNode *node;
- view->edited_node = NULL;
+ view->edited_node = NULL;
- g_object_set (G_OBJECT (view->editable_renderer),
- "editable", FALSE,
- NULL);
+ g_object_set (G_OBJECT (view->editable_renderer),
+ "editable", FALSE,
+ NULL);
- path = gtk_tree_path_new_from_string (path_str);
- gtk_tree_model_get_iter (view->sortmodel, &iter, path);
- gtk_tree_model_sort_convert_iter_to_child_iter
- (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
- gtk_tree_model_filter_convert_iter_to_child_iter
- (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter, &iter2);
- node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter);
+ path = gtk_tree_path_new_from_string (path_str);
+ gtk_tree_model_get_iter (view->sortmodel, &iter, path);
+ gtk_tree_model_sort_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
+ gtk_tree_model_filter_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter, &iter2);
+ node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter);
- ephy_node_set_property_string (node, view->editable_property,
- new_text);
+ ephy_node_set_property_string (node, view->editable_property,
+ new_text);
- gtk_tree_path_free (path);
+ gtk_tree_path_free (path);
- view->remove_if_cancelled = FALSE;
+ view->remove_if_cancelled = FALSE;
}
static void
renderer_editing_canceled_cb (GtkCellRendererText *cell,
- EphyNodeView *view)
+ EphyNodeView *view)
{
- if (view->remove_if_cancelled)
- {
- ephy_node_unref (view->edited_node);
- view->remove_if_cancelled = FALSE;
- }
+ if (view->remove_if_cancelled) {
+ ephy_node_unref (view->edited_node);
+ view->remove_if_cancelled = FALSE;
+ }
}
static inline int
compare_string_values (const GValue *a_value, const GValue *b_value)
{
- const char *str1, *str2;
- int retval;
-
- str1 = g_value_get_string (a_value);
- str2 = g_value_get_string (b_value);
-
- if (str1 == NULL)
- {
- retval = -1;
- }
- else if (str2 == NULL)
- {
- retval = 1;
- }
- else
- {
- char *str_a;
- char *str_b;
-
- str_a = g_utf8_casefold (str1, -1);
- str_b = g_utf8_casefold (str2, -1);
- retval = g_utf8_collate (str_a, str_b);
- g_free (str_a);
- g_free (str_b);
- }
-
- return retval;
+ const char *str1, *str2;
+ int retval;
+
+ str1 = g_value_get_string (a_value);
+ str2 = g_value_get_string (b_value);
+
+ if (str1 == NULL) {
+ retval = -1;
+ } else if (str2 == NULL) {
+ retval = 1;
+ } else {
+ char *str_a;
+ char *str_b;
+
+ str_a = g_utf8_casefold (str1, -1);
+ str_b = g_utf8_casefold (str2, -1);
+ retval = g_utf8_collate (str_a, str_b);
+ g_free (str_a);
+ g_free (str_b);
+ }
+
+ return retval;
}
static int
ephy_node_view_sort_func (GtkTreeModel *model,
- GtkTreeIter *a,
- GtkTreeIter *b,
- EphyNodeView *view)
-{
- GValue a_value = {0, };
- GValue b_value = {0, };
- int p_column, column, retval = 0;
- GtkSortType sort_type;
-
- g_return_val_if_fail (model != NULL, 0);
- g_return_val_if_fail (view != NULL, 0);
-
- p_column = view->priority_column;
- column = view->sort_column;
- sort_type = view->sort_type;
-
- if (p_column >= 0)
- {
- gtk_tree_model_get_value (model, a, p_column, &a_value);
- gtk_tree_model_get_value (model, b, p_column, &b_value);
-
- if (g_value_get_int (&a_value) < g_value_get_int (&b_value))
- {
- retval = -1;
- }
- else if (g_value_get_int (&a_value) == g_value_get_int (&b_value))
- {
- retval = 0;
- }
- else
- {
- retval = 1;
- }
-
- g_value_unset (&a_value);
- g_value_unset (&b_value);
- }
-
-
- if (retval == 0)
- {
- GType type;
-
- type = gtk_tree_model_get_column_type (model, column);
-
- gtk_tree_model_get_value (model, a, column, &a_value);
- gtk_tree_model_get_value (model, b, column, &b_value);
-
- switch (G_TYPE_FUNDAMENTAL (type))
- {
- case G_TYPE_STRING:
- retval = compare_string_values (&a_value, &b_value);
- break;
- case G_TYPE_INT:
- if (g_value_get_int (&a_value) < g_value_get_int (&b_value))
- {
- retval = -1;
- }
- else if (g_value_get_int (&a_value) == g_value_get_int (&b_value))
- {
- retval = 0;
- }
- else
- {
- retval = 1;
- }
- break;
- case G_TYPE_BOOLEAN:
- if (g_value_get_boolean (&a_value) < g_value_get_boolean (&b_value))
- {
- retval = -1;
- }
- else if (g_value_get_boolean (&a_value) == g_value_get_boolean (&b_value))
- {
- retval = 0;
- }
- else
- {
- retval = 1;
- }
- break;
- default:
- g_warning ("Attempting to sort on invalid type %s\n", g_type_name (type));
- break;
- }
-
- g_value_unset (&a_value);
- g_value_unset (&b_value);
- }
-
- if (sort_type == GTK_SORT_DESCENDING)
- {
- if (retval > 0)
- {
- retval = -1;
- }
- else if (retval < 0)
- {
- retval = 1;
- }
- }
-
- return retval;
+ GtkTreeIter *a,
+ GtkTreeIter *b,
+ EphyNodeView *view)
+{
+ GValue a_value = { 0, };
+ GValue b_value = { 0, };
+ int p_column, column, retval = 0;
+ GtkSortType sort_type;
+
+ g_return_val_if_fail (model != NULL, 0);
+ g_return_val_if_fail (view != NULL, 0);
+
+ p_column = view->priority_column;
+ column = view->sort_column;
+ sort_type = view->sort_type;
+
+ if (p_column >= 0) {
+ gtk_tree_model_get_value (model, a, p_column, &a_value);
+ gtk_tree_model_get_value (model, b, p_column, &b_value);
+
+ if (g_value_get_int (&a_value) < g_value_get_int (&b_value)) {
+ retval = -1;
+ } else if (g_value_get_int (&a_value) == g_value_get_int (&b_value)) {
+ retval = 0;
+ } else {
+ retval = 1;
+ }
+
+ g_value_unset (&a_value);
+ g_value_unset (&b_value);
+ }
+
+
+ if (retval == 0) {
+ GType type;
+
+ type = gtk_tree_model_get_column_type (model, column);
+
+ gtk_tree_model_get_value (model, a, column, &a_value);
+ gtk_tree_model_get_value (model, b, column, &b_value);
+
+ switch (G_TYPE_FUNDAMENTAL (type)) {
+ case G_TYPE_STRING:
+ retval = compare_string_values (&a_value, &b_value);
+ break;
+ case G_TYPE_INT:
+ if (g_value_get_int (&a_value) < g_value_get_int (&b_value)) {
+ retval = -1;
+ } else if (g_value_get_int (&a_value) == g_value_get_int (&b_value)) {
+ retval = 0;
+ } else {
+ retval = 1;
+ }
+ break;
+ case G_TYPE_BOOLEAN:
+ if (g_value_get_boolean (&a_value) < g_value_get_boolean (&b_value)) {
+ retval = -1;
+ } else if (g_value_get_boolean (&a_value) == g_value_get_boolean (&b_value)) {
+ retval = 0;
+ } else {
+ retval = 1;
+ }
+ break;
+ default:
+ g_warning ("Attempting to sort on invalid type %s\n", g_type_name (type));
+ break;
+ }
+
+ g_value_unset (&a_value);
+ g_value_unset (&b_value);
+ }
+
+ if (sort_type == GTK_SORT_DESCENDING) {
+ if (retval > 0) {
+ retval = -1;
+ } else if (retval < 0) {
+ retval = 1;
+ }
+ }
+
+ return retval;
}
static void
provide_priority (EphyNode *node, GValue *value, EphyNodeView *view)
{
- int priority;
-
- g_value_init (value, G_TYPE_INT);
- priority = ephy_node_get_property_int (node, view->priority_prop_id);
- if (priority == EPHY_NODE_VIEW_ALL_PRIORITY ||
- priority == EPHY_NODE_VIEW_SPECIAL_PRIORITY)
- g_value_set_int (value, priority);
- else
- g_value_set_int (value, EPHY_NODE_VIEW_NORMAL_PRIORITY);
+ int priority;
+
+ g_value_init (value, G_TYPE_INT);
+ priority = ephy_node_get_property_int (node, view->priority_prop_id);
+ if (priority == EPHY_NODE_VIEW_ALL_PRIORITY ||
+ priority == EPHY_NODE_VIEW_SPECIAL_PRIORITY)
+ g_value_set_int (value, priority);
+ else
+ g_value_set_int (value, EPHY_NODE_VIEW_NORMAL_PRIORITY);
}
static void
provide_text_weight (EphyNode *node, GValue *value, EphyNodeView *view)
{
- int priority;
-
- g_value_init (value, G_TYPE_INT);
- priority = ephy_node_get_property_int
- (node, view->priority_prop_id);
- if (priority == EPHY_NODE_VIEW_ALL_PRIORITY ||
- priority == EPHY_NODE_VIEW_SPECIAL_PRIORITY)
- {
- g_value_set_int (value, PANGO_WEIGHT_BOLD);
- }
- else
- {
- g_value_set_int (value, PANGO_WEIGHT_NORMAL);
- }
+ int priority;
+
+ g_value_init (value, G_TYPE_INT);
+ priority = ephy_node_get_property_int
+ (node, view->priority_prop_id);
+ if (priority == EPHY_NODE_VIEW_ALL_PRIORITY ||
+ priority == EPHY_NODE_VIEW_SPECIAL_PRIORITY) {
+ g_value_set_int (value, PANGO_WEIGHT_BOLD);
+ } else {
+ g_value_set_int (value, PANGO_WEIGHT_NORMAL);
+ }
}
/**
@@ -1208,26 +1114,23 @@ provide_text_weight (EphyNode *node, GValue *value, EphyNodeView *view)
* Returns: the id of the new column
**/
int
-ephy_node_view_add_data_column (EphyNodeView *view,
- GType value_type,
- guint prop_id,
- EphyTreeModelNodeValueFunc func,
- gpointer data)
-{
- int column;
-
- if (func)
- {
- column = ephy_tree_model_node_add_func_column
- (view->nodemodel, value_type, func, data);
- }
- else
- {
- column = ephy_tree_model_node_add_prop_column
- (view->nodemodel, value_type, prop_id);
- }
-
- return column;
+ephy_node_view_add_data_column (EphyNodeView *view,
+ GType value_type,
+ guint prop_id,
+ EphyTreeModelNodeValueFunc func,
+ gpointer data)
+{
+ int column;
+
+ if (func) {
+ column = ephy_tree_model_node_add_func_column
+ (view->nodemodel, value_type, func, data);
+ } else {
+ column = ephy_tree_model_node_add_prop_column
+ (view->nodemodel, value_type, prop_id);
+ }
+
+ return column;
}
/**
@@ -1247,103 +1150,97 @@ ephy_node_view_add_data_column (EphyNodeView *view,
* Returns: the id of the new column
**/
int
-ephy_node_view_add_column_full (EphyNodeView *view,
- const char *title,
- GType value_type,
- guint prop_id,
- EphyNodeViewFlags flags,
- EphyTreeModelNodeValueFunc func,
- gpointer user_data,
- EphyTreeModelNodeValueFunc icon_func,
- GtkTreeViewColumn **ret)
-{
- GtkTreeViewColumn *gcolumn;
- GtkCellRenderer *renderer;
- int column;
- int icon_column;
-
- column = ephy_tree_model_node_add_column_full
- (view->nodemodel, value_type, prop_id, func, user_data);
-
- gcolumn = (GtkTreeViewColumn *) gtk_tree_view_column_new ();
-
- if (icon_func)
- {
- icon_column = ephy_tree_model_node_add_func_column
- (view->nodemodel, GDK_TYPE_PIXBUF, icon_func, view);
-
- renderer = gtk_cell_renderer_pixbuf_new ();
- gtk_tree_view_column_pack_start (gcolumn, renderer, FALSE);
- gtk_tree_view_column_set_attributes (gcolumn, renderer,
- "pixbuf", icon_column,
- NULL);
- }
-
- renderer = gtk_cell_renderer_text_new ();
-
- if (flags & EPHY_NODE_VIEW_EDITABLE)
- {
- view->editable_renderer = renderer;
- view->editable_column = gcolumn;
- view->editable_node_column = column;
- view->editable_property = prop_id;
-
- g_signal_connect (renderer, "edited",
- G_CALLBACK (cell_renderer_edited), view);
- g_signal_connect (renderer, "editing-canceled",
- G_CALLBACK (renderer_editing_canceled_cb), view);
- }
-
- gtk_tree_view_column_pack_start (gcolumn, renderer, TRUE);
- gtk_tree_view_column_set_attributes (gcolumn, renderer,
- "text", column,
- NULL);
-
- gtk_tree_view_column_set_title (gcolumn, title);
- gtk_tree_view_append_column (GTK_TREE_VIEW (view),
- gcolumn);
-
- if (flags & EPHY_NODE_VIEW_SHOW_PRIORITY)
- {
- int wcol;
-
- wcol = ephy_tree_model_node_add_func_column
- (view->nodemodel, G_TYPE_INT,
- (EphyTreeModelNodeValueFunc) provide_text_weight,
- view);
- gtk_tree_view_column_add_attribute (gcolumn, renderer,
- "weight", wcol);
- }
-
- if (flags & EPHY_NODE_VIEW_SORTABLE)
- {
- /* Now we have created a new column, re-create the
- * sort model, but ensure that the set_sort function
- * hasn't been called, see bug #320686 */
- g_assert (view->sort_column == -1);
- g_object_unref (view->sortmodel);
- view->sortmodel = ephy_tree_model_sort_new (view->filtermodel);
- gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL (view->sortmodel));
-
- gtk_tree_view_column_set_sort_column_id (gcolumn, column);
- }
-
- if (flags & EPHY_NODE_VIEW_SEARCHABLE)
- {
- gtk_tree_view_set_search_column (GTK_TREE_VIEW (view), column);
- gtk_tree_view_set_enable_search (GTK_TREE_VIEW (view), TRUE);
- }
-
- if (flags & EPHY_NODE_VIEW_ELLIPSIZED)
- {
- g_object_set (renderer, "ellipsize-set", TRUE,
- "ellipsize", PANGO_ELLIPSIZE_END, NULL);
- }
-
- if (ret != NULL)
- *ret = gcolumn;
-
- return column;
+ephy_node_view_add_column_full (EphyNodeView *view,
+ const char *title,
+ GType value_type,
+ guint prop_id,
+ EphyNodeViewFlags flags,
+ EphyTreeModelNodeValueFunc func,
+ gpointer user_data,
+ EphyTreeModelNodeValueFunc icon_func,
+ GtkTreeViewColumn **ret)
+{
+ GtkTreeViewColumn *gcolumn;
+ GtkCellRenderer *renderer;
+ int column;
+ int icon_column;
+
+ column = ephy_tree_model_node_add_column_full
+ (view->nodemodel, value_type, prop_id, func, user_data);
+
+ gcolumn = (GtkTreeViewColumn *)gtk_tree_view_column_new ();
+
+ if (icon_func) {
+ icon_column = ephy_tree_model_node_add_func_column
+ (view->nodemodel, GDK_TYPE_PIXBUF, icon_func, view);
+
+ renderer = gtk_cell_renderer_pixbuf_new ();
+ gtk_tree_view_column_pack_start (gcolumn, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (gcolumn, renderer,
+ "pixbuf", icon_column,
+ NULL);
+ }
+
+ renderer = gtk_cell_renderer_text_new ();
+
+ if (flags & EPHY_NODE_VIEW_EDITABLE) {
+ view->editable_renderer = renderer;
+ view->editable_column = gcolumn;
+ view->editable_node_column = column;
+ view->editable_property = prop_id;
+
+ g_signal_connect (renderer, "edited",
+ G_CALLBACK (cell_renderer_edited), view);
+ g_signal_connect (renderer, "editing-canceled",
+ G_CALLBACK (renderer_editing_canceled_cb), view);
+ }
+
+ gtk_tree_view_column_pack_start (gcolumn, renderer, TRUE);
+ gtk_tree_view_column_set_attributes (gcolumn, renderer,
+ "text", column,
+ NULL);
+
+ gtk_tree_view_column_set_title (gcolumn, title);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (view),
+ gcolumn);
+
+ if (flags & EPHY_NODE_VIEW_SHOW_PRIORITY) {
+ int wcol;
+
+ wcol = ephy_tree_model_node_add_func_column
+ (view->nodemodel, G_TYPE_INT,
+ (EphyTreeModelNodeValueFunc)provide_text_weight,
+ view);
+ gtk_tree_view_column_add_attribute (gcolumn, renderer,
+ "weight", wcol);
+ }
+
+ if (flags & EPHY_NODE_VIEW_SORTABLE) {
+ /* Now we have created a new column, re-create the
+ * sort model, but ensure that the set_sort function
+ * hasn't been called, see bug #320686 */
+ g_assert (view->sort_column == -1);
+ g_object_unref (view->sortmodel);
+ view->sortmodel = ephy_tree_model_sort_new (view->filtermodel);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL (view->sortmodel));
+
+ gtk_tree_view_column_set_sort_column_id (gcolumn, column);
+ }
+
+ if (flags & EPHY_NODE_VIEW_SEARCHABLE) {
+ gtk_tree_view_set_search_column (GTK_TREE_VIEW (view), column);
+ gtk_tree_view_set_enable_search (GTK_TREE_VIEW (view), TRUE);
+ }
+
+ if (flags & EPHY_NODE_VIEW_ELLIPSIZED) {
+ g_object_set (renderer, "ellipsize-set", TRUE,
+ "ellipsize", PANGO_ELLIPSIZE_END, NULL);
+ }
+
+ if (ret != NULL)
+ *ret = gcolumn;
+
+ return column;
}
/**
@@ -1361,16 +1258,16 @@ ephy_node_view_add_column_full (EphyNodeView *view,
* Returns: the id of the new column
**/
int
-ephy_node_view_add_column (EphyNodeView *view,
- const char *title,
- GType value_type,
- guint prop_id,
- EphyNodeViewFlags flags,
- EphyTreeModelNodeValueFunc icon_func,
- GtkTreeViewColumn **ret)
-{
- return ephy_node_view_add_column_full (view, title, value_type, prop_id,
- flags, NULL, NULL, icon_func, ret);
+ephy_node_view_add_column (EphyNodeView *view,
+ const char *title,
+ GType value_type,
+ guint prop_id,
+ EphyNodeViewFlags flags,
+ EphyTreeModelNodeValueFunc icon_func,
+ GtkTreeViewColumn **ret)
+{
+ return ephy_node_view_add_column_full (view, title, value_type, prop_id,
+ flags, NULL, NULL, icon_func, ret);
}
/**
@@ -1383,15 +1280,15 @@ ephy_node_view_add_column (EphyNodeView *view,
void
ephy_node_view_set_priority (EphyNodeView *view, EphyNodeViewPriority priority_prop_id)
{
- int priority_column;
+ int priority_column;
- priority_column = ephy_tree_model_node_add_func_column
- (view->nodemodel, G_TYPE_INT,
- (EphyTreeModelNodeValueFunc) provide_priority,
- view);
+ priority_column = ephy_tree_model_node_add_func_column
+ (view->nodemodel, G_TYPE_INT,
+ (EphyTreeModelNodeValueFunc)provide_priority,
+ view);
- view->priority_column = priority_column;
- view->priority_prop_id = priority_prop_id;
+ view->priority_column = priority_column;
+ view->priority_prop_id = priority_prop_id;
}
/**
@@ -1405,49 +1302,49 @@ ephy_node_view_set_priority (EphyNodeView *view, EphyNodeViewPriority priority_p
**/
void
ephy_node_view_set_sort (EphyNodeView *view, GType value_type, guint prop_id,
- GtkSortType sort_type)
-{
- GtkTreeSortable *sortable = GTK_TREE_SORTABLE (view->sortmodel);
- int column;
-
- column = ephy_tree_model_node_add_prop_column
- (view->nodemodel, value_type, prop_id);
- view->sort_column = column;
- view->sort_type = sort_type;
-
- gtk_tree_sortable_set_default_sort_func
- (sortable, (GtkTreeIterCompareFunc)ephy_node_view_sort_func,
- view, NULL);
- gtk_tree_sortable_set_sort_column_id
- (sortable, GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
- sort_type);
+ GtkSortType sort_type)
+{
+ GtkTreeSortable *sortable = GTK_TREE_SORTABLE (view->sortmodel);
+ int column;
+
+ column = ephy_tree_model_node_add_prop_column
+ (view->nodemodel, value_type, prop_id);
+ view->sort_column = column;
+ view->sort_type = sort_type;
+
+ gtk_tree_sortable_set_default_sort_func
+ (sortable, (GtkTreeIterCompareFunc)ephy_node_view_sort_func,
+ view, NULL);
+ gtk_tree_sortable_set_sort_column_id
+ (sortable, GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
+ sort_type);
}
static void
ephy_node_view_init (EphyNodeView *view)
{
- view->toggle_column = -1;
- view->priority_column = -1;
- view->priority_prop_id = 0;
- view->sort_column = -1;
- view->sort_type = GTK_SORT_ASCENDING;
+ view->toggle_column = -1;
+ view->priority_column = -1;
+ view->priority_prop_id = 0;
+ view->sort_column = -1;
+ view->sort_type = GTK_SORT_ASCENDING;
- gtk_tree_view_set_enable_search (GTK_TREE_VIEW (view), FALSE);
+ gtk_tree_view_set_enable_search (GTK_TREE_VIEW (view), FALSE);
}
static void
get_selection (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer *data)
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer *data)
{
- GList **list = data[0];
- EphyNodeView *view = EPHY_NODE_VIEW (data[1]);
- EphyNode *node;
+ GList **list = data[0];
+ EphyNodeView *view = EPHY_NODE_VIEW (data[1]);
+ EphyNode *node;
- node = get_node_from_path (view, path);
+ node = get_node_from_path (view, path);
- *list = g_list_prepend (*list, node);
+ *list = g_list_prepend (*list, node);
}
/**
@@ -1461,20 +1358,20 @@ get_selection (GtkTreeModel *model,
GList *
ephy_node_view_get_selection (EphyNodeView *view)
{
- GList *list = NULL;
- GtkTreeSelection *selection;
- gpointer data[2];
+ GList *list = NULL;
+ GtkTreeSelection *selection;
+ gpointer data[2];
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
- data[0] = &list;
- data[1] = view;
- gtk_tree_selection_selected_foreach
- (selection,
- (GtkTreeSelectionForeachFunc) get_selection,
- (gpointer) data);
+ data[0] = &list;
+ data[1] = view;
+ gtk_tree_selection_selected_foreach
+ (selection,
+ (GtkTreeSelectionForeachFunc)get_selection,
+ (gpointer)data);
- return list;
+ return list;
}
/**
@@ -1486,73 +1383,66 @@ ephy_node_view_get_selection (EphyNodeView *view)
void
ephy_node_view_remove (EphyNodeView *view)
{
- GList *list, *l;
- EphyNode *node;
- GtkTreeIter iter, iter2, iter3;
- GtkTreePath *path;
- GtkTreeRowReference *row_ref = NULL;
- GtkTreeSelection *selection;
-
- /* Before removing we try to get a reference to the next node in the view. If that is
- * not available we try with the previous one, and if that is absent too,
- * we will not select anything (which equals to select the topic "All")
- */
-
- list = ephy_node_view_get_selection (view);
- if (list == NULL) return;
-
- node = g_list_first (list)->data;
- ephy_tree_model_node_iter_from_node (EPHY_TREE_MODEL_NODE (view->nodemodel),
- node, &iter3);
- gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (view->filtermodel),
- &iter2, &iter3);
- gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (view->sortmodel),
- &iter, &iter2);
- iter2 = iter;
-
- if (gtk_tree_model_iter_next (GTK_TREE_MODEL (view->sortmodel), &iter))
- {
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->sortmodel), &iter);
- row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (view->sortmodel), path);
- }
- else
- {
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->sortmodel), &iter2);
- if (gtk_tree_path_prev (path))
- {
- row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (view->sortmodel), path);
- }
- }
- gtk_tree_path_free (path);
-
- /* Work around bug #346662 */
- view->changing_selection = TRUE;
- for (l = list; l != NULL; l = l->next)
- {
- ephy_node_unref (l->data);
- }
- view->changing_selection = FALSE;
-
- g_list_free (list);
-
- /* Fake a selection changed signal */
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
- g_signal_emit_by_name (selection, "changed");
-
- /* Select the "next" node */
-
- if (row_ref != NULL)
- {
- path = gtk_tree_row_reference_get_path (row_ref);
-
- if (path != NULL)
- {
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path, NULL, FALSE);
- gtk_tree_path_free (path);
- }
-
- gtk_tree_row_reference_free (row_ref);
- }
+ GList *list, *l;
+ EphyNode *node;
+ GtkTreeIter iter, iter2, iter3;
+ GtkTreePath *path;
+ GtkTreeRowReference *row_ref = NULL;
+ GtkTreeSelection *selection;
+
+ /* Before removing we try to get a reference to the next node in the view. If that is
+ * not available we try with the previous one, and if that is absent too,
+ * we will not select anything (which equals to select the topic "All")
+ */
+
+ list = ephy_node_view_get_selection (view);
+ if (list == NULL) return;
+
+ node = g_list_first (list)->data;
+ ephy_tree_model_node_iter_from_node (EPHY_TREE_MODEL_NODE (view->nodemodel),
+ node, &iter3);
+ gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (view->filtermodel),
+ &iter2, &iter3);
+ gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (view->sortmodel),
+ &iter, &iter2);
+ iter2 = iter;
+
+ if (gtk_tree_model_iter_next (GTK_TREE_MODEL (view->sortmodel), &iter)) {
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->sortmodel), &iter);
+ row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (view->sortmodel), path);
+ } else {
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->sortmodel), &iter2);
+ if (gtk_tree_path_prev (path)) {
+ row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (view->sortmodel), path);
+ }
+ }
+ gtk_tree_path_free (path);
+
+ /* Work around bug #346662 */
+ view->changing_selection = TRUE;
+ for (l = list; l != NULL; l = l->next) {
+ ephy_node_unref (l->data);
+ }
+ view->changing_selection = FALSE;
+
+ g_list_free (list);
+
+ /* Fake a selection changed signal */
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
+ g_signal_emit_by_name (selection, "changed");
+
+ /* Select the "next" node */
+
+ if (row_ref != NULL) {
+ path = gtk_tree_row_reference_get_path (row_ref);
+
+ if (path != NULL) {
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path, NULL, FALSE);
+ gtk_tree_path_free (path);
+ }
+
+ gtk_tree_row_reference_free (row_ref);
+ }
}
/**
@@ -1564,21 +1454,21 @@ ephy_node_view_remove (EphyNodeView *view)
**/
void
ephy_node_view_select_node (EphyNodeView *view,
- EphyNode *node)
+ EphyNode *node)
{
- GtkTreeIter iter, iter2;
+ GtkTreeIter iter, iter2;
- g_return_if_fail (node != NULL);
+ g_return_if_fail (node != NULL);
- ephy_tree_model_node_iter_from_node (EPHY_TREE_MODEL_NODE (view->nodemodel),
- node, &iter);
- gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (view->filtermodel),
- &iter2, &iter);
- gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (view->sortmodel),
- &iter, &iter2);
+ ephy_tree_model_node_iter_from_node (EPHY_TREE_MODEL_NODE (view->nodemodel),
+ node, &iter);
+ gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (view->filtermodel),
+ &iter2, &iter);
+ gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (view->sortmodel),
+ &iter, &iter2);
- gtk_tree_selection_select_iter (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)),
- &iter);
+ gtk_tree_selection_select_iter (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)),
+ &iter);
}
/**
@@ -1592,37 +1482,37 @@ ephy_node_view_select_node (EphyNodeView *view,
* Sets @view as a drag source.
**/
void
-ephy_node_view_enable_drag_source (EphyNodeView *view,
- const GtkTargetEntry *types,
- int n_types,
- int base_drag_column_id,
- int extra_drag_column_id)
-{
- g_return_if_fail (view != NULL);
-
- view->source_target_list =
- gtk_target_list_new (types, n_types);
-
- ephy_tree_model_sort_set_base_drag_column_id (EPHY_TREE_MODEL_SORT (view->sortmodel),
- base_drag_column_id);
- ephy_tree_model_sort_set_extra_drag_column_id (EPHY_TREE_MODEL_SORT (view->sortmodel),
- extra_drag_column_id);
-
- g_signal_connect_object (G_OBJECT (view),
- "button_release_event",
- G_CALLBACK (button_release_cb),
- view,
- 0);
- g_signal_connect_object (G_OBJECT (view),
- "motion_notify_event",
- G_CALLBACK (motion_notify_cb),
- view,
- 0);
- g_signal_connect_object (G_OBJECT (view),
- "drag_data_get",
- G_CALLBACK (drag_data_get_cb),
- view,
- 0);
+ephy_node_view_enable_drag_source (EphyNodeView *view,
+ const GtkTargetEntry *types,
+ int n_types,
+ int base_drag_column_id,
+ int extra_drag_column_id)
+{
+ g_return_if_fail (view != NULL);
+
+ view->source_target_list =
+ gtk_target_list_new (types, n_types);
+
+ ephy_tree_model_sort_set_base_drag_column_id (EPHY_TREE_MODEL_SORT (view->sortmodel),
+ base_drag_column_id);
+ ephy_tree_model_sort_set_extra_drag_column_id (EPHY_TREE_MODEL_SORT (view->sortmodel),
+ extra_drag_column_id);
+
+ g_signal_connect_object (G_OBJECT (view),
+ "button_release_event",
+ G_CALLBACK (button_release_cb),
+ view,
+ 0);
+ g_signal_connect_object (G_OBJECT (view),
+ "motion_notify_event",
+ G_CALLBACK (motion_notify_cb),
+ view,
+ 0);
+ g_signal_connect_object (G_OBJECT (view),
+ "drag_data_get",
+ G_CALLBACK (drag_data_get_cb),
+ view,
+ 0);
}
/**
@@ -1636,33 +1526,33 @@ ephy_node_view_enable_drag_source (EphyNodeView *view,
void
ephy_node_view_edit (EphyNodeView *view, gboolean remove_if_cancelled)
{
- GtkTreePath *path;
- GtkTreeSelection *selection;
- GList *rows;
- GtkTreeModel *model;
+ GtkTreePath *path;
+ GtkTreeSelection *selection;
+ GList *rows;
+ GtkTreeModel *model;
- g_return_if_fail (view->editable_renderer != NULL);
+ g_return_if_fail (view->editable_renderer != NULL);
- selection = gtk_tree_view_get_selection
- (GTK_TREE_VIEW (view));
- rows = gtk_tree_selection_get_selected_rows (selection, &model);
- if (rows == NULL) return;
+ selection = gtk_tree_view_get_selection
+ (GTK_TREE_VIEW (view));
+ rows = gtk_tree_selection_get_selected_rows (selection, &model);
+ if (rows == NULL) return;
- path = rows->data;
+ path = rows->data;
- g_object_set (G_OBJECT (view->editable_renderer),
- "editable", TRUE,
- NULL);
+ g_object_set (G_OBJECT (view->editable_renderer),
+ "editable", TRUE,
+ NULL);
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path,
- view->editable_column,
- TRUE);
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path,
+ view->editable_column,
+ TRUE);
- view->edited_node = get_node_from_path (view, path);
- view->remove_if_cancelled = remove_if_cancelled;
+ view->edited_node = get_node_from_path (view, path);
+ view->remove_if_cancelled = remove_if_cancelled;
- g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
- g_list_free (rows);
+ g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
+ g_list_free (rows);
}
/**
@@ -1676,63 +1566,62 @@ ephy_node_view_edit (EphyNodeView *view, gboolean remove_if_cancelled)
gboolean
ephy_node_view_is_target (EphyNodeView *view)
{
- return gtk_widget_is_focus (GTK_WIDGET (view));
+ return gtk_widget_is_focus (GTK_WIDGET (view));
}
static gboolean
filter_visible_func (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
{
- EphyNode *node;
- EphyNodeView *view = EPHY_NODE_VIEW (data);
+ EphyNode *node;
+ EphyNodeView *view = EPHY_NODE_VIEW (data);
- if (view->filter)
- {
- node = ephy_tree_model_node_node_from_iter (view->nodemodel, iter);
+ if (view->filter) {
+ node = ephy_tree_model_node_node_from_iter (view->nodemodel, iter);
- return ephy_node_filter_evaluate (view->filter, node);
- }
+ return ephy_node_filter_evaluate (view->filter, node);
+ }
- return TRUE;
+ return TRUE;
}
static GObject *
ephy_node_view_constructor (GType type, guint n_construct_properties,
- GObjectConstructParam *construct_params)
-
-{
- GObject *object;
- EphyNodeView *view;
- GtkTreeSelection *selection;
-
- object = G_OBJECT_CLASS (ephy_node_view_parent_class)->constructor (type,
- n_construct_properties,
- construct_params);
- view = EPHY_NODE_VIEW (object);
-
- view->nodemodel = ephy_tree_model_node_new (view->root);
- view->filtermodel = gtk_tree_model_filter_new (GTK_TREE_MODEL (view->nodemodel),
- NULL);
- gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (view->filtermodel),
- filter_visible_func, view, NULL);
- view->sortmodel = ephy_tree_model_sort_new (view->filtermodel);
- gtk_tree_view_set_model (GTK_TREE_VIEW (object), GTK_TREE_MODEL (view->sortmodel));
- g_signal_connect_object (object, "button_press_event",
- G_CALLBACK (ephy_node_view_button_press_cb),
- view, 0);
- g_signal_connect (object, "key_press_event",
- G_CALLBACK (ephy_node_view_key_press_cb),
- view);
- g_signal_connect_object (object, "row_activated",
- G_CALLBACK (ephy_node_view_row_activated_cb),
- view, 0);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
- g_signal_connect_object (G_OBJECT (selection), "changed",
- G_CALLBACK (ephy_node_view_selection_changed_cb),
- view, 0);
-
- return object;
+ GObjectConstructParam *construct_params)
+
+{
+ GObject *object;
+ EphyNodeView *view;
+ GtkTreeSelection *selection;
+
+ object = G_OBJECT_CLASS (ephy_node_view_parent_class)->constructor (type,
+ n_construct_properties,
+ construct_params);
+ view = EPHY_NODE_VIEW (object);
+
+ view->nodemodel = ephy_tree_model_node_new (view->root);
+ view->filtermodel = gtk_tree_model_filter_new (GTK_TREE_MODEL (view->nodemodel),
+ NULL);
+ gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (view->filtermodel),
+ filter_visible_func, view, NULL);
+ view->sortmodel = ephy_tree_model_sort_new (view->filtermodel);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (object), GTK_TREE_MODEL (view->sortmodel));
+ g_signal_connect_object (object, "button_press_event",
+ G_CALLBACK (ephy_node_view_button_press_cb),
+ view, 0);
+ g_signal_connect (object, "key_press_event",
+ G_CALLBACK (ephy_node_view_key_press_cb),
+ view);
+ g_signal_connect_object (object, "row_activated",
+ G_CALLBACK (ephy_node_view_row_activated_cb),
+ view, 0);
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+ g_signal_connect_object (G_OBJECT (selection), "changed",
+ G_CALLBACK (ephy_node_view_selection_changed_cb),
+ view, 0);
+
+ return object;
}
/**
@@ -1746,20 +1635,20 @@ ephy_node_view_constructor (GType type, guint n_construct_properties,
**/
void
ephy_node_view_add_toggle (EphyNodeView *view, EphyTreeModelNodeValueFunc value_func,
- gpointer data)
+ gpointer data)
{
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *col;
- int column;
-
- column = ephy_tree_model_node_add_func_column
- (view->nodemodel, G_TYPE_BOOLEAN, value_func, data);
- view->toggle_column = column;
-
- renderer = gtk_cell_renderer_toggle_new ();
- col = gtk_tree_view_column_new_with_attributes
- ("", renderer, "active", column, NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (view), col);
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *col;
+ int column;
+
+ column = ephy_tree_model_node_add_func_column
+ (view->nodemodel, G_TYPE_BOOLEAN, value_func, data);
+ view->toggle_column = column;
+
+ renderer = gtk_cell_renderer_toggle_new ();
+ col = gtk_tree_view_column_new_with_attributes
+ ("", renderer, "active", column, NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (view), col);
}
/**
@@ -1772,165 +1661,161 @@ ephy_node_view_add_toggle (EphyNodeView *view, EphyTreeModelNodeValueFunc value_
void
ephy_node_view_popup (EphyNodeView *view, GtkWidget *menu)
{
- GdkEvent *event;
-
- event = gtk_get_current_event ();
- if (event)
- {
- if (event->type == GDK_KEY_PRESS)
- {
- GdkEventKey *key = (GdkEventKey *) event;
-
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
- ephy_gui_menu_position_tree_selection,
- view, 0, key->time);
- gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
- }
- else if (event->type == GDK_BUTTON_PRESS)
- {
- GdkEventButton *button = (GdkEventButton *) event;
-
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL,
- NULL, button->button, button->time);
- }
-
- gdk_event_free (event);
- }
+ GdkEvent *event;
+
+ event = gtk_get_current_event ();
+ if (event) {
+ if (event->type == GDK_KEY_PRESS) {
+ GdkEventKey *key = (GdkEventKey *)event;
+
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
+ ephy_gui_menu_position_tree_selection,
+ view, 0, key->time);
+ gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
+ } else if (event->type == GDK_BUTTON_PRESS) {
+ GdkEventButton *button = (GdkEventButton *)event;
+
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL,
+ NULL, button->button, button->time);
+ }
+
+ gdk_event_free (event);
+ }
}
gboolean
ephy_node_view_get_iter_for_node (EphyNodeView *view,
- GtkTreeIter *iter,
- EphyNode *node)
+ GtkTreeIter *iter,
+ EphyNode *node)
{
- GtkTreeIter node_iter, filter_iter;
+ GtkTreeIter node_iter, filter_iter;
- ephy_tree_model_node_iter_from_node (EPHY_TREE_MODEL_NODE (view->nodemodel), node, &node_iter);
- if (!gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (view->filtermodel),
- &filter_iter, &node_iter))
- return FALSE;
+ ephy_tree_model_node_iter_from_node (EPHY_TREE_MODEL_NODE (view->nodemodel), node, &node_iter);
+ if (!gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (view->filtermodel),
+ &filter_iter, &node_iter))
+ return FALSE;
- if (!gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (view->sortmodel),
- iter, &filter_iter))
- return FALSE;
+ if (!gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (view->sortmodel),
+ iter, &filter_iter))
+ return FALSE;
- return TRUE;
+ return TRUE;
}
static void
ephy_node_view_class_init (EphyNodeViewClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->constructor = ephy_node_view_constructor;
- object_class->finalize = ephy_node_view_finalize;
-
- object_class->set_property = ephy_node_view_set_property;
- object_class->get_property = ephy_node_view_get_property;
-
- /**
- * EphyNodeView:root:
- *
- * A #gpointer to the root node of the #EphyNode elements of the view.
- */
- obj_properties[PROP_ROOT] =
- g_param_spec_pointer ("root",
- "Root node",
- "Root node",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
-
- /**
- * EphyNodeView:filter:
- *
- * An #EphyNodeFilter object to use in the view.
- */
- obj_properties[PROP_FILTER] =
- g_param_spec_object ("filter",
- "Filter object",
- "Filter object",
- EPHY_TYPE_NODE_FILTER,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
-
- /**
- * EphyNodeView::node-toggled:
- * @view: the object on which the signal is emitted
- * @node: the target #EphyNode
- * @checked: the new value of the toggle column
- *
- * Emitted when a row value is toggled, only emitted for toggle columns.
- */
- ephy_node_view_signals[NODE_TOGGLED] =
- g_signal_new ("node_toggled",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 2,
- G_TYPE_POINTER,
- G_TYPE_BOOLEAN);
- /**
- * EphyNodeView::node-activated:
- * @view: the object on which the signal is emitted
- * @node: the activated #EphyNode
- *
- * Emitted when a row is activated.
- */
- ephy_node_view_signals[NODE_ACTIVATED] =
- g_signal_new ("node_activated",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 1,
- G_TYPE_POINTER);
- /**
- * EphyNodeView::node-selected:
- * @view: the object on which the signal is emitted
- * @node: the selected #EphyNode
- *
- * Emitted when a row is selected.
- */
- ephy_node_view_signals[NODE_SELECTED] =
- g_signal_new ("node_selected",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 1,
- G_TYPE_POINTER);
- /**
- * EphyNodeView::node-dropped:
- * @view: the object on which the signal is emitted
- * @node: the dropped #EphyNode
- * @uris: URIs from the dragged data
- *
- * Emitted when an #EphyNode is dropped into the #EphyNodeView.
- */
- ephy_node_view_signals[NODE_DROPPED] =
- g_signal_new ("node_dropped",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 2,
- G_TYPE_POINTER,
- G_TYPE_POINTER);
-
- /**
- * EphyNodeView::node-middle-clicked:
- * @view: the object on which the signal is emitted
- * @node: the clicked #EphyNode
- *
- * Emitted when the user middle clicks on a row of the #EphyNodeView.
- */
- ephy_node_view_signals[NODE_MIDDLE_CLICKED] =
- g_signal_new ("node_middle_clicked",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 1,
- G_TYPE_POINTER);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->constructor = ephy_node_view_constructor;
+ object_class->finalize = ephy_node_view_finalize;
+
+ object_class->set_property = ephy_node_view_set_property;
+ object_class->get_property = ephy_node_view_get_property;
+
+ /**
+ * EphyNodeView:root:
+ *
+ * A #gpointer to the root node of the #EphyNode elements of the view.
+ */
+ obj_properties[PROP_ROOT] =
+ g_param_spec_pointer ("root",
+ "Root node",
+ "Root node",
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
+
+ /**
+ * EphyNodeView:filter:
+ *
+ * An #EphyNodeFilter object to use in the view.
+ */
+ obj_properties[PROP_FILTER] =
+ g_param_spec_object ("filter",
+ "Filter object",
+ "Filter object",
+ EPHY_TYPE_NODE_FILTER,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+
+ /**
+ * EphyNodeView::node-toggled:
+ * @view: the object on which the signal is emitted
+ * @node: the target #EphyNode
+ * @checked: the new value of the toggle column
+ *
+ * Emitted when a row value is toggled, only emitted for toggle columns.
+ */
+ ephy_node_view_signals[NODE_TOGGLED] =
+ g_signal_new ("node_toggled",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_POINTER,
+ G_TYPE_BOOLEAN);
+ /**
+ * EphyNodeView::node-activated:
+ * @view: the object on which the signal is emitted
+ * @node: the activated #EphyNode
+ *
+ * Emitted when a row is activated.
+ */
+ ephy_node_view_signals[NODE_ACTIVATED] =
+ g_signal_new ("node_activated",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER);
+ /**
+ * EphyNodeView::node-selected:
+ * @view: the object on which the signal is emitted
+ * @node: the selected #EphyNode
+ *
+ * Emitted when a row is selected.
+ */
+ ephy_node_view_signals[NODE_SELECTED] =
+ g_signal_new ("node_selected",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER);
+ /**
+ * EphyNodeView::node-dropped:
+ * @view: the object on which the signal is emitted
+ * @node: the dropped #EphyNode
+ * @uris: URIs from the dragged data
+ *
+ * Emitted when an #EphyNode is dropped into the #EphyNodeView.
+ */
+ ephy_node_view_signals[NODE_DROPPED] =
+ g_signal_new ("node_dropped",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_POINTER,
+ G_TYPE_POINTER);
+
+ /**
+ * EphyNodeView::node-middle-clicked:
+ * @view: the object on which the signal is emitted
+ * @node: the clicked #EphyNode
+ *
+ * Emitted when the user middle clicks on a row of the #EphyNodeView.
+ */
+ ephy_node_view_signals[NODE_MIDDLE_CLICKED] =
+ g_signal_new ("node_middle_clicked",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER);
}
diff --git a/lib/widgets/ephy-security-popover.c b/lib/widgets/ephy-security-popover.c
index e1003b691..4e2c76bd8 100644
--- a/lib/widgets/ephy-security-popover.c
+++ b/lib/widgets/ephy-security-popover.c
@@ -34,8 +34,7 @@
* can also be used to show that a connection does not use TLS at all.
*/
-enum
-{
+enum {
PROP_0,
PROP_ADDRESS,
PROP_CERTIFICATE,
@@ -46,8 +45,7 @@ enum
static GParamSpec *obj_properties[LAST_PROP];
-struct _EphySecurityPopover
-{
+struct _EphySecurityPopover {
GtkPopover parent_instance;
char *address;
char *hostname;
@@ -64,7 +62,7 @@ G_DEFINE_TYPE (EphySecurityPopover, ephy_security_popover, GTK_TYPE_POPOVER)
static void
ephy_security_popover_set_address (EphySecurityPopover *popover,
- const char *address)
+ const char *address)
{
SoupURI *uri;
char *label_text;
@@ -86,7 +84,7 @@ ephy_security_popover_set_address (EphySecurityPopover *popover,
static void
ephy_security_popover_set_certificate (EphySecurityPopover *popover,
- GTlsCertificate *certificate)
+ GTlsCertificate *certificate)
{
if (certificate)
popover->certificate = g_object_ref (certificate);
@@ -94,7 +92,7 @@ ephy_security_popover_set_certificate (EphySecurityPopover *popover,
static void
ephy_security_popover_set_security_level (EphySecurityPopover *popover,
- EphySecurityLevel security_level)
+ EphySecurityLevel security_level)
{
GIcon *icon;
char *address_text;
@@ -105,38 +103,38 @@ ephy_security_popover_set_security_level (EphySecurityPopover *popover,
address_text = g_markup_printf_escaped ("<span weight=\"bold\">%s</span>", popover->hostname);
switch (security_level) {
- case EPHY_SECURITY_LEVEL_UNACCEPTABLE_CERTIFICATE:
- /* Label in certificate popover when site is untrusted. %s is a URL. */
- label_text = g_strdup_printf (_("This web site’s digital identification is not trusted. "
- "You may have connected to an attacker pretending to be %s."),
- address_text);
- gtk_label_set_markup (GTK_LABEL (popover->security_label), label_text);
- gtk_widget_hide (popover->host_label);
- break;
- case EPHY_SECURITY_LEVEL_NO_SECURITY:
- /* Label in certificate popover when site uses HTTP. %s is a URL. */
- label_text = g_strdup_printf (_("%s has no security. An attacker could see any information "
- "you send, or control the content that you see."),
- address_text);
- gtk_label_set_markup (GTK_LABEL (popover->security_label), label_text);
- gtk_widget_hide (popover->host_label);
- break;
- case EPHY_SECURITY_LEVEL_MIXED_CONTENT:
- gtk_label_set_text (GTK_LABEL (popover->security_label),
- /* Label in certificate popover when site sends mixed content. */
- _("This web site did not properly secure your connection."));
- gtk_widget_show (popover->host_label);
- break;
- case EPHY_SECURITY_LEVEL_STRONG_SECURITY:
- gtk_label_set_text (GTK_LABEL (popover->security_label),
- /* Label in certificate popover on secure sites. */
- _("Your connection seems to be secure."));
- gtk_widget_show (popover->host_label);
- break;
- case EPHY_SECURITY_LEVEL_TO_BE_DETERMINED:
- case EPHY_SECURITY_LEVEL_LOCAL_PAGE:
- default:
- g_assert_not_reached ();
+ case EPHY_SECURITY_LEVEL_UNACCEPTABLE_CERTIFICATE:
+ /* Label in certificate popover when site is untrusted. %s is a URL. */
+ label_text = g_strdup_printf (_("This web site’s digital identification is not trusted. "
+ "You may have connected to an attacker pretending to be %s."),
+ address_text);
+ gtk_label_set_markup (GTK_LABEL (popover->security_label), label_text);
+ gtk_widget_hide (popover->host_label);
+ break;
+ case EPHY_SECURITY_LEVEL_NO_SECURITY:
+ /* Label in certificate popover when site uses HTTP. %s is a URL. */
+ label_text = g_strdup_printf (_("%s has no security. An attacker could see any information "
+ "you send, or control the content that you see."),
+ address_text);
+ gtk_label_set_markup (GTK_LABEL (popover->security_label), label_text);
+ gtk_widget_hide (popover->host_label);
+ break;
+ case EPHY_SECURITY_LEVEL_MIXED_CONTENT:
+ gtk_label_set_text (GTK_LABEL (popover->security_label),
+ /* Label in certificate popover when site sends mixed content. */
+ _("This web site did not properly secure your connection."));
+ gtk_widget_show (popover->host_label);
+ break;
+ case EPHY_SECURITY_LEVEL_STRONG_SECURITY:
+ gtk_label_set_text (GTK_LABEL (popover->security_label),
+ /* Label in certificate popover on secure sites. */
+ _("Your connection seems to be secure."));
+ gtk_widget_show (popover->host_label);
+ break;
+ case EPHY_SECURITY_LEVEL_TO_BE_DETERMINED:
+ case EPHY_SECURITY_LEVEL_LOCAL_PAGE:
+ default:
+ g_assert_not_reached ();
}
icon = g_themed_icon_new_with_default_fallbacks (ephy_security_level_to_icon_name (security_level));
@@ -149,7 +147,7 @@ ephy_security_popover_set_security_level (EphySecurityPopover *popover,
static void
certificate_button_clicked_cb (GtkButton *button,
- gpointer user_data)
+ gpointer user_data)
{
EphySecurityPopover *popover = EPHY_SECURITY_POPOVER (user_data);
GtkWidget *dialog;
@@ -214,42 +212,42 @@ ephy_security_popover_finalize (GObject *object)
}
static void
-ephy_security_popover_set_property (GObject *object,
- guint prop_id,
+ephy_security_popover_set_property (GObject *object,
+ guint prop_id,
const GValue *value,
- GParamSpec *pspec)
+ GParamSpec *pspec)
{
EphySecurityPopover *popover = EPHY_SECURITY_POPOVER (object);
switch (prop_id) {
- case PROP_ADDRESS:
- ephy_security_popover_set_address (popover, g_value_get_string (value));
- break;
- case PROP_CERTIFICATE:
- ephy_security_popover_set_certificate (popover, g_value_get_object (value));
- break;
- case PROP_SECURITY_LEVEL:
- ephy_security_popover_set_security_level (popover, g_value_get_enum (value));
- break;
- case PROP_TLS_ERRORS:
- popover->tls_errors = g_value_get_flags (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ case PROP_ADDRESS:
+ ephy_security_popover_set_address (popover, g_value_get_string (value));
+ break;
+ case PROP_CERTIFICATE:
+ ephy_security_popover_set_certificate (popover, g_value_get_object (value));
+ break;
+ case PROP_SECURITY_LEVEL:
+ ephy_security_popover_set_security_level (popover, g_value_get_enum (value));
+ break;
+ case PROP_TLS_ERRORS:
+ popover->tls_errors = g_value_get_flags (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
ephy_security_popover_get_preferred_width (GtkWidget *widget,
- gint *minimum_width,
- gint *natural_width)
+ gint *minimum_width,
+ gint *natural_width)
{
GTK_WIDGET_CLASS (ephy_security_popover_parent_class)->get_preferred_width (widget,
- minimum_width,
- natural_width);
+ minimum_width,
+ natural_width);
if (*natural_width > 600)
- *natural_width = MAX(600, *minimum_width);
+ *natural_width = MAX (600, *minimum_width);
}
static void
@@ -342,11 +340,11 @@ ephy_security_popover_init (EphySecurityPopover *popover)
gtk_widget_show_all (popover->grid);
}
-GtkWidget *ephy_security_popover_new (GtkWidget *relative_to,
- const char *address,
- GTlsCertificate *certificate,
+GtkWidget *ephy_security_popover_new (GtkWidget *relative_to,
+ const char *address,
+ GTlsCertificate *certificate,
GTlsCertificateFlags tls_errors,
- EphySecurityLevel security_level)
+ EphySecurityLevel security_level)
{
g_return_val_if_fail (address != NULL, NULL);
diff --git a/lib/widgets/ephy-tree-model-node.c b/lib/widgets/ephy-tree-model-node.c
index bca8a3684..d43c45378 100644
--- a/lib/widgets/ephy-tree-model-node.c
+++ b/lib/widgets/ephy-tree-model-node.c
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright © 2002 Jorn Baayen <jorn@nl.linux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -36,31 +36,28 @@
static void ephy_tree_model_node_finalize (GObject *object);
static void ephy_tree_model_node_tree_model_interface_init (GtkTreeModelIface *iface);
-struct _EphyTreeModelNode
-{
- GObject parent_instance;
+struct _EphyTreeModelNode {
+ GObject parent_instance;
- EphyNode *root;
+ EphyNode *root;
- GPtrArray *columns;
- int columns_num;
+ GPtrArray *columns;
+ int columns_num;
- int stamp;
+ int stamp;
};
-typedef struct
-{
- GType type;
- int prop_id;
- EphyTreeModelNodeValueFunc func;
- gpointer user_data;
+typedef struct {
+ GType type;
+ int prop_id;
+ EphyTreeModelNodeValueFunc func;
+ gpointer user_data;
} EphyTreeModelNodeColData;
-enum
-{
- PROP_0,
- PROP_ROOT,
- LAST_PROP
+enum {
+ PROP_0,
+ PROP_ROOT,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
@@ -70,204 +67,199 @@ G_DEFINE_TYPE_WITH_CODE (EphyTreeModelNode, ephy_tree_model_node, G_TYPE_OBJECT,
ephy_tree_model_node_tree_model_interface_init))
static void
-root_child_removed_cb (EphyNode *node,
- EphyNode *child,
- guint old_index,
- EphyTreeModelNode *model)
+root_child_removed_cb (EphyNode *node,
+ EphyNode *child,
+ guint old_index,
+ EphyTreeModelNode *model)
{
- GtkTreePath *path;
+ GtkTreePath *path;
- path = gtk_tree_path_new ();
- gtk_tree_path_append_index (path, old_index);
- gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
- gtk_tree_path_free (path);
+ path = gtk_tree_path_new ();
+ gtk_tree_path_append_index (path, old_index);
+ gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
+ gtk_tree_path_free (path);
}
static inline GtkTreePath *
get_path_real (EphyTreeModelNode *model,
- EphyNode *node)
+ EphyNode *node)
{
- GtkTreePath *retval;
+ GtkTreePath *retval;
- retval = gtk_tree_path_new ();
- gtk_tree_path_append_index (retval, ephy_node_get_child_index (model->root, node));
+ retval = gtk_tree_path_new ();
+ gtk_tree_path_append_index (retval, ephy_node_get_child_index (model->root, node));
- return retval;
+ return retval;
}
static void
-root_child_added_cb (EphyNode *node,
- EphyNode *child,
- EphyTreeModelNode *model)
+root_child_added_cb (EphyNode *node,
+ EphyNode *child,
+ EphyTreeModelNode *model)
{
- GtkTreePath *path;
- GtkTreeIter iter;
+ GtkTreePath *path;
+ GtkTreeIter iter;
- ephy_tree_model_node_iter_from_node (model, child, &iter);
+ ephy_tree_model_node_iter_from_node (model, child, &iter);
- path = get_path_real (model, child);
- gtk_tree_model_row_inserted (GTK_TREE_MODEL (model), path, &iter);
- gtk_tree_path_free (path);
+ path = get_path_real (model, child);
+ gtk_tree_model_row_inserted (GTK_TREE_MODEL (model), path, &iter);
+ gtk_tree_path_free (path);
}
static inline void
ephy_tree_model_node_update_node (EphyTreeModelNode *model,
- EphyNode *node,
- int idx)
+ EphyNode *node,
+ int idx)
{
- GtkTreePath *path;
- GtkTreeIter iter;
+ GtkTreePath *path;
+ GtkTreeIter iter;
- ephy_tree_model_node_iter_from_node (model, node, &iter);
+ ephy_tree_model_node_iter_from_node (model, node, &iter);
- if (idx >= 0)
- {
- path = gtk_tree_path_new ();
- gtk_tree_path_append_index (path, idx);
- }
- else
- {
- path = get_path_real (model, node);
- }
+ if (idx >= 0) {
+ path = gtk_tree_path_new ();
+ gtk_tree_path_append_index (path, idx);
+ } else {
+ path = get_path_real (model, node);
+ }
- LOG ("Updating row");
+ LOG ("Updating row");
- gtk_tree_model_row_changed (GTK_TREE_MODEL (model), path, &iter);
- gtk_tree_path_free (path);
+ gtk_tree_model_row_changed (GTK_TREE_MODEL (model), path, &iter);
+ gtk_tree_path_free (path);
}
static void
-root_child_changed_cb (EphyNode *node,
- EphyNode *child,
- guint property_id,
- EphyTreeModelNode *model)
+root_child_changed_cb (EphyNode *node,
+ EphyNode *child,
+ guint property_id,
+ EphyTreeModelNode *model)
{
- ephy_tree_model_node_update_node (model, child, -1);
+ ephy_tree_model_node_update_node (model, child, -1);
}
static void
-root_children_reordered_cb (EphyNode *node,
- int *new_order,
- EphyTreeModelNode *model)
+root_children_reordered_cb (EphyNode *node,
+ int *new_order,
+ EphyTreeModelNode *model)
{
- GtkTreePath *path;
+ GtkTreePath *path;
- path = gtk_tree_path_new ();
- gtk_tree_model_rows_reordered (GTK_TREE_MODEL (model), path, NULL, new_order);
- gtk_tree_path_free (path);
+ path = gtk_tree_path_new ();
+ gtk_tree_model_rows_reordered (GTK_TREE_MODEL (model), path, NULL, new_order);
+ gtk_tree_path_free (path);
}
static void
-root_destroy_cb (EphyNode *node,
- EphyTreeModelNode *model)
+root_destroy_cb (EphyNode *node,
+ EphyTreeModelNode *model)
{
- model->root = NULL;
+ model->root = NULL;
- /* no need to do other stuff since we should have had a bunch of child_removed
- * signals already */
+ /* no need to do other stuff since we should have had a bunch of child_removed
+ * signals already */
}
static void
-ephy_tree_model_node_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (object);
-
- switch (prop_id)
- {
- case PROP_ROOT:
- model->root = g_value_get_pointer (value);
-
- ephy_node_signal_connect_object (model->root,
- EPHY_NODE_CHILD_ADDED,
- (EphyNodeCallback) root_child_added_cb,
- G_OBJECT (model));
- ephy_node_signal_connect_object (model->root,
- EPHY_NODE_CHILD_REMOVED,
- (EphyNodeCallback) root_child_removed_cb,
- G_OBJECT (model));
- ephy_node_signal_connect_object (model->root,
- EPHY_NODE_CHILD_CHANGED,
- (EphyNodeCallback) root_child_changed_cb,
- G_OBJECT (model));
- ephy_node_signal_connect_object (model->root,
- EPHY_NODE_CHILDREN_REORDERED,
- (EphyNodeCallback) root_children_reordered_cb,
- G_OBJECT (model));
- ephy_node_signal_connect_object (model->root,
- EPHY_NODE_DESTROY,
- (EphyNodeCallback) root_destroy_cb,
- G_OBJECT (model));
-
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ephy_tree_model_node_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (object);
+
+ switch (prop_id) {
+ case PROP_ROOT:
+ model->root = g_value_get_pointer (value);
+
+ ephy_node_signal_connect_object (model->root,
+ EPHY_NODE_CHILD_ADDED,
+ (EphyNodeCallback)root_child_added_cb,
+ G_OBJECT (model));
+ ephy_node_signal_connect_object (model->root,
+ EPHY_NODE_CHILD_REMOVED,
+ (EphyNodeCallback)root_child_removed_cb,
+ G_OBJECT (model));
+ ephy_node_signal_connect_object (model->root,
+ EPHY_NODE_CHILD_CHANGED,
+ (EphyNodeCallback)root_child_changed_cb,
+ G_OBJECT (model));
+ ephy_node_signal_connect_object (model->root,
+ EPHY_NODE_CHILDREN_REORDERED,
+ (EphyNodeCallback)root_children_reordered_cb,
+ G_OBJECT (model));
+ ephy_node_signal_connect_object (model->root,
+ EPHY_NODE_DESTROY,
+ (EphyNodeCallback)root_destroy_cb,
+ G_OBJECT (model));
+
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-ephy_tree_model_node_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (object);
-
- switch (prop_id)
- {
- case PROP_ROOT:
- g_value_set_pointer (value, model->root);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ephy_tree_model_node_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (object);
+
+ switch (prop_id) {
+ case PROP_ROOT:
+ g_value_set_pointer (value, model->root);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
ephy_tree_model_node_class_init (EphyTreeModelNodeClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = ephy_tree_model_node_finalize;
+ object_class->finalize = ephy_tree_model_node_finalize;
- object_class->set_property = ephy_tree_model_node_set_property;
- object_class->get_property = ephy_tree_model_node_get_property;
+ object_class->set_property = ephy_tree_model_node_set_property;
+ object_class->get_property = ephy_tree_model_node_get_property;
- /**
- * EphyTreeModelNode:root:
- *
- * The root #EphyNode of the model.
- */
- obj_properties[PROP_ROOT] =
- g_param_spec_pointer ("root",
- "Root node",
- "Root node",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
+ /**
+ * EphyTreeModelNode:root:
+ *
+ * The root #EphyNode of the model.
+ */
+ obj_properties[PROP_ROOT] =
+ g_param_spec_pointer ("root",
+ "Root node",
+ "Root node",
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
}
static void
ephy_tree_model_node_init (EphyTreeModelNode *model)
{
- model->stamp = g_random_int ();
- model->columns = g_ptr_array_new ();
- model->columns_num = 0;
+ model->stamp = g_random_int ();
+ model->columns = g_ptr_array_new ();
+ model->columns_num = 0;
}
static void
ephy_tree_model_node_finalize (GObject *object)
{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (object);
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (object);
- g_ptr_array_foreach (model->columns, (GFunc) g_free, NULL);
- g_ptr_array_free (model->columns, TRUE);
+ g_ptr_array_foreach (model->columns, (GFunc)g_free, NULL);
+ g_ptr_array_free (model->columns, TRUE);
- G_OBJECT_CLASS (ephy_tree_model_node_parent_class)->finalize (object);
+ G_OBJECT_CLASS (ephy_tree_model_node_parent_class)->finalize (object);
}
/**
@@ -281,13 +273,13 @@ ephy_tree_model_node_finalize (GObject *object)
EphyTreeModelNode *
ephy_tree_model_node_new (EphyNode *root)
{
- EphyTreeModelNode *model;
+ EphyTreeModelNode *model;
- model = EPHY_TREE_MODEL_NODE (g_object_new (EPHY_TYPE_TREE_MODEL_NODE,
- "root", root,
- NULL));
+ model = EPHY_TREE_MODEL_NODE (g_object_new (EPHY_TYPE_TREE_MODEL_NODE,
+ "root", root,
+ NULL));
- return model;
+ return model;
}
/**
@@ -304,26 +296,26 @@ ephy_tree_model_node_new (EphyNode *root)
* Returns: the id of the new column
**/
int
-ephy_tree_model_node_add_column_full (EphyTreeModelNode *model,
- GType value_type,
- int prop_id,
- EphyTreeModelNodeValueFunc func,
- gpointer user_data)
-{
- EphyTreeModelNodeColData *col;
- int col_id;
-
- col = g_new0 (EphyTreeModelNodeColData, 1);
- col->prop_id = prop_id;
- col->type = value_type;
- col->func = func;
- col->user_data = user_data;
-
- g_ptr_array_add (model->columns, col);
- col_id = model->columns_num;
- model->columns_num++;
-
- return col_id;
+ephy_tree_model_node_add_column_full (EphyTreeModelNode *model,
+ GType value_type,
+ int prop_id,
+ EphyTreeModelNodeValueFunc func,
+ gpointer user_data)
+{
+ EphyTreeModelNodeColData *col;
+ int col_id;
+
+ col = g_new0 (EphyTreeModelNodeColData, 1);
+ col->prop_id = prop_id;
+ col->type = value_type;
+ col->func = func;
+ col->user_data = user_data;
+
+ g_ptr_array_add (model->columns, col);
+ col_id = model->columns_num;
+ model->columns_num++;
+
+ return col_id;
}
@@ -339,10 +331,10 @@ ephy_tree_model_node_add_column_full (EphyTreeModelNode *model,
**/
int
ephy_tree_model_node_add_prop_column (EphyTreeModelNode *model,
- GType value_type,
- int prop_id)
+ GType value_type,
+ int prop_id)
{
- return ephy_tree_model_node_add_column_full (model, value_type, prop_id, NULL, NULL);
+ return ephy_tree_model_node_add_column_full (model, value_type, prop_id, NULL, NULL);
}
/**
@@ -357,237 +349,230 @@ ephy_tree_model_node_add_prop_column (EphyTreeModelNode *model,
* Returns: the id of the new column
**/
int
-ephy_tree_model_node_add_func_column (EphyTreeModelNode *model,
- GType value_type,
- EphyTreeModelNodeValueFunc func,
- gpointer user_data)
+ephy_tree_model_node_add_func_column (EphyTreeModelNode *model,
+ GType value_type,
+ EphyTreeModelNodeValueFunc func,
+ gpointer user_data)
{
- return ephy_tree_model_node_add_column_full (model, value_type, -1, func, user_data);
+ return ephy_tree_model_node_add_column_full (model, value_type, -1, func, user_data);
}
static int
ephy_tree_model_node_get_n_columns (GtkTreeModel *tree_model)
{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- return model->columns_num;
+ return model->columns_num;
}
static GType
ephy_tree_model_node_get_column_type (GtkTreeModel *tree_model,
- int index)
+ int index)
{
- EphyTreeModelNodeColData *col;
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ EphyTreeModelNodeColData *col;
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- col = g_ptr_array_index (model->columns, index);
+ col = g_ptr_array_index (model->columns, index);
- return col->type;
+ return col->type;
}
static void
ephy_tree_model_node_get_value (GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- int column,
- GValue *value)
+ GtkTreeIter *iter,
+ int column,
+ GValue *value)
{
- EphyTreeModelNodeColData *col;
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- EphyNode *node;
-
- g_return_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model));
- g_return_if_fail (iter != NULL);
- g_return_if_fail (iter->stamp == model->stamp);
-
- if (model->root == NULL)
- return;
-
- node = iter->user_data;
-
- col = g_ptr_array_index (model->columns, column);
-
- g_return_if_fail (col != NULL);
-
- if (col->prop_id >= 0)
- {
- if (!ephy_node_get_property (node, col->prop_id, value))
- {
- /* make sure to return a valid string anyway */
- g_value_init (value, col->type);
- if (col->type == G_TYPE_STRING)
- {
- g_value_set_string (value, "");
- }
- }
- }
-
- if (col->func)
- {
- col->func (node, value, col->user_data);
- }
+ EphyTreeModelNodeColData *col;
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ EphyNode *node;
+
+ g_return_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model));
+ g_return_if_fail (iter != NULL);
+ g_return_if_fail (iter->stamp == model->stamp);
+
+ if (model->root == NULL)
+ return;
+
+ node = iter->user_data;
+
+ col = g_ptr_array_index (model->columns, column);
+
+ g_return_if_fail (col != NULL);
+
+ if (col->prop_id >= 0) {
+ if (!ephy_node_get_property (node, col->prop_id, value)) {
+ /* make sure to return a valid string anyway */
+ g_value_init (value, col->type);
+ if (col->type == G_TYPE_STRING) {
+ g_value_set_string (value, "");
+ }
+ }
+ }
+
+ if (col->func) {
+ col->func (node, value, col->user_data);
+ }
}
static GtkTreeModelFlags
ephy_tree_model_node_get_flags (GtkTreeModel *tree_model)
{
- return GTK_TREE_MODEL_ITERS_PERSIST | GTK_TREE_MODEL_LIST_ONLY;
+ return GTK_TREE_MODEL_ITERS_PERSIST | GTK_TREE_MODEL_LIST_ONLY;
}
static gboolean
ephy_tree_model_node_get_iter (GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- GtkTreePath *path)
+ GtkTreeIter *iter,
+ GtkTreePath *path)
{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- int i;
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ int i;
- g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (model), FALSE);
- g_return_val_if_fail (gtk_tree_path_get_depth (path) > 0, FALSE);
+ g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (model), FALSE);
+ g_return_val_if_fail (gtk_tree_path_get_depth (path) > 0, FALSE);
- if (model->root == NULL)
- return FALSE;
+ if (model->root == NULL)
+ return FALSE;
- i = gtk_tree_path_get_indices (path)[0];
+ i = gtk_tree_path_get_indices (path)[0];
- iter->stamp = model->stamp;
- iter->user_data = ephy_node_get_nth_child (model->root, i);
+ iter->stamp = model->stamp;
+ iter->user_data = ephy_node_get_nth_child (model->root, i);
- if (iter->user_data == NULL)
- {
- iter->stamp = 0;
- return FALSE;
- }
+ if (iter->user_data == NULL) {
+ iter->stamp = 0;
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
static GtkTreePath *
ephy_tree_model_node_get_path (GtkTreeModel *tree_model,
- GtkTreeIter *iter)
+ GtkTreeIter *iter)
{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- EphyNode *node;
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ EphyNode *node;
- g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model), NULL);
- g_return_val_if_fail (iter != NULL, NULL);
- g_return_val_if_fail (iter->user_data != NULL, NULL);
- g_return_val_if_fail (iter->stamp == model->stamp, NULL);
+ g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model), NULL);
+ g_return_val_if_fail (iter != NULL, NULL);
+ g_return_val_if_fail (iter->user_data != NULL, NULL);
+ g_return_val_if_fail (iter->stamp == model->stamp, NULL);
- if (model->root == NULL)
- return NULL;
+ if (model->root == NULL)
+ return NULL;
- node = iter->user_data;
+ node = iter->user_data;
- if (node == model->root)
- return gtk_tree_path_new ();
+ if (node == model->root)
+ return gtk_tree_path_new ();
- return get_path_real (model, node);
+ return get_path_real (model, node);
}
static gboolean
ephy_tree_model_node_iter_next (GtkTreeModel *tree_model,
- GtkTreeIter *iter)
+ GtkTreeIter *iter)
{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- EphyNode *node;
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ EphyNode *node;
- g_return_val_if_fail (iter != NULL, FALSE);
- g_return_val_if_fail (iter->user_data != NULL, FALSE);
- g_return_val_if_fail (iter->stamp == model->stamp, FALSE);
+ g_return_val_if_fail (iter != NULL, FALSE);
+ g_return_val_if_fail (iter->user_data != NULL, FALSE);
+ g_return_val_if_fail (iter->stamp == model->stamp, FALSE);
- if (model->root == NULL)
- return FALSE;
+ if (model->root == NULL)
+ return FALSE;
- node = iter->user_data;
+ node = iter->user_data;
- if (node == model->root)
- return FALSE;
+ if (node == model->root)
+ return FALSE;
- iter->user_data = ephy_node_get_next_child (model->root, node);
+ iter->user_data = ephy_node_get_next_child (model->root, node);
- return (iter->user_data != NULL);
+ return (iter->user_data != NULL);
}
static gboolean
ephy_tree_model_node_iter_children (GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- GtkTreeIter *parent)
+ GtkTreeIter *iter,
+ GtkTreeIter *parent)
{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- if (model->root == NULL)
- return FALSE;
+ if (model->root == NULL)
+ return FALSE;
- if (parent != NULL)
- return FALSE;
+ if (parent != NULL)
+ return FALSE;
- iter->stamp = model->stamp;
- iter->user_data = model->root;
+ iter->stamp = model->stamp;
+ iter->user_data = model->root;
- return TRUE;
+ return TRUE;
}
static gboolean
ephy_tree_model_node_iter_has_child (GtkTreeModel *tree_model,
- GtkTreeIter *iter)
+ GtkTreeIter *iter)
{
- return FALSE;
+ return FALSE;
}
static int
ephy_tree_model_node_iter_n_children (GtkTreeModel *tree_model,
- GtkTreeIter *iter)
+ GtkTreeIter *iter)
{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model), -1);
+ g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model), -1);
- if (model->root == NULL)
- return 0;
+ if (model->root == NULL)
+ return 0;
- if (iter == NULL)
- return ephy_node_get_n_children (model->root);
+ if (iter == NULL)
+ return ephy_node_get_n_children (model->root);
- g_return_val_if_fail (model->stamp == iter->stamp, -1);
+ g_return_val_if_fail (model->stamp == iter->stamp, -1);
- return 0;
+ return 0;
}
static gboolean
ephy_tree_model_node_iter_nth_child (GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- GtkTreeIter *parent,
- int n)
+ GtkTreeIter *iter,
+ GtkTreeIter *parent,
+ int n)
{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- EphyNode *node;
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ EphyNode *node;
- g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model), FALSE);
+ g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model), FALSE);
- if (model->root == NULL)
- return FALSE;
+ if (model->root == NULL)
+ return FALSE;
- if (parent != NULL)
- return FALSE;
+ if (parent != NULL)
+ return FALSE;
- node = ephy_node_get_nth_child (model->root, n);
+ node = ephy_node_get_nth_child (model->root, n);
- if (node != NULL)
- {
- iter->stamp = model->stamp;
- iter->user_data = node;
- return TRUE;
- }
- else
- return FALSE;
+ if (node != NULL) {
+ iter->stamp = model->stamp;
+ iter->user_data = node;
+ return TRUE;
+ } else
+ return FALSE;
}
static gboolean
ephy_tree_model_node_iter_parent (GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- GtkTreeIter *child)
+ GtkTreeIter *iter,
+ GtkTreeIter *child)
{
- return FALSE;
+ return FALSE;
}
/**
@@ -601,9 +586,9 @@ ephy_tree_model_node_iter_parent (GtkTreeModel *tree_model,
**/
EphyNode *
ephy_tree_model_node_node_from_iter (EphyTreeModelNode *model,
- GtkTreeIter *iter)
+ GtkTreeIter *iter)
{
- return iter->user_data;
+ return iter->user_data;
}
/**
@@ -616,26 +601,26 @@ ephy_tree_model_node_node_from_iter (EphyTreeModelNode *model,
**/
void
ephy_tree_model_node_iter_from_node (EphyTreeModelNode *model,
- EphyNode *node,
- GtkTreeIter *iter)
+ EphyNode *node,
+ GtkTreeIter *iter)
{
- iter->stamp = model->stamp;
- iter->user_data = node;
+ iter->stamp = model->stamp;
+ iter->user_data = node;
}
static void
ephy_tree_model_node_tree_model_interface_init (GtkTreeModelIface *iface)
{
- iface->get_flags = ephy_tree_model_node_get_flags;
- iface->get_iter = ephy_tree_model_node_get_iter;
- iface->get_path = ephy_tree_model_node_get_path;
- iface->iter_next = ephy_tree_model_node_iter_next;
- iface->iter_children = ephy_tree_model_node_iter_children;
- iface->iter_has_child = ephy_tree_model_node_iter_has_child;
- iface->iter_n_children = ephy_tree_model_node_iter_n_children;
- iface->iter_nth_child = ephy_tree_model_node_iter_nth_child;
- iface->iter_parent = ephy_tree_model_node_iter_parent;
- iface->get_n_columns = ephy_tree_model_node_get_n_columns;
- iface->get_column_type = ephy_tree_model_node_get_column_type;
- iface->get_value = ephy_tree_model_node_get_value;
+ iface->get_flags = ephy_tree_model_node_get_flags;
+ iface->get_iter = ephy_tree_model_node_get_iter;
+ iface->get_path = ephy_tree_model_node_get_path;
+ iface->iter_next = ephy_tree_model_node_iter_next;
+ iface->iter_children = ephy_tree_model_node_iter_children;
+ iface->iter_has_child = ephy_tree_model_node_iter_has_child;
+ iface->iter_n_children = ephy_tree_model_node_iter_n_children;
+ iface->iter_nth_child = ephy_tree_model_node_iter_nth_child;
+ iface->iter_parent = ephy_tree_model_node_iter_parent;
+ iface->get_n_columns = ephy_tree_model_node_get_n_columns;
+ iface->get_column_type = ephy_tree_model_node_get_column_type;
+ iface->get_value = ephy_tree_model_node_get_value;
}
diff --git a/lib/widgets/ephy-tree-model-sort.c b/lib/widgets/ephy-tree-model-sort.c
index 82d0441dc..96037f45c 100644
--- a/lib/widgets/ephy-tree-model-sort.c
+++ b/lib/widgets/ephy-tree-model-sort.c
@@ -37,19 +37,18 @@
static void ephy_tree_model_sort_finalize (GObject *object);
static void ephy_tree_model_sort_multi_drag_source_interface_init (EggTreeMultiDragSourceIface *iface);
static gboolean ephy_tree_model_sort_multi_row_draggable (EggTreeMultiDragSource *drag_source,
- GList *path_list);
+ GList *path_list);
static gboolean ephy_tree_model_sort_multi_drag_data_get (EggTreeMultiDragSource *drag_source,
- GList *path_list,
- GtkSelectionData *selection_data);
+ GList *path_list,
+ GtkSelectionData *selection_data);
static gboolean ephy_tree_model_sort_multi_drag_data_delete (EggTreeMultiDragSource *drag_source,
- GList *path_list);
+ GList *path_list);
-struct _EphyTreeModelSort
-{
- GtkTreeModelSort parent_instance;
- char *str_list;
- int base_drag_column_id;
- int extra_drag_column_id;
+struct _EphyTreeModelSort {
+ GtkTreeModelSort parent_instance;
+ char *str_list;
+ int base_drag_column_id;
+ int extra_drag_column_id;
};
G_DEFINE_TYPE_WITH_CODE (EphyTreeModelSort, ephy_tree_model_sort, GTK_TYPE_TREE_MODEL_SORT,
@@ -59,26 +58,26 @@ G_DEFINE_TYPE_WITH_CODE (EphyTreeModelSort, ephy_tree_model_sort, GTK_TYPE_TREE_
static void
ephy_tree_model_sort_class_init (EphyTreeModelSortClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = ephy_tree_model_sort_finalize;
+ object_class->finalize = ephy_tree_model_sort_finalize;
}
static void
ephy_tree_model_sort_init (EphyTreeModelSort *ma)
{
- ma->base_drag_column_id = -1;
- ma->extra_drag_column_id = -1;
+ ma->base_drag_column_id = -1;
+ ma->extra_drag_column_id = -1;
}
static void
ephy_tree_model_sort_finalize (GObject *object)
{
- EphyTreeModelSort *model = EPHY_TREE_MODEL_SORT (object);
+ EphyTreeModelSort *model = EPHY_TREE_MODEL_SORT (object);
- g_free (model->str_list);
+ g_free (model->str_list);
- G_OBJECT_CLASS (ephy_tree_model_sort_parent_class)->finalize (object);
+ G_OBJECT_CLASS (ephy_tree_model_sort_parent_class)->finalize (object);
}
/**
@@ -89,32 +88,32 @@ ephy_tree_model_sort_finalize (GObject *object)
*
* Returns: a new #EphyTreeModelSort, as a #GtkWidget
**/
-GtkTreeModel*
+GtkTreeModel *
ephy_tree_model_sort_new (GtkTreeModel *child_model)
{
- GtkTreeModel *model;
+ GtkTreeModel *model;
- g_return_val_if_fail (child_model != NULL, NULL);
+ g_return_val_if_fail (child_model != NULL, NULL);
- model = GTK_TREE_MODEL (g_object_new (EPHY_TYPE_TREE_MODEL_SORT,
- "model", child_model,
- NULL));
+ model = GTK_TREE_MODEL (g_object_new (EPHY_TYPE_TREE_MODEL_SORT,
+ "model", child_model,
+ NULL));
- return model;
+ return model;
}
static void
ephy_tree_model_sort_multi_drag_source_interface_init (EggTreeMultiDragSourceIface *iface)
{
- iface->row_draggable = ephy_tree_model_sort_multi_row_draggable;
- iface->drag_data_get = ephy_tree_model_sort_multi_drag_data_get;
- iface->drag_data_delete = ephy_tree_model_sort_multi_drag_data_delete;
+ iface->row_draggable = ephy_tree_model_sort_multi_row_draggable;
+ iface->drag_data_get = ephy_tree_model_sort_multi_drag_data_get;
+ iface->drag_data_delete = ephy_tree_model_sort_multi_drag_data_delete;
}
static gboolean
ephy_tree_model_sort_multi_row_draggable (EggTreeMultiDragSource *drag_source, GList *path_list)
{
- return (EPHY_TREE_MODEL_SORT (drag_source)->base_drag_column_id >= 0);
+ return (EPHY_TREE_MODEL_SORT (drag_source)->base_drag_column_id >= 0);
}
/**
@@ -126,9 +125,9 @@ ephy_tree_model_sort_multi_row_draggable (EggTreeMultiDragSource *drag_source, G
**/
void
ephy_tree_model_sort_set_base_drag_column_id (EphyTreeModelSort *ms,
- int id)
+ int id)
{
- ms->base_drag_column_id = id;
+ ms->base_drag_column_id = id;
}
/**
@@ -140,76 +139,75 @@ ephy_tree_model_sort_set_base_drag_column_id (EphyTreeModelSort *ms,
**/
void
ephy_tree_model_sort_set_extra_drag_column_id (EphyTreeModelSort *ms,
- int id)
+ int id)
{
- ms->extra_drag_column_id = id;
+ ms->extra_drag_column_id = id;
}
static gboolean
ephy_tree_model_sort_multi_drag_data_delete (EggTreeMultiDragSource *drag_source,
- GList *path_list)
+ GList *path_list)
{
- return TRUE;
+ return TRUE;
}
static void
each_property_get_data_binder (EphyDragEachSelectedItemDataGet iteratee,
- gpointer iterator_context, gpointer data)
+ gpointer iterator_context, gpointer data)
{
- gpointer *context = (gpointer *) iterator_context;
- GList *path_list = (GList *) (context[0]);
- GList *i;
- EphyTreeModelSort *model = EPHY_TREE_MODEL_SORT (context[1]);
- GValue base_value = {0, }, extra_value = {0, };
-
- for (i = path_list; i != NULL; i = i->next)
- {
- GtkTreeIter iter;
- GtkTreePath *path = NULL;
- const char *base_data, *extra_data;
-
- path = gtk_tree_row_reference_get_path (i->data);
- gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
-
- gtk_tree_model_get_value (GTK_TREE_MODEL (model), &iter,
- model->base_drag_column_id,
- &base_value);
- base_data = g_value_get_string (&base_value);
-
- if (model->extra_drag_column_id >= 0) {
- gtk_tree_model_get_value (GTK_TREE_MODEL (model), &iter,
- model->extra_drag_column_id,
- &extra_value);
- extra_data = g_value_get_string (&extra_value);
- } else
- extra_data = NULL;
-
- g_return_if_fail (base_data != NULL);
-
- LOG ("Data get %s (%s)", base_data, extra_data);
-
- iteratee (base_data, extra_data, data);
-
- gtk_tree_path_free (path);
- g_value_unset (&base_value);
-
- if (model->extra_drag_column_id >= 0)
- g_value_unset (&extra_value);
- }
+ gpointer *context = (gpointer *)iterator_context;
+ GList *path_list = (GList *)(context[0]);
+ GList *i;
+ EphyTreeModelSort *model = EPHY_TREE_MODEL_SORT (context[1]);
+ GValue base_value = { 0, }, extra_value = { 0, };
+
+ for (i = path_list; i != NULL; i = i->next) {
+ GtkTreeIter iter;
+ GtkTreePath *path = NULL;
+ const char *base_data, *extra_data;
+
+ path = gtk_tree_row_reference_get_path (i->data);
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
+
+ gtk_tree_model_get_value (GTK_TREE_MODEL (model), &iter,
+ model->base_drag_column_id,
+ &base_value);
+ base_data = g_value_get_string (&base_value);
+
+ if (model->extra_drag_column_id >= 0) {
+ gtk_tree_model_get_value (GTK_TREE_MODEL (model), &iter,
+ model->extra_drag_column_id,
+ &extra_value);
+ extra_data = g_value_get_string (&extra_value);
+ } else
+ extra_data = NULL;
+
+ g_return_if_fail (base_data != NULL);
+
+ LOG ("Data get %s (%s)", base_data, extra_data);
+
+ iteratee (base_data, extra_data, data);
+
+ gtk_tree_path_free (path);
+ g_value_unset (&base_value);
+
+ if (model->extra_drag_column_id >= 0)
+ g_value_unset (&extra_value);
+ }
}
static gboolean
ephy_tree_model_sort_multi_drag_data_get (EggTreeMultiDragSource *drag_source,
- GList *path_list,
- GtkSelectionData *selection_data)
+ GList *path_list,
+ GtkSelectionData *selection_data)
{
- gpointer icontext[2];
+ gpointer icontext[2];
- icontext[0] = path_list;
- icontext[1] = drag_source;
+ icontext[0] = path_list;
+ icontext[1] = drag_source;
- ephy_dnd_drag_data_get (NULL, NULL, selection_data,
- 0, &icontext, each_property_get_data_binder);
+ ephy_dnd_drag_data_get (NULL, NULL, selection_data,
+ 0, &icontext, each_property_get_data_binder);
- return TRUE;
+ return TRUE;
}
diff --git a/lib/widgets/ephy-zoom-action.c b/lib/widgets/ephy-zoom-action.c
index fe1c89938..5be43842e 100644
--- a/lib/widgets/ephy-zoom-action.c
+++ b/lib/widgets/ephy-zoom-action.c
@@ -32,24 +32,21 @@
#define EPHY_ZOOM_ACTION_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_ZOOM_ACTION, EphyZoomActionPrivate))
-struct _EphyZoomActionPrivate
-{
- float zoom;
+struct _EphyZoomActionPrivate {
+ float zoom;
};
-enum
-{
- PROP_0,
- PROP_ZOOM,
- LAST_PROP
+enum {
+ PROP_0,
+ PROP_ZOOM,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
-enum
-{
- ZOOM_TO_LEVEL_SIGNAL,
- LAST_SIGNAL
+enum {
+ ZOOM_TO_LEVEL_SIGNAL,
+ LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
@@ -59,149 +56,145 @@ G_DEFINE_TYPE (EphyZoomAction, ephy_zoom_action, GTK_TYPE_ACTION)
static void
proxy_menu_activate_cb (GtkMenuItem *menu_item, EphyZoomAction *action)
{
- gint index;
- float zoom;
+ gint index;
+ float zoom;
- /* menu item was toggled OFF */
- if (!gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menu_item))) return;
+ /* menu item was toggled OFF */
+ if (!gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menu_item))) return;
- index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "zoom-level"));
- zoom = zoom_levels[index].level;
+ index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "zoom-level"));
+ zoom = zoom_levels[index].level;
- if (zoom != action->priv->zoom)
- {
- g_signal_emit (action, signals[ZOOM_TO_LEVEL_SIGNAL], 0, zoom);
- }
+ if (zoom != action->priv->zoom) {
+ g_signal_emit (action, signals[ZOOM_TO_LEVEL_SIGNAL], 0, zoom);
+ }
}
static GtkWidget *
create_menu_item (GtkAction *action)
{
- EphyZoomActionPrivate *p = EPHY_ZOOM_ACTION (action)->priv;
- GtkWidget *menu, *menu_item;
- GSList *group = NULL;
- guint i;
+ EphyZoomActionPrivate *p = EPHY_ZOOM_ACTION (action)->priv;
+ GtkWidget *menu, *menu_item;
+ GSList *group = NULL;
+ guint i;
- menu = gtk_menu_new ();
+ menu = gtk_menu_new ();
- for (i = 0; i < n_zoom_levels; i++)
- {
- menu_item = gtk_radio_menu_item_new_with_label (group, _(zoom_levels[i].name));
- group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_item));
+ for (i = 0; i < n_zoom_levels; i++) {
+ menu_item = gtk_radio_menu_item_new_with_label (group, _(zoom_levels[i].name));
+ group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_item));
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
- p->zoom == zoom_levels[i].level);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
+ p->zoom == zoom_levels[i].level);
- gtk_widget_show (menu_item);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+ gtk_widget_show (menu_item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
- g_object_set_data (G_OBJECT (menu_item), "zoom-level", GINT_TO_POINTER (i));
- g_signal_connect_object (G_OBJECT (menu_item), "activate",
- G_CALLBACK (proxy_menu_activate_cb), action, 0);
- }
+ g_object_set_data (G_OBJECT (menu_item), "zoom-level", GINT_TO_POINTER (i));
+ g_signal_connect_object (G_OBJECT (menu_item), "activate",
+ G_CALLBACK (proxy_menu_activate_cb), action, 0);
+ }
- gtk_widget_show (menu);
+ gtk_widget_show (menu);
- menu_item = GTK_ACTION_CLASS (ephy_zoom_action_parent_class)->create_menu_item (action);
+ menu_item = GTK_ACTION_CLASS (ephy_zoom_action_parent_class)->create_menu_item (action);
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), menu);
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), menu);
- gtk_widget_show (menu_item);
+ gtk_widget_show (menu_item);
- return menu_item;
+ return menu_item;
}
static void
-ephy_zoom_action_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ephy_zoom_action_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- EphyZoomAction *action;
-
- action = EPHY_ZOOM_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_ZOOM:
- action->priv->zoom = g_value_get_float (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
+ EphyZoomAction *action;
+
+ action = EPHY_ZOOM_ACTION (object);
+
+ switch (prop_id) {
+ case PROP_ZOOM:
+ action->priv->zoom = g_value_get_float (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
-ephy_zoom_action_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ephy_zoom_action_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- EphyZoomAction *action;
-
- action = EPHY_ZOOM_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_ZOOM:
- g_value_set_float (value, action->priv->zoom);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
+ EphyZoomAction *action;
+
+ action = EPHY_ZOOM_ACTION (object);
+
+ switch (prop_id) {
+ case PROP_ZOOM:
+ g_value_set_float (value, action->priv->zoom);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
ephy_zoom_action_class_init (EphyZoomActionClass *class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
- GtkActionClass *action_class = GTK_ACTION_CLASS (class);
-
- object_class->set_property = ephy_zoom_action_set_property;
- object_class->get_property = ephy_zoom_action_get_property;
-
- action_class->create_menu_item = create_menu_item;
-
- /**
- * EphyZoomAction:zoom:
- *
- * The current value of #EphyZoomAction, as a float.
- */
- obj_properties[PROP_ZOOM] =
- g_param_spec_float ("zoom", NULL, NULL,
- ZOOM_MINIMAL,
- ZOOM_MAXIMAL,
- 1.0,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
-
- /**
- * EphyZoomAction::zoom-to-level:
- * @action: the object on which the signal is emitted
- * @level: new zoom level
- *
- * Emitted when the user changes the value of the #EphyZoomAction.
- */
- signals[ZOOM_TO_LEVEL_SIGNAL] =
- g_signal_new ("zoom-to-level",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EphyZoomActionClass, zoom_to_level),
- NULL, NULL, NULL,
- G_TYPE_NONE,
- 1,
- G_TYPE_FLOAT);
-
- g_type_class_add_private (object_class, sizeof (EphyZoomActionPrivate));
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ GtkActionClass *action_class = GTK_ACTION_CLASS (class);
+
+ object_class->set_property = ephy_zoom_action_set_property;
+ object_class->get_property = ephy_zoom_action_get_property;
+
+ action_class->create_menu_item = create_menu_item;
+
+ /**
+ * EphyZoomAction:zoom:
+ *
+ * The current value of #EphyZoomAction, as a float.
+ */
+ obj_properties[PROP_ZOOM] =
+ g_param_spec_float ("zoom", NULL, NULL,
+ ZOOM_MINIMAL,
+ ZOOM_MAXIMAL,
+ 1.0,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+
+ /**
+ * EphyZoomAction::zoom-to-level:
+ * @action: the object on which the signal is emitted
+ * @level: new zoom level
+ *
+ * Emitted when the user changes the value of the #EphyZoomAction.
+ */
+ signals[ZOOM_TO_LEVEL_SIGNAL] =
+ g_signal_new ("zoom-to-level",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EphyZoomActionClass, zoom_to_level),
+ NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_FLOAT);
+
+ g_type_class_add_private (object_class, sizeof (EphyZoomActionPrivate));
}
static void
ephy_zoom_action_init (EphyZoomAction *action)
{
- action->priv = EPHY_ZOOM_ACTION_GET_PRIVATE (action);
+ action->priv = EPHY_ZOOM_ACTION_GET_PRIVATE (action);
- action->priv->zoom = 1.0;
+ action->priv->zoom = 1.0;
}
/**
@@ -214,12 +207,12 @@ ephy_zoom_action_init (EphyZoomAction *action)
void
ephy_zoom_action_set_zoom_level (EphyZoomAction *action, float zoom)
{
- g_return_if_fail (EPHY_IS_ZOOM_ACTION (action));
-
- if (zoom < ZOOM_MINIMAL || zoom > ZOOM_MAXIMAL) return;
+ g_return_if_fail (EPHY_IS_ZOOM_ACTION (action));
- action->priv->zoom = zoom;
- g_object_notify_by_pspec (G_OBJECT (action), obj_properties[PROP_ZOOM]);
+ if (zoom < ZOOM_MINIMAL || zoom > ZOOM_MAXIMAL) return;
+
+ action->priv->zoom = zoom;
+ g_object_notify_by_pspec (G_OBJECT (action), obj_properties[PROP_ZOOM]);
}
/**
@@ -233,7 +226,7 @@ ephy_zoom_action_set_zoom_level (EphyZoomAction *action, float zoom)
float
ephy_zoom_action_get_zoom_level (EphyZoomAction *action)
{
- g_return_val_if_fail (EPHY_IS_ZOOM_ACTION (action), 1.0);
-
- return action->priv->zoom;
+ g_return_val_if_fail (EPHY_IS_ZOOM_ACTION (action), 1.0);
+
+ return action->priv->zoom;
}
diff --git a/lib/widgets/nautilus-floating-bar.c b/lib/widgets/nautilus-floating-bar.c
index 52219b95f..586dcd069 100644
--- a/lib/widgets/nautilus-floating-bar.c
+++ b/lib/widgets/nautilus-floating-bar.c
@@ -28,27 +28,27 @@
#include "nautilus-floating-bar.h"
struct _NautilusFloatingBarDetails {
- gchar *primary_label;
- gchar *details_label;
-
- GtkWidget *primary_label_widget;
- GtkWidget *details_label_widget;
- GtkWidget *spinner;
- gboolean show_spinner;
- gboolean is_interactive;
- guint hover_timeout_id;
+ gchar *primary_label;
+ gchar *details_label;
+
+ GtkWidget *primary_label_widget;
+ GtkWidget *details_label_widget;
+ GtkWidget *spinner;
+ gboolean show_spinner;
+ gboolean is_interactive;
+ guint hover_timeout_id;
};
enum {
- PROP_PRIMARY_LABEL = 1,
- PROP_DETAILS_LABEL,
- PROP_SHOW_SPINNER,
- NUM_PROPERTIES
+ PROP_PRIMARY_LABEL = 1,
+ PROP_DETAILS_LABEL,
+ PROP_SHOW_SPINNER,
+ NUM_PROPERTIES
};
enum {
- ACTION,
- NUM_SIGNALS
+ ACTION,
+ NUM_SIGNALS
};
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
@@ -58,458 +58,458 @@ G_DEFINE_TYPE (NautilusFloatingBar, nautilus_floating_bar,
GTK_TYPE_BOX);
static void
-action_button_clicked_cb (GtkButton *button,
- NautilusFloatingBar *self)
+action_button_clicked_cb (GtkButton *button,
+ NautilusFloatingBar *self)
{
- gint action_id;
+ gint action_id;
- action_id = GPOINTER_TO_INT
- (g_object_get_data (G_OBJECT (button), "action-id"));
-
- g_signal_emit (self, signals[ACTION], 0, action_id);
+ action_id = GPOINTER_TO_INT
+ (g_object_get_data (G_OBJECT (button), "action-id"));
+
+ g_signal_emit (self, signals[ACTION], 0, action_id);
}
static void
nautilus_floating_bar_finalize (GObject *obj)
{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (obj);
+ NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (obj);
- g_free (self->priv->primary_label);
- g_free (self->priv->details_label);
+ g_free (self->priv->primary_label);
+ g_free (self->priv->details_label);
- G_OBJECT_CLASS (nautilus_floating_bar_parent_class)->finalize (obj);
+ G_OBJECT_CLASS (nautilus_floating_bar_parent_class)->finalize (obj);
}
static void
-nautilus_floating_bar_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+nautilus_floating_bar_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (object);
-
- switch (property_id) {
- case PROP_PRIMARY_LABEL:
- g_value_set_string (value, self->priv->primary_label);
- break;
- case PROP_DETAILS_LABEL:
- g_value_set_string (value, self->priv->details_label);
- break;
- case PROP_SHOW_SPINNER:
- g_value_set_boolean (value, self->priv->show_spinner);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
+ NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (object);
+
+ switch (property_id) {
+ case PROP_PRIMARY_LABEL:
+ g_value_set_string (value, self->priv->primary_label);
+ break;
+ case PROP_DETAILS_LABEL:
+ g_value_set_string (value, self->priv->details_label);
+ break;
+ case PROP_SHOW_SPINNER:
+ g_value_set_boolean (value, self->priv->show_spinner);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
}
static void
-nautilus_floating_bar_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
+nautilus_floating_bar_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (object);
-
- switch (property_id) {
- case PROP_PRIMARY_LABEL:
- nautilus_floating_bar_set_primary_label (self, g_value_get_string (value));
- break;
- case PROP_DETAILS_LABEL:
- nautilus_floating_bar_set_details_label (self, g_value_get_string (value));
- break;
- case PROP_SHOW_SPINNER:
- nautilus_floating_bar_set_show_spinner (self, g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
+ NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (object);
+
+ switch (property_id) {
+ case PROP_PRIMARY_LABEL:
+ nautilus_floating_bar_set_primary_label (self, g_value_get_string (value));
+ break;
+ case PROP_DETAILS_LABEL:
+ nautilus_floating_bar_set_details_label (self, g_value_get_string (value));
+ break;
+ case PROP_SHOW_SPINNER:
+ nautilus_floating_bar_set_show_spinner (self, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
}
static void
update_labels (NautilusFloatingBar *self)
{
- gboolean primary_visible, details_visible;
+ gboolean primary_visible, details_visible;
- primary_visible = (self->priv->primary_label != NULL) &&
- (strlen (self->priv->primary_label) > 0);
- details_visible = (self->priv->details_label != NULL) &&
- (strlen (self->priv->details_label) > 0);
+ primary_visible = (self->priv->primary_label != NULL) &&
+ (strlen (self->priv->primary_label) > 0);
+ details_visible = (self->priv->details_label != NULL) &&
+ (strlen (self->priv->details_label) > 0);
- gtk_label_set_text (GTK_LABEL (self->priv->primary_label_widget),
- self->priv->primary_label);
- gtk_widget_set_visible (self->priv->primary_label_widget, primary_visible);
+ gtk_label_set_text (GTK_LABEL (self->priv->primary_label_widget),
+ self->priv->primary_label);
+ gtk_widget_set_visible (self->priv->primary_label_widget, primary_visible);
- gtk_label_set_text (GTK_LABEL (self->priv->details_label_widget),
- self->priv->details_label);
- gtk_widget_set_visible (self->priv->details_label_widget, details_visible);
+ gtk_label_set_text (GTK_LABEL (self->priv->details_label_widget),
+ self->priv->details_label);
+ gtk_widget_set_visible (self->priv->details_label_widget, details_visible);
}
static void
nautilus_floating_bar_show (GtkWidget *widget)
{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);
+ NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);
- /* Epiphany: never show the bar on top of the web view. */
- if (gtk_widget_get_valign (widget) == GTK_ALIGN_START)
- return;
+ /* Epiphany: never show the bar on top of the web view. */
+ if (gtk_widget_get_valign (widget) == GTK_ALIGN_START)
+ return;
- GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->show (widget);
+ GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->show (widget);
- if (self->priv->show_spinner) {
- gtk_spinner_start (GTK_SPINNER (self->priv->spinner));
- }
+ if (self->priv->show_spinner) {
+ gtk_spinner_start (GTK_SPINNER (self->priv->spinner));
+ }
}
static void
nautilus_floating_bar_hide (GtkWidget *widget)
{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);
+ NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);
- GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->hide (widget);
+ GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->hide (widget);
- gtk_spinner_stop (GTK_SPINNER (self->priv->spinner));
+ gtk_spinner_stop (GTK_SPINNER (self->priv->spinner));
}
typedef struct {
- GtkWidget *overlay;
- GtkWidget *floating_bar;
- GdkDevice *device;
- gint y_down_limit;
- gint y_upper_limit;
- gboolean first_time;
+ GtkWidget *overlay;
+ GtkWidget *floating_bar;
+ GdkDevice *device;
+ gint y_down_limit;
+ gint y_upper_limit;
+ gboolean first_time;
} CheckPointerData;
static gboolean
check_pointer_timeout (gpointer user_data)
{
- CheckPointerData *data = user_data;
- gint pointer_y = -1;
-
- gdk_window_get_device_position (gtk_widget_get_window (data->overlay), data->device,
- NULL, &pointer_y, NULL);
-
- if (pointer_y == -1 || pointer_y < data->y_down_limit || pointer_y > data->y_upper_limit) {
- if (!data->first_time) {
- gtk_widget_set_valign (data->floating_bar, GTK_ALIGN_END);
- nautilus_floating_bar_show (data->floating_bar);
- }
- NAUTILUS_FLOATING_BAR (data->floating_bar)->priv->hover_timeout_id = 0;
- return G_SOURCE_REMOVE;
- }
-
- if (data->first_time) {
- // Hide floating bar at top position of widget
- nautilus_floating_bar_hide (data->floating_bar);
- gtk_widget_set_valign (data->floating_bar, GTK_ALIGN_START);
- gtk_widget_queue_resize (data->floating_bar);
- }
-
- data->first_time = FALSE;
- return G_SOURCE_CONTINUE;
+ CheckPointerData *data = user_data;
+ gint pointer_y = -1;
+
+ gdk_window_get_device_position (gtk_widget_get_window (data->overlay), data->device,
+ NULL, &pointer_y, NULL);
+
+ if (pointer_y == -1 || pointer_y < data->y_down_limit || pointer_y > data->y_upper_limit) {
+ if (!data->first_time) {
+ gtk_widget_set_valign (data->floating_bar, GTK_ALIGN_END);
+ nautilus_floating_bar_show (data->floating_bar);
+ }
+ NAUTILUS_FLOATING_BAR (data->floating_bar)->priv->hover_timeout_id = 0;
+ return G_SOURCE_REMOVE;
+ }
+
+ if (data->first_time) {
+ /* Hide floating bar at top position of widget */
+ nautilus_floating_bar_hide (data->floating_bar);
+ gtk_widget_set_valign (data->floating_bar, GTK_ALIGN_START);
+ gtk_widget_queue_resize (data->floating_bar);
+ }
+
+ data->first_time = FALSE;
+ return G_SOURCE_CONTINUE;
}
static gboolean
overlay_enter_notify_cb (GtkWidget *parent,
- GdkEventCrossing *event,
- gpointer user_data)
+ GdkEventCrossing *event,
+ gpointer user_data)
{
- GtkWidget *widget = user_data;
- CheckPointerData *data;
- GtkAllocation alloc_parent;
- gint y_pos;
-
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);
-
- if (self->priv->hover_timeout_id != 0) {
- g_source_remove (self->priv->hover_timeout_id);
- self->priv->hover_timeout_id = 0;
- }
-
- if (event->window != gtk_widget_get_window (widget)) {
- return GDK_EVENT_PROPAGATE;
- }
-
- if (NAUTILUS_FLOATING_BAR (widget)->priv->is_interactive) {
- return GDK_EVENT_PROPAGATE;
- }
-
- gtk_widget_get_allocation (parent, &alloc_parent);
- gdk_window_get_position (gtk_widget_get_window (widget), NULL, &y_pos);
-
- data = g_new (CheckPointerData, 1);
- data->overlay = parent;
- data->floating_bar = widget;
- data->device = gdk_event_get_device ((GdkEvent *) event);
- data->y_down_limit = y_pos;
- data->y_upper_limit = alloc_parent.height;
- data->first_time = TRUE;
-
- self->priv->hover_timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT, 250,
- check_pointer_timeout, data,
- g_free);
- g_source_set_name_by_id (self->priv->hover_timeout_id, "[nautilus-floating-bar] overlay_enter_notify_cb");
-
- return GDK_EVENT_STOP;
+ GtkWidget *widget = user_data;
+ CheckPointerData *data;
+ GtkAllocation alloc_parent;
+ gint y_pos;
+
+ NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);
+
+ if (self->priv->hover_timeout_id != 0) {
+ g_source_remove (self->priv->hover_timeout_id);
+ self->priv->hover_timeout_id = 0;
+ }
+
+ if (event->window != gtk_widget_get_window (widget)) {
+ return GDK_EVENT_PROPAGATE;
+ }
+
+ if (NAUTILUS_FLOATING_BAR (widget)->priv->is_interactive) {
+ return GDK_EVENT_PROPAGATE;
+ }
+
+ gtk_widget_get_allocation (parent, &alloc_parent);
+ gdk_window_get_position (gtk_widget_get_window (widget), NULL, &y_pos);
+
+ data = g_new (CheckPointerData, 1);
+ data->overlay = parent;
+ data->floating_bar = widget;
+ data->device = gdk_event_get_device ((GdkEvent *)event);
+ data->y_down_limit = y_pos;
+ data->y_upper_limit = alloc_parent.height;
+ data->first_time = TRUE;
+
+ self->priv->hover_timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT, 250,
+ check_pointer_timeout, data,
+ g_free);
+ g_source_set_name_by_id (self->priv->hover_timeout_id, "[nautilus-floating-bar] overlay_enter_notify_cb");
+
+ return GDK_EVENT_STOP;
}
static void
nautilus_floating_bar_parent_set (GtkWidget *widget,
- GtkWidget *old_parent)
+ GtkWidget *old_parent)
{
- GtkWidget *parent;
+ GtkWidget *parent;
- parent = gtk_widget_get_parent (widget);
+ parent = gtk_widget_get_parent (widget);
- if (old_parent != NULL) {
- g_signal_handlers_disconnect_by_func (old_parent,
- overlay_enter_notify_cb, widget);
- }
+ if (old_parent != NULL) {
+ g_signal_handlers_disconnect_by_func (old_parent,
+ overlay_enter_notify_cb, widget);
+ }
- if (parent != NULL) {
- g_signal_connect (parent, "enter-notify-event",
- G_CALLBACK (overlay_enter_notify_cb), widget);
- }
+ if (parent != NULL) {
+ g_signal_connect (parent, "enter-notify-event",
+ G_CALLBACK (overlay_enter_notify_cb), widget);
+ }
}
static gboolean
nautilus_floating_bar_draw (GtkWidget *widget,
- cairo_t *cr)
+ cairo_t *cr)
{
- GtkStyleContext *context;
+ GtkStyleContext *context;
- context = gtk_widget_get_style_context (widget);
+ context = gtk_widget_get_style_context (widget);
- gtk_style_context_save (context);
- gtk_style_context_set_state (context, gtk_widget_get_state_flags (widget));
+ gtk_style_context_save (context);
+ gtk_style_context_set_state (context, gtk_widget_get_state_flags (widget));
- gtk_render_background (context, cr, 0, 0,
- gtk_widget_get_allocated_width (widget),
- gtk_widget_get_allocated_height (widget));
+ gtk_render_background (context, cr, 0, 0,
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget));
- gtk_render_frame (context, cr, 0, 0,
- gtk_widget_get_allocated_width (widget),
- gtk_widget_get_allocated_height (widget));
+ gtk_render_frame (context, cr, 0, 0,
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget));
- gtk_style_context_restore (context);
+ gtk_style_context_restore (context);
- return GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->draw (widget, cr);;
+ return GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->draw (widget, cr);;
}
static void
nautilus_floating_bar_constructed (GObject *obj)
{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (obj);
- GtkWidget *w, *box, *labels_box;
-
- G_OBJECT_CLASS (nautilus_floating_bar_parent_class)->constructed (obj);
-
- box = GTK_WIDGET (obj);
-
- w = gtk_spinner_new ();
- gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0);
- gtk_widget_set_visible (w, self->priv->show_spinner);
- self->priv->spinner = w;
-
- gtk_widget_set_size_request (w, 16, 16);
- gtk_widget_set_margin_left (w, 8);
-
- labels_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_box_pack_start (GTK_BOX (box), labels_box, TRUE, TRUE, 0);
- g_object_set (labels_box,
- "margin-top", 2,
- "margin-bottom", 2,
- "margin-start", 12,
- "margin-end", 12,
- NULL);
- gtk_widget_show (labels_box);
-
- w = gtk_label_new (NULL);
- gtk_label_set_ellipsize (GTK_LABEL (w), PANGO_ELLIPSIZE_MIDDLE);
- gtk_label_set_single_line_mode (GTK_LABEL (w), TRUE);
- gtk_container_add (GTK_CONTAINER (labels_box), w);
- self->priv->primary_label_widget = w;
- gtk_widget_show (w);
-
- w = gtk_label_new (NULL);
- gtk_label_set_single_line_mode (GTK_LABEL (w), TRUE);
- gtk_container_add (GTK_CONTAINER (labels_box), w);
- self->priv->details_label_widget = w;
- gtk_widget_show (w);
+ NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (obj);
+ GtkWidget *w, *box, *labels_box;
+
+ G_OBJECT_CLASS (nautilus_floating_bar_parent_class)->constructed (obj);
+
+ box = GTK_WIDGET (obj);
+
+ w = gtk_spinner_new ();
+ gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0);
+ gtk_widget_set_visible (w, self->priv->show_spinner);
+ self->priv->spinner = w;
+
+ gtk_widget_set_size_request (w, 16, 16);
+ gtk_widget_set_margin_left (w, 8);
+
+ labels_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ gtk_box_pack_start (GTK_BOX (box), labels_box, TRUE, TRUE, 0);
+ g_object_set (labels_box,
+ "margin-top", 2,
+ "margin-bottom", 2,
+ "margin-start", 12,
+ "margin-end", 12,
+ NULL);
+ gtk_widget_show (labels_box);
+
+ w = gtk_label_new (NULL);
+ gtk_label_set_ellipsize (GTK_LABEL (w), PANGO_ELLIPSIZE_MIDDLE);
+ gtk_label_set_single_line_mode (GTK_LABEL (w), TRUE);
+ gtk_container_add (GTK_CONTAINER (labels_box), w);
+ self->priv->primary_label_widget = w;
+ gtk_widget_show (w);
+
+ w = gtk_label_new (NULL);
+ gtk_label_set_single_line_mode (GTK_LABEL (w), TRUE);
+ gtk_container_add (GTK_CONTAINER (labels_box), w);
+ self->priv->details_label_widget = w;
+ gtk_widget_show (w);
}
static void
nautilus_floating_bar_init (NautilusFloatingBar *self)
{
- GtkStyleContext *context;
+ GtkStyleContext *context;
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NAUTILUS_TYPE_FLOATING_BAR,
- NautilusFloatingBarDetails);
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NAUTILUS_TYPE_FLOATING_BAR,
+ NautilusFloatingBarDetails);
- context = gtk_widget_get_style_context (GTK_WIDGET (self));
- gtk_style_context_add_class (context, "floating-bar");
+ context = gtk_widget_get_style_context (GTK_WIDGET (self));
+ gtk_style_context_add_class (context, "floating-bar");
}
static void
nautilus_floating_bar_class_init (NautilusFloatingBarClass *klass)
{
- GObjectClass *oclass = G_OBJECT_CLASS (klass);
- GtkWidgetClass *wclass = GTK_WIDGET_CLASS (klass);
-
- oclass->constructed = nautilus_floating_bar_constructed;
- oclass->set_property = nautilus_floating_bar_set_property;
- oclass->get_property = nautilus_floating_bar_get_property;
- oclass->finalize = nautilus_floating_bar_finalize;
-
- wclass->draw = nautilus_floating_bar_draw;
- wclass->show = nautilus_floating_bar_show;
- wclass->hide = nautilus_floating_bar_hide;
- wclass->parent_set = nautilus_floating_bar_parent_set;
-
- properties[PROP_PRIMARY_LABEL] =
- g_param_spec_string ("primary-label",
- "Bar's primary label",
- "Primary label displayed by the bar",
- NULL,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
- properties[PROP_DETAILS_LABEL] =
- g_param_spec_string ("details-label",
- "Bar's details label",
- "Details label displayed by the bar",
- NULL,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
- properties[PROP_SHOW_SPINNER] =
- g_param_spec_boolean ("show-spinner",
- "Show spinner",
- "Whether a spinner should be shown in the floating bar",
- FALSE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- signals[ACTION] =
- g_signal_new ("action",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE, 1,
- G_TYPE_INT);
-
- g_type_class_add_private (klass, sizeof (NautilusFloatingBarDetails));
- g_object_class_install_properties (oclass, NUM_PROPERTIES, properties);
+ GObjectClass *oclass = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *wclass = GTK_WIDGET_CLASS (klass);
+
+ oclass->constructed = nautilus_floating_bar_constructed;
+ oclass->set_property = nautilus_floating_bar_set_property;
+ oclass->get_property = nautilus_floating_bar_get_property;
+ oclass->finalize = nautilus_floating_bar_finalize;
+
+ wclass->draw = nautilus_floating_bar_draw;
+ wclass->show = nautilus_floating_bar_show;
+ wclass->hide = nautilus_floating_bar_hide;
+ wclass->parent_set = nautilus_floating_bar_parent_set;
+
+ properties[PROP_PRIMARY_LABEL] =
+ g_param_spec_string ("primary-label",
+ "Bar's primary label",
+ "Primary label displayed by the bar",
+ NULL,
+ G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
+ properties[PROP_DETAILS_LABEL] =
+ g_param_spec_string ("details-label",
+ "Bar's details label",
+ "Details label displayed by the bar",
+ NULL,
+ G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
+ properties[PROP_SHOW_SPINNER] =
+ g_param_spec_boolean ("show-spinner",
+ "Show spinner",
+ "Whether a spinner should be shown in the floating bar",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ signals[ACTION] =
+ g_signal_new ("action",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE, 1,
+ G_TYPE_INT);
+
+ g_type_class_add_private (klass, sizeof (NautilusFloatingBarDetails));
+ g_object_class_install_properties (oclass, NUM_PROPERTIES, properties);
}
void
nautilus_floating_bar_set_primary_label (NautilusFloatingBar *self,
- const gchar *label)
+ const gchar *label)
{
- if (g_strcmp0 (self->priv->primary_label, label) != 0) {
- g_free (self->priv->primary_label);
- self->priv->primary_label = g_strdup (label);
+ if (g_strcmp0 (self->priv->primary_label, label) != 0) {
+ g_free (self->priv->primary_label);
+ self->priv->primary_label = g_strdup (label);
- g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PRIMARY_LABEL]);
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PRIMARY_LABEL]);
- update_labels (self);
- }
+ update_labels (self);
+ }
}
void
nautilus_floating_bar_set_details_label (NautilusFloatingBar *self,
- const gchar *label)
+ const gchar *label)
{
- if (g_strcmp0 (self->priv->details_label, label) != 0) {
- g_free (self->priv->details_label);
- self->priv->details_label = g_strdup (label);
+ if (g_strcmp0 (self->priv->details_label, label) != 0) {
+ g_free (self->priv->details_label);
+ self->priv->details_label = g_strdup (label);
- g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DETAILS_LABEL]);
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DETAILS_LABEL]);
- update_labels (self);
- }
+ update_labels (self);
+ }
}
void
nautilus_floating_bar_set_labels (NautilusFloatingBar *self,
- const gchar *primary_label,
- const gchar *details_label)
+ const gchar *primary_label,
+ const gchar *details_label)
{
- nautilus_floating_bar_set_primary_label (self, primary_label);
- nautilus_floating_bar_set_details_label (self, details_label);
+ nautilus_floating_bar_set_primary_label (self, primary_label);
+ nautilus_floating_bar_set_details_label (self, details_label);
}
void
nautilus_floating_bar_set_show_spinner (NautilusFloatingBar *self,
- gboolean show_spinner)
+ gboolean show_spinner)
{
- if (self->priv->show_spinner != show_spinner) {
- self->priv->show_spinner = show_spinner;
- gtk_widget_set_visible (self->priv->spinner,
- show_spinner);
+ if (self->priv->show_spinner != show_spinner) {
+ self->priv->show_spinner = show_spinner;
+ gtk_widget_set_visible (self->priv->spinner,
+ show_spinner);
- g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHOW_SPINNER]);
- }
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHOW_SPINNER]);
+ }
}
GtkWidget *
nautilus_floating_bar_new (const gchar *primary_label,
- const gchar *details_label,
- gboolean show_spinner)
+ const gchar *details_label,
+ gboolean show_spinner)
{
- return g_object_new (NAUTILUS_TYPE_FLOATING_BAR,
- "primary-label", primary_label,
- "details-label", details_label,
- "show-spinner", show_spinner,
- "orientation", GTK_ORIENTATION_HORIZONTAL,
- "spacing", 8,
- NULL);
+ return g_object_new (NAUTILUS_TYPE_FLOATING_BAR,
+ "primary-label", primary_label,
+ "details-label", details_label,
+ "show-spinner", show_spinner,
+ "orientation", GTK_ORIENTATION_HORIZONTAL,
+ "spacing", 8,
+ NULL);
}
void
nautilus_floating_bar_add_action (NautilusFloatingBar *self,
- const gchar *icon_name,
- gint action_id)
+ const gchar *icon_name,
+ gint action_id)
{
- GtkWidget *w, *button;
+ GtkWidget *w, *button;
- w = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
- gtk_widget_show (w);
+ w = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
+ gtk_widget_show (w);
- button = gtk_button_new ();
- gtk_button_set_image (GTK_BUTTON (button), w);
- gtk_box_pack_end (GTK_BOX (self), button, FALSE, FALSE, 0);
- gtk_widget_show (button);
+ button = gtk_button_new ();
+ gtk_button_set_image (GTK_BUTTON (button), w);
+ gtk_box_pack_end (GTK_BOX (self), button, FALSE, FALSE, 0);
+ gtk_widget_show (button);
- g_object_set_data (G_OBJECT (button), "action-id",
- GINT_TO_POINTER (action_id));
+ g_object_set_data (G_OBJECT (button), "action-id",
+ GINT_TO_POINTER (action_id));
- g_signal_connect (button, "clicked",
- G_CALLBACK (action_button_clicked_cb), self);
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (action_button_clicked_cb), self);
- self->priv->is_interactive = TRUE;
+ self->priv->is_interactive = TRUE;
}
void
nautilus_floating_bar_cleanup_actions (NautilusFloatingBar *self)
{
- GtkWidget *widget;
- GList *children, *l;
- gpointer data;
+ GtkWidget *widget;
+ GList *children, *l;
+ gpointer data;
- children = gtk_container_get_children (GTK_CONTAINER (self));
- l = children;
+ children = gtk_container_get_children (GTK_CONTAINER (self));
+ l = children;
- while (l != NULL) {
- widget = l->data;
- data = g_object_get_data (G_OBJECT (widget), "action-id");
- l = l->next;
+ while (l != NULL) {
+ widget = l->data;
+ data = g_object_get_data (G_OBJECT (widget), "action-id");
+ l = l->next;
- if (data != NULL) {
- /* destroy this */
- gtk_widget_destroy (widget);
- }
- }
+ if (data != NULL) {
+ /* destroy this */
+ gtk_widget_destroy (widget);
+ }
+ }
- g_list_free (children);
+ g_list_free (children);
- self->priv->is_interactive = FALSE;
+ self->priv->is_interactive = FALSE;
}