mirror of
https://gitlab.gnome.org/GNOME/evince
synced 2024-07-05 00:59:07 +00:00
properties: Add document size in the file properties window
https://bugzilla.gnome.org/show_bug.cgi?id=741057
This commit is contained in:
parent
9c31b99295
commit
c69275293b
|
@ -39,6 +39,7 @@ typedef struct _EvPageSize
|
|||
struct _EvDocumentPrivate
|
||||
{
|
||||
gchar *uri;
|
||||
guint64 file_size;
|
||||
|
||||
gint n_pages;
|
||||
|
||||
|
@ -59,6 +60,8 @@ struct _EvDocumentPrivate
|
|||
synctex_scanner_t synctex_scanner;
|
||||
};
|
||||
|
||||
static guint64 _ev_document_get_size_gfile (GFile *file);
|
||||
static guint64 _ev_document_get_size (const char *uri);
|
||||
static gint _ev_document_get_n_pages (EvDocument *document);
|
||||
static void _ev_document_get_page_size (EvDocument *document,
|
||||
EvPage *page,
|
||||
|
@ -329,6 +332,7 @@ ev_document_load (EvDocument *document,
|
|||
} else {
|
||||
ev_document_setup_cache (document);
|
||||
document->priv->uri = g_strdup (uri);
|
||||
document->priv->file_size = _ev_document_get_size (uri);
|
||||
ev_document_initialize_synctex (document, uri);
|
||||
}
|
||||
|
||||
|
@ -420,6 +424,7 @@ ev_document_load_gfile (EvDocument *document,
|
|||
|
||||
ev_document_setup_cache (document);
|
||||
document->priv->uri = g_file_get_uri (file);
|
||||
document->priv->file_size = _ev_document_get_size_gfile (file);
|
||||
ev_document_initialize_synctex (document, document->priv->uri);
|
||||
|
||||
return TRUE;
|
||||
|
@ -574,6 +579,32 @@ ev_document_synctex_forward_search (EvDocument *document,
|
|||
return result;
|
||||
}
|
||||
|
||||
static guint64
|
||||
_ev_document_get_size_gfile (GFile *file)
|
||||
{
|
||||
goffset size = 0;
|
||||
GFileInfo *info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SIZE,
|
||||
G_FILE_QUERY_INFO_NONE, NULL, NULL);
|
||||
if (info) {
|
||||
size = g_file_info_get_size (info);
|
||||
|
||||
g_object_unref (info);
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static guint64
|
||||
_ev_document_get_size (const char *uri)
|
||||
{
|
||||
GFile *file = g_file_new_for_uri (uri);
|
||||
guint64 size = _ev_document_get_size_gfile (file);
|
||||
|
||||
g_object_unref (file);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static gint
|
||||
_ev_document_get_n_pages (EvDocument *document)
|
||||
{
|
||||
|
@ -802,6 +833,14 @@ ev_document_check_dimensions (EvDocument *document)
|
|||
return (document->priv->max_width > 0 && document->priv->max_height > 0);
|
||||
}
|
||||
|
||||
guint64
|
||||
ev_document_get_size (EvDocument *document)
|
||||
{
|
||||
g_return_val_if_fail (EV_IS_DOCUMENT (document), 0);
|
||||
|
||||
return document->priv->file_size;
|
||||
}
|
||||
|
||||
gint
|
||||
ev_document_get_max_label_len (EvDocument *document)
|
||||
{
|
||||
|
|
|
@ -181,6 +181,7 @@ GdkPixbuf *ev_document_get_thumbnail (EvDocument *document,
|
|||
EvRenderContext *rc);
|
||||
cairo_surface_t *ev_document_get_thumbnail_surface (EvDocument *document,
|
||||
EvRenderContext *rc);
|
||||
guint64 ev_document_get_size (EvDocument *document);
|
||||
const gchar *ev_document_get_uri (EvDocument *document);
|
||||
const gchar *ev_document_get_title (EvDocument *document);
|
||||
gboolean ev_document_is_page_size_uniform (EvDocument *document);
|
||||
|
|
|
@ -114,7 +114,7 @@ ev_properties_get_pages (NautilusPropertyPageProvider *provider,
|
|||
}
|
||||
|
||||
label = gtk_label_new (_("Document"));
|
||||
page = ev_properties_view_new (uri);
|
||||
page = ev_properties_view_new (document);
|
||||
ev_properties_view_set_info (EV_PROPERTIES_VIEW (page),
|
||||
ev_document_get_info (document));
|
||||
gtk_widget_show (page);
|
||||
|
|
|
@ -48,7 +48,8 @@ typedef enum {
|
|||
FORMAT_PROPERTY,
|
||||
SECURITY_PROPERTY,
|
||||
PAPER_SIZE_PROPERTY,
|
||||
N_PROPERTIES
|
||||
FILE_SIZE_PROPERTY,
|
||||
N_PROPERTIES,
|
||||
} Property;
|
||||
|
||||
typedef struct {
|
||||
|
@ -70,7 +71,8 @@ static const PropertyInfo properties_info[] = {
|
|||
{ LINEARIZED_PROPERTY, N_("Optimized:") },
|
||||
{ FORMAT_PROPERTY, N_("Format:") },
|
||||
{ SECURITY_PROPERTY, N_("Security:") },
|
||||
{ PAPER_SIZE_PROPERTY, N_("Paper Size:") }
|
||||
{ PAPER_SIZE_PROPERTY, N_("Paper Size:") },
|
||||
{ FILE_SIZE_PROPERTY, N_("Size:") }
|
||||
};
|
||||
|
||||
struct _EvPropertiesView {
|
||||
|
@ -79,6 +81,7 @@ struct _EvPropertiesView {
|
|||
GtkWidget *grid;
|
||||
GtkWidget *labels[N_PROPERTIES];
|
||||
gchar *uri;
|
||||
guint64 file_size;
|
||||
};
|
||||
|
||||
struct _EvPropertiesViewClass {
|
||||
|
@ -370,6 +373,11 @@ ev_properties_view_set_info (EvPropertiesView *properties, const EvDocumentInfo
|
|||
set_property (properties, GTK_GRID (grid), PAPER_SIZE_PROPERTY, text, &row);
|
||||
g_free (text);
|
||||
}
|
||||
if (properties->file_size) {
|
||||
text = g_format_size (properties->file_size);
|
||||
set_property (properties, GTK_GRID (grid), FILE_SIZE_PROPERTY, text, &row);
|
||||
g_free (text);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -390,14 +398,15 @@ ev_properties_view_register_type (GTypeModule *module)
|
|||
}
|
||||
|
||||
GtkWidget *
|
||||
ev_properties_view_new (const gchar *uri)
|
||||
ev_properties_view_new (EvDocument *document)
|
||||
{
|
||||
EvPropertiesView *properties;
|
||||
|
||||
properties = g_object_new (EV_TYPE_PROPERTIES,
|
||||
"orientation", GTK_ORIENTATION_VERTICAL,
|
||||
NULL);
|
||||
properties->uri = g_uri_unescape_string (uri, NULL);
|
||||
properties->uri = g_uri_unescape_string (ev_document_get_uri (document), NULL);
|
||||
properties->file_size = ev_document_get_size (document);
|
||||
|
||||
return GTK_WIDGET (properties);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ typedef struct _EvPropertiesViewPrivate EvPropertiesViewPrivate;
|
|||
GType ev_properties_view_get_type (void);
|
||||
void ev_properties_view_register_type (GTypeModule *module);
|
||||
|
||||
GtkWidget *ev_properties_view_new (const gchar *uri);
|
||||
GtkWidget *ev_properties_view_new (EvDocument *document);
|
||||
void ev_properties_view_set_info (EvPropertiesView *properties,
|
||||
const EvDocumentInfo *info);
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ ev_properties_dialog_set_document (EvPropertiesDialog *properties,
|
|||
|
||||
if (properties->general_page == NULL) {
|
||||
label = gtk_label_new (_("General"));
|
||||
properties->general_page = ev_properties_view_new (uri);
|
||||
properties->general_page = ev_properties_view_new (document);
|
||||
gtk_notebook_append_page (GTK_NOTEBOOK (properties->notebook),
|
||||
properties->general_page, label);
|
||||
gtk_widget_show (properties->general_page);
|
||||
|
|
Loading…
Reference in New Issue
Block a user