X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=sidebyside;f=shell%2Fev-window.c;h=532aa4e4aef3d40e99454b554ec3abe9c28210c3;hb=8497f6813f18d359a857ec1ac841059dcc24e833;hp=7863c28cf36592edb14fa6b8c06df214190ffcb1;hpb=c5495be1b3803a125c48d39d3ee34b86acc0bba0;p=evince.git diff --git a/shell/ev-window.c b/shell/ev-window.c index 7863c28c..532aa4e4 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -606,6 +606,16 @@ update_sizing_buttons (EvWindow *window) } } +/** + * 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) { @@ -1340,12 +1350,27 @@ ev_window_load_job_cb (EvJobLoad *job, 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) { @@ -4516,10 +4541,45 @@ launch_action (EvWindow *window, EvLinkAction *action) 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 @@ -5152,6 +5212,13 @@ ev_window_init (EvWindow *ev_window) 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) {