diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2004-12-14 01:57:12 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2004-12-14 01:57:12 +0800 |
commit | 43955b584199f99428660d47bc2a7297ffdf763f (patch) | |
tree | 8fe84b888fa2e1cdef16d27fbf3049d164f09ae4 | |
parent | f58beaee60ebf176074bcad300c5e7ac0e253694 (diff) | |
download | gsoc2013-epiphany-43955b584199f99428660d47bc2a7297ffdf763f.tar gsoc2013-epiphany-43955b584199f99428660d47bc2a7297ffdf763f.tar.gz gsoc2013-epiphany-43955b584199f99428660d47bc2a7297ffdf763f.tar.bz2 gsoc2013-epiphany-43955b584199f99428660d47bc2a7297ffdf763f.tar.lz gsoc2013-epiphany-43955b584199f99428660d47bc2a7297ffdf763f.tar.xz gsoc2013-epiphany-43955b584199f99428660d47bc2a7297ffdf763f.tar.zst gsoc2013-epiphany-43955b584199f99428660d47bc2a7297ffdf763f.zip |
Make distcheck fix.
2004-12-13 Christian Persch <chpe@cvs.gnome.org>
* Makefile.am:
Make distcheck fix.
* lib/ephy-string.c:
* lib/ephy-string.h:
Finally remove ephy_string_shorten().
* src/bookmarks/ephy-bookmark-action.c: (create_tool_item),
(ephy_bookmark_action_sync_label):
* src/bookmarks/ephy-bookmarks-menu.c: (connect_proxy_cb):
* src/bookmarks/ephy-favorites-menu.c: (connect_proxy_cb):
* src/bookmarks/ephy-topic-action.c: (create_tool_item),
(ephy_topic_action_sync_label), (append_bookmarks_menu),
(build_topics_menu):
* src/ephy-navigation-action.c: (new_history_menu_item):
Use gtk_label_set_max_width_chars() and ellipsise the labels.
-rw-r--r-- | ChangeLog | 22 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | lib/ephy-string.c | 37 | ||||
-rw-r--r-- | lib/ephy-string.h | 3 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmark-action.c | 27 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks-menu.c | 2 | ||||
-rw-r--r-- | src/bookmarks/ephy-favorites-menu.c | 2 | ||||
-rw-r--r-- | src/bookmarks/ephy-topic-action.c | 19 | ||||
-rw-r--r-- | src/ephy-navigation-action.c | 17 |
9 files changed, 51 insertions, 80 deletions
@@ -1,5 +1,27 @@ 2004-12-13 Christian Persch <chpe@cvs.gnome.org> + * Makefile.am: + + Make distcheck fix. + + * lib/ephy-string.c: + * lib/ephy-string.h: + + Finally remove ephy_string_shorten(). + + * src/bookmarks/ephy-bookmark-action.c: (create_tool_item), + (ephy_bookmark_action_sync_label): + * src/bookmarks/ephy-bookmarks-menu.c: (connect_proxy_cb): + * src/bookmarks/ephy-favorites-menu.c: (connect_proxy_cb): + * src/bookmarks/ephy-topic-action.c: (create_tool_item), + (ephy_topic_action_sync_label), (append_bookmarks_menu), + (build_topics_menu): + * src/ephy-navigation-action.c: (new_history_menu_item): + + Use gtk_label_set_max_width_chars() and ellipsise the labels. + +2004-12-13 Christian Persch <chpe@cvs.gnome.org> + * configure.ac: Adapt PSM configure check for new header location in SDK. diff --git a/Makefile.am b/Makefile.am index d801cde99..8503c2f35 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,7 +4,7 @@ SUBDIRS = lib embed idl src data po help doc distcleancheck_listfiles = find . -type f -print | grep -v 'omf\.out' -distuninstallcheck_listfiles = find . -type f -print | grep -v '^\./var/scrollkeeper' | grep -v 'omf' | grep -v 'figures' +distuninstallcheck_listfiles = find . -type f -print | grep -v '/var/scrollkeeper' EXTRA_DIST = \ intltool-merge.in \ diff --git a/lib/ephy-string.c b/lib/ephy-string.c index e3095c376..da89dd2c5 100644 --- a/lib/ephy-string.c +++ b/lib/ephy-string.c @@ -27,43 +27,6 @@ #include <stdlib.h> #include <glib.h> -#define ELLIPSIS "\xe2\x80\xa6" - -/** - * ephy_string_shorten: returns a newly allocated shortened version of str. - * The input must be valid utf-8. - * @str: the string to shorten - * @target_length: the length of the shortened string (in characters) - * - * FIXME: this function is a big mess. While it is utf-8 safe now, - * it can still split a sequence of combining characters - */ -char * -ephy_string_shorten (const char *str, int target_length) -{ - char *new_str; - glong actual_length; - gulong bytes; - - if (!str) return NULL; - - 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 (actual_length <= target_length) return g_strdup (str); - - /* create string */ - bytes = GPOINTER_TO_UINT (g_utf8_offset_to_pointer (str, target_length - 1) - str); - - new_str = g_new0 (gchar, bytes + strlen(ELLIPSIS) + 1); - - strncpy (new_str, str, bytes); - strncpy (new_str + bytes, ELLIPSIS, strlen (ELLIPSIS)); - - return new_str; -} - gboolean ephy_string_to_int (const char *string, gulong *integer) { diff --git a/lib/ephy-string.h b/lib/ephy-string.h index f2907219f..886bca5dc 100644 --- a/lib/ephy-string.h +++ b/lib/ephy-string.h @@ -30,9 +30,6 @@ gboolean ephy_string_to_int (const char *string, char *ephy_string_blank_chr (char *source); -char *ephy_string_shorten (const char *str, - int target_length); - char *ephy_string_elide_underscores (const char *original); char *ephy_string_double_underscores (const char *string); diff --git a/src/bookmarks/ephy-bookmark-action.c b/src/bookmarks/ephy-bookmark-action.c index 27ab1d870..05975cc2c 100644 --- a/src/bookmarks/ephy-bookmark-action.c +++ b/src/bookmarks/ephy-bookmark-action.c @@ -33,11 +33,14 @@ #include "ephy-favicon-cache.h" #include "ephy-shell.h" #include "ephy-debug.h" -#include "ephy-string.h" #include "ephy-gui.h" #include <string.h> +/* FIXME tweak this, or make it configurable? (bug 148093) */ +#define ENTRY_WIDTH_CHARS 16 +#define TOOLITEM_WIDTH_CHARS 24 + static void ephy_bookmark_action_init (EphyBookmarkAction *action); static void ephy_bookmark_action_class_init (EphyBookmarkActionClass *class); @@ -107,9 +110,6 @@ ephy_bookmark_action_get_type (void) return type; } -/* FIXME tweak this, or make it configurable? (bug 148093) */ -#define ENTRY_WIDTH_CHARS 16 - static GtkWidget * create_tool_item (GtkAction *action) { @@ -145,6 +145,8 @@ create_tool_item (GtkAction *action) g_object_set_data (G_OBJECT (item), "icon", icon); label = gtk_label_new (NULL); + gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); + gtk_label_set_max_width_chars (GTK_LABEL (label), TOOLITEM_WIDTH_CHARS); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0); g_object_set_data (G_OBJECT (item), "label", label); @@ -260,8 +262,6 @@ ephy_bookmark_action_sync_icon (GtkAction *action, GParamSpec *pspec, GtkWidget } } -#define MAX_LABEL_LENGTH 32 - static void ephy_bookmark_action_sync_label (GtkAction *gaction, GParamSpec *pspec, @@ -271,36 +271,29 @@ ephy_bookmark_action_sync_label (GtkAction *gaction, g_return_if_fail (EPHY_IS_NODE (action->priv->node)); - /* note that we cannot use ellipsizing label with defined width, - * since that makes the label exactly that wide, even if the - * text takes less space. So we have to shorten the string. - */ if (GTK_IS_TOOL_ITEM (proxy)) { GtkWidget *label = NULL; const char *title; - char *title_short, *label_text; + char *label_text; label = g_object_get_data (G_OBJECT (proxy), "label"); g_return_if_fail (label != NULL); title = ephy_node_get_property_string (action->priv->node, EPHY_NODE_BMK_PROP_TITLE); - title_short = ephy_string_shorten (title, MAX_LABEL_LENGTH); - if (EPHY_BOOKMARK_ACTION (action)->priv->smart_url) + if (action->priv->smart_url) { - label_text = g_strdup_printf (_("%s:"), title_short); + label_text = g_strdup_printf (_("%s:"), title); gtk_label_set_label (GTK_LABEL (label), label_text); g_free (label_text); } else { - gtk_label_set_label (GTK_LABEL (label), title_short); + gtk_label_set_label (GTK_LABEL (label), title); } - - g_free (title_short); } } diff --git a/src/bookmarks/ephy-bookmarks-menu.c b/src/bookmarks/ephy-bookmarks-menu.c index dfb3aea22..3d8fa466c 100644 --- a/src/bookmarks/ephy-bookmarks-menu.c +++ b/src/bookmarks/ephy-bookmarks-menu.c @@ -129,8 +129,8 @@ connect_proxy_cb (GtkActionGroup *action_group, GtkLabel *label; label = (GtkLabel *) ((GtkBin *) proxy)->child; - gtk_label_set_width_chars (label, LABEL_WIDTH_CHARS); gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END); + gtk_label_set_max_width_chars (label, LABEL_WIDTH_CHARS); } } diff --git a/src/bookmarks/ephy-favorites-menu.c b/src/bookmarks/ephy-favorites-menu.c index dce6e5561..b0dc3c631 100644 --- a/src/bookmarks/ephy-favorites-menu.c +++ b/src/bookmarks/ephy-favorites-menu.c @@ -117,8 +117,8 @@ connect_proxy_cb (GtkActionGroup *action_group, GtkLabel *label; label = (GtkLabel *) ((GtkBin *) proxy)->child; - gtk_label_set_width_chars (label, LABEL_WIDTH_CHARS); gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END); + gtk_label_set_max_width_chars (label, LABEL_WIDTH_CHARS); } } diff --git a/src/bookmarks/ephy-topic-action.c b/src/bookmarks/ephy-topic-action.c index 878b7da54..eb57b48a6 100644 --- a/src/bookmarks/ephy-topic-action.c +++ b/src/bookmarks/ephy-topic-action.c @@ -34,13 +34,13 @@ #include "ephy-debug.h" #include "ephy-dnd.h" #include "ephy-gui.h" -#include "ephy-string.h" #include "ephy-marshal.h" static void ephy_topic_action_init (EphyTopicAction *action); static void ephy_topic_action_class_init (EphyTopicActionClass *class); -#define LABEL_WIDTH_CHARS 32 +#define TOOLITEM_WIDTH_CHARS 24 +#define MENUITEM_WIDTH_CHARS 32 #define EPHY_TOPIC_ACTION_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_TOPIC_ACTION, EphyTopicActionPrivate)) @@ -135,6 +135,8 @@ create_tool_item (GtkAction *action) gtk_container_add (GTK_CONTAINER (button), hbox); label = gtk_label_new (NULL); + gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); + gtk_label_set_max_width_chars (GTK_LABEL (label), TOOLITEM_WIDTH_CHARS); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), arrow, TRUE, TRUE, 0); @@ -173,8 +175,6 @@ menu_activate_cb (GtkWidget *item, GtkAction *action) } } -#define MAX_LABEL_LENGTH 32 - static void ephy_topic_action_sync_label (GtkAction *gaction, GParamSpec *pspec, @@ -192,17 +192,14 @@ ephy_topic_action_sync_label (GtkAction *gaction, { GtkWidget *label = NULL; char *title; - char *title_short; label = g_object_get_data (G_OBJECT (proxy), "label"); g_return_if_fail (label != NULL); g_object_get (G_OBJECT (action), "label", &title, NULL); - title_short = ephy_string_shorten (title, MAX_LABEL_LENGTH); - gtk_label_set_label (GTK_LABEL (label), title_short); + gtk_label_set_label (GTK_LABEL (label), title); - g_free (title_short); g_free (title); } } @@ -240,8 +237,6 @@ sort_bookmarks (gconstpointer a, gconstpointer b) return retval; } -#define MAX_LENGTH 32 - static gboolean can_open_in_tabs (EphyNode *node) { @@ -306,7 +301,7 @@ append_bookmarks_menu (EphyTopicAction *action, GtkWidget *menu, EphyNode *node, item = gtk_image_menu_item_new_with_label (title); label = (GtkLabel *) ((GtkBin *) item)->child; - gtk_label_set_width_chars (label, LABEL_WIDTH_CHARS); + gtk_label_set_max_width_chars (label, MENUITEM_WIDTH_CHARS); gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END); if (icon_location) @@ -565,7 +560,7 @@ build_topics_menu (EphyTopicAction *action) item = gtk_image_menu_item_new_with_label (title); label = (GtkLabel *) ((GtkBin *) item)->child; - gtk_label_set_width_chars (label, LABEL_WIDTH_CHARS); + gtk_label_set_max_width_chars (label, MENUITEM_WIDTH_CHARS); gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END); gtk_widget_show (item); diff --git a/src/ephy-navigation-action.c b/src/ephy-navigation-action.c index 5f826d9bc..0e166f506 100644 --- a/src/ephy-navigation-action.c +++ b/src/ephy-navigation-action.c @@ -22,12 +22,12 @@ #include "ephy-navigation-action.h" #include "ephy-window.h" -#include "ephy-string.h" #include "ephy-favicon-cache.h" #include "ephy-history.h" #include "ephy-embed-shell.h" #include "ephy-debug.h" +#include <gtk/gtklabel.h> #include <gtk/gtkimage.h> #include <gtk/gtkmenuitem.h> #include <gtk/gtkimagemenuitem.h> @@ -89,7 +89,7 @@ ephy_navigation_action_get_type (void) return type; } -#define MAX_LENGTH 60 +#define MAX_LABEL_LENGTH 48 static GtkWidget * new_history_menu_item (const char *origtext, @@ -99,15 +99,16 @@ new_history_menu_item (const char *origtext, EphyHistory *history; GtkWidget *item, *image; GdkPixbuf *icon = NULL; + GtkLabel *label; const char *icon_address; - char *short_text; - g_return_val_if_fail (address != NULL, NULL); + g_return_val_if_fail (address != NULL && origtext != NULL, NULL); - /* FIXME: use ellipsisation in the menu item instead */ - short_text = ephy_string_shorten (origtext, MAX_LENGTH); - item = gtk_image_menu_item_new_with_label (short_text); - g_free (short_text); + item = gtk_image_menu_item_new_with_label (origtext); + + label = GTK_LABEL (GTK_BIN (item)->child); + gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END); + gtk_label_set_max_width_chars (label, MAX_LABEL_LENGTH); history = EPHY_HISTORY (ephy_embed_shell_get_global_history (embed_shell)); |