Esempio n. 1
0
void FileBar::on_actionLoad_triggered()
{
    const QString DIR_KEY("SessionLoadPath");
    QSettings settings;
    // Show the dialog
    const QString file_name = QFileDialog::getOpenFileName(
        this, tr("Open Session"), settings.value(DIR_KEY).toString(), tr(
            "DSView Session (*.dsc)"));
    if (!file_name.isEmpty()) {
        QDir CurrentDir;
        settings.setValue(DIR_KEY, CurrentDir.absoluteFilePath(file_name));
        load_session(file_name);
    }
}
Esempio n. 2
0
void FileBar::on_actionDefault_triggered()
{
    QDir dir(DS_RES_PATH);
    if (!dir.exists()) {
        dialogs::DSMessageBox msg(this);
        msg.mBox()->setText(tr("Session Load"));
        msg.mBox()->setInformativeText(tr("Cannot find default session file for this device!"));
        msg.mBox()->setStandardButtons(QMessageBox::Ok);
        msg.mBox()->setIcon(QMessageBox::Warning);
        msg.exec();
        return;
    }

    QString driver_name = _session.get_device()->name();
    QString mode_name = QString::number(_session.get_device()->dev_inst()->mode);
    QString file_name = dir.absolutePath() + "/" + driver_name + mode_name + ".def.dsc";
    if (!file_name.isEmpty())
        load_session(file_name);
}
Esempio n. 3
0
/* +-----------------------------------+
 * | Open Related Functions            |
 * +-----------------------------------+ */
void
on_open_file_okbutton_clicked          (GtkButton       *button,
                                        gpointer         user_data)
{
    char *filename;
    int   load_status;

    gtk_widget_hide(open_file_window);
    flush();

    filename = (char*)
        gtk_file_selection_get_filename(GTK_FILE_SELECTION
                                        (open_file_window));

    load_status = load_session(filename);
    if( SESSION_LOADED_OK == load_status ) {
    } else {
        show_error( error_to_string(load_status) );
    }
}
Esempio n. 4
0
/* Create the windows. */
static void
prepare_app (void)
{
	CORBA_Object              factory;
	gboolean                  use_factory = FALSE;
	CORBA_Environment         env;
	GNOME_GThumb_Application  app;
	GList                    *scan;

	factory = bonobo_activation_activate_from_id ("OAFIID:GNOME_GThumb_Application_Factory",
                                                      Bonobo_ACTIVATION_FLAG_EXISTING_ONLY,
                                                      NULL, NULL);

	if (factory != NULL) {
		use_factory = TRUE;
		CORBA_exception_init (&env);
		app = bonobo_activation_activate_from_id ("OAFIID:GNOME_GThumb_Application", 0, NULL, &env);
	}

	if (session_is_restored ()) {
		load_session (use_factory, app, &env);
		return;
	}

	if (ImportPhotos) {
		if (use_factory)
		 	GNOME_GThumb_Application_import_photos (app, &env);
		else
			gth_browser_activate_action_file_camera_import (NULL, NULL);
	} 
	else if (! view_comline_catalog
		 && (n_dir_urls == 0)
		 && (n_file_urls == 0)) 
	{
		open_browser_window (NULL, TRUE, use_factory, app, &env);
	} 
	else if (view_single_image) {
		if (use_factory && eel_gconf_get_boolean (PREF_SINGLE_WINDOW, FALSE)) 
		{ 
			GNOME_GThumb_Application_load_image (app, file_urls->data, &env);
		}
		else {
			if (UseViewer)
				open_viewer_window (file_urls->data, use_factory, app, &env);
			else
				open_browser_window (file_urls->data, TRUE, use_factory, app, &env);
		}
	} 
	else if (view_comline_catalog) {
		char *catalog_path;
		char *catalog_uri;

		ViewFirstImage = TRUE;
		HideSidebar = TRUE;

		catalog_path = get_command_line_catalog_path ();
		catalog_uri = g_strconcat ("catalog://", remove_host_from_uri (catalog_path), NULL);

		open_browser_window (catalog_uri, TRUE, use_factory, app, &env);

		g_free (catalog_path);
		g_free (catalog_uri);
	}

	for (scan = dir_urls; scan; scan = scan->next) {
		/* Go to the specified directory. */
		open_browser_window (scan->data, TRUE, use_factory, app, &env);
	}

	path_list_free (file_urls);
	path_list_free (dir_urls);

	/**/

	if (use_factory) {
		bonobo_object_release_unref (app, &env);
		CORBA_exception_free (&env);
		gdk_notify_startup_complete ();
		exit (0);
	} 
	else
		gth_application = gth_application_new (gdk_screen_get_default ());
}
Esempio n. 5
0
/*****************************************************************************
 * run_session_load_dialog()
 *
 * Callback for running the 'Load Session' dialog from the main menu.
 *****************************************************************************/
void
run_session_load_dialog(GtkWidget *UNUSED(widget), gpointer UNUSED(data))
{
    SESSION         *session    = get_current_session();
    PATCH           *patch;
    DIR_LIST        *pdir       = session_dir_list;
    char            *directory;
    GSList          *file_list;
    GSList          *cur;
    GError          *error;
    unsigned int    sess_num    = session_io_start;
    unsigned int    part_num;

    /* create dialog if needed */
    if (session_load_dialog == NULL) {
        create_session_load_dialog();
    }

    gtk_widget_show(session_load_dialog);

    /* add all session directories to shortcuts */
    while (pdir != NULL) {
        if (!pdir->load_shortcut) {
            error = NULL;
            gtk_file_chooser_add_shortcut_folder(GTK_FILE_CHOOSER(session_load_dialog),
                                                 pdir->name, &error);
            if (error != NULL) {
                PHASEX_ERROR("Error %d: %s\n", error->code, error->message);
                g_error_free(error);
            }
            pdir->load_shortcut = 1;
        }
        pdir = pdir->next;
    }

    /* set filename and current directory */
    if ((session->directory != NULL) && (* (session->directory) != '\0')) {
        gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(session_load_dialog), session->directory);
    }
    else if ((session->parent_dir != NULL) && (* (session->parent_dir) != '\0')) {
        gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(session_load_dialog),
                                            session->parent_dir);
    }
    else {
        gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(session_load_dialog),
                                            user_session_dir);
    }

    /* set position in patch bank to start loading patches */
    session_io_start = visible_sess_num;
    gtk_adjustment_set_value(GTK_ADJUSTMENT(session_io_start_adj), (session_io_start + 1));

    /* run the dialog and load if necessary */
    if (gtk_dialog_run(GTK_DIALOG(session_load_dialog)) == GTK_RESPONSE_ACCEPT) {

        /* get list of selected files from chooser */
        file_list = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(session_load_dialog));
        if (file_list != NULL) {
            session_io_start =
                (unsigned int) gtk_adjustment_get_value(GTK_ADJUSTMENT(session_io_start_adj)) - 1;

            /* read in each session and increment session bank slot number */
            sess_num = session_io_start;
            session_load_in_progress = 1;
            cur = file_list;
            while (cur != NULL) {
                directory = (char *) cur->data;
                if (load_session(directory, sess_num) == 0) {
                    if (sess_num == visible_sess_num) {
                        for (part_num = 0; part_num < MAX_PARTS; part_num++) {
                            visible_prog_num[part_num] = 0;
                            patch = set_active_patch(visible_sess_num, part_num, 0);
                            init_patch_state(patch);
                            if (part_num == visible_part_num) {
                                update_gui_patch(patch, 0);
                            }
                        }
                    }
                    sess_num++;
                }
                if (sess_num >= SESSION_BANK_SIZE) {
                    break;
                }
                cur = g_slist_next(cur);
            }
            session_load_in_progress = 0;
            g_slist_free(file_list);

            update_gui_patch_name();
            update_gui_session_name();

            save_session_bank();
        }

    }

    /* save this widget for next time */
    gtk_widget_hide(session_load_dialog);
}
Esempio n. 6
0
/*****************************************************************************
 * on_load_session()
 *
 * Handler for the 'Load Session' button in the navbar.
 *****************************************************************************/
