[epiphany] ephy-lockdown: use new coding style



commit cff4a9f4db331f8ba8bf2967fc1435a94ee6c84e
Author: Xan Lopez <xan igalia com>
Date:   Sun Oct 7 08:06:16 2012 -0400

    ephy-lockdown: use new coding style

 src/ephy-lockdown.c |  305 +++++++++++++++++++++++++--------------------------
 src/ephy-lockdown.h |   29 +++---
 2 files changed, 165 insertions(+), 169 deletions(-)
---
diff --git a/src/ephy-lockdown.c b/src/ephy-lockdown.c
index 7b0bfb9..46a5fde 100644
--- a/src/ephy-lockdown.c
+++ b/src/ephy-lockdown.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /*
  *  Copyright  2000, 2001, 2002, 2003, 2004 Marco Pesenti Gritti
  *  Copyright  2003, 2004, 2005 Christian Persch
@@ -38,212 +38,207 @@
 
 static int
 find_name (GtkActionGroup *action_group,
-	   const char *name)
+           const char *name)
 {
-	return g_strcmp0 (gtk_action_group_get_name (action_group), name);
+  return g_strcmp0 (gtk_action_group_get_name (action_group), name);
 }
 
 static GtkActionGroup *
 find_action_group (GtkUIManager *manager,
-		   const char *name)
+                   const char *name)
 {
-	GList *list, *element;
+  GList *list, *element;
 
-	list = gtk_ui_manager_get_action_groups (manager);
-	element = g_list_find_custom (list, name, (GCompareFunc) find_name);
-	g_return_val_if_fail (element != NULL, NULL);
+  list = gtk_ui_manager_get_action_groups (manager);
+  element = g_list_find_custom (list, name, (GCompareFunc) find_name);
+  g_return_val_if_fail (element != NULL, NULL);
 
-	return GTK_ACTION_GROUP (element->data);
+  return GTK_ACTION_GROUP (element->data);
 }
 
 static void
 arbitrary_url_cb (GSettings *settings,
-		  char *key,
-		  EphyWindow *window)
+                  char *key,
+                  EphyWindow *window)
 {
-	EphyEmbed *embed;
-	const char *address;
-
-	/* Restore the real web page address when disabling entry */
-	if (g_settings_get_boolean (settings, key))
-	{
-		embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
-		/* embed is NULL on startup */
-		if (embed == NULL)
-			return;
-
-		address = ephy_web_view_get_address (ephy_embed_get_web_view (embed));
-		ephy_window_set_location (window, address);
-		ephy_web_view_set_typed_address (ephy_embed_get_web_view (embed), NULL);
-	}
+  EphyEmbed *embed;
+  const char *address;
+
+  /* Restore the real web page address when disabling entry */
+  if (g_settings_get_boolean (settings, key)) {
+    embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+    /* embed is NULL on startup */
+    if (embed == NULL)
+      return;
+
+    address = ephy_web_view_get_address (ephy_embed_get_web_view (embed));
+    ephy_window_set_location (window, address);
+    ephy_web_view_set_typed_address (ephy_embed_get_web_view (embed), NULL);
+  }
 }
 
 static void
 fullscreen_cb (GSettings *settings,
-	       char *key,
-	       EphyWindow *window)
+               char *key,
+               EphyWindow *window)
 {
-	if (g_settings_get_boolean (settings, key))
-		gtk_window_fullscreen (GTK_WINDOW (window));
-	else
-		gtk_window_unfullscreen (GTK_WINDOW (window));
+  if (g_settings_get_boolean (settings, key))
+    gtk_window_fullscreen (GTK_WINDOW (window));
+  else
+    gtk_window_unfullscreen (GTK_WINDOW (window));
 }
 
 typedef struct {
-	char *key;
-	char *action;
-	char *prop;
+  char *key;
+  char *action;
+  char *prop;
 } BindAction;
 
 static const BindAction window_actions[] = {
-	{ EPHY_PREFS_LOCKDOWN_PRINTING, "FilePrint", "sensitive" },
+  { EPHY_PREFS_LOCKDOWN_PRINTING, "FilePrint", "sensitive" },
 
-	{ EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING, "FileBookmarkPage", "sensitive" },
+  { EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING, "FileBookmarkPage", "sensitive" },
 
-	{ EPHY_PREFS_LOCKDOWN_ARBITRARY_URL, "GoLocation", "sensitive" },
-	{ EPHY_PREFS_LOCKDOWN_SAVE_TO_DISK, "FileSaveAs", "sensitive" },
+  { EPHY_PREFS_LOCKDOWN_ARBITRARY_URL, "GoLocation", "sensitive" },
+  { EPHY_PREFS_LOCKDOWN_SAVE_TO_DISK, "FileSaveAs", "sensitive" },
 
-	{ EPHY_PREFS_LOCKDOWN_FULLSCREEN, "ViewFullscreen", "sensitive" },
-	{ EPHY_PREFS_LOCKDOWN_FULLSCREEN, "TabsDetach", "sensitive" }
+  { EPHY_PREFS_LOCKDOWN_FULLSCREEN, "ViewFullscreen", "sensitive" },
+  { EPHY_PREFS_LOCKDOWN_FULLSCREEN, "TabsDetach", "sensitive" }
 };
 
 static const BindAction popup_actions[] = {
-	{ EPHY_PREFS_LOCKDOWN_SAVE_TO_DISK, "DownloadLink", "sensitive" },
-	{ EPHY_PREFS_LOCKDOWN_SAVE_TO_DISK, "DownloadLinkAs", "sensitive" },
-	{ EPHY_PREFS_LOCKDOWN_SAVE_TO_DISK, "SaveImageAs", "sensitive" },
-	{ EPHY_PREFS_LOCKDOWN_SAVE_TO_DISK, "OpenImage", "sensitive" },
-	{ EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING, "BookmarkLink", "sensitive" }
+  { EPHY_PREFS_LOCKDOWN_SAVE_TO_DISK, "DownloadLink", "sensitive" },
+  { EPHY_PREFS_LOCKDOWN_SAVE_TO_DISK, "DownloadLinkAs", "sensitive" },
+  { EPHY_PREFS_LOCKDOWN_SAVE_TO_DISK, "SaveImageAs", "sensitive" },
+  { EPHY_PREFS_LOCKDOWN_SAVE_TO_DISK, "OpenImage", "sensitive" },
+  { EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING, "BookmarkLink", "sensitive" }
 };
 
 static const BindAction special_toolbar_actions[] = {
-	{ EPHY_PREFS_LOCKDOWN_HISTORY, "NavigationBack", "visible" },
-	{ EPHY_PREFS_LOCKDOWN_HISTORY, "NavigationBack", "sensitive" },
-	{ EPHY_PREFS_LOCKDOWN_HISTORY, "NavigationForward", "visible" },
-	{ EPHY_PREFS_LOCKDOWN_HISTORY, "NavigationForward", "sensitive" },
+  { EPHY_PREFS_LOCKDOWN_HISTORY, "NavigationBack", "visible" },
+  { EPHY_PREFS_LOCKDOWN_HISTORY, "NavigationBack", "sensitive" },
+  { EPHY_PREFS_LOCKDOWN_HISTORY, "NavigationForward", "visible" },
+  { EPHY_PREFS_LOCKDOWN_HISTORY, "NavigationForward", "sensitive" },
 };
 
 static gboolean
 sensitive_get_mapping (GValue *value,
-		       GVariant *variant,
-		       gpointer data)
+                       GVariant *variant,
+                       gpointer data)
 {
-	GtkAction *action;
-	gboolean active, before, after;
+  GtkAction *action;
+  gboolean active, before, after;
 
-	action = GTK_ACTION (data);
-	active = g_variant_get_boolean (variant);
+  action = GTK_ACTION (data);
+  active = g_variant_get_boolean (variant);
 
-	before = gtk_action_get_sensitive (action);
-	ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, active);
-	after = gtk_action_get_sensitive (action);
+  before = gtk_action_get_sensitive (action);
+  ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, active);
+  after = gtk_action_get_sensitive (action);
 
