After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 558799 - [PATCH] Tab options for epiphany
[PATCH] Tab options for epiphany
Status: RESOLVED WONTFIX
Product: epiphany
Classification: Core
Component: Interface
2.22.x
Other Linux
: Normal enhancement
: ---
Assigned To: Epiphany Maintainers
Epiphany Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-11-01 13:48 UTC by Tatu Kilappa
Modified: 2011-12-12 11:22 UTC
See Also:
GNOME target: ---
GNOME version: 2.11/2.12


Attachments
Patch against epiphany 2.22.3 (7.14 KB, patch)
2008-11-01 13:51 UTC, Tatu Kilappa
none Details | Review
Updated patch. (9.71 KB, patch)
2008-11-02 17:24 UTC, Tatu Kilappa
none Details | Review

Description Tatu Kilappa 2008-11-01 13:48:59 UTC
Few minor interface enhancements. I initially submitted this patch to the Epiphany mailing list:
http://mail.gnome.org/archives/epiphany-list/2008-October/msg00009.html
However, I was instructed to send the patch here too.

Patch contents:
- Ability to move the tab bar to any side of the browser window. The configuration is accessible from gconf. Default is top. This is equal to the old Galeon model.
- Ability to change the individual tab label width in terms of pango character count. The default was 15 characters. Added a gconf option to set it to anything from 5 to 15.

--

In addition to the former, the initial patch included a modification to the preferences window to add the tab bar position as a combobox and "always_show_tabs_bar" -option as a checkbutton. However, one of you devs said:

(Reinout van Schouwen): "...for Epiphany it is recommended to add such "power user" features via extensions rather than by patching the core code, and we strive to keep the Preferences window as minimalistic as possible."

Because of this, I deleted the modified preference window code and the modified glade file.

--

I think Schouwen's comment is appropriate, but the options themselves (as accessed from gconf and default operation being as it is now) should still be incorporated into the main trunk just as the "always_show_tabs_bar" -option is now.

Thus, they would be available for users who have the patience to dig through gconf while the layman user would not be bothered nor would even know of them. After this, people could write extensions that would allow for changing the options from the GUI itself - if they wanted.

--

If you disagree with the view above, delete this patch and I'll just try to write something equivalent as an extension.
Comment 1 Tatu Kilappa 2008-11-01 13:51:27 UTC
Created attachment 121778 [details] [review]
Patch against epiphany 2.22.3

For the prefs window modifications, look for an equivalent patch in:
http://mail.gnome.org/archives/epiphany-list/2008-October/msg00009.html
Comment 2 Tatu Kilappa 2008-11-01 14:46:21 UTC
Comment on attachment 121778 [details] [review]
Patch against epiphany 2.22.3

diff -ur ../epiphany-2.22.3/data/epiphany.schemas.in ./data/epiphany.schemas.in
--- ../epiphany-2.22.3/data/epiphany.schemas.in	2008-03-28 16:59:45.000000000 +0200
+++ ./data/epiphany.schemas.in	2008-11-01 15:14:19.000000000 +0200
@@ -129,6 +129,28 @@
         </locale>
       </schema>
       <schema>
+        <key>/schemas/apps/epiphany/general/tab_position</key>
+        <applyto>/apps/epiphany/general/tab_position</applyto>
+        <owner>epiphany</owner>
+        <type>int</type>
+        <default>2</default>
+        <locale name="C">
+        <short>Position of the tab bar</short>
+        <long>The position of the tab bar relative to the browser window. Valid values are 0 for left, 1 for right, 2 for top and 3 for bottom. Other values will put the tab bar on top.</long>
+        </locale>
+      </schema>
+      <schema>
+        <key>/schemas/apps/epiphany/general/tab_width</key>
+        <applyto>/apps/epiphany/general/tab_width</applyto>
+        <owner>epiphany</owner>
+        <type>int</type>
+        <default>0</default>
+        <locale name="C">
+        <short>Width of individual tabs</short>
+        <long>Width of individual tabs as fullwidth Pango characters. Values are bound to the hard-coded allowed range (when writing this, from 5 to 15 characters).</long>
+        </locale>
+      </schema>
+      <schema>
         <key>/schemas/apps/epiphany/general/automatic_downloads</key>
         <applyto>/apps/epiphany/general/automatic_downloads</applyto>
         <owner>epiphany</owner>