void
on_load_session(GtkWidget *UNUSED(widget), gpointer data)
{
    SESSION         *session            = get_current_session();
    PATCH           *patch;
    GtkEntry        *entry              = GTK_ENTRY(data);
    GtkWidget       *dialog;
    GtkWidget       *label;
    const char      *name;
    char            directory[PATH_MAX];
    gint            response;
    int             need_load           = 0;
    unsigned int    part_num;

    /* build directory from entry widget and current session directory */
    name = gtk_entry_get_text(entry);
    if (session->parent_dir == NULL) {
        snprintf(directory, PATH_MAX, "%s/%s", user_session_dir, name);
    }
    else {
        snprintf(directory, PATH_MAX, "%s/%s", session->parent_dir, name);
    }

    /* handle saving of current session based on mem mode */
    switch (setting_bank_mem_mode) {

    case BANK_MEM_AUTOSAVE:
        /* save current session if modified */
        if (session->modified) {
            on_session_save_activate(NULL, NULL);
        }
        need_load = 1;
        break;

    case BANK_MEM_WARN:
        /* if modified, warn about losing current session */
        if (session->modified) {

            /* create dialog with buttons */
            dialog = gtk_dialog_new_with_buttons("WARNING:  Session Modified",
                                                 GTK_WINDOW(main_window),
                                                 GTK_DIALOG_DESTROY_WITH_PARENT,
                                                 GTK_STOCK_CANCEL,
                                                 GTK_RESPONSE_CANCEL,
                                                 "Ignore Changes",
                                                 GTK_RESPONSE_NO,
                                                 "Save and Load New",
                                                 GTK_RESPONSE_YES,
                                                 NULL);
            gtk_window_set_wmclass(GTK_WINDOW(dialog), "phasex", "phasex-dialog");
            gtk_window_set_role(GTK_WINDOW(dialog), "verify-save");

            /* Alert message */
            label = gtk_label_new("The current session has not been saved since it "
                                  "was last modified.  Save now before loading new "
                                  "session?");
            gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
            gtk_misc_set_padding(GTK_MISC(label), 8, 8);
            gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label);
            //widget_set_custom_font (dialog);
            gtk_widget_show_all(dialog);

            /* Run the dialog */
            response = gtk_dialog_run(GTK_DIALOG(dialog));
            switch (response) {
            case GTK_RESPONSE_YES:
                /* save session and get ready to load a new one */
                on_session_save_activate(NULL, NULL);
                need_load = 1;
                break;
            case GTK_RESPONSE_NO:
                /* no save, only set flag to load new session */
                need_load = 1;
                break;
            case GTK_RESPONSE_CANCEL:
                /* find old session name and revert text in entry */
                if ((session->name == NULL) && (session->directory != NULL)) {
                    session->name = get_session_name_from_directory(session->directory);
                }
                update_gui_session_name();
                /* cancel out on loading new session */
                need_load = 0;
                break;
            }
            gtk_widget_destroy(dialog);
        }
        /* if not modified, just load new session */
        else {
            need_load = 1;
        }
        break;

    case BANK_MEM_PROTECT:
        /* explicitly don't save in protect mode */
        need_load = 1;
        break;
    }

    /* load session specified by entry or assign an Untitled name */
    if (need_load) {
        session_load_in_progress = 1;
        if ((need_load = load_session(directory, visible_sess_num)) != 0) {
            snprintf(directory, PATH_MAX, "%s/%s", user_session_dir, name);
            need_load = load_session(directory, visible_sess_num);
        }
        for (part_num = 0; part_num < MAX_PARTS; part_num++) {
            visible_prog_num[part_num] = 0;
            patch = set_active_patch(visible_sess_num, part_num, 0);
            init_patch_state(patch);
            if (part_num == visible_part_num) {
                update_gui_patch(patch, 0);
            }
        }
        if (session->name == NULL) {
            sprintf(directory, "Untitled-%04d", visible_sess_num);
            session->name = strdup(directory);
        }
        session->modified = 0;
        session_load_in_progress = 0;
        update_gui_patch(NULL, 0);
        save_session_bank();
    }
}