-	/* Set (GtkAction::sensitive) to the value in GSettings _only if_
-	 * the LOCKDOWN_FLAG had some real effect in the GtkAction */
-	g_value_set_boolean (value, (before != after) ? after : before);
+  /* Set (GtkAction::sensitive) to the value in GSettings _only if_
+   * the LOCKDOWN_FLAG had some real effect in the GtkAction */
+  g_value_set_boolean (value, (before != after) ? after : before);
 
-	return TRUE;
+  return TRUE;
 }
 
 static void
 bind_settings_and_actions (GSettings *settings,
-			   GtkActionGroup *action_group,
-			   const BindAction *actions,
-			   int actions_n)
+                           GtkActionGroup *action_group,
+                           const BindAction *actions,
+                           int actions_n)
 {
-	int i;
-
-	for (i = 0; i < actions_n; i++)
-	{
-		GtkAction *action;
-
-		action = gtk_action_group_get_action (action_group,
-						      actions[i].action);
-
-		if (g_strcmp0 (actions[i].prop, "visible") == 0)
-		{
-			g_settings_bind (settings, actions[i].key,
-					 action, actions[i].prop,
-					 G_SETTINGS_BIND_GET |
-					 G_SETTINGS_BIND_INVERT_BOOLEAN);
-		}
-		else
-		{
-			/* We need a custom get_mapping for 'sensitive'
-			 * properties, see usage of
-			 * ephy_action_change_sensitivity_flags in
-			 * ephy-window.c. */
-			g_settings_bind_with_mapping (settings, actions[i].key,
-						      action, actions[i].prop,
-						      G_SETTINGS_BIND_GET,
-						      sensitive_get_mapping,
-						      NULL,
-						      action, NULL);
-		}
-	}
+  int i;
+
+  for (i = 0; i < actions_n; i++) {
+    GtkAction *action;
+
+    action = gtk_action_group_get_action (action_group,
+                  actions[i].action);
+
+    if (g_strcmp0 (actions[i].prop, "visible") == 0) {
+      g_settings_bind (settings, actions[i].key,
+                       action, actions[i].prop,
+                       G_SETTINGS_BIND_GET |
+                       G_SETTINGS_BIND_INVERT_BOOLEAN);
+    } else {
+      /* We need a custom get_mapping for 'sensitive'
+       * properties, see usage of
+       * ephy_action_change_sensitivity_flags in
+       * ephy-window.c. */
+      g_settings_bind_with_mapping (settings, actions[i].key,
+                                    action, actions[i].prop,
+                                    G_SETTINGS_BIND_GET,
+                                    sensitive_get_mapping,
+                                    NULL,
+                                    action, NULL);
+    }
+  }
 }
 
 static void
 bind_location_controller (GSettings *settings,
-			  EphyLocationController *controller)
+                          EphyLocationController *controller)
 {
-	g_settings_bind (settings, EPHY_PREFS_LOCKDOWN_ARBITRARY_URL,
-			 controller, "editable",
-			 G_SETTINGS_BIND_GET |
-			 G_SETTINGS_BIND_INVERT_BOOLEAN);
+  g_settings_bind (settings, EPHY_PREFS_LOCKDOWN_ARBITRARY_URL,
+                   controller, "editable  ",
+                   G_SETTINGS_BIND_GET |
+                   G_SETTINGS_BIND_INVERT_BOOLEAN);
 }
 
 static void
 window_added_cb (GtkApplication *application,
-		 GtkWindow *window,
-		 EphyLockdown *lockdown)
+                 GtkWindow *window,
+                 EphyLockdown *lockdown)
 {
-	GtkUIManager *manager;
-	GtkActionGroup *action_group;
-	GtkAction *action;
-	GSettings *settings;
-	EphyLocationController *location_controller;
-
-	if (!EPHY_IS_WINDOW (window))
-		return;
-
-	g_signal_connect (EPHY_SETTINGS_LOCKDOWN,
-			  "changed::" EPHY_PREFS_LOCKDOWN_FULLSCREEN,
-			  G_CALLBACK (fullscreen_cb), window);
-	g_signal_connect (EPHY_SETTINGS_LOCKDOWN,
-			  "changed::" EPHY_PREFS_LOCKDOWN_ARBITRARY_URL,
-			  G_CALLBACK (arbitrary_url_cb), window);
-
-	/* Trigger an initial state on these elements. */
-	fullscreen_cb (EPHY_SETTINGS_LOCKDOWN,
-		       EPHY_PREFS_LOCKDOWN_FULLSCREEN, EPHY_WINDOW (window));
-	arbitrary_url_cb (EPHY_SETTINGS_LOCKDOWN,
-			  EPHY_PREFS_LOCKDOWN_ARBITRARY_URL, EPHY_WINDOW (window));
-
-	manager = GTK_UI_MANAGER (ephy_window_get_ui_manager (EPHY_WINDOW (window)));
-
-	action_group = find_action_group (manager, "WindowActions");
-	bind_settings_and_actions (EPHY_SETTINGS_LOCKDOWN,
-				   action_group, window_actions,
-				   G_N_ELEMENTS (window_actions));
-
-	action_group = find_action_group (manager, "PopupsActions");
-	bind_settings_and_actions (EPHY_SETTINGS_LOCKDOWN,
-				   action_group, popup_actions,
-				   G_N_ELEMENTS (popup_actions));
-
-	action = gtk_action_group_get_action (action_group,
-					      "SetImageAsBackground");
-	settings = ephy_settings_get ("org.gnome.desktop.background");
-	g_settings_bind_writable (settings, "picture-filename",
-				  action, "sensitive", FALSE);
-
-	action_group = find_action_group (manager, "SpecialToolbarActions");
-	bind_settings_and_actions (EPHY_SETTINGS_LOCKDOWN,
-				   action_group, special_toolbar_actions,
-				   G_N_ELEMENTS (special_toolbar_actions));
-
-	location_controller = ephy_window_get_location_controller (EPHY_WINDOW (window));
-	bind_location_controller (EPHY_SETTINGS_LOCKDOWN, location_controller);
+  GtkUIManager *manager;
+  GtkActionGroup *action_group;
+  GtkAction *action;
+  GSettings *settings;
+  EphyLocationController *location_controller;
+
+  if (!EPHY_IS_WINDOW (window))
+    return;
+
+  g_signal_connect (EPHY_SETTINGS_LOCKDOWN,
+                    "changed::" EPHY_PREFS_LOCKDOWN_FULLSCREEN,
+                    G_CALLBACK (fullscreen_cb), window);
+  g_signal_connect (EPHY_SETTINGS_LOCKDOWN,
+                    "changed::" EPHY_PREFS_LOCKDOWN_ARBITRARY_URL,
+                    G_CALLBACK (arbitrary_url_cb), window);
+
+  /* Trigger an initial state on these elements. */
+  fullscreen_cb (EPHY_SETTINGS_LOCKDOWN,
+                 EPHY_PREFS_LOCKDOWN_FULLSCREEN, EPHY_WINDOW (window));
+  arbitrary_url_cb (EPHY_SETTINGS_LOCKDOWN,
+                    EPHY_PREFS_LOCKDOWN_ARBITRARY_URL, EPHY_WINDOW (window));
+
+  manager = GTK_UI_MANAGER (ephy_window_get_ui_manager (EPHY_WINDOW (window)));
+
+  action_group = find_action_group (manager, "WindowActions");
+  bind_settings_and_actions (EPHY_SETTINGS_LOCKDOWN,
+                             action_group, window_actions,
+                             G_N_ELEMENTS (window_actions));
+
+  action_group = find_action_group (manager, "PopupsActions");
+  bind_settings_and_actions (EPHY_SETTINGS_LOCKDOWN,
+                             action_group, popup_actions,
+                             G_N_ELEMENTS (popup_actions));
+
+  action = gtk_action_group_get_action (action_group,
+                                        "SetImageAsBackground");
+  settings = ephy_settings_get ("org.gnome.desktop.background");
+  g_settings_bind_writable (settings, "picture-filename",
+                            action, "sensitive", FALSE);
+
+  action_group = find_action_group (manager, "SpecialToo  lbarActions");
+  bind_settings_and_actions (EPHY_SETTINGS_LOCKDOWN,
+                             action_group, special_toolbar_actions,
+                             G_N_ELEMENTS (special_toolbar_actions));
+  
+  location_controller = ephy_window_get_location_controller (EPHY_WINDOW (window));
+  bind_location_controller (EPHY_SETTINGS_LOCKDOWN, location_controller);
 }
 
 G_DEFINE_TYPE (EphyLockdown, ephy_lockdown, G_TYPE_OBJECT)
