From: Christian Persch Date: Thu, 29 Apr 2010 12:15:31 +0000 (+0200) Subject: [shell] Ellipsise the recent action's label X-Git-Tag: EVINCE_2_31_1~20 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=fa43b132d2ed3880438466efc090111e32026573;p=evince.git [shell] Ellipsise the recent action's label Otherwise a long document name makes the menu oversized. --- diff --git a/shell/ev-window.c b/shell/ev-window.c index a7debed6..e55c739e 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -239,6 +239,8 @@ struct _EvWindowPrivate { #define MIN_SCALE 0.05409 #define MAX_SCALE 4.0 +#define MAX_RECENT_ITEM_LEN (40) + static const gchar *document_print_settings[] = { GTK_PRINT_SETTINGS_N_COPIES, GTK_PRINT_SETTINGS_COLLATE, @@ -2324,6 +2326,23 @@ ev_window_get_recent_file_label (gint index, const gchar *filename) return g_string_free (str, FALSE); } +static void +ev_window_recent_action_connect_proxy_cb (GtkActionGroup *action_group, + GtkAction *action, + GtkWidget *proxy, + gpointer data) +{ + GtkLabel *label; + + if (!GTK_IS_MENU_ITEM (proxy)) + return; + + label = GTK_LABEL (gtk_bin_get_child (GTK_BIN (proxy))); + + gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_MIDDLE); + gtk_label_set_max_width_chars (label, MAX_RECENT_ITEM_LEN); +} + static void ev_window_setup_recent (EvWindow *ev_window) { @@ -2345,8 +2364,11 @@ ev_window_setup_recent (EvWindow *ev_window) g_object_unref (ev_window->priv->recent_action_group); } ev_window->priv->recent_action_group = gtk_action_group_new ("RecentFilesActions"); + g_signal_connect (ev_window->priv->recent_action_group, "connect-proxy", + G_CALLBACK (ev_window_recent_action_connect_proxy_cb), NULL); + gtk_ui_manager_insert_action_group (ev_window->priv->ui_manager, - ev_window->priv->recent_action_group, 0); + ev_window->priv->recent_action_group, -1); items = gtk_recent_manager_get_items (ev_window->priv->recent_manager); items = g_list_sort (items, (GCompareFunc) compare_recent_items);