Commit 851ef7cd authored by Moritz Lipp's avatar Moritz Lipp

Adjust on resize / Adjust on open

parent 3d5aa9ea
......@@ -281,3 +281,16 @@ error_ret:
return false;
}
bool
cb_view_resized(GtkWidget* UNUSED(widget), GtkAllocation* UNUSED(allocation), zathura_t* zathura)
{
if (zathura == NULL || zathura->document == NULL) {
return false;
}
girara_argument_t argument = { zathura->document->adjust_mode, NULL };
sc_adjust_window(zathura->ui.session, &argument, NULL, 0);
return true;
}
......@@ -87,4 +87,14 @@ void cb_file_monitor(GFileMonitor* monitor, GFile* file, GFile* other_file,
*/
bool cb_password_dialog(GtkEntry* entry, zathura_password_dialog_info_t* dialog);
/**
* Emitted when the view has been resized
*
* @param widget View
* @param allocation Allocation
* @param zathura Zathura session
* @return true if signal has been handled successfully
*/
bool cb_view_resized(GtkWidget* widget, GtkAllocation* allocation, zathura_t* zathura);
#endif // CALLBACKS_H
......@@ -55,11 +55,13 @@ config_load_default(zathura_t* zathura)
girara_setting_add(gsession, "recolor-lightcolor", string_value, STRING, false, "Recoloring (light color)", NULL, NULL);
string_value = "#9FBC00";
girara_setting_add(gsession, "highlight-color", string_value, STRING, false, "Color for highlighting", NULL, NULL);
girara_setting_add(gsession, "highlight-color", string_value, STRING, false, "Color for highlighting", NULL, NULL);
float_value = 0.5;
girara_setting_add(gsession, "highlight-transparency", &float_value, FLOAT, false, "Transparency for highlighting", NULL, NULL);
girara_setting_add(gsession, "highlight-transparency", &float_value, FLOAT, false, "Transparency for highlighting", NULL, NULL);
bool_value = true;
girara_setting_add(gsession, "render-loading", &bool_value, BOOLEAN, false, "Render 'Loading ...'", NULL, NULL);
int_value = ADJUST_BESTFIT;
girara_setting_add(gsession, "adjust-open", &int_value, INT, false, "Adjust to when opening file", NULL, NULL);
/* define default shortcuts */
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_c, NULL, sc_abort, 0, 0, NULL);
......@@ -184,10 +186,10 @@ config_load_default(zathura_t* zathura)
girara_argument_mapping_add(gsession, "bottom", BOTTOM);
girara_argument_mapping_add(gsession, "default", DEFAULT);
girara_argument_mapping_add(gsession, "down", DOWN);
girara_argument_mapping_add(gsession, "full_down", FULL_DOWN);
girara_argument_mapping_add(gsession, "full_up", FULL_UP);
girara_argument_mapping_add(gsession, "half_down", HALF_DOWN);
girara_argument_mapping_add(gsession, "half_up", HALF_UP);
girara_argument_mapping_add(gsession, "full-down", FULL_DOWN);
girara_argument_mapping_add(gsession, "full-up", FULL_UP);
girara_argument_mapping_add(gsession, "half-down", HALF_DOWN);
girara_argument_mapping_add(gsession, "half-up", HALF_UP);
girara_argument_mapping_add(gsession, "in", ZOOM_IN);
girara_argument_mapping_add(gsession, "left", LEFT);
girara_argument_mapping_add(gsession, "next", NEXT);
......@@ -197,6 +199,8 @@ config_load_default(zathura_t* zathura)
girara_argument_mapping_add(gsession, "specific", ZOOM_SPECIFIC);
girara_argument_mapping_add(gsession, "top", TOP);
girara_argument_mapping_add(gsession, "up", UP);
girara_argument_mapping_add(gsession, "best-fit", ADJUST_BESTFIT);
girara_argument_mapping_add(gsession, "width", ADJUST_WIDTH);
}
void
......
......@@ -29,6 +29,7 @@
#include <girara/utils.h>
#include <girara/statusbar.h>
#include <girara/session.h>
#include <girara/settings.h>
/**
* Register document plugin
......@@ -345,6 +346,11 @@ zathura_document_open(zathura_t* zathura, const char* path, const char* password
g_signal_connect(G_OBJECT(document->file_monitor.monitor), "changed", G_CALLBACK(cb_file_monitor), zathura->ui.session);
/* apply open adjustment */
int adjust_open = ADJUST_BESTFIT;
girara_setting_get(zathura->ui.session, "adjust-open", &adjust_open);
g_free(file_uri);
return document;
......
......@@ -211,6 +211,7 @@ struct zathura_document_s
int rotate; /**< Rotation */
void* data; /**< Custom data */
zathura_t* zathura; /** Zathura object */
int adjust_mode; /**< Adjust mode (best-fit, width) */
struct
{
......
/* See LICENSE file for license and copyright information */
#include "page_widget.h"
#include "render.h"
#include "utils.h"
#include <girara/utils.h>
#include <girara/settings.h>
#include <girara/datastructures.h>
#include "page_widget.h"
#include "render.h"
#include "utils.h"
#include "shortcuts.h"
G_DEFINE_TYPE(ZathuraPage, zathura_page_widget, GTK_TYPE_DRAWING_AREA)
typedef struct zathura_page_widget_private_s {
......
......@@ -56,6 +56,8 @@ sc_adjust_window(girara_session_t* session, girara_argument_t* argument,
goto error_ret;
}
zathura->document->adjust_mode = argument->n;
/* get window size */
GtkAllocation allocation;
gtk_widget_get_allocation(session->gtk.view, &allocation);
......@@ -764,6 +766,8 @@ sc_zoom(girara_session_t* session, girara_argument_t* argument, girara_event_t*
g_return_val_if_fail(argument != NULL, false);
g_return_val_if_fail(zathura->document != NULL, false);
zathura->document->adjust_mode = ADJUST_NONE;
/* retreive zoom step value */
int value = 1;
girara_setting_get(zathura->ui.session, "zoom-step", &value);
......
......@@ -176,6 +176,8 @@ zathura_init(int argc, char* argv[])
goto error_free;
}
g_signal_connect(G_OBJECT(zathura->ui.session->gtk.view), "size-allocate", G_CALLBACK(cb_view_resized), zathura);
/* callbacks */
GtkAdjustment* view_vadjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
g_signal_connect(G_OBJECT(view_vadjustment), "value-changed", G_CALLBACK(cb_view_vadjustment_value_changed), zathura);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment