#include <string.h>
-#include "xdg-user-dir-lookup.c"
+char *xdg_user_dir_lookup (char *type);
typedef enum {
PAGE_MODE_DOCUMENT,
}
}
+/**
+ * ev_window_is_empty:
+ * @ev_window: The instance of the #EvWindow.
+ *
+ * It does look if there is any document loaded or if there is any job to load
+ * a document.
+ *
+ * Returns: %TRUE if there isn't any document loaded or any any documente to be
+ * loaded, %FALSE in other case.
+ */
gboolean
ev_window_is_empty (const EvWindow *ev_window)
{
if (window->priv->page_cache &&
ev_metadata_manager_get (uri, "window_width_ratio", &width_ratio, FALSE) &&
ev_metadata_manager_get (uri, "window_height_ratio", &height_ratio, FALSE)) {
+
gint document_width;
gint document_height;
+
+ GdkScreen *screen;
+
+ gint request_width;
+ gint request_height;
ev_page_cache_get_max_width (window->priv->page_cache,
0, 1.0,
0, 1.0,
&document_height);
+ request_width = g_value_get_double (&width_ratio) * document_width;
+ request_height = g_value_get_double (&height_ratio) * document_height;
+
+ screen = gtk_window_get_screen (GTK_WINDOW (window));
+
+ if (screen) {
+ request_width = MIN (request_width, gdk_screen_get_width (screen));
+ request_height = MIN (request_width, gdk_screen_get_height (screen));
+ }
+
gtk_window_resize (GTK_WINDOW (window),
- g_value_get_double (&width_ratio) * document_width,
- g_value_get_double (&height_ratio) * document_height);
+ request_width,
+ request_height);
g_value_unset (&width_ratio);
g_value_unset (&height_ratio);
}
return;
}
+/**
+ * ev_window_get_uri:
+ * @ev_window: The instance of the #EvWindow.
+ *
+ * It returns the uri of the document showed in the #EvWindow.
+ *
+ * Returns: the uri of the document showed in the #EvWindow.
+ */
const char *
ev_window_get_uri (EvWindow *ev_window)
{
return ev_window->priv->uri;
}
+/**
+ * ev_window_close_dialogs:
+ * @ev_window: The window where dialogs will be closed.
+ *
+ * It looks for password, print and properties dialogs and closes them and
+ * frees them from memory. If there is any print job it does free it too.
+ */
static void
ev_window_close_dialogs (EvWindow *ev_window)
{
{ "FileOpen", GTK_STOCK_OPEN, N_("_Open..."), "<control>O",
N_("Open an existing document"),
G_CALLBACK (ev_window_cmd_file_open) },
- { "FileOpenCopy", NULL, N_("Open a _Copy"), NULL,
+ { "FileOpenCopy", NULL, N_("Op_en a Copy"), NULL,
N_("Open a copy of the current document in a new window"),
G_CALLBACK (ev_window_cmd_file_open_copy) },
{ "FileSaveAs", GTK_STOCK_SAVE_AS, N_("_Save a Copy..."), "<control>S",
allowing to launch executables is a good idea though. -- marco */
}
+static gboolean
+uri_is_valid (const gchar *uri)
+{
+ gchar *p = (gchar *) uri;
+
+ if (!p || !g_ascii_isalpha (*p))
+ return FALSE;
+
+ p++;
+ while (g_ascii_isalnum (*p))
+ p++;
+
+ return (g_ascii_strncasecmp (p, "://", strlen ("://")) == 0);
+}
+
static void
launch_external_uri (EvWindow *window, EvLinkAction *action)
{
- gnome_vfs_url_show (ev_link_action_get_uri (action));
+ const gchar *uri = ev_link_action_get_uri (action);
+
+ if (!uri_is_valid (uri)) {
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("Unable to open external link"));
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ _("Invalid URI: ā%sā"), uri);
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (gtk_widget_destroy),
+ NULL);
+ gtk_widget_show (dialog);
+
+ return;
+ }
+
+ gnome_vfs_url_show (uri);
}
static void
ev_window_setup_action_sensitivity (ev_window);
}
+/**
+ * ev_window_new:
+ *
+ * Creates a #GtkWidget that represents the window.
+ *
+ * Returns: the #GtkWidget that represents the window.
+ */
GtkWidget *
ev_window_new (void)
{