aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2005-10-07 02:28:55 +0800
committerChristian Persch <chpe@src.gnome.org>2005-10-07 02:28:55 +0800
commitc3422e72c44eb2999de994b8151ec2db2e591631 (patch)
tree95365fcd667709b2abcd86082fadec4fc3d3c037
parent91edd219e3e228dfaa559d524401aceed31329c7 (diff)
downloadgsoc2013-epiphany-c3422e72c44eb2999de994b8151ec2db2e591631.tar
gsoc2013-epiphany-c3422e72c44eb2999de994b8151ec2db2e591631.tar.gz
gsoc2013-epiphany-c3422e72c44eb2999de994b8151ec2db2e591631.tar.bz2
gsoc2013-epiphany-c3422e72c44eb2999de994b8151ec2db2e591631.tar.lz
gsoc2013-epiphany-c3422e72c44eb2999de994b8151ec2db2e591631.tar.xz
gsoc2013-epiphany-c3422e72c44eb2999de994b8151ec2db2e591631.tar.zst
gsoc2013-epiphany-c3422e72c44eb2999de994b8151ec2db2e591631.zip
Add style properties for 'secure-[bg|fg]-color', and apply them when the
2005-10-06 Christian Persch <chpe@cvs.gnome.org> * lib/widgets/ephy-location-entry.c: (ephy_location_entry_style_set), (ephy_location_entry_class_init), (ephy_location_entry_set_favicon), (ephy_location_entry_set_secure): * lib/widgets/ephy-location-entry.h: Add style properties for 'secure-[bg|fg]-color', and apply them when the entry is in 'secure' mode. Reset the IM context before emitting the 'activate' signal. * src/ephy-location-action.c: (sync_secure), (connect_proxy), (ephy_location_action_set_property), (ephy_location_action_get_property), (ephy_location_action_class_init): * src/ephy-toolbar.c: (ephy_toolbar_set_security_state), (ephy_toolbar_init): * src/ephy-toolbar.h: * src/ephy-window.c: (sync_chromes_visibility), (sync_tab_security): Set the location entry's 'secure' property on secure sites, and also always show the lock for secure sites.
-rw-r--r--ChangeLog25
-rw-r--r--lib/widgets/ephy-location-entry.c103
-rw-r--r--lib/widgets/ephy-location-entry.h3
-rw-r--r--src/ephy-location-action.c31
-rwxr-xr-xsrc/ephy-toolbar.c10
-rw-r--r--src/ephy-toolbar.h1
-rw-r--r--src/ephy-window.c7
7 files changed, 175 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index b1f20a3eb..3e9125158 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,30 @@
2005-10-06 Christian Persch <chpe@cvs.gnome.org>
+ * lib/widgets/ephy-location-entry.c:
+ (ephy_location_entry_style_set), (ephy_location_entry_class_init),
+ (ephy_location_entry_set_favicon),
+ (ephy_location_entry_set_secure):
+ * lib/widgets/ephy-location-entry.h:
+
+ Add style properties for 'secure-[bg|fg]-color', and apply them when
+ the entry is in 'secure' mode. Reset the IM context before emitting
+ the 'activate' signal.
+
+ * src/ephy-location-action.c: (sync_secure), (connect_proxy),
+ (ephy_location_action_set_property),
+ (ephy_location_action_get_property),
+ (ephy_location_action_class_init):
+ * src/ephy-toolbar.c: (ephy_toolbar_set_security_state),
+ (ephy_toolbar_init):
+ * src/ephy-toolbar.h:
+ * src/ephy-window.c: (sync_chromes_visibility),
+ (sync_tab_security):
+
+ Set the location entry's 'secure' property on secure sites,
+ and also always show the lock for secure sites.
+
+2005-10-06 Christian Persch <chpe@cvs.gnome.org>
+
* configure.ac:
* embed/mozilla/Makefile.am:
* embed/mozilla/mozilla-embed-single.cpp:
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c
index 9a670df2e..a9e94f724 100644
--- a/lib/widgets/ephy-location-entry.c
+++ b/lib/widgets/ephy-location-entry.c
@@ -65,6 +65,8 @@ struct _EphyLocationEntryPrivate
GtkWidget *lock_ebox;
GtkWidget *lock;
GdkPixbuf *favicon;
+ GdkColor secure_bg_colour;
+ GdkColor secure_fg_colour;
char *before_completion;
@@ -74,8 +76,11 @@ struct _EphyLocationEntryPrivate
guint relevance_col;
guint hash;
+
guint user_changed : 1;
guint original_address : 1;
+ guint secure : 1;
+ guint apply_colours : 1;
};
static const struct
@@ -99,6 +104,8 @@ static const GtkTargetEntry url_drag_types [] =
{ EPHY_DND_TEXT_TYPE, 0, 2 }
};
+static const GdkColor fallback_bg_colour = { 0, 0xf7f7, 0xf7f7, 0xbebe }; /* yellow-ish */
+
static void ephy_location_entry_class_init (EphyLocationEntryClass *klass);
static void ephy_location_entry_init (EphyLocationEntry *le);
@@ -162,6 +169,61 @@ ephy_location_entry_set_tooltip (GtkToolItem *tool_item,
}
static void
+ephy_location_entry_style_set (GtkWidget *widget,
+ GtkStyle *previous_style)
+{
+ EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (widget);
+ EphyLocationEntryPrivate *priv = entry->priv;
+ GtkSettings *settings;
+ GdkColor *bg_colour = NULL, *fg_colour = NULL;
+ char *theme;
+ gboolean is_a11y_theme;
+
+ if (GTK_WIDGET_CLASS (parent_class)->style_set)
+ {
+ GTK_WIDGET_CLASS (parent_class)->style_set (widget, previous_style);
+ }
+
+ settings = gtk_settings_get_for_screen (gtk_widget_get_screen (widget));
+ g_object_get (settings, "gtk-theme-name", &theme, NULL);
+ is_a11y_theme = strncmp (theme, "HighContrast", strlen ("HighContrast")) == 0 ||
+ strncmp (theme, "LowContrast", strlen ("LowContrast")) == 0;
+ g_free (theme);
+
+ gtk_widget_style_get (widget,
+ "secure-fg-color", &fg_colour,
+ "secure-bg-color", &bg_colour,
+ NULL);
+
+ /* We only use the fallback colours when we don't have an a11y theme */
+ priv->apply_colours = !is_a11y_theme || (fg_colour != NULL && bg_colour != NULL);
+
+ if (fg_colour != NULL)
+ {
+ priv->secure_fg_colour = *fg_colour;
+ gdk_color_free (fg_colour);
+ }
+ else
+ {
+ /* FIXME: fall back to black text maybe? */
+ priv->secure_fg_colour = widget->style->text[GTK_STATE_NORMAL];
+ }
+
+ if (bg_colour != NULL)
+ {
+ priv->secure_bg_colour = *bg_colour;
+ gdk_color_free (bg_colour);
+ }
+ else
+ {
+ priv->secure_bg_colour = fallback_bg_colour;
+ }
+
+ /* Apply the new style */
+ ephy_location_entry_set_secure (entry, priv->secure);
+}
+
+static void
ephy_location_entry_finalize (GObject *object)
{
EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (object);
@@ -181,12 +243,15 @@ static void
ephy_location_entry_class_init (EphyLocationEntryClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkToolItemClass *tool_item_class = GTK_TOOL_ITEM_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = ephy_location_entry_finalize;
+ widget_class->style_set = ephy_location_entry_style_set;
+
tool_item_class->set_tooltip = ephy_location_entry_set_tooltip;
signals[USER_CHANGED] = g_signal_new (
@@ -229,6 +294,19 @@ ephy_location_entry_class_init (EphyLocationEntryClass *klass)
0,
G_TYPE_NONE);
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_boxed ("secure-bg-color",
+ "Secure background colour",
+ "Background colour to use for secure sites",
+ GDK_TYPE_COLOR,
+ G_PARAM_READABLE));
+
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_boxed ("secure-fg-color",
+ "Secure foreground Colour",
+ "Foreground colour to use for secure sites",
+ GDK_TYPE_COLOR,
+ G_PARAM_READABLE));
g_type_class_add_private (object_class, sizeof (EphyLocationEntryPrivate));
}
@@ -851,6 +929,31 @@ ephy_location_entry_set_favicon (EphyLocationEntry *entry,
}
void
+ephy_location_entry_set_secure (EphyLocationEntry *entry,
+ gboolean secure)
+{
+ EphyLocationEntryPrivate *priv = entry->priv;
+ GtkWidget *widget = GTK_WIDGET (entry);
+ GtkWidget *gentry = ephy_icon_entry_get_entry (entry->priv->icon_entry);
+
+ priv->secure = secure;
+
+ /* We have to set the colour of the GtkEntry in the EphyIconEntry */
+ if (priv->secure && priv->apply_colours)
+ {
+ gtk_widget_modify_text (gentry, GTK_STATE_NORMAL, &priv->secure_fg_colour);
+ gtk_widget_modify_base (gentry, GTK_STATE_NORMAL, &priv->secure_bg_colour);
+ }
+ else
+ {
+ gtk_widget_modify_text (gentry, GTK_STATE_NORMAL, NULL);
+ gtk_widget_modify_base (gentry, GTK_STATE_NORMAL, NULL);
+ }
+
+ gtk_widget_queue_draw (widget);
+}
+
+void
ephy_location_entry_set_show_lock (EphyLocationEntry *entry,
gboolean show_lock)
{
diff --git a/lib/widgets/ephy-location-entry.h b/lib/widgets/ephy-location-entry.h
index 7838abd93..993047410 100644
--- a/lib/widgets/ephy-location-entry.h
+++ b/lib/widgets/ephy-location-entry.h
@@ -88,6 +88,9 @@ GtkWidget *ephy_location_entry_get_entry (EphyLocationEntry *entry);
void ephy_location_entry_set_favicon (EphyLocationEntry *entry,
GdkPixbuf *pixbuf);
+void ephy_location_entry_set_secure (EphyLocationEntry *entry,
+ gboolean secure);
+
void ephy_location_entry_set_show_lock (EphyLocationEntry *entry,
gboolean show_lock);
diff --git a/src/ephy-location-action.c b/src/ephy-location-action.c
index 4cce221cf..c3c0b4109 100644
--- a/src/ephy-location-action.c
+++ b/src/ephy-location-action.c
@@ -50,6 +50,7 @@ struct _EphyLocationActionPrivate
char *lock_tooltip;
guint editable : 1;
guint show_lock : 1;
+ guint secure : 1;
};
static void ephy_location_action_init (EphyLocationAction *action);
@@ -69,6 +70,7 @@ enum
PROP_ICON,
PROP_LOCK_STOCK,
PROP_LOCK_TOOLTIP,
+ PROP_SECURE,
PROP_SHOW_LOCK,
PROP_WINDOW
};
@@ -267,6 +269,18 @@ sync_lock_tooltip (GtkAction *gaction,
}
static void
+sync_secure (GtkAction *gaction,
+ GParamSpec *pspec,
+ GtkWidget *proxy)
+{
+ EphyLocationAction *action = EPHY_LOCATION_ACTION (gaction);
+ EphyLocationActionPrivate *priv = action->priv;
+ EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (proxy);
+
+ ephy_location_entry_set_secure (entry, priv->secure);
+}
+
+static void
sync_show_lock (GtkAction *gaction,
GParamSpec *pspec,
GtkWidget *proxy)
@@ -387,6 +401,9 @@ connect_proxy (GtkAction *action, GtkWidget *proxy)
sync_lock_tooltip (action, NULL, proxy);
g_signal_connect_object (action, "notify::lock-tooltip",
G_CALLBACK (sync_lock_tooltip), proxy, 0);
+ sync_secure (action, NULL, proxy);
+ g_signal_connect_object (action, "notify::secure",
+ G_CALLBACK (sync_secure), proxy, 0);
sync_show_lock (action, NULL, proxy);
g_signal_connect_object (action, "notify::show-lock",
G_CALLBACK (sync_show_lock), proxy, 0);
@@ -461,6 +478,9 @@ ephy_location_action_set_property (GObject *object,
g_free (priv->lock_tooltip);
priv->lock_tooltip = g_value_dup_string (value);
break;
+ case PROP_SECURE:
+ priv->secure = g_value_get_boolean (value);
+ break;
case PROP_SHOW_LOCK:
priv->show_lock = g_value_get_boolean (value);
break;
@@ -496,6 +516,9 @@ ephy_location_action_get_property (GObject *object,
case PROP_LOCK_TOOLTIP:
g_value_set_string (value, priv->lock_tooltip);
break;
+ case PROP_SECURE:
+ g_value_set_boolean (value, priv->secure);
+ break;
case PROP_SHOW_LOCK:
g_value_set_boolean (value, priv->show_lock);
break;
@@ -571,6 +594,14 @@ ephy_location_action_class_init (EphyLocationActionClass *class)
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
+ PROP_SECURE,
+ g_param_spec_boolean ("secure",
+ "Secure",
+ "Secure",
+ FALSE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
PROP_SHOW_LOCK,
g_param_spec_boolean ("show-lock",
"Show Lock",
diff --git a/src/ephy-toolbar.c b/src/ephy-toolbar.c
index eb8691fae..1e6e8a0e1 100755
--- a/src/ephy-toolbar.c
+++ b/src/ephy-toolbar.c
@@ -78,6 +78,7 @@ struct _EphyToolbarPrivate
gulong set_focus_handler;
gboolean updating_address;
gboolean show_lock;
+ gboolean is_secure;
gboolean lock_visible;
gboolean leave_fullscreen_visible;
gboolean spinning;
@@ -471,6 +472,7 @@ ephy_toolbar_set_navigation_actions (EphyToolbar *toolbar,
void
ephy_toolbar_set_security_state (EphyToolbar *toolbar,
+ gboolean is_secure,
gboolean show_lock,
const char *stock_id,
const char *tooltip)
@@ -478,11 +480,13 @@ ephy_toolbar_set_security_state (EphyToolbar *toolbar,
EphyToolbarPrivate *priv = toolbar->priv;
priv->show_lock = show_lock;
+ priv->is_secure = is_secure;
g_object_set (priv->actions[LOCATION_ACTION],
"lock-stock-id", stock_id,
"lock-tooltip", tooltip,
"show-lock", priv->lock_visible && priv->show_lock,
+ "secure", is_secure,
NULL);
}
@@ -588,7 +592,11 @@ ephy_toolbar_hide (GtkWidget *widget)
static void
ephy_toolbar_init (EphyToolbar *toolbar)
{
- toolbar->priv = EPHY_TOOLBAR_GET_PRIVATE (toolbar);
+ EphyToolbarPrivate *priv;
+
+ priv = toolbar->priv = EPHY_TOOLBAR_GET_PRIVATE (toolbar);
+
+ priv->lock_visible = TRUE;
}
static GObject *
diff --git a/src/ephy-toolbar.h b/src/ephy-toolbar.h
index 2c349c5c0..026588448 100644
--- a/src/ephy-toolbar.h
+++ b/src/ephy-toolbar.h
@@ -85,6 +85,7 @@ void ephy_toolbar_set_navigation_actions (EphyToolbar *toolbar,
gboolean up);
void ephy_toolbar_set_security_state (EphyToolbar *toolbar,
+ gboolean is_secure,
gboolean show_lock,
const char *stock_id,
const char *tooltip);
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 04fa156b9..3dfdb4c39 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -592,8 +592,6 @@ sync_chromes_visibility (EphyWindow *window)
g_object_set (priv->bookmarksbar, "visible", show_bookmarksbar, NULL);
g_object_set (priv->statusbar, "visible", show_statusbar, NULL);
- ephy_toolbar_set_lock_visibility (priv->toolbar, !show_statusbar);
-
ephy_notebook_set_show_tabs (EPHY_NOTEBOOK (priv->notebook), show_tabsbar);
if (priv->fullscreen_popup != NULL)
@@ -1307,7 +1305,7 @@ sync_tab_security (EphyTab *tab, GParamSpec *pspec, EphyWindow *window)
char *state = NULL;
char *tooltip;
const char *stock_id = STOCK_LOCK_INSECURE;
- gboolean show_lock = FALSE;
+ gboolean show_lock = FALSE, is_secure = FALSE;
if (window->priv->closing) return;
@@ -1344,6 +1342,7 @@ sync_tab_security (EphyTab *tab, GParamSpec *pspec, EphyWindow *window)
state = _("High");
stock_id = STOCK_LOCK_SECURE;
show_lock = TRUE;
+ is_secure = TRUE;
break;
default:
g_assert_not_reached ();
@@ -1363,7 +1362,7 @@ sync_tab_security (EphyTab *tab, GParamSpec *pspec, EphyWindow *window)
ephy_statusbar_set_security_state (EPHY_STATUSBAR (window->priv->statusbar),
stock_id, tooltip);
- ephy_toolbar_set_security_state (window->priv->toolbar,
+ ephy_toolbar_set_security_state (window->priv->toolbar, is_secure,
show_lock, stock_id, tooltip);
if (window->priv->fullscreen_popup != NULL)