@@ -251,14 +246,14 @@ G_DEFINE_TYPE (EphyLockdown, ephy_lockdown, G_TYPE_OBJECT)
 static void
 ephy_lockdown_init (EphyLockdown *lockdown)
 {
-	EphyShell *shell;
+  EphyShell *shell;
 
-	LOG ("EphyLockdown initialising");
+  LOG ("EphyLockdown initialising");
 
-	shell = ephy_shell_get_default ();
+  shell = ephy_shell_get_default ();
 
-	g_signal_connect (shell, "window-added",
-			  G_CALLBACK (window_added_cb), lockdown);
+  g_signal_connect (shell, "window-added",
+                    G_CALLBACK (window_added_cb), lockdown);
 }
 
 static void
diff --git a/src/ephy-lockdown.h b/src/ephy-lockdown.h
index 3fd9238..ea6bb37 100644
--- a/src/ephy-lockdown.h
+++ b/src/ephy-lockdown.h
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /*
  *  Copyright  2003, 2004 Marco Pesenti Gritti
  *  Copyright  2003, 2004, 2005 Christian Persch
@@ -30,31 +31,31 @@
 
 G_BEGIN_DECLS
 
-#define EPHY_TYPE_LOCKDOWN		(ephy_lockdown_get_type ())
-#define EPHY_LOCKDOWN(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_LOCKDOWN, EphyLockdown))
-#define EPHY_LOCKDOWN_CLASS(k)		(G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_LOCKDOWN, EphyLockdownClass))
-#define EPHY_IS_LOCKDOWN(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_LOCKDOWN))
-#define EPHY_IS_LOCKDOWN_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_LOCKDOWN))
-#define EPHY_LOCKDOWN_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_LOCKDOWN, EphyLockdownClass))
+#define EPHY_TYPE_LOCKDOWN          (ephy_lockdown_get_type ())
+#define EPHY_LOCKDOWN(o)            (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_LOCKDOWN, EphyLockdown))
+#define EPHY_LOCKDOWN_CLASS(k)      (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_LOCKDOWN, EphyLockdownClass))
+#define EPHY_IS_LOCKDOWN(o)         (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_LOCKDOWN))
+#define EPHY_IS_LOCKDOWN_CLASS(k)   (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_LOCKDOWN))
+#define EPHY_LOCKDOWN_GET_CLASS(o)  (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_LOCKDOWN, EphyLockdownClass))
 
-typedef struct _EphyLockdownClass	EphyLockdownClass;
-typedef struct _EphyLockdown		EphyLockdown;
-typedef struct _EphyLockdownPrivate	EphyLockdownPrivate;
+typedef struct _EphyLockdownClass   EphyLockdownClass;
+typedef struct _EphyLockdown        EphyLockdown;
+typedef struct _EphyLockdownPrivate EphyLockdownPrivate;
 
 struct _EphyLockdownClass
 {
-	GObjectClass parent_class;
+  GObjectClass parent_class;
 };
 
 struct _EphyLockdown
 {
-	GObject parent_instance;
+  GObject parent_instance;
 
-	/*< private >*/
-	EphyLockdownPrivate *priv;
+  /*< private >*/
+  EphyLockdownPrivate *priv;
 };
 
-GType	ephy_lockdown_get_type		(void);
+GType ephy_lockdown_get_type    (void);
 
 G_END_DECLS
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]