diff -ur ../epiphany-2.22.3/lib/ephy-prefs.h ./lib/ephy-prefs.h
--- ../epiphany-2.22.3/lib/ephy-prefs.h	2008-03-28 16:59:46.000000000 +0200
+++ ./lib/ephy-prefs.h	2008-11-01 15:14:45.000000000 +0200
@@ -29,6 +29,8 @@
 /* General */
 #define CONF_GENERAL_HOMEPAGE			"/apps/epiphany/general/homepage"
 #define CONF_ALWAYS_SHOW_TABS_BAR		"/apps/epiphany/general/always_show_tabs_bar"
+#define CONF_TAB_POSITION		"/apps/epiphany/general/tab_position"
+#define CONF_TAB_WIDTH		"/apps/epiphany/general/tab_width"
 #define CONF_WINDOWS_SHOW_TOOLBARS		"/apps/epiphany/general/show_toolbars"
 #define CONF_WINDOWS_SHOW_BOOKMARKS_BAR		"/apps/epiphany/general/show_bookmarks_bar"
 #define CONF_WINDOWS_SHOW_STATUSBAR		"/apps/epiphany/general/show_statusbar"
diff -ur ../epiphany-2.22.3/src/ephy-notebook.c ./src/ephy-notebook.c
--- ../epiphany-2.22.3/src/ephy-notebook.c	2008-03-28 16:59:49.000000000 +0200
+++ ./src/ephy-notebook.c	2008-11-01 16:44:56.000000000 +0200
@@ -46,7 +46,8 @@
 #include <gtk/gtkaccelgroup.h>
 #include <gtk/gtkiconfactory.h>
 
-#define TAB_WIDTH_N_CHARS 15
+#define TAB_WIDTH_N_CHARS_MIN 5
+#define TAB_WIDTH_N_CHARS_MAX 15
 
 #define AFTER_ALL_TABS -1
 #define NOT_IN_APP_WINDOWS -2
@@ -59,9 +60,12 @@
 {
 	GList *focused_pages;
 	guint tabs_vis_notifier_id;
+	guint tab_position_notifier_id;
+	guint tab_width_notifier_id;
 
 	guint show_tabs : 1;
 	guint dnd_enabled : 1;
+	guint tab_position : (guint)GTK_POS_TOP;
 };
 
 static void ephy_notebook_init		 (EphyNotebook *notebook);
@@ -85,7 +89,8 @@
 {
 	PROP_0,
 	PROP_DND_ENABLED,
-	PROP_SHOW_TABS
+	PROP_SHOW_TABS,
+	PROP_TAB_POSITION
 };
 
 enum
@@ -129,6 +134,9 @@
 		case PROP_SHOW_TABS:
 			g_value_set_boolean (value, priv->show_tabs);
 			break;
+		case PROP_TAB_POSITION:
+			g_value_set_uint (value, priv->tab_position);
+			break;
 	}
 }
 
@@ -148,6 +156,9 @@
 		case PROP_SHOW_TABS:
 			ephy_notebook_set_show_tabs (notebook, g_value_get_boolean (value));
 			break;
+		case PROP_TAB_POSITION:
+			ephy_notebook_set_tab_position (notebook, g_value_get_uint (value));
+			break;
 	}
 }
 
@@ -198,6 +209,14 @@
 							       TRUE,
 							       G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
 
+	g_object_class_install_property (object_class,
+			PROP_TAB_POSITION,
+			g_param_spec_uint ("tab-position", NULL, NULL,
+				GTK_POS_LEFT,
+				GTK_POS_BOTTOM,
+				GTK_POS_TOP,
+				G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+
 	g_type_class_add_private (object_class, sizeof (EphyNotebookPrivate));
 }
 
@@ -416,6 +435,54 @@
 }
 
 /*
+ * Set the width of a tab to n pango chars.
+ */
+static void
+tab_label_set_size_request(GtkWidget *hbox, int width_n_chars)
+{
+	GtkWidget *button;
+	PangoFontMetrics *metrics;
+	PangoContext *context;
+	int char_width, h, w;
+ 
+	context = gtk_widget_get_pango_context (hbox);
+	metrics = pango_context_get_metrics (context,
+			hbox->style->font_desc,
+			pango_context_get_language (context));
+	char_width = pango_font_metrics_get_approximate_digit_width (metrics);
+	pango_font_metrics_unref (metrics);
+
+	gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (hbox),
+					   GTK_ICON_SIZE_MENU, &w, &h);
+
+	gtk_widget_set_size_request
+		(hbox, width_n_chars * PANGO_PIXELS(char_width) + 2 * w, -1);
+
+	button = g_object_get_data (G_OBJECT (hbox), "close-button");
+	gtk_widget_set_size_request (button, w + 2, h + 2);
+}
+
+/*
+ * Extract the desired tab width in chars from gconf.
+ */
+static int
+tab_label_get_width_n_chars()
+{
+	int width_n_chars = eel_gconf_get_integer (CONF_TAB_WIDTH);
+
+	if((width_n_chars <= 0) || (width_n_chars > TAB_WIDTH_N_CHARS_MAX))
+	{
+		return TAB_WIDTH_N_CHARS_MAX;
+	}
+	else if(width_n_chars < TAB_WIDTH_N_CHARS_MIN)
+	{
+		return TAB_WIDTH_N_CHARS_MIN;
+	}
+
+	return width_n_chars;
+}
+
+/*
  * update_tabs_visibility: Hide tabs if there is only one tab
  * and the pref is not set.
  */
@@ -437,6 +504,35 @@
 	gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nb), show_tabs);
 }
 
+/*
+ * update_tab_position: move the notebook tabs to one certain side of
+ * the notebook.
+ */
+static void
+update_tab_position (EphyNotebook *nb)
+{
+	EphyNotebookPrivate *priv = nb->priv;
+
+	GtkPositionType tab_position =
+		(GtkPositionType)(eel_gconf_get_integer (CONF_TAB_POSITION));
+
+	switch(tab_position)
+	{
+		case GTK_POS_LEFT:
+		case GTK_POS_RIGHT:
+		case GTK_POS_TOP:
+		case GTK_POS_BOTTOM:
+			priv->tab_position = tab_position;
+			break;
+		default:
+			priv->tab_position = GTK_POS_TOP;
+			break;
+	}
+
+	gtk_notebook_set_tab_pos (GTK_NOTEBOOK(nb),
+			(GtkPositionType)(priv->tab_position));
+}
+
 static void
 tabs_visibility_notifier (GConfClient *client,
 			  guint cnxn_id,
@@ -447,6 +543,34 @@
 }
 
 static void
+tab_position_notifier (GConfClient *client,
+			  guint cnxn_id,
+			  GConfEntry *entry,
+			  EphyNotebook *nb)
+{
+	update_tab_position (nb);
+}
+
+static void
+tab_width_notifier (GConfClient *client,
+		guint cnxn_id,
+		GConfEntry *entry,
+		EphyNotebook *nb)
+{
+	GtkWidget *child;
+	int tab_width = tab_label_get_width_n_chars();
+	int ii = 0;
+	while ((child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(nb), ii)) != NULL)
+	{
+		GtkWidget *label = gtk_notebook_get_tab_label(GTK_NOTEBOOK(nb), child);
+
+		tab_label_set_size_request(label, tab_width);
+
+		++ii;
+	}
+}
+
+static void
 ephy_notebook_init (EphyNotebook *notebook)
 {
 	EphyNotebookPrivate *priv;
@@ -459,6 +583,7 @@
 
 	priv->show_tabs = TRUE;
 	priv->dnd_enabled = TRUE;
+	priv->tab_position = (guint)GTK_POS_TOP;
 
 	g_signal_connect (notebook, "button-press-event",
 			  (GCallback)button_press_cb, NULL);
@@ -480,6 +605,14 @@
 	priv->tabs_vis_notifier_id = eel_gconf_notification_add
 		(CONF_ALWAYS_SHOW_TABS_BAR,
 		 (GConfClientNotifyFunc)tabs_visibility_notifier, notebook);
+	priv->tab_position_notifier_id = eel_gconf_notification_add
+		(CONF_TAB_POSITION,
+		 (GConfClientNotifyFunc)tab_position_notifier, notebook);
+	priv->tab_width_notifier_id = eel_gconf_notification_add
+		(CONF_TAB_WIDTH,
+		 (GConfClientNotifyFunc)tab_width_notifier, notebook);
+
+	update_tab_position(notebook);
 }
 
 static void
@@ -489,6 +622,8 @@
 	EphyNotebookPrivate *priv = notebook->priv;
 
 	eel_gconf_notification_remove (priv->tabs_vis_notifier_id);
+	eel_gconf_notification_remove (priv->tab_position_notifier_id);
+	eel_gconf_notification_remove (priv->tab_width_notifier_id);
 
 	g_list_free (priv->focused_pages);
 
@@ -555,27 +690,7 @@
 			GtkStyle *previous_style,
 			gpointer user_data)
 {
-	PangoFontMetrics *metrics;
-	PangoContext *context;
-	GtkWidget *button;
-	int char_width, h, w;
-
-	context = gtk_widget_get_pango_context (hbox);
-	metrics = pango_context_get_metrics (context,
-					     hbox->style->font_desc,
-					     pango_context_get_language (context));
-
-	char_width = pango_font_metrics_get_approximate_digit_width (metrics);
-	pango_font_metrics_unref (metrics);
-
-	gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (hbox),
-					   GTK_ICON_SIZE_MENU, &w, &h);
-
-	gtk_widget_set_size_request
-		(hbox, TAB_WIDTH_N_CHARS * PANGO_PIXELS(char_width) + 2 * w, -1);
-
-	button = g_object_get_data (G_OBJECT (hbox), "close-button");
-	gtk_widget_set_size_request (button, w + 2, h + 2);
+	tab_label_set_size_request(hbox, tab_label_get_width_n_chars());
 }
 
 static GtkWidget *
@@ -670,6 +785,15 @@
 	update_tabs_visibility (nb, FALSE);
 }
 
+void
+ephy_notebook_set_tab_position (EphyNotebook *nb,
+		guint tab_position)
+{
+	eel_gconf_set_integer (CONF_TAB_POSITION, (int)tab_position);
+
+	update_tab_position (nb);
+}
+
 GList *
 ephy_notebook_get_focused_pages (EphyNotebook *nb)
 {
diff -ur ../epiphany-2.22.3/src/ephy-notebook.h ./src/ephy-notebook.h
--- ../epiphany-2.22.3/src/ephy-notebook.h	2007-10-28 16:46:28.000000000 +0200
+++ ./src/ephy-notebook.h	2008-11-01 16:32:57.000000000 +0200
@@ -71,6 +71,10 @@
 void		ephy_notebook_set_dnd_enabled	(EphyNotebook *nb,
 						 gboolean enabled);
 
+void
+ephy_notebook_set_tab_position (EphyNotebook *nb,
+		guint tab_position);
+
 GList *         ephy_notebook_get_focused_pages (EphyNotebook *nb);
 
 G_END_DECLS
Comment 3 Tatu Kilappa 2008-11-01 15:09:54 UTC
To clarify. Comment 2 includes modifications that change the tab width immediately when tampered from gconf instead of waiting for program restart.

Disregard comment 1.
Comment 4 Christian Persch 2008-11-01 15:36:43 UTC
Please don't put patches inline; always attach them.

(In reply to comment #0)
> (Reinout van Schouwen): "...for Epiphany it is recommended to add such "power
> user" features via extensions rather than by patching the core code, and we
> strive to keep the Preferences window as minimalistic as possible."

This definitely should be an extension. 
 
> I think Schouwen's comment is appropriate, but the options themselves (as
> accessed from gconf and default operation being as it is now) should still be
> incorporated into the main trunk just as the "always_show_tabs_bar" -option is
> now.

I'm not sure about that; I think the extension providing the prefs would be more natural. 

BTW, the tab_position pref should not use integer but be a string with one of the GtkPositionType enum nick values.
Comment 5 Tatu Kilappa 2008-11-02 17:24:19 UTC
Created attachment 121824 [details] [review]
Updated patch.

> (In reply to comment #0)
>> (Reinout van Schouwen): "...for Epiphany it is recommended to add such "power
>> user" features via extensions rather than by patching the core code, and we
>> strive to keep the Preferences window as minimalistic as possible."
> This definitely should be an extension. 

The prefs window modification or everything?
 
>> [treat this just like "always_show_tabs_bar"]
> I'm not sure about that; I think the extension providing the prefs would be
> more natural. 

Well, here's an updated version of the patch anyway in case you change your mind.
 
> BTW, the tab_position pref should not use integer but be a string with one of
> the GtkPositionType enum nick values.

This is now done.

I think I'll look into making an extension now.
Comment 6 Xan Lopez 2011-12-12 11:22:05 UTC
This should be done as an extension (especially considering the new design), so I'll close the bug. Thanks for your contributions though!