diff options
author | Christian Persch <chpe@gnome.org> | 2007-07-24 15:21:21 +0000 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2007-07-24 15:21:21 +0000 |
commit | ee2c880e610fef1a694ab4ce3d134dad8e2f42d9 (patch) | |
tree | ba22ccbe2971927f2f8e30bb8c2414e3d5969e1e /src | |
parent | 32ec3056f6975cc4aa577ea53f6f5194fd1e399b (diff) | |
download | nautilus-ee2c880e610fef1a694ab4ce3d134dad8e2f42d9.tar.gz |
Use pango ellipsisation instead of truncating the strings. Bug #410113.
2007-07-24 Christian Persch <chpe@gnome.org>
* libnautilus-private/nautilus-bookmark.c:
(nautilus_bookmark_menu_item_new):
* libnautilus-private/nautilus-customization-data.c:
(nautilus_customization_data_new),
(nautilus_customization_data_get_next_element_for_display):
* libnautilus-private/nautilus-customization-data.h:
* src/nautilus-application.c:
* src/nautilus-bookmark-list.c: (new_bookmark_from_uri):
* src/nautilus-navigation-window-menus.c: (connect_proxy_cb),
(refresh_go_menu):
* src/nautilus-places-sidebar.c: (bookmarks_drop_uris),
(drag_data_received_callback):
* src/nautilus-property-browser.c:
(make_properties_from_directories):
* src/nautilus-window-bookmarks.c: (connect_proxy_cb),
(update_bookmarks):
* src/nautilus-window-menus.c:
(nautilus_menus_append_bookmark_to_menu):
* test/test-nautilus-wrap-table.c: (main): Use pango ellipsisation
instead of truncating the strings. Bug #410113.
svn path=/trunk/; revision=13025
Diffstat (limited to 'src')
-rw-r--r-- | src/nautilus-application.c | 2 | ||||
-rw-r--r-- | src/nautilus-bookmark-list.c | 16 | ||||
-rw-r--r-- | src/nautilus-navigation-window-menus.c | 20 | ||||
-rw-r--r-- | src/nautilus-places-sidebar.c | 14 | ||||
-rw-r--r-- | src/nautilus-property-browser.c | 1 | ||||
-rw-r--r-- | src/nautilus-window-bookmarks.c | 22 | ||||
-rw-r--r-- | src/nautilus-window-menus.c | 24 |
7 files changed, 58 insertions, 41 deletions
diff --git a/src/nautilus-application.c b/src/nautilus-application.c index e5cf24a7f..d2bd67e5f 100644 --- a/src/nautilus-application.c +++ b/src/nautilus-application.c @@ -58,6 +58,7 @@ #include "nautilus-window-manage-views.h" #include <libxml/xmlsave.h> #include <glib/gstdio.h> +#include <glib/gi18n.h> #include <bonobo/bonobo-main.h> #include <bonobo/bonobo-object.h> #include <eel/eel-gtk-extensions.h> @@ -70,7 +71,6 @@ #include <gtk/gtksignal.h> #include <gtk/gtkwindow.h> #include <libgnome/gnome-config.h> -#include <glib/gi18n.h> #include <libgnome/gnome-util.h> #include <libgnomeui/gnome-authentication-manager.h> #include <libgnomeui/gnome-client.h> diff --git a/src/nautilus-bookmark-list.c b/src/nautilus-bookmark-list.c index 6c3dc44be..d0e566289 100644 --- a/src/nautilus-bookmark-list.c +++ b/src/nautilus-bookmark-list.c @@ -72,20 +72,6 @@ static void bookmark_monitor_notify_cb (GnomeVFSMonitorHandle *handle, GnomeVFSMonitorEventType event_type, gpointer user_data); - -static char * -get_default_bookmark_name (const char *text_uri) -{ - char *title, *title_truncated; - - title = nautilus_compute_title_for_uri (text_uri); - title_truncated = eel_str_middle_truncate (title, MAX_BOOKMARK_LENGTH); - g_free (title); - - return title_truncated; - -} - static NautilusBookmark * new_bookmark_from_uri (const char *uri, const char *label) { @@ -96,7 +82,7 @@ new_bookmark_from_uri (const char *uri, const char *label) has_label = FALSE; if (!label) { - name = get_default_bookmark_name (uri); + name = nautilus_compute_title_for_uri (uri); } else { name = g_strdup (label); has_label = TRUE; diff --git a/src/nautilus-navigation-window-menus.c b/src/nautilus-navigation-window-menus.c index 82ac93206..b9e70efbc 100644 --- a/src/nautilus-navigation-window-menus.c +++ b/src/nautilus-navigation-window-menus.c @@ -65,6 +65,7 @@ #define MENU_PATH_HISTORY_PLACEHOLDER "/MenuBar/Other Menus/Go/History Placeholder" #define RESPONSE_FORGET 1000 +#define MENU_ITEM_MAX_WIDTH_CHARS 32 static void schedule_refresh_go_menu (NautilusNavigationWindow *window); @@ -296,6 +297,23 @@ show_bogus_history_window (NautilusWindow *window, g_free (detail); } +static void +connect_proxy_cb (GtkActionGroup *action_group, + GtkAction *action, + GtkWidget *proxy, + gpointer dummy) +{ + GtkLabel *label; + + if (!GTK_IS_MENU_ITEM (proxy)) + return; + + label = GTK_LABEL (GTK_BIN (proxy)->child); + + gtk_label_set_use_underline (label, FALSE); + gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END); + gtk_label_set_max_width_chars (label, MENU_ITEM_MAX_WIDTH_CHARS); +} /** * refresh_go_menu: @@ -322,6 +340,8 @@ refresh_go_menu (NautilusNavigationWindow *window) window->details->go_menu_merge_id = gtk_ui_manager_new_merge_id (ui_manager); window->details->go_menu_action_group = gtk_action_group_new ("GoMenuGroup"); + g_signal_connect (window->details->go_menu_action_group, "connect-proxy", + G_CALLBACK (connect_proxy_cb), NULL); gtk_ui_manager_insert_action_group (ui_manager, window->details->go_menu_action_group, diff --git a/src/nautilus-places-sidebar.c b/src/nautilus-places-sidebar.c index 4fc45db53..2a1b913bb 100644 --- a/src/nautilus-places-sidebar.c +++ b/src/nautilus-places-sidebar.c @@ -766,16 +766,18 @@ drag_leave_callback (GtkTreeView *tree_view, /* Parses a "text/uri-list" string and inserts its URIs as bookmarks */ static void bookmarks_drop_uris (NautilusPlacesSidebar *sidebar, - const char *data, + GtkSelectionData *selection_data, int position) { NautilusBookmark *bookmark; NautilusFile *file; - char *uri, *name, *name_truncated; + char *uri, *name; char **uris; int i; - uris = g_uri_list_extract_uris (data); + uris = gtk_selection_data_get_uris (selection_data); + if (!uris) + return; for (i = 0; uris[i]; i++) { uri = uris[i]; @@ -790,9 +792,8 @@ bookmarks_drop_uris (NautilusPlacesSidebar *sidebar, nautilus_file_unref (file); name = nautilus_compute_title_for_uri (uri); - name_truncated = eel_truncate_text_for_menu_item (name); - bookmark = nautilus_bookmark_new_with_icon (uri, name_truncated, + bookmark = nautilus_bookmark_new_with_icon (uri, name, FALSE, "gnome-fs-directory"); if (!nautilus_bookmark_list_contains (sidebar->bookmarks, bookmark)) { @@ -800,7 +801,6 @@ bookmarks_drop_uris (NautilusPlacesSidebar *sidebar, } g_object_unref (bookmark); - g_free (name_truncated); g_free (name); g_free (uri); } @@ -964,7 +964,7 @@ drag_data_received_callback (GtkWidget *widget, switch (info) { case TEXT_URI_LIST: - bookmarks_drop_uris (sidebar, selection_data->data, position); + bookmarks_drop_uris (sidebar, selection_data, position); success = TRUE; break; case GTK_TREE_MODEL_ROW: diff --git a/src/nautilus-property-browser.c b/src/nautilus-property-browser.c index 71b701f38..ad6a2df78 100644 --- a/src/nautilus-property-browser.c +++ b/src/nautilus-property-browser.c @@ -1760,7 +1760,6 @@ make_properties_from_directories (NautilusPropertyBrowser *property_browser) } else { customization_data = nautilus_customization_data_new (property_browser->details->category, !property_browser->details->remove_mode, - FALSE, MAX_ICON_WIDTH, MAX_ICON_HEIGHT); if (customization_data == NULL) { diff --git a/src/nautilus-window-bookmarks.c b/src/nautilus-window-bookmarks.c index ded90d252..50d01f44d 100644 --- a/src/nautilus-window-bookmarks.c +++ b/src/nautilus-window-bookmarks.c @@ -39,6 +39,8 @@ #include <eel/eel-vfs-extensions.h> #include <eel/eel-gtk-extensions.h> +#define MENU_ITEM_MAX_WIDTH_CHARS 32 + static GtkWindow *bookmarks_window = NULL; static NautilusBookmarkList *bookmarks = NULL; @@ -201,6 +203,24 @@ remove_bookmarks_menu_items (NautilusWindow *window) } static void +connect_proxy_cb (GtkActionGroup *action_group, + GtkAction *action, + GtkWidget *proxy, + gpointer dummy) +{ + GtkLabel *label; + + if (!GTK_IS_MENU_ITEM (proxy)) + return; + + label = GTK_LABEL (GTK_BIN (proxy)->child); + + gtk_label_set_use_underline (label, FALSE); + gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END); + gtk_label_set_max_width_chars (label, MENU_ITEM_MAX_WIDTH_CHARS); +} + +static void update_bookmarks (NautilusWindow *window) { NautilusBookmarkList *bookmarks; @@ -219,6 +239,8 @@ update_bookmarks (NautilusWindow *window) window->details->bookmarks_merge_id = gtk_ui_manager_new_merge_id (ui_manager); window->details->bookmarks_action_group = gtk_action_group_new ("BookmarksGroup"); + g_signal_connect (window->details->bookmarks_action_group, "connect-proxy", + G_CALLBACK (connect_proxy_cb), NULL); gtk_ui_manager_insert_action_group (ui_manager, window->details->bookmarks_action_group, diff --git a/src/nautilus-window-menus.c b/src/nautilus-window-menus.c index 3ed312c24..39bcc5fe8 100644 --- a/src/nautilus-window-menus.c +++ b/src/nautilus-window-menus.c @@ -152,8 +152,9 @@ nautilus_menus_append_bookmark_to_menu (NautilusWindow *window, GCallback refresh_callback, NautilusBookmarkFailedCallback failed_callback) { - BookmarkHolder *bookmark_holder; - char *raw_name, *display_name, *truncated_name, *action_name; + BookmarkHolder *bookmark_holder; + char action_name[128]; + char *name; GdkPixbuf *pixbuf; GtkAction *action; @@ -161,25 +162,15 @@ nautilus_menus_append_bookmark_to_menu (NautilusWindow *window, g_assert (NAUTILUS_IS_BOOKMARK (bookmark)); bookmark_holder = bookmark_holder_new (bookmark, window, refresh_callback, failed_callback); - - /* We double the underscores here to escape them so gtk+ will know they are - * not keyboard accelerator character prefixes. If we ever find we need to - * escape more than just the underscores, we'll add a menu helper function - * instead of a string utility. (Like maybe escaping control characters.) - */ - raw_name = nautilus_bookmark_get_name (bookmark); - truncated_name = eel_truncate_text_for_menu_item (raw_name); - display_name = eel_str_double_underscores (truncated_name); - g_free (raw_name); - g_free (truncated_name); + name = nautilus_bookmark_get_name (bookmark); /* Create menu item with pixbuf */ pixbuf = nautilus_bookmark_get_pixbuf (bookmark, GTK_ICON_SIZE_MENU); - action_name = g_strdup_printf ("bookmark_%s_%d", parent_id, index_in_parent); + g_snprintf (action_name, sizeof (action_name), "%s%d", parent_id, index_in_parent); action = gtk_action_new (action_name, - display_name, + name, _("Go to the location specified by this bookmark"), NULL); @@ -206,8 +197,7 @@ nautilus_menus_append_bookmark_to_menu (NautilusWindow *window, FALSE); g_object_unref (pixbuf); - g_free (action_name); - g_free (display_name); + g_free (name); } static void |