+/**
+ * get_screen_from_args:
+ * @args: a #GHashTable with data passed to the application.
+ *
+ * Looks for the screen in the display available in the hash table passed to the
+ * application. If the display isn't opened, it's opened and the #GdkScreen
+ * assigned to the screen in that display returned.
+ *
+ * Returns: the #GdkScreen assigned to the screen on the display indicated by
+ * the data on the #GHashTable.
+ */
+static GdkScreen *
+get_screen_from_args (GHashTable *args)
+{
+ GValue *value = NULL;
+ GdkDisplay *display = NULL;
+ GdkScreen *screen = NULL;
+
+ g_assert (args != NULL);
+
+ value = g_hash_table_lookup (args, "display");
+ if (value) {
+ const gchar *display_name;
+
+ display_name = g_value_get_string (value);
+ display = ev_display_open_if_needed (display_name);
+ }
+
+ value = g_hash_table_lookup (args, "screen");
+ if (value) {
+ gint screen_number;
+
+ screen_number = g_value_get_int (value);
+ screen = gdk_display_get_screen (display, screen_number);
+ }
+
+ return screen;
+}
+
+/**
+ * get_window_run_mode_from_args:
+ * @args: a #GHashTable with data passed to the application.
+ *
+ * It does look if the mode option has been passed from command line, using it
+ * as the window run mode, otherwise the run mode will be the normal mode.
+ *
+ * Returns: The window run mode passed from command line or
+ * EV_WINDOW_MODE_NORMAL in other case.
+ */
+static EvWindowRunMode
+get_window_run_mode_from_args (GHashTable *args)
+{
+ EvWindowRunMode mode = EV_WINDOW_MODE_NORMAL;
+ GValue *value = NULL;
+
+ g_assert (args != NULL);
+
+ value = g_hash_table_lookup (args, "mode");
+ if (value) {
+ mode = g_value_get_uint (value);
+ }
+
+ return mode;
+}
+
+/**
+ * get_destination_from_args:
+ * @args: a #GHashTable with data passed to the application.
+ *
+ * It does look for the page-label argument parsed from the command line and
+ * if it does exist, it returns an #EvLinkDest.
+ *
+ * Returns: An #EvLinkDest to page-label if it has been passed from the command
+ * line, NULL in other case.
+ */
+static EvLinkDest *
+get_destination_from_args (GHashTable *args)
+{
+ EvLinkDest *dest = NULL;
+ GValue *value = NULL;
+
+ g_assert (args != NULL);
+
+ value = g_hash_table_lookup (args, "page-label");
+ if (value) {
+ const gchar *page_label;
+
+ page_label = g_value_get_string (value);
+ dest = ev_link_dest_new_page_label (page_label);
+ }
+
+ return dest;
+}
+
+static const gchar *
+get_find_string_from_args (GHashTable *args)
+{
+ GValue *value = NULL;
+
+ g_assert (args != NULL);
+
+ value = g_hash_table_lookup (args, "find-string");
+
+ return value ? g_value_get_string (value) : NULL;
+}
+
+/**
+ * get_unlink_temp_file_from_args:
+ * @args: a #GHashTable with data passed to the application.
+ *
+ * It does look if the unlink-temp-file option has been passed from the command
+ * line returning it's boolean representation, otherwise it does return %FALSE.
+ *
+ * Returns: the boolean representation of the unlink-temp-file value or %FALSE
+ * in other case.
+ */
+static gboolean
+get_unlink_temp_file_from_args (GHashTable *args)
+{
+ gboolean unlink_temp_file = FALSE;
+ GValue *value = NULL;
+
+ g_assert (args != NULL);
+
+ value = g_hash_table_lookup (args, "unlink-temp-file");
+ if (value) {
+ unlink_temp_file = g_value_get_boolean (value);
+ }
+
+ return unlink_temp_file;
+}
+
+static const gchar *
+get_print_settings_from_args (GHashTable *args)
+{
+ const gchar *print_settings = NULL;
+ GValue *value = NULL;
+
+ g_assert (args != NULL);
+
+ value = g_hash_table_lookup (args, "print-settings");
+ if (value) {
+ print_settings = g_value_get_string (value);
+ }
+
+ return print_settings;
+}
+
+/**
+ * ev_application_open_window:
+ * @application: The instance of the application.
+ * @args: A #GHashTable with the arguments data.
+ * @timestamp: Current time value.
+ * @error: The #GError facility.
+ *
+ * Creates a new window and if the args are available, it's not NULL, it gets
+ * the screen from them and assigns the just created window to it. At last it
+ * does show it.
+ *
+ * Returns: %TRUE.
+ */
+gboolean
+ev_application_open_window (EvApplication *application,
+ GHashTable *args,
+ guint32 timestamp,
+ GError **error)
+{
+ GtkWidget *new_window = ev_window_new ();
+ GdkScreen *screen = NULL;
+
+ if (args) {
+ screen = get_screen_from_args (args);
+ }
+
+ if (screen) {
+ gtk_window_set_screen (GTK_WINDOW (new_window), screen);
+ }
+ ev_application_add_icon_path_for_screen (screen);
+
+ if (!GTK_WIDGET_REALIZED (new_window))
+ gtk_widget_realize (new_window);
+
+#ifdef GDK_WINDOWING_X11
+ if (timestamp <= 0)
+ timestamp = gdk_x11_get_server_time (GTK_WIDGET (new_window)->window);
+ gdk_x11_window_set_user_time (GTK_WIDGET (new_window)->window, timestamp);
+
+ gtk_window_present (GTK_WINDOW (new_window));
+#else
+ gtk_window_present_with_time (GTK_WINDOW (new_window), timestamp);
+#endif /* GDK_WINDOWING_X11 */
+
+ return TRUE;
+}
+
+/**
+ * ev_application_get_empty_window:
+ * @application: The instance of the application.
+ * @screen: The screen where the empty window will be search.
+ *
+ * It does look if there is any empty window in the indicated screen.
+ *
+ * Returns: The first empty #EvWindow in the passed #GdkScreen or NULL in other
+ * case.
+ */