26 #include <glib/gi18n.h>
29 #define EV_BACKEND_PS "PSDocument"
30 #define EV_BACKEND_PDF "PdfDocument"
66 filename = g_uri_unescape_string (uri, NULL);
67 basename = g_path_get_basename (filename);
80 backend = G_OBJECT_TYPE_NAME (window_title->document);
82 for (i = 0; i < G_N_ELEMENTS (bad_extensions); i++) {
83 if (g_ascii_strcasecmp (bad_extensions[i].backend, backend) == 0 &&
84 g_str_has_suffix (*title, bad_extensions[i].text)) {
88 new_title = g_strndup (*title, strlen(*title) - strlen(bad_extensions[i].text));
95 for (i = 0; i < G_N_ELEMENTS (bad_prefixes); i++) {
96 if (g_ascii_strcasecmp (bad_prefixes[i].backend, backend) == 0 &&
97 g_str_has_prefix (*title, bad_prefixes[i].text)) {
99 int len = strlen(bad_prefixes[i].text);
101 new_title = g_strdup_printf (
"%s", (*title) + len);
111 GtkWindow *
window = GTK_WINDOW (window_title->window);
113 char *title = NULL, *p;
114 char *subtitle = NULL, *title_header = NULL;
117 gtk_header_bar_set_subtitle (toolbar, NULL);
118 gtk_window_set_title (window,
_(
"Recent Documents"));
122 if (window_title->doc_title && window_title->uri) {
123 title = g_strdup (window_title->doc_title);
128 title_header = title;
129 title = g_strdup_printf (
"%s — %s", subtitle, title);
131 for (p = title; *p; ++p) {
136 }
else if (window_title->uri) {
139 title = g_strdup (
_(
"Document Viewer"));
142 switch (window_title->type) {
144 gtk_window_set_title (window, title);
145 if (title_header && subtitle) {
146 gtk_header_bar_set_title (toolbar, title_header);
147 gtk_header_bar_set_subtitle (toolbar, subtitle);
151 gchar *password_title;
153 password_title = g_strdup_printf (
"%s — %s", title,
_(
"Password Required"));
154 gtk_window_set_title (window, password_title);
155 g_free (password_title);
157 gtk_header_bar_set_title (toolbar,
_(
"Password Required"));
158 gtk_header_bar_set_subtitle (toolbar, title);
162 g_assert_not_reached ();
168 g_free (title_header);
177 window_title->window =
window;
188 window_title->type = type;
197 window_title->document = NULL;
198 g_clear_pointer (&window_title->doc_title, g_free);
205 if (window_title->document == document)
208 if (window_title->document)
209 g_object_weak_unref (G_OBJECT (window_title->document), (GWeakNotify)
document_destroyed_cb, window_title);
210 window_title->document = document;
211 g_object_weak_ref (G_OBJECT (window_title->document), (GWeakNotify)document_destroyed_cb, window_title);
212 g_clear_pointer (&window_title->doc_title, g_free);
214 if (window_title->document != NULL) {
220 if (doc_title != NULL) {
221 doc_title = g_strstrip (doc_title);
223 if (doc_title[0] !=
'\0' &&
224 g_utf8_validate (doc_title, -1, NULL)) {
225 window_title->doc_title = doc_title;
239 if (g_strcmp0 (uri, window_title->uri) == 0)
242 g_free (window_title->uri);
243 window_title->uri = g_strdup (uri);
251 if (window_title->document)
252 g_object_weak_unref (G_OBJECT (window_title->document), (GWeakNotify)
document_destroyed_cb, window_title);
253 g_free (window_title->doc_title);
254 g_free (window_title->uri);
255 g_free (window_title);