From a32592d276fc8433bcd5d71ba384520915d7e69a Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Sun, 19 Jun 2005 18:20:55 +0000 Subject: [PATCH] Use pango ellipsisation. 2005-06-19 Christian Persch * cut-n-paste/recent-files/egg-recent-view-uimanager.c: (connect_proxy_cb), (egg_recent_view_uimanager_set_list): Use pango ellipsisation. * pdf/ev-poppler.cc: Fix refcount leak, from nsh. --- ChangeLog | 11 ++++++ .../recent-files/egg-recent-view-uimanager.c | 39 ++++++++++++------- pdf/ev-poppler.cc | 1 + 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index fc26f900..dc056112 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2005-06-19 Christian Persch + + * cut-n-paste/recent-files/egg-recent-view-uimanager.c: + (connect_proxy_cb), (egg_recent_view_uimanager_set_list): + + Use pango ellipsisation. + + * pdf/ev-poppler.cc: + + Fix refcount leak, from nsh. + 2005-06-19 Nickolay V. Shmyrev * cut-n-paste/recent-files/Makefile.am: diff --git a/cut-n-paste/recent-files/egg-recent-view-uimanager.c b/cut-n-paste/recent-files/egg-recent-view-uimanager.c index 1ae6f3e4..ab03426a 100644 --- a/cut-n-paste/recent-files/egg-recent-view-uimanager.c +++ b/cut-n-paste/recent-files/egg-recent-view-uimanager.c @@ -43,6 +43,8 @@ #define EGG_RECENT_ACTION "EggRecentFile" #define EGG_RECENT_SEPARATOR (NULL) +#define LABEL_WIDTH_CHARS 32 + struct _EggRecentViewUIManager { GObject parent_instance; @@ -114,6 +116,23 @@ egg_recent_view_uimanager_clear (EggRecentViewUIManager *view) gtk_ui_manager_ensure_update (view->uimanager); } +static void +connect_proxy_cb (GtkActionGroup *action_group, + GtkAction *action, + GtkWidget *proxy) +{ + if (GTK_IS_MENU_ITEM (proxy)) + { + GtkLabel *label; + + label = (GtkLabel *) ((GtkBin *) proxy)->child; + + gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END); + gtk_label_set_max_width_chars (label, LABEL_WIDTH_CHARS); + } +} + + static void egg_recent_view_uimanager_set_list (EggRecentViewUIManager *view, GList *list) { @@ -131,7 +150,9 @@ egg_recent_view_uimanager_set_list (EggRecentViewUIManager *view, GList *list) gchar *group = g_strdup_printf ("EggRecentActions%u", view->merge_id); view->action_group = gtk_action_group_new (group); - gtk_ui_manager_insert_action_group (view->uimanager, view->action_group, 0); + g_signal_connect (view->action_group, "connect-proxy", + G_CALLBACK (connect_proxy_cb), view); + gtk_ui_manager_insert_action_group (view->uimanager, view->action_group, -1); g_free (group); } @@ -155,7 +176,6 @@ egg_recent_view_uimanager_set_list (EggRecentViewUIManager *view, GList *list) gchar *uri; gchar *basename; gchar *escaped; - gchar *ellipsized; gchar *label; gchar *tooltip = NULL; @@ -174,26 +194,19 @@ egg_recent_view_uimanager_set_list (EggRecentViewUIManager *view, GList *list) escaped = egg_recent_util_escape_underlines (basename); g_free (basename); g_free (uri); - - if (strlen (escaped) > 40) { - ellipsized = g_strdup_printf ("%.40s...", escaped); - g_free (escaped); - } else { - ellipsized = escaped; - } if (view->show_numbers) { if (index >= 10) label = g_strdup_printf ("%d. %s", index, - ellipsized); + escaped); else label = g_strdup_printf ("_%d. %s", index, - ellipsized); - g_free (ellipsized); + escaped); + g_free (escaped); } else - label = ellipsized; + label = basename; action = g_object_new (GTK_TYPE_ACTION, "name", name, diff --git a/pdf/ev-poppler.cc b/pdf/ev-poppler.cc index 90bae3ae..cfb745d0 100644 --- a/pdf/ev-poppler.cc +++ b/pdf/ev-poppler.cc @@ -732,6 +732,7 @@ build_tree (PdfDocument *pdf_document, EV_DOCUMENT_LINKS_COLUMN_LINK, link, EV_DOCUMENT_LINKS_COLUMN_EXPAND, expand, -1); + g_object_unref (link); child = poppler_index_iter_get_child (iter); if (child) build_tree (pdf_document, model, &tree_iter, child); -- 2.43.5