mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-29 01:44:56 +01:00
Show document information
This commit is contained in:
parent
16467e74af
commit
2aef3f259c
2 changed files with 102 additions and 18 deletions
|
@ -85,6 +85,7 @@ InputbarShortcut inputbar_shortcuts[] = {
|
||||||
Command commands[] = {
|
Command commands[] = {
|
||||||
/* command, abbreviation, function, completion, description */
|
/* command, abbreviation, function, completion, description */
|
||||||
{"close", "c", cmd_close, 0, "Close current file" },
|
{"close", "c", cmd_close, 0, "Close current file" },
|
||||||
|
{"info", "i", cmd_info, 0, "Show information about the document" },
|
||||||
{"open", "o", cmd_open, cc_open, "Open a file" },
|
{"open", "o", cmd_open, cc_open, "Open a file" },
|
||||||
{"print", "p", cmd_print, cc_print, "Print the document" },
|
{"print", "p", cmd_print, cc_print, "Print the document" },
|
||||||
{"rotate", "r", cmd_rotate, 0, "Rotate the page" },
|
{"rotate", "r", cmd_rotate, 0, "Rotate the page" },
|
||||||
|
|
119
zathura.c
119
zathura.c
|
@ -139,6 +139,7 @@ struct
|
||||||
GtkBox *statusbar_entries;
|
GtkBox *statusbar_entries;
|
||||||
GtkEntry *inputbar;
|
GtkEntry *inputbar;
|
||||||
GtkWidget *index;
|
GtkWidget *index;
|
||||||
|
GtkWidget *information;
|
||||||
} UI;
|
} UI;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
|
@ -240,6 +241,7 @@ void isc_string_manipulation(Argument*);
|
||||||
|
|
||||||
/* command declarations */
|
/* command declarations */
|
||||||
gboolean cmd_close(int, char**);
|
gboolean cmd_close(int, char**);
|
||||||
|
gboolean cmd_info(int, char**);
|
||||||
gboolean cmd_open(int, char**);
|
gboolean cmd_open(int, char**);
|
||||||
gboolean cmd_print(int, char**);
|
gboolean cmd_print(int, char**);
|
||||||
gboolean cmd_rotate(int, char**);
|
gboolean cmd_rotate(int, char**);
|
||||||
|
@ -818,14 +820,14 @@ sc_toggle_index(Argument* argument)
|
||||||
if(!Zathura.PDF.document)
|
if(!Zathura.PDF.document)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GtkWidget *treeview;
|
|
||||||
GtkTreeModel *model;
|
|
||||||
PopplerIndexIter *index_iter;
|
|
||||||
GtkCellRenderer *renderer;
|
|
||||||
GtkTreeSelection *selection;
|
|
||||||
|
|
||||||
if(!Zathura.UI.index)
|
if(!Zathura.UI.index)
|
||||||
{
|
{
|
||||||
|
GtkWidget *treeview;
|
||||||
|
GtkTreeModel *model;
|
||||||
|
PopplerIndexIter *index_iter;
|
||||||
|
GtkCellRenderer *renderer;
|
||||||
|
GtkTreeSelection *selection;
|
||||||
|
|
||||||
Zathura.UI.index = gtk_scrolled_window_new(NULL, NULL);
|
Zathura.UI.index = gtk_scrolled_window_new(NULL, NULL);
|
||||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(Zathura.UI.index),
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(Zathura.UI.index),
|
||||||
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||||
|
@ -860,9 +862,9 @@ sc_toggle_index(Argument* argument)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean hide = TRUE;
|
static gboolean show = TRUE;
|
||||||
|
|
||||||
if(hide)
|
if(show)
|
||||||
{
|
{
|
||||||
gtk_widget_show(Zathura.UI.index);
|
gtk_widget_show(Zathura.UI.index);
|
||||||
switch_view(Zathura.UI.index);
|
switch_view(Zathura.UI.index);
|
||||||
|
@ -874,12 +876,7 @@ sc_toggle_index(Argument* argument)
|
||||||
pthread_mutex_unlock(&(Zathura.PDF.pages[Zathura.PDF.page_number]->lock));
|
pthread_mutex_unlock(&(Zathura.PDF.pages[Zathura.PDF.page_number]->lock));
|
||||||
}
|
}
|
||||||
|
|
||||||
hide = !hide;
|
show = !show;
|
||||||
|
|
||||||
/*if(GTK_WIDGET_VISIBLE(GTK_WIDGET(Zathura.UI.index)))*/
|
|
||||||
/*gtk_widget_hide(GTK_WIDGET(Zathura.UI.index));*/
|
|
||||||
/*else*/
|
|
||||||
/*gtk_widget_show(GTK_WIDGET(Zathura.UI.index));*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1265,11 +1262,101 @@ cmd_close(int argc, char** argv)
|
||||||
Zathura.PDF.scale = 0;
|
Zathura.PDF.scale = 0;
|
||||||
Zathura.PDF.rotate = 0;
|
Zathura.PDF.rotate = 0;
|
||||||
|
|
||||||
|
/* destroy index */
|
||||||
|
if(Zathura.UI.index)
|
||||||
|
{
|
||||||
|
gtk_widget_destroy(Zathura.UI.index);
|
||||||
|
Zathura.UI.index = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* destroy information */
|
||||||
|
if(Zathura.UI.information)
|
||||||
|
{
|
||||||
|
gtk_widget_destroy(Zathura.UI.information);
|
||||||
|
Zathura.UI.information = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
update_status();
|
update_status();
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
cmd_info(int argc, char** argv)
|
||||||
|
{
|
||||||
|
if(!Zathura.PDF.document)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
if(!Zathura.UI.information)
|
||||||
|
{
|
||||||
|
GtkListStore *list;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
GtkCellRenderer *renderer;
|
||||||
|
GtkTreeSelection *selection;
|
||||||
|
|
||||||
|
list = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
|
||||||
|
|
||||||
|
/* read document information */
|
||||||
|
gchar *title, *author;
|
||||||
|
gchar *subject, *keywords;
|
||||||
|
gchar *creator, *producer;
|
||||||
|
GTime creation_date, modification_date;
|
||||||
|
|
||||||
|
g_object_get(Zathura.PDF.document,
|
||||||
|
"title", &title,
|
||||||
|
"author", &author,
|
||||||
|
"subject", &subject,
|
||||||
|
"keywords", &keywords,
|
||||||
|
"creator", &creator,
|
||||||
|
"producer", &producer,
|
||||||
|
"creation-date", &creation_date,
|
||||||
|
"mod-date", &modification_date,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
/* append information to list */
|
||||||
|
gtk_list_store_append(list, &iter);
|
||||||
|
gtk_list_store_set(list, &iter, 0, "Author", 1, author ? author : "", -1);
|
||||||
|
gtk_list_store_append(list, &iter);
|
||||||
|
gtk_list_store_set(list, &iter, 0, "Title", 1, title ? title : "", -1);
|
||||||
|
gtk_list_store_append(list, &iter);
|
||||||
|
gtk_list_store_set(list, &iter, 0, "Subject", 1, subject ? subject : "", -1);
|
||||||
|
gtk_list_store_append(list, &iter);
|
||||||
|
gtk_list_store_set(list, &iter, 0, "Keywords", 1, keywords ? keywords : "", -1);
|
||||||
|
gtk_list_store_append(list, &iter);
|
||||||
|
gtk_list_store_set(list, &iter, 0, "Creator", 1, creator ? creator : "", -1);
|
||||||
|
gtk_list_store_append(list, &iter);
|
||||||
|
gtk_list_store_set(list, &iter, 0, "Producer", 1, producer ? producer : "", -1);
|
||||||
|
|
||||||
|
Zathura.UI.information = gtk_tree_view_new_with_model(GTK_TREE_MODEL(list));
|
||||||
|
renderer = gtk_cell_renderer_text_new();
|
||||||
|
|
||||||
|
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(Zathura.UI.information), -1,
|
||||||
|
"Name", renderer, "text", 0, NULL);
|
||||||
|
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(Zathura.UI.information), -1,
|
||||||
|
"Value", renderer, "text", 1, NULL);
|
||||||
|
|
||||||
|
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(Zathura.UI.information));
|
||||||
|
gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
|
||||||
|
|
||||||
|
gtk_widget_show_all(Zathura.UI.information);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean show = TRUE;
|
||||||
|
|
||||||
|
if(show)
|
||||||
|
switch_view(Zathura.UI.information);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pthread_mutex_lock(&(Zathura.PDF.pages[Zathura.PDF.page_number]->lock));
|
||||||
|
switch_view( Zathura.PDF.pages[Zathura.PDF.page_number]->drawing_area );
|
||||||
|
pthread_mutex_unlock(&(Zathura.PDF.pages[Zathura.PDF.page_number]->lock));
|
||||||
|
}
|
||||||
|
|
||||||
|
show = !show;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
cmd_open(int argc, char** argv)
|
cmd_open(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
@ -1302,10 +1389,6 @@ cmd_open(int argc, char** argv)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Zathura.UI.index != NULL)
|
|
||||||
gtk_widget_destroy(Zathura.UI.index);
|
|
||||||
Zathura.UI.index = NULL;
|
|
||||||
|
|
||||||
Zathura.PDF.number_of_pages = poppler_document_get_n_pages(Zathura.PDF.document);
|
Zathura.PDF.number_of_pages = poppler_document_get_n_pages(Zathura.PDF.document);
|
||||||
Zathura.PDF.file = file;
|
Zathura.PDF.file = file;
|
||||||
pthread_mutex_lock(&(Zathura.Lock.scale_lock));
|
pthread_mutex_lock(&(Zathura.Lock.scale_lock));
|
||||||
|
|
Loading…
Reference in a new issue