Re: Re: Tab width
Stelian Ionescu <[email protected]> Tue, 5 Apr 2005 00:38:18 +0200
| Newsgroups | gmane.comp.web.galeon.devel |
|---|---|
| Message-ID | <[email protected]> |
--8GpibOaaTibBMecb Content-Type: multipart/mixed; boundary="nFreZHaLTZJo0R7j" Content-Disposition: inline --nFreZHaLTZJo0R7j Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Apr 04, 2005 at 09:29:53PM +0200, Stelian Ionescu wrote: >On Mon, Apr 04, 2005 at 10:19:24PM +0300, Tommi Komulainen wrote: >>Unfortunately some things are badly wrong in that patch and we can't >>accept it as is. There are two things that go against the existing >>design: >> >>1. Introducing GConf dependency to GulNotebook >> >>I know this isn't clearly documented anywhere, but the basic idea is >>that GulNotebook should have no dependencies outside gtk+ Long time ago >>there was some attempt to get the extra functionality (tab dragging >>etc.) included in GtkNotebook. Unfortunately these days no one is >>really driving that effort. >> >> >>2. Confused responsibilities in tab width calculation >> >>No one outside GulNotebook should have no part in actually calculating >>the tab width in pixels. At most one can provide the tab width in >>characters to GulNotebook and let it handle the calculation. >> >> >> >>Basically you just need to move all the calculations behind the >>gul_notebook_set_tab_width() function. The code in GaleonWindow only >>needs to pass the tab width from GConf to GulNotebook. >thanks for the suggestions. I'll work on it tonight what about this patch ? I made two new functions for GulNotebook: gul_notebook_set_tab_width() and gul_notebook_refresh_tab_width(). They could me merged but I think that having these functionalities apart could be useful(some day). --=20 Stelian Ionescu aka fe[nl]ix Quidquid latine dictum sit, altum viditur. --nFreZHaLTZJo0R7j Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename="tab_width-v3.diff" Content-Transfer-Encoding: quoted-printable diff -abBdru --exclude-from=3Dexclude /usr/src/cvs/gnome/galeon/ChangeLog g= aleon/ChangeLog --- /usr/src/cvs/gnome/galeon/ChangeLog 2005-04-04 21:54:19.000000000 +0200 +++ galeon/ChangeLog 2005-04-05 00:26:48.723563448 +0200 @@ -1,3 +1,18 @@ +2005-04-05 Stelian Ionescu <[email protected]> + + * utils/prefs-strings.h + * galeon.schemas.in: Added /apps/galeon/UI/Tabs/tab_width key + + * src/galeon-window.c (tab_width_gconf_changed_cb): Added key + listener for tab_width key + (setup_notebook): initial tab width now set using to the value in + tab_width key + + * utils/gul-notebook.h=20 + * utils/gul-notebook.c: (gul_notebook_set_tab_width): New function + (gul_notebook_refresh_tab_width): New function + (calc_tab_width_in_pixels): New function + 2005-04-02 Philip Langdale <[email protected]> =20 * configure.in diff -abBdru --exclude-from=3Dexclude /usr/src/cvs/gnome/galeon/galeon.sche= mas.in galeon/galeon.schemas.in --- /usr/src/cvs/gnome/galeon/galeon.schemas.in 2004-11-13 12:59:08.0000000= 00 +0100 +++ galeon/galeon.schemas.in 2005-03-28 15:06:59.993919824 +0200 @@ -349,6 +349,17 @@ </locale> </schema> <schema> + <key>/schemas/apps/galeon/UI/Tabs/tab_width</key> + <applyto>/apps/galeon/UI/Tabs/tab_width</applyto> + <owner>galeon</owner> + <type>int</type> + <default>15</default> + <locale name=3D"C"> + <short>Tab width</short> + <long>Tab width in characters.</long> + </locale> + </schema> + <schema> <key>/schemas/apps/galeon/UI/Tabs/favicons_in_tabs</key> <applyto>/apps/galeon/UI/Tabs/favicons_in_tabs</applyto> <owner>galeon</owner> diff -abBdru --exclude-from=3Dexclude /usr/src/cvs/gnome/galeon/src/galeon-= window.c galeon/src/galeon-window.c --- /usr/src/cvs/gnome/galeon/src/galeon-window.c 2005-01-31 18:53:35.00000= 0000 +0100 +++ galeon/src/galeon-window.c 2005-04-04 23:54:42.947325936 +0200 @@ -944,12 +944,27 @@ gul_notebook_set_policy (GUL_NOTEBOOK (notebook), policy); } =20 +static void +tab_width_gconf_changed_cb(GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + GtkNotebook *notebook) +{ + gint tab_width; + + tab_width =3D eel_gconf_get_integer (CONF_TABS_TAB_WIDTH); + tab_width =3D tab_width >=3D 0 ? tab_width : 0; + gul_notebook_set_tab_width (GUL_NOTEBOOK (notebook), tab_width); + gul_notebook_refresh_tab_width (GUL_NOTEBOOK (notebook)); +} + static GtkNotebook * setup_notebook (GaleonWindow *window) { GtkNotebook *notebook; GtkPolicyType policy; GtkPositionType position =3D eel_gconf_get_integer (CONF_TABS_TABBED_EDGE= ); + gint tab_width; =20 policy =3D eel_gconf_get_boolean (CONF_TABS_TABBED_ALWAYS_SHOW) ? GTK_POLICY_ALWAYS @@ -959,6 +974,11 @@ gtk_notebook_set_scrollable (notebook, TRUE); gtk_notebook_set_show_border (notebook, FALSE); gtk_notebook_set_tab_pos (notebook, position); + + tab_width =3D eel_gconf_get_integer (CONF_TABS_TAB_WIDTH); + tab_width =3D tab_width >=3D 0 ? tab_width : 0; + gul_notebook_set_tab_width(GUL_NOTEBOOK (notebook), tab_width); + gul_notebook_set_policy (GUL_NOTEBOOK (notebook), policy); gtk_notebook_popup_disable (notebook); =20 @@ -1012,6 +1032,10 @@ (GConfClientNotifyFunc)tabbed_always_show_gconf_changed_cb, notebook, &window->priv->notifiers); =20 + galeon_notification_add(CONF_TABS_TAB_WIDTH, + (GConfClientNotifyFunc)tab_width_gconf_changed_cb, + notebook, &window->priv->notifiers); + =20 gtk_widget_show (GTK_WIDGET (notebook)); =20 return notebook; diff -abBdru --exclude-from=3Dexclude /usr/src/cvs/gnome/galeon/utils/gul-n= otebook.c galeon/utils/gul-notebook.c --- /usr/src/cvs/gnome/galeon/utils/gul-notebook.c 2005-01-07 15:00:24.0000= 00000 +0100 +++ galeon/utils/gul-notebook.c 2005-04-05 00:06:15.890982488 +0200 @@ -728,16 +728,13 @@ } } =20 -static void -tab_label_style_set (GtkWidget *label, GtkStyle *previous_style, GtkWidget= *hbox) +static gint +calc_tab_width_in_pixels(GtkWidget *label, + gint tab_width) { - GulNotebook *notebook; PangoFontMetrics *metrics; PangoContext *context; - gint char_width; - gint n_pixels; - - notebook =3D GUL_NOTEBOOK (gtk_widget_get_ancestor (hbox, GUL_TYPE_NOTEBO= OK)); + gint char_width, n_pixels; =20 context =3D gtk_widget_get_pango_context (label); metrics =3D pango_context_get_metrics (context, @@ -747,8 +744,6 @@ char_width =3D pango_font_metrics_get_approximate_char_width (metrics); pango_font_metrics_unref (metrics); =20 - n_pixels =3D notebook->priv->tab_width_chars * PANGO_PIXELS(char_width); - /* We need to set the width of the widget that contains not only the * label, but also the favicon as otherwise tabs with icon would be * wider and we want to avoid that. Consequently we need to take the @@ -756,9 +751,23 @@ * characters when the icon is shown (and a little more when not.) */ =20 + n_pixels =3D tab_width * PANGO_PIXELS(char_width); n_pixels +=3D 16; n_pixels +=3D SPACING; =20 + return n_pixels; +} + +static void +tab_label_style_set (GtkWidget *label, GtkStyle *previous_style, GtkWidget= *hbox) +{ + GulNotebook *notebook; + gint n_pixels; + + notebook =3D GUL_NOTEBOOK (gtk_widget_get_ancestor (hbox, GUL_TYPE_NOTEBO= OK)); + + n_pixels =3D calc_tab_width_in_pixels(label, notebook->priv->tab_width_ch= ars); + hbox =3D g_object_get_data (G_OBJECT (hbox), "label-hbox"); gtk_widget_set_size_request (hbox, n_pixels, -1); } @@ -1089,3 +1098,28 @@ nb->priv->policy =3D policy; update_tabs_visibility (nb, FALSE); } + +void +gul_notebook_set_tab_width (GulNotebook *nb, + gint width) +{ + nb->priv->tab_width_chars =3D width; +} + +void +gul_notebook_refresh_tab_width (GulNotebook *nb) +{ + GtkWidget *curr_tab =3D gtk_notebook_get_nth_page(&nb->parent, 0); + GtkWidget *label, *hbox; + gint n_pixels, curr_tab_num; + gint total_tab_num =3D gtk_notebook_get_n_pages(&nb->parent); + + label =3D tab_get_label(GUL_NOTEBOOK (nb), GTK_WIDGET(curr_tab)); + n_pixels =3D calc_tab_width_in_pixels(label, nb->priv->tab_width_chars); + + for(curr_tab_num =3D 0; curr_tab_num < total_tab_num; curr_tab_num++) { + label =3D tab_get_label(GUL_NOTEBOOK (nb), GTK_WIDGET(curr_tab)); + hbox =3D GTK_WIDGET (gtk_widget_get_ancestor (label, GTK_TYPE_HBOX)); + gtk_widget_set_size_request (hbox, n_pixels, -1); + } +} diff -abBdru --exclude-from=3Dexclude /usr/src/cvs/gnome/galeon/utils/gul-n= otebook.h galeon/utils/gul-notebook.h --- /usr/src/cvs/gnome/galeon/utils/gul-notebook.h 2004-06-05 20:23:49.0000= 00000 +0200 +++ galeon/utils/gul-notebook.h 2005-04-04 23:43:42.598714184 +0200 @@ -101,6 +101,10 @@ GtkWidget *child, GtkWidget *icon); =20 +void gul_notebook_set_tab_width (GulNotebook *nb, + gint width); +void gul_notebook_refresh_tab_width (GulNotebook *nb); + G_END_DECLS =20 #endif /* GUL_NOTEBOOK_H */ diff -abBdru --exclude-from=3Dexclude /usr/src/cvs/gnome/galeon/utils/prefs= -strings.h galeon/utils/prefs-strings.h --- /usr/src/cvs/gnome/galeon/utils/prefs-strings.h 2004-07-26 16:53:38.000= 000000 +0200 +++ galeon/utils/prefs-strings.h 2005-03-28 13:34:43.300625144 +0200 @@ -24,6 +24,7 @@ #define CONF_TABS_TABBED_NEW_COLOR "/apps/galeon/UI/Tabs/tabbed_new_color" #define CONF_TABS_TABBED_ALWAYS_SHOW "/apps/galeon/UI/Tabs/tabbed_always_s= how" #define CONF_TABS_TABBED_EDGE "/apps/galeon/UI/Tabs/tabbed_position" +#define CONF_TABS_TAB_WIDTH "/apps/galeon/UI/Tabs/tab_width" #define CONF_TABS_FAVICON "/apps/galeon/UI/Tabs/favicons_in_tabs" =20 /* Window appeareance */ --nFreZHaLTZJo0R7j-- --8GpibOaaTibBMecb Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFCUcHaKTyIuNqLpocRAj4AAKCrYoxYIzCJQsvSA0JR+EqgBeYOswCgqI73 JQF2rzwBP1ME4OZSGc9Dy4w= =AHMb -----END PGP SIGNATURE----- --8GpibOaaTibBMecb-- ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click