81 return "Evince Browser Plugin";
86 return "The <a href=\"http://wiki.gnome.org/Apps/Evince/\">Evince</a> " PACKAGE_VERSION
" plugin handles documents inside the browser window.";
107 template <
typename IntegerType>
108 static inline void parseInteger(
const char *strValue, IntegerType &intValue)
110 static const IntegerType intMax = std::numeric_limits<IntegerType>::max();
111 static const bool isSigned = std::numeric_limits<IntegerType>::is_signed;
116 char *endPtr =
nullptr;
118 gint64 value = isSigned ? g_ascii_strtoll(strValue, &endPtr, 0) : g_ascii_strtoull(strValue, &endPtr, 0);
119 if (endPtr != strValue && errno == 0 && value <= intMax)
120 intValue =
static_cast<IntegerType
>(value);
123 static inline void parseDouble(
const char *strValue,
double &doubleValue)
128 char *endPtr =
nullptr;
130 double value = g_ascii_strtod(strValue, &endPtr);
131 if (endPtr != strValue && errno == 0)
141 if (g_ascii_strcasecmp(value.get(),
"false") == 0 || g_ascii_strcasecmp(value.get(),
"no") == 0)
143 else if (g_ascii_strcasecmp(value.get(),
"true") == 0 || g_ascii_strcasecmp(value.get(),
"yes") == 0)
146 int intValue = boolValue;
147 parseInteger<int>(strValue, intValue);
148 boolValue = intValue > 0;
158 if (g_ascii_strcasecmp(value.get(),
"none") == 0)
160 else if (g_ascii_strcasecmp(value.get(),
"fit-page") == 0)
162 else if (g_ascii_strcasecmp(value.get(),
"fit-width") == 0)
164 else if (g_ascii_strcasecmp(value.get(),
"auto") == 0)
174 bool continuous =
true;
178 for (int16_t i = 0; i < argc; ++i) {
179 if (g_ascii_strcasecmp(argn[i],
"toolbar") == 0)
181 else if (g_ascii_strcasecmp(argn[i],
"currentpage") == 0)
183 else if (g_ascii_strcasecmp(argn[i],
"zoom") == 0)
185 else if (g_ascii_strcasecmp(argn[i],
"zoommode") == 0)
187 else if (g_ascii_strcasecmp(argn[i],
"continuous") == 0)
189 else if (g_ascii_strcasecmp(argn[i],
"dual") == 0)
217 m_window = gtk_plug_new(reinterpret_cast<Window>(window->
window));
220 GtkWidget *vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
223 GtkWidget *scrolledWindow = gtk_scrolled_window_new(
nullptr,
nullptr);
224 gtk_container_add(GTK_CONTAINER(scrolledWindow), GTK_WIDGET(
m_view));
225 gtk_widget_show(GTK_WIDGET(
m_view));
227 gtk_box_pack_start(GTK_BOX(vbox), scrolledWindow,
TRUE,
TRUE, 0);
228 gtk_widget_show(scrolledWindow);
230 gtk_container_add(GTK_CONTAINER(
m_window), vbox);
231 gtk_widget_show(vbox);
254 GFile *file = g_file_new_for_commandline_arg(fname);
256 g_object_unref(file);
260 GError *error =
nullptr;
263 g_printerr(
"Error loading document %s: %s\n", uri.get(), error->message);
267 g_object_unref(document);
353 gtk_widget_grab_focus(GTK_WIDGET(
m_view));
420 g_return_if_fail(
m_url);
440 if (
char *dot = g_strrstr(outputBasename.get(),
"."))
443 unique_gptr<char> unescapedBasename(g_uri_unescape_string(outputBasename.get(),
nullptr));
445 GtkPrintSettings *printSettings = gtk_print_settings_new();
446 gtk_print_settings_set(printSettings, GTK_PRINT_SETTINGS_OUTPUT_BASENAME, unescapedBasename.get());
453 g_object_unref(printSettings);
455 g_signal_connect(printOperation,
"done", G_CALLBACK(g_object_unref),
nullptr);
457 GtkWidget *toplevel = gtk_widget_get_toplevel(GTK_WIDGET(
m_view));
470 return gtk_widget_get_visible(
m_toolbar);
508 gtk_widget_queue_draw(GTK_WIDGET(
m_view));
533 for (
unsigned i = 0; i < EvBrowserPluginClass::Methods::NumMethodIdentifiers; ++i) {
535 if (i == EvBrowserPluginClass::Methods::Download)
597 for (
unsigned i = 0; i < EvBrowserPluginClass::Properties::NumPropertyIdentifiers; ++i) {
621 const char *zoomMode;
628 zoomMode =
"fit-page";
631 zoomMode =
"fit-width";
640 size_t zoomModeLength = strlen(zoomMode);
641 char *result =
static_cast<char *
>(
NPN_MemAlloc(zoomModeLength + 1));
642 memcpy(result, zoomMode, zoomModeLength);
643 result[zoomModeLength] =
'\0';
680 if (g_strcmp0(zoomMode.get(),
"none") == 0)
682 else if (g_strcmp0(zoomMode.get(),
"fit-page") == 0)
684 else if (g_strcmp0(zoomMode.get(),
"fit-width") == 0)
686 else if (g_strcmp0(zoomMode.get(),
"auto") == 0)