From: Nickolay V. Shmyrev Date: Mon, 13 Oct 2008 20:54:15 +0000 (+0000) Subject: Removes bad prefixes from window title. Patch by Robin Sonefors X-Git-Tag: EVINCE_2_24_1~7 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=f9e30fddad31007cd22eb5d7cc55483d8387f23f;p=evince.git Removes bad prefixes from window title. Patch by Robin Sonefors 2008-10-14 Nickolay V. Shmyrev * shell/ev-window-title.c (ev_window_title_sanitize_title): Removes bad prefixes from window title. Patch by Robin Sonefors fixes bug #534684. svn path=/trunk/; revision=3220 --- diff --git a/ChangeLog b/ChangeLog index 22c3c5a5..47e9c407 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-10-14 Nickolay V. Shmyrev + + * shell/ev-window-title.c (ev_window_title_sanitize_title): + + Removes bad prefixes from window title. Patch by + Robin Sonefors fixes bug #534684. + 2008-10-12 Carlos Garcia Campos * shell/ev-window.c: (launch_external_uri): diff --git a/shell/ev-window-title.c b/shell/ev-window-title.c index b43775a6..9cfd865b 100644 --- a/shell/ev-window-title.c +++ b/shell/ev-window-title.c @@ -21,6 +21,7 @@ #include "ev-window-title.h" #include "ev-backends-manager.h" +#include #include #include @@ -31,8 +32,8 @@ typedef struct { const gchar *backend; - const gchar *ext; -} BadExtensionEntry; + const gchar *text; +} BadTitleEntry; struct _EvWindowTitle { @@ -42,7 +43,7 @@ struct _EvWindowTitle char *uri; }; -static const BadExtensionEntry bad_extensions[] = { +static const BadTitleEntry bad_extensions[] = { { EV_BACKEND_PS, ".dvi" }, { EV_BACKEND_PDF, ".doc" }, { EV_BACKEND_PDF, ".dvi" }, @@ -50,6 +51,11 @@ static const BadExtensionEntry bad_extensions[] = { { EV_BACKEND_PDF, ".rtf" } }; +static const BadTitleEntry bad_prefixes[] = { + { EV_BACKEND_PDF, "Microsoft Word - " }, + { EV_BACKEND_PDF, "Microsoft PowerPoint - " } +}; + EvWindowTitle * ev_window_title_new (EvWindow *window) { @@ -78,7 +84,7 @@ get_filename_from_uri (const char *uri) /* Some docs report titles with confusing extensions (ex. .doc for pdf). Let's show the filename in this case */ static void -ev_window_title_sanitize_extension (EvWindowTitle *window_title, char **title) { +ev_window_title_sanitize_title (EvWindowTitle *window_title, char **title) { const gchar *backend; int i; @@ -86,7 +92,7 @@ ev_window_title_sanitize_extension (EvWindowTitle *window_title, char **title) { for (i = 0; i < G_N_ELEMENTS (bad_extensions); i++) { if (g_ascii_strcasecmp (bad_extensions[i].backend, backend) == 0 && - g_str_has_suffix (*title, bad_extensions[i].ext)) { + g_str_has_suffix (*title, bad_extensions[i].text)) { char *new_title; char *filename = get_filename_from_uri (window_title->uri); @@ -97,6 +103,17 @@ ev_window_title_sanitize_extension (EvWindowTitle *window_title, char **title) { g_free (filename); } } + for (i = 0; i < G_N_ELEMENTS (bad_prefixes); i++) { + if (g_ascii_strcasecmp (bad_prefixes[i].backend, backend) == 0 && + g_str_has_prefix (*title, bad_prefixes[i].text)) { + char *new_title; + int len = strlen(bad_prefixes[i].text); + + new_title = g_strdup_printf ("%s", (*title) + len); + g_free (*title); + *title = new_title; + } + } } static void @@ -125,7 +142,7 @@ ev_window_title_update (EvWindowTitle *window_title) } if (title && window_title->uri) { - ev_window_title_sanitize_extension (window_title, &title); + ev_window_title_sanitize_title (window_title, &title); } else if (window_title->uri) { title = get_filename_from_uri (window_title->uri); } else if (!title) {