예제 #1
0
static void
ev_window_title_update (EvWindowTitle *window_title)
{
	GtkWindow *window = GTK_WINDOW (window_title->window);
	char *title = NULL, *password_title, *p;

	if (window_title->document != NULL) {
		gchar *doc_title;

		doc_title = g_strdup (ev_document_get_title (window_title->document));

		/* Make sure we get a valid title back */
		if (doc_title != NULL) {
			doc_title = g_strstrip (doc_title);

			if (doc_title[0] != '\0' &&
			    g_utf8_validate (doc_title, -1, NULL)) {
				title = g_strdup (doc_title);
			}

			g_free (doc_title);
		}
	}

	if (title && window_title->uri) {
		char *tmp_title;
		char *filename = get_filename_from_uri (window_title->uri);

		ev_window_title_sanitize_title (window_title, &title);
		tmp_title = g_strdup_printf ("%s — %s", filename, title);

		g_free (title);
		g_free (filename);
		title = tmp_title;
	} else if (window_title->uri) {
		title = get_filename_from_uri (window_title->uri);
	} else if (!title) {
		title = g_strdup (_("Document Viewer"));
	}

	for (p = title; *p; ++p) {
		/* an '\n' byte is always ASCII, no need for UTF-8 special casing */
		if (*p == '\n')	*p = ' ';
	}

	switch (window_title->type) {
	case EV_WINDOW_TITLE_DOCUMENT:
		gtk_window_set_title (window, title);
		break;
	case EV_WINDOW_TITLE_PASSWORD:
		password_title = g_strdup_printf (_("%s — Password Required"), title);
		gtk_window_set_title (window, password_title);
		g_free (password_title);
		break;
	}

	g_free (title);
}
예제 #2
0
static void
ev_window_title_update (EvWindowTitle *window_title)
{
	GtkWindow *window = GTK_WINDOW (window_title->window);
	GtkHeaderBar *toolbar = GTK_HEADER_BAR (ev_window_get_toolbar (EV_WINDOW (window)));
	char *title = NULL, *p;
	char *subtitle = NULL, *title_header = NULL;

        if (window_title->type == EV_WINDOW_TITLE_RECENT) {
                gtk_header_bar_set_subtitle (toolbar, NULL);
                gtk_window_set_title (window, _("Recent Documents"));
                return;
        }

	if (window_title->doc_title && window_title->uri) {
                title = g_strdup (window_title->doc_title);
                ev_window_title_sanitize_title (window_title, &title);

		subtitle = get_filename_from_uri (window_title->uri);

		title_header = title;
		title = g_strdup_printf ("%s — %s", subtitle, title);

                for (p = title; *p; ++p) {
                        /* an '\n' byte is always ASCII, no need for UTF-8 special casing */
                        if (*p == '\n')
                                *p = ' ';
                }
	} else if (window_title->uri) {
		title = get_filename_from_uri (window_title->uri);
	} else if (!title) {
		title = g_strdup (_("Document Viewer"));
	}

	switch (window_title->type) {
	case EV_WINDOW_TITLE_DOCUMENT:
		gtk_window_set_title (window, title);
		if (title_header && subtitle) {
			gtk_header_bar_set_title (toolbar, title_header);
			gtk_header_bar_set_subtitle (toolbar, subtitle);
		}
		break;
	case EV_WINDOW_TITLE_PASSWORD: {
                gchar *password_title;

		password_title = g_strdup_printf ("%s — %s", title, _("Password Required"));
		gtk_window_set_title (window, password_title);
		g_free (password_title);

                gtk_header_bar_set_title (toolbar, _("Password Required"));
                gtk_header_bar_set_subtitle (toolbar, title);
        }
		break;
        case EV_WINDOW_TITLE_RECENT:
                g_assert_not_reached ();
                break;
	}

	g_free (title);
	g_free (subtitle);
	g_free (title_header);
}