bool sc_toggle_fullscreen(girara_session_t* session, girara_argument_t* UNUSED(argument), girara_event_t* UNUSED(event), unsigned int UNUSED(t)) { g_return_val_if_fail(session != NULL, false); g_return_val_if_fail(session->global.data != NULL, false); zathura_t* zathura = session->global.data; if (zathura->document == NULL) { girara_notify(session, GIRARA_WARNING, _("No document opened.")); return false; } const girara_mode_t old_mode = girara_mode_get(session); if (old_mode == zathura->modes.fullscreen) { gtk_window_unfullscreen(GTK_WINDOW(session->gtk.window)); refresh_view(zathura); girara_mode_set(session, zathura->modes.normal); } else if (old_mode == zathura->modes.normal) { gtk_window_fullscreen(GTK_WINDOW(session->gtk.window)); refresh_view(zathura); girara_mode_set(session, zathura->modes.fullscreen); } return false; }
void cb_view_hadjustment_value_changed(GtkAdjustment* adjustment, gpointer data) { zathura_t* zathura = data; if (zathura == NULL || zathura->document == NULL) { return; } /* Do nothing in index mode */ if (girara_mode_get(zathura->ui.session) == zathura->modes.index) { return; } update_visible_pages(zathura); double position_x = zathura_adjustment_get_ratio(adjustment); double position_y = zathura_document_get_position_y(zathura->document); unsigned int page_id = position_to_page_number(zathura->document, position_x, position_y); zathura_document_set_position_x(zathura->document, position_x); zathura_document_set_position_y(zathura->document, position_y); zathura_document_set_current_page_number(zathura->document, page_id); statusbar_page_number_update(zathura); }
static void cb_view_adjustment_changed(GtkAdjustment* adjustment, zathura_t* zathura, bool width) { /* Do nothing in index mode */ if (girara_mode_get(zathura->ui.session) == zathura->modes.index) { return; } const zathura_adjust_mode_t adjust_mode = zathura_document_get_adjust_mode(zathura->document); /* Don't scroll, we're focusing the inputbar. */ if (adjust_mode == ZATHURA_ADJUST_INPUTBAR) { return; } /* Save the viewport size */ unsigned int size = (unsigned int)floor(gtk_adjustment_get_page_size(adjustment)); if (width == true) { zathura_document_set_viewport_width(zathura->document, size); } else { zathura_document_set_viewport_height(zathura->document, size); } /* reset the adjustment, in case bounds have changed */ const double ratio = width == true ? zathura_document_get_position_x(zathura->document) : zathura_document_get_position_y(zathura->document); zathura_adjustment_set_value_from_ratio(adjustment, ratio); }
void cb_page_widget_text_selected(ZathuraPage* page, const char* text, void* data) { g_return_if_fail(page != NULL); g_return_if_fail(text != NULL); g_return_if_fail(data != NULL); zathura_t* zathura = data; girara_mode_t mode = girara_mode_get(zathura->ui.session); if (mode != zathura->modes.normal && mode != zathura->modes.fullscreen) { return; } GdkAtom* selection = get_selection(zathura); /* copy to clipboard */ if (selection != NULL) { gtk_clipboard_set_text(gtk_clipboard_get(*selection), text, -1); bool notification = true; girara_setting_get(zathura->ui.session, "selection-notification", ¬ification); if (notification == true) { char* target = NULL; girara_setting_get(zathura->ui.session, "selection-clipboard", &target); char* stripped_text = g_strdelimit(g_strdup(text), "\n\t\r\n", ' '); char* escaped_text = g_markup_printf_escaped( _("Copied selected text to selection %s: %s"), target, stripped_text); g_free(target); g_free(stripped_text); girara_notify(zathura->ui.session, GIRARA_INFO, "%s", escaped_text); g_free(escaped_text); } } g_free(selection); }
bool sc_toggle_presentation(girara_session_t* session, girara_argument_t* UNUSED(argument), girara_event_t* UNUSED(event), unsigned int UNUSED(t)) { g_return_val_if_fail(session != NULL, false); g_return_val_if_fail(session->global.data != NULL, false); zathura_t* zathura = session->global.data; if (zathura->document == NULL) { girara_notify(session, GIRARA_WARNING, _("No document opened.")); return false; } const girara_mode_t old_mode = girara_mode_get(session); if (old_mode == zathura->modes.presentation) { /* reset pages per row */ girara_setting_set(session, "pages-per-row", &zathura->shortcut.toggle_presentation_mode.pages); /* reset first page column */ if (zathura->shortcut.toggle_presentation_mode.first_page_column_list != NULL) { girara_setting_set(session, "first-page-column", zathura->shortcut.toggle_presentation_mode.first_page_column_list); } /* show status bar */ gtk_widget_show(GTK_WIDGET(session->gtk.statusbar)); /* set full screen */ gtk_window_unfullscreen(GTK_WINDOW(session->gtk.window)); /* reset scale */ zathura_document_set_scale(zathura->document, zathura->shortcut.toggle_presentation_mode.zoom); render_all(zathura); refresh_view(zathura); /* set mode */ girara_mode_set(session, zathura->modes.normal); } else if (old_mode == zathura->modes.normal) { /* backup pages per row */ girara_setting_get(session, "pages-per-row", &zathura->shortcut.toggle_presentation_mode.pages); /* backup first page column */ g_free(zathura->shortcut.toggle_presentation_mode.first_page_column_list); zathura->shortcut.toggle_presentation_mode.first_page_column_list = NULL; /* this will leak. we need to move the values somewhere else */ girara_setting_get(session, "first-page-column", &zathura->shortcut.toggle_presentation_mode.first_page_column_list); /* set single view */ int int_value = 1; girara_setting_set(session, "pages-per-row", &int_value); /* back up zoom */ zathura->shortcut.toggle_presentation_mode.zoom = zathura_document_get_scale(zathura->document); /* adjust window */ girara_argument_t argument = { ZATHURA_ADJUST_BESTFIT, NULL }; sc_adjust_window(session, &argument, NULL, 0); /* hide status and inputbar */ gtk_widget_hide(GTK_WIDGET(session->gtk.inputbar)); gtk_widget_hide(GTK_WIDGET(session->gtk.statusbar)); /* set full screen */ gtk_window_fullscreen(GTK_WINDOW(session->gtk.window)); refresh_view(zathura); /* set mode */ girara_mode_set(session, zathura->modes.presentation); } return false; }