mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-02-04 21:54:56 +01:00
Show scale status
This commit is contained in:
parent
af83daf16f
commit
c99a94125b
2 changed files with 34 additions and 12 deletions
|
@ -2,6 +2,8 @@
|
||||||
static const int DEFAULT_WIDTH = 800;
|
static const int DEFAULT_WIDTH = 800;
|
||||||
static const int DEFAULT_HEIGHT = 600;
|
static const int DEFAULT_HEIGHT = 600;
|
||||||
static const float ZOOM_STEP = 0.1;
|
static const float ZOOM_STEP = 0.1;
|
||||||
|
static const float ZOOM_MIN = 0.1;
|
||||||
|
static const float ZOOM_MAX = 4.1;
|
||||||
|
|
||||||
/* completion */
|
/* completion */
|
||||||
static const char FORMAT_COMMAND[] = "<b>%s</b>";
|
static const char FORMAT_COMMAND[] = "<b>%s</b>";
|
||||||
|
|
28
zathura.c
28
zathura.c
|
@ -384,7 +384,10 @@ update_status()
|
||||||
gtk_label_set_markup((GtkLabel*) Zathura.Global.status_text, Zathura.State.filename);
|
gtk_label_set_markup((GtkLabel*) Zathura.Global.status_text, Zathura.State.filename);
|
||||||
|
|
||||||
/* update state */
|
/* update state */
|
||||||
gtk_label_set_markup((GtkLabel*) Zathura.Global.status_state, Zathura.State.pages);
|
char* zoom_level = (Zathura.PDF.scale != 0) ? g_strdup_printf("%f%%", Zathura.PDF.scale) : "";
|
||||||
|
char* status_text = g_strdup_printf("%s %s", zoom_level, Zathura.State.pages);
|
||||||
|
gtk_label_set_markup((GtkLabel*) Zathura.Global.status_state, status_text);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkEventBox*
|
GtkEventBox*
|
||||||
|
@ -934,6 +937,8 @@ cmd_open(int argc, char** argv)
|
||||||
|
|
||||||
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;
|
||||||
|
Zathura.PDF.scale = 1.0;
|
||||||
|
Zathura.PDF.rotate = 0;
|
||||||
Zathura.State.filename = file;
|
Zathura.State.filename = file;
|
||||||
|
|
||||||
set_page(0);
|
set_page(0);
|
||||||
|
@ -1076,11 +1081,19 @@ void
|
||||||
bcmd_zoom(char* buffer, Argument* argument)
|
bcmd_zoom(char* buffer, Argument* argument)
|
||||||
{
|
{
|
||||||
if(argument->n == ZOOM_IN)
|
if(argument->n == ZOOM_IN)
|
||||||
|
{
|
||||||
|
if((Zathura.PDF.scale + ZOOM_STEP) <= ZOOM_MAX)
|
||||||
Zathura.PDF.scale += ZOOM_STEP;
|
Zathura.PDF.scale += ZOOM_STEP;
|
||||||
|
}
|
||||||
else if(argument->n == ZOOM_OUT)
|
else if(argument->n == ZOOM_OUT)
|
||||||
|
{
|
||||||
|
if((Zathura.PDF.scale - ZOOM_STEP) >= ZOOM_MIN)
|
||||||
Zathura.PDF.scale -= ZOOM_STEP;
|
Zathura.PDF.scale -= ZOOM_STEP;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
Zathura.PDF.scale = 1.0;
|
Zathura.PDF.scale = 1.0;
|
||||||
|
|
||||||
|
update_status();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* special command implementation */
|
/* special command implementation */
|
||||||
|
@ -1194,6 +1207,7 @@ cb_inputbar_activate(GtkEntry* entry, gpointer data)
|
||||||
int length = g_strv_length(tokens);
|
int length = g_strv_length(tokens);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
gboolean retv = FALSE;
|
gboolean retv = FALSE;
|
||||||
|
gboolean succ = FALSE;
|
||||||
|
|
||||||
/* no input */
|
/* no input */
|
||||||
if(length < 1)
|
if(length < 1)
|
||||||
|
@ -1202,6 +1216,9 @@ cb_inputbar_activate(GtkEntry* entry, gpointer data)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* append input to the command history */
|
||||||
|
Zathura.Global.history = g_list_append(Zathura.Global.history, g_strdup(gtk_entry_get_text(entry)));
|
||||||
|
|
||||||
/* special commands */
|
/* special commands */
|
||||||
char identifier = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, 1)[0];
|
char identifier = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, 1)[0];
|
||||||
for(i = 0; i < LENGTH(special_commands); i++)
|
for(i = 0; i < LENGTH(special_commands); i++)
|
||||||
|
@ -1222,14 +1239,17 @@ cb_inputbar_activate(GtkEntry* entry, gpointer data)
|
||||||
(g_strcmp0(command, commands[i].abbr) == 0))
|
(g_strcmp0(command, commands[i].abbr) == 0))
|
||||||
{
|
{
|
||||||
retv = commands[i].function(length - 1, tokens + 1);
|
retv = commands[i].function(length - 1, tokens + 1);
|
||||||
|
succ = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* append input to the command history */
|
if(retv)
|
||||||
Zathura.Global.history = g_list_append(Zathura.Global.history, g_strdup(gtk_entry_get_text(entry)));
|
isc_abort(NULL);
|
||||||
|
|
||||||
|
if(!succ)
|
||||||
|
notify(ERROR, "Unknown command.");
|
||||||
|
|
||||||
if(retv) isc_abort(NULL);
|
|
||||||
gtk_widget_grab_focus(GTK_WIDGET(Zathura.UI.view));
|
gtk_widget_grab_focus(GTK_WIDGET(Zathura.UI.view));
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
Loading…
Reference in a new issue