Example #1
0
G_MODULE_EXPORT
void
on_save_activate                       (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{
  save_as(mainwindow);
}
Example #2
0
Top_Menu::Top_Menu(Window* window)

{
    setParent(window);
    window_ = window;
    file_menu_ = new QMenu(tr("&File"), this);

    save_action_ = file_menu_->addAction(tr("&Save"),this, SLOT(save()), QKeySequence(Qt::CTRL + Qt::Key_S));
    save_as_action_ = file_menu_->addAction(tr("Save &as..."),this, SLOT(save_as()), QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S));
    load_action_ = file_menu_->addAction(tr("&Open..."),this, SLOT(open()), QKeySequence(Qt::CTRL + Qt::Key_O));
    print_action_ = file_menu_->addAction(tr("&Print..."),this, SLOT(print()), QKeySequence(Qt::CTRL + Qt::Key_P));
    exit_action_ = file_menu_->addAction(tr("E&xit"),window_, SLOT(close()), QKeySequence(Qt::CTRL + Qt::Key_Q));
    addMenu(file_menu_);

    setting_menu_ = new QMenu(tr("&Settings"), this);

    load_image_action_ = setting_menu_->addAction(tr("&Set image..."),window_, SLOT(load_image()), QKeySequence(Qt::CTRL + Qt::Key_I));
    addMenu( setting_menu_);
    help_menu_ = new QMenu(tr("&Help"), this);

    help_action_ = help_menu_->addAction(tr("&Help"),this,SLOT(help()), QKeySequence(Qt::Key_F1));
    about_action_ = help_menu_->addAction(tr("&About"), this, SLOT(about()));
    addMenu(help_menu_);


    show_save_image_warning_ = true;
}
Example #3
0
void TE_View::save_popup()
{
    if (chooser_ == nil) {
	chooser_ = new OpenFileChooser(".", WidgetKit::instance(), style_);
	Resource::ref(chooser_);
    }
    char buf[256];
    boolean error = true;
    sprintf(buf, "Save To File:");
    style_->attribute("open", "Save");
    style_->attribute("caption", "");
    style_->attribute("subcaption", buf);
    while (error) {
	if (!chooser_->post_for(current_window_))
	    return;
	const String* s = chooser_->selected();
	switch(save_as(s->string())) {
	case EivTextBuffer::OpenError:
	    style_->attribute("caption", "Can't open file, Retry!");
	    error = true;
	    break;
	case EivTextBuffer::WriteError:
	    style_->attribute("caption", "Can't write to file, Retry!");
	    error = true;
	    break;
	default:
	    error = false;
	    break;
	}
    }
}
Example #4
0
void Top_Menu::save()
{
    if (window_->mode_flag_ == DRAW_2_CURVES && window_->input_menu_->choose_coloring_box_2_->currentIndex() == T_IMAGE
            && show_save_image_warning_)
    {
        QMessageBox message_box;
        message_box.setWindowTitle("Save...");
        message_box.setIcon(QMessageBox::Information);
        QString message = QString("Saving the image is not supported.");
        message_box.setText(message);
        message_box.setInformativeText("You may need to set an image again when you load the file.");
        message_box.setStandardButtons(QMessageBox::Ok);
        message_box.exec();

        show_save_image_warning_ = false;
    }


    if(last_loaded_file_.isEmpty())
    {
        save_as();
    }
    std::ofstream save_file(last_loaded_file_.toStdString().c_str(), std::ios::out | std::ios::trunc);
    window_->configuration_->update_parameters();
    window_->configuration_->write_in_file(save_file);
    save_file.close();
    return;
}
Example #5
0
void MainWindow::setupActions()
{
    buildActions = new QActionGroup(this);
    buildActions->addAction(ui.action_Build);
    buildActions->addAction(ui.action_Upload);

    connect(ui.tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
    connect(ui.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabHasChanged()));
    connect(ui.action_New, SIGNAL(triggered()), this, SLOT(newProject()));
    connect(ui.action_Open, SIGNAL(triggered()), this, SLOT(open()));
    connect(ui.action_Save, SIGNAL(triggered()), this, SLOT(save()));
    connect(ui.action_Saveas, SIGNAL(triggered()), this, SLOT(save_as()));
    connect(ui.action_Close, SIGNAL(triggered()), this, SLOT(closeTab()));
    connect(ui.actionUpPastebin, SIGNAL(triggered()), this, SLOT(uploadToPastebin()));
    connect(ui.actionUndo, SIGNAL(triggered()), this, SLOT(undo()));
    connect(ui.actionRedo, SIGNAL(triggered()), this, SLOT(redo()));
    connect(ui.action_Copy, SIGNAL(triggered()), this, SLOT(copy()));
    connect(ui.action_Cut, SIGNAL(triggered()), this, SLOT(cut()));
    connect(ui.action_Find, SIGNAL(triggered(bool)), this, SLOT(showFindBox(bool)));
    connect(ui.action_Paste, SIGNAL(triggered()), this, SLOT(paste()));
    connect(ui.action_Build, SIGNAL(triggered()), this, SLOT(build()));
    connect(ui.action_Upload, SIGNAL(triggered()), this, SLOT(upload()));
    connect(ui.action_Utilities, SIGNAL(triggered()), this, SLOT(toggleDock()));
    connect(ui.actionGo_to_the_next_tab, SIGNAL(triggered()), this, SLOT(nextTab()));
    connect(ui.actionGo_to_the_previous_tab, SIGNAL(triggered()), this, SLOT(previousTab()));
    connect(ui.action_Configure_the_IDE, SIGNAL(triggered()), this, SLOT(configure()));
    connect(ui.action_Contextual_help, SIGNAL(triggered()), this, SLOT(contextualHelp()));
    connect(ui.actionCommunityArduinoCC, SIGNAL(triggered()), this, SLOT(openCommunityArduinoCC()));
    connect(ui.actionCommunityArduinoForums, SIGNAL(triggered()), this, SLOT(openCommunityArduinoForums()));
    connect(ui.actionAbout, SIGNAL(triggered()), this, SLOT(about()));
    connect(ui.actionAbout_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));

    connect(ui.lineFind, SIGNAL(returnPressed()), this, SLOT(find()));
    connect(ui.lineReplace, SIGNAL(returnPressed()), this, SLOT(find()));
    connect(ui.pushFind, SIGNAL(clicked()), this, SLOT(find()));
    connect(ui.pushReplace, SIGNAL(clicked()), this, SLOT(replace()));
    connect(ui.pushReplaceAll, SIGNAL(clicked()), this, SLOT(replaceAll()));
    connect(this, SIGNAL(tabChanged(bool)), ui.pushReplace, SLOT(setEnabled(bool)));
    connect(this, SIGNAL(tabChanged(bool)), ui.pushReplaceAll, SLOT(setEnabled(bool)));
    connect(this, SIGNAL(tabChanged(bool)), ui.checkRegExp, SLOT(setEnabled(bool)));
    connect(this, SIGNAL(tabChanged(bool)), ui.checkWordOnly, SLOT(setEnabled(bool)));

    connect(this, SIGNAL(tabChanged(bool)), ui.menu_Libraries, SLOT(setEnabled(bool)));
    connect(ui.action_Lib_Refresh, SIGNAL(triggered()), this, SLOT(refreshLibrariesMenu()));

    connect(browser, SIGNAL(newProjectRequested()), this, SLOT(newProject()));
    connect(browser, SIGNAL(newProjectRequested(const QString &, const QString &)), this, SLOT(newProject(const QString &, const QString &)));
    connect(browser, SIGNAL(openProjectRequested()), this, SLOT(open()));
    connect(browser, SIGNAL(openProjectRequested(const QString &)), this, SLOT(open(const QString &)));
    connect(browser, SIGNAL(newPageLoaded(QUrl)), this, SLOT(tabContentHasChanged()));
    connect(ui.action_Prev, SIGNAL(triggered()), browser, SLOT(back()));
    connect(ui.action_Next, SIGNAL(triggered()), browser, SLOT(forward()));

    connect(ideApp->projectHistory(), SIGNAL(historyUpdated(QString)), browser, SLOT(refresh()));

    connect(ideApp->settings(), SIGNAL(fontChanged(const QFont &)), this, SLOT(setFont(const QFont &)));

    connect(&pastebin, SIGNAL(finished(QNetworkReply*)), this, SLOT(pastebinUploadDone(QNetworkReply*)));
}
Example #6
0
void VoxelEditor::save()
{
    if (current_model.isEmpty()) {
        save_as();
        return;
    }
    voxel->save(current_model);
    setWindowModified(false);
}
Example #7
0
void main_model::save(const save_callback& callback) {
    if (project::is_project_file(currently_open_file_)) {
        project.save_to(currently_open_file_);
    } else {
        if (const auto fpath = callback()) {
            save_as(*fpath);
        }
    }
}
Example #8
0
/**
 * \brief Save the animation.
 */
bool bf::main_frame::save()
{
  bool result = false;

  if ( m_animation_file.empty() )
    result = save_as();
  else
    result = effective_save();

  return result;
} // main_frame::save()
Example #9
0
CInifile::~CInifile( )
{
    if (!m_flags.test(eReadOnly) && m_flags.test(eSaveAtEnd))
    {
        if (!save_as())
            Log		("! Can't save inifile:",m_file_name);
    }

    RootIt			I = DATA.begin();
    RootIt			E = DATA.end();
    for ( ; I != E; ++I)
        xr_delete	(*I);
}
Example #10
0
CInifile::~CInifile( )
{
	if (!bReadOnly&&bSaveAtEnd) {
		if (!save_as())
			Log		("!Can't save inifile:",fName);
	}

	xr_free			(fName);

	RootIt			I = DATA.begin();
	RootIt			E = DATA.end();
	for ( ; I != E; ++I)
		xr_delete	(*I);
}
Example #11
0
bool CInifile::save_as	(LPCSTR new_fname)
{
    // save if needed
    if (new_fname && new_fname[0])
        strcpy_s		(m_file_name, new_fname);

    R_ASSERT			(m_file_name&&m_file_name[0]);
    IWriter* F			= FS.w_open_ex(m_file_name);
    if (!F)
        return			(false);

    save_as				(*F);
    FS.w_close			(F);
    return				(true);
}
Example #12
0
static void
save_cb (GtkWidget *dialog,
         gint       response_id,
         gpointer   data)
{
  if (response_id == GTK_RESPONSE_OK)
    {
      gchar *filename;

      filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));

      save_as (filename);
      g_free (filename);
    }

  gtk_widget_hide (dialog);
}
Example #13
0
bool mime_builder::save_as(const char* to)
{
	acl::ofstream fp;
	if (fp.open_write(to) == false)
	{
		logger_error("open file %s failed %s", to, acl::last_serror());
		return false;
	}
	else if (save_as(fp) == false)
	{
		fp.close();
		_unlink(to);
		return false;
	}
	else
		return true;
}
Example #14
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    connect(ui->actionOpen,SIGNAL(triggered()),this,SLOT(open()));
    connect(ui->actionSave_As,SIGNAL(triggered()),this,SLOT(save_as()));
    connect(ui->actionGrayscale, SIGNAL(triggered()), this, SLOT(gray_scale()));
    connect(ui->actionHistogram, SIGNAL(triggered()), this, SLOT(show_histogram()));
    connect(ui->actionBinarization, SIGNAL(triggered()), this, SLOT(show_binarization()));
    connect(ui->actionRecognition, SIGNAL(triggered()), this, SLOT(show_recognition()));

    connect(&mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(subwindow_changed(QMdiSubWindow*)));

    //Window
    QDesktopWidget desktop;

    int width = geometry().width();
    int height = geometry().height();

    int screenWidth = desktop.screen()->width();
    int screenHeight = desktop.screen()->height();

    setGeometry((screenWidth/2)-(width/2),(screenHeight/2)-(height/2),width,height);
    setCentralWidget(&mdiArea);

    // Histogram dialog
    histogramDlg = new dlgHistogram(&mdiArea);
    mdiArea.addSubWindow(histogramDlg);

    histogramDlg->parentWidget()->hide();

    // Binarization dialog
    binarizationDlg = new dlgBinarization(&mdiArea);
    mdiArea.addSubWindow(binarizationDlg);

    binarizationDlg->parentWidget()->hide();

    // Recognition dialog
    recognitionDlg = new dlgRecognition(&mdiArea);
    mdiArea.addSubWindow(recognitionDlg);

    recognitionDlg->parentWidget()->hide();
}
Example #15
0
/**
 * \brief Compile the animation.
 */
void bf::main_frame::compile_animation()
{
  Disable();
  Refresh();

  if ( m_animation_edit->validate() )
    {
      bool do_it = true;

      if ( m_animation_file.IsEmpty() )
        do_it = save_as();

      if ( do_it )
        compile_animation_no_check();
    }

  Enable();
  GetStatusBar()->SetStatusText( _("Compilation done."), 0 );
} // main_frame::compile_animation()
Example #16
0
File: main.c Project: wavs/ocre
void on_save_show (GtkImageMenuItem* test, gpointer user_data)
{
  GtkWidget* save;
  GUI_* guisex;  GtkTextBuffer *txtbuffer;
  char *filename, *text;  (void)test;
  guisex = (GUI_ *)user_data;
  /* guisex->textview = gtk_text_view_new (); */
  txtbuffer = gtk_text_view_get_buffer(
	      GTK_TEXT_VIEW(guisex->textview));
  /* create a 'save file' dialog */
  save = gtk_file_chooser_dialog_new (NULL,
				      NULL,
				      GTK_FILE_CHOOSER_ACTION_SAVE,
				      GTK_STOCK_SAVE,
				      GTK_RESPONSE_ACCEPT,
				      GTK_STOCK_CANCEL,
				      GTK_RESPONSE_CANCEL,
				      NULL);
  gtk_file_chooser_set_do_overwrite_confirmation
    (GTK_FILE_CHOOSER(save),TRUE );
  /*if (!gtk_text_buffer_get_modified (txtbuffer))
    {*/
  gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (save), "/" );
  gtk_file_chooser_set_current_name
    (GTK_FILE_CHOOSER (save), "Untitled" );
  gtk_text_buffer_set_modified (txtbuffer, FALSE);
  if (gtk_dialog_run (GTK_DIALOG (save)) == GTK_RESPONSE_ACCEPT)
    {
      GtkTextIter iStart, iEnd;
      filename = gtk_file_chooser_get_filename
        (GTK_FILE_CHOOSER (save) );
      /* on chope le debut et la fin du buffer */
      gtk_text_buffer_get_start_iter(txtbuffer, &iStart);
      gtk_text_buffer_get_end_iter(txtbuffer, &iEnd);
      text = gtk_text_buffer_get_text
        (GTK_TEXT_BUFFER(txtbuffer), &iStart, &iEnd, FALSE );
      save_as(text, filename);
      g_free (filename);
    }
  gtk_widget_destroy (save);
}
Example #17
0
void Window::create_actions()
{
    open_action = new QAction(QIcon(":/fileopen.ico"), tr("Open"), this);
    open_action->setShortcuts(QKeySequence::Open);
    connect(open_action, SIGNAL(triggered()), this, SLOT(open()));

    save_as_action = new QAction(QIcon(":/filesaveas.ico"), tr("Save As"), this);
    save_as_action->setShortcuts(QKeySequence::SaveAs);
    connect(save_as_action, SIGNAL(triggered()), this, SLOT(save_as()));
    save_as_action->setEnabled(false);

    exit_action = new QAction(QIcon(":/exit.ico"), tr("Quit"), this);
    exit_action->setShortcuts(QKeySequence::Quit);
    connect(exit_action, SIGNAL(triggered()), this, SLOT(close()));

    zoom_in_action = new QAction(QIcon(":/zoom_in.ico"),tr("Zoom &In (25%)"), this);
    zoom_in_action->setShortcuts(QList<QKeySequence>() << QKeySequence::ZoomIn << QKeySequence(tr("Ctrl++")));
    zoom_in_action->setEnabled(false);
    connect(zoom_in_action, SIGNAL(triggered()), this, SLOT(zoom_in()));

    zoom_out_action = new QAction(QIcon(":/zoom_out.ico"),tr("Zoom &Out (25%)"), this);
    zoom_out_action->setShortcuts(QList<QKeySequence>() << QKeySequence::ZoomOut << QKeySequence(tr("Ctrl+-")));
    zoom_out_action->setEnabled(false);
    connect(zoom_out_action, SIGNAL(triggered()), this, SLOT(zoom_out()));

    zoom_original_action = new QAction(QIcon(":/zoom_original.ico"),tr("&Normal Size"), this);
    zoom_original_action->setShortcut(tr("Ctrl+S"));
    zoom_original_action->setEnabled(false);
    connect(zoom_original_action, SIGNAL(triggered()), this, SLOT(zoom_original()));

    zoom_fit_action = new QAction(QIcon(":/zoom_fit_best.ico"),tr("&Fit to Window"), this);
    zoom_fit_action->setShortcut(tr("Ctrl+F"));
    zoom_fit_action->setEnabled(false);
    zoom_fit_action->setCheckable(true);
    connect(zoom_fit_action, SIGNAL(triggered()), this, SLOT(zoom_fit()));

    gaussian_blur_action = new QAction(tr("Gaussian blur"), this);
    gaussian_blur_action->setShortcut(tr("Ctrl+g"));
    gaussian_blur_action->setEnabled(false);
    connect(gaussian_blur_action, SIGNAL(triggered()), this, SLOT(gaussian_blur()));
}
Example #18
0
G_MODULE_EXPORT void cb_saveas(GtkButton *button, Dialogs *data)
{
	/* Save as Dialog */
	gint ret;
	static char *filename = NULL;

	if (!channel_data || !num_active_channels) {
		gtk_widget_hide(save_csv);
		gtk_widget_hide(save_vsa);
		gtk_widget_hide(save_mat);
	} else {
		gtk_widget_show(save_csv);
		gtk_widget_show(save_vsa);
		gtk_widget_show(save_mat);
	}

	gtk_file_chooser_set_action(GTK_FILE_CHOOSER (data->saveas), GTK_FILE_CHOOSER_ACTION_SAVE);
	gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(data->saveas), TRUE);

	if(!filename) {
		gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER (data->saveas), getenv("HOME"));
		gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER (data->saveas), current_device);
	} else {
		gtk_file_chooser_set_filename(GTK_FILE_CHOOSER (data->saveas), filename);
		g_free(filename);
		filename = NULL;

	}

	ret = gtk_dialog_run(GTK_DIALOG(data->saveas));

	filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (data->saveas));
	if (filename) {
		save_as(filename, ret);
	}
	gtk_widget_hide(data->saveas);
}
Example #19
0
void MainWindow::create_actions()
{
    QStyle * style = tree_widget->style();

    open_act = new QAction(tr("&Open..."), this);				// create actions
    open_act->setIcon(style->standardPixmap(QStyle::SP_DialogOpenButton));    // and set icons
    open_act->setShortcut(Qt::CTRL + Qt::Key_O);				// set a short cut
    open_act->setStatusTip(tr("Open a XML file"));				// set a status tip
    connect(open_act, SIGNAL(triggered()), this, SLOT(open()));		// and connect

    save_act = new QAction(tr("&Save ..."), this);
    save_act->setIcon(style->standardPixmap(QStyle::SP_DialogSaveButton));
    save_act->setShortcut(Qt::CTRL + Qt::Key_S);
    save_act->setStatusTip(tr("Save the current XML file"));
    connect(save_act, SIGNAL(triggered()), this, SLOT(save()));

    save_as_act = new QAction(tr("&Save As..."), this);
    save_as_act->setIcon(style->standardPixmap(QStyle::SP_DialogSaveButton));
    save_as_act->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Q);
    save_as_act->setStatusTip(tr("Save the current XML file as"));
    connect(save_as_act, SIGNAL(triggered()), this, SLOT(save_as()));

    exit_act = new QAction(tr("E&xit"), this);
    exit_act->setIcon(style->standardPixmap(QStyle::SP_DialogCloseButton));
    exit_act->setShortcut(Qt::CTRL + Qt::Key_Q);
    exit_act->setStatusTip(tr("Exit the parameterGUI application"));
    connect(exit_act, SIGNAL(triggered()), this, SLOT(close()));

    about_act = new QAction(tr("&About"), this);
    about_act->setIcon(style->standardPixmap(QStyle::SP_FileDialogInfoView));
    about_act->setStatusTip(tr("Show the parameterGUI About box"));
    connect(about_act, SIGNAL(triggered()), this, SLOT(about()));

    about_qt_act = new QAction(tr("About &Qt"), this);
    about_qt_act->setStatusTip(tr("Show the Qt library's About box"));
    connect(about_qt_act, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
}
Example #20
0
/**
 * \brief Answer to a click on "Save as".
 * \param event This event occured.
 */
void bf::main_frame::on_save_as( wxCommandEvent& WXUNUSED(event) )
{
  save_as();
} // main_frame::on_save_as()
Example #21
0
void MainWindow::create_actions()
{
    // file menu

    new_model_action = new QAction(tr("New voxel model"), this);
    connect(new_model_action, SIGNAL(triggered()), this, SLOT(new_model()));
 
    open_model_action = new QAction(tr("Open voxel model"), this);
    connect(open_model_action, SIGNAL(triggered()), this, SLOT(open_model()));

    clone_model_action = new QAction(tr("Clone voxel model"), this);
    connect(clone_model_action, SIGNAL(triggered()), this, SLOT(clone_model()));
 
    save_action = new QAction(tr("&Save"), this);
    save_action->setShortcuts(QKeySequence::Save);
    connect(save_action, SIGNAL(triggered()), this, SLOT(save()));
 
    save_as_action = new QAction(tr("Save &As..."), this);
    save_as_action->setShortcuts(QKeySequence::SaveAs);
    connect(save_as_action, SIGNAL(triggered()), this, SLOT(save_as()));
 
    exit_action = new QAction(tr("E&xit"), this);
    exit_action->setShortcuts(QKeySequence::Quit);
    exit_action->setStatusTip(tr("Exit the application"));
    connect(exit_action, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));
 
/*        cut_action = new QAction(tr("Cu&t"), this);
    cut_action->setShortcuts(QKeySequence::Cut);
    cut_action->setStatusTip(tr("Cut the current selection's contents to the "
                            "clipboard"));
    connect(cut_action, SIGNAL(triggered()), this, SLOT(cut()));
 
    copy_action = new QAction(tr("&Copy"), this);
    copy_action->setShortcuts(QKeySequence::Copy);
    copy_action->setStatusTip(tr("Copy the current selection's contents to the "
                             "clipboard"));
    connect(copy_action, SIGNAL(triggered()), this, SLOT(copy()));
 
    paste_action = new QAction(tr("&Paste"), this);
    paste_action->setShortcuts(QKeySequence::Paste);
    paste_action->setStatusTip(tr("Paste the clipboard's contents into the current "
                              "selection"));
    connect(paste_action, SIGNAL(triggered()), this, SLOT(paste()));*/

    // model menu

    double_size_action = new QAction(tr("Double size"), this);
    // new_action->setShortcuts(QKeySequence::New);
    connect(double_size_action, SIGNAL(triggered()), this, 
        SLOT(double_size()));
 
    half_size_action = new QAction(tr("Half size"), this);
    // open_action->setShortcuts(QKeySequence::Open);
    connect(half_size_action, SIGNAL(triggered()), this, 
        SLOT(half_size()));
 
    optimize_action = new QAction(tr("Optimize dimensions"), this);
    // save_action->setShortcuts(QKeySequence::Save);
    connect(optimize_action, SIGNAL(triggered()), this,
        SLOT(optimize()));

    rotate_action = new QAction(tr("Rotate 90 degrees"), this);
    // save_action->setShortcuts(QKeySequence::Save);
    connect(rotate_action, SIGNAL(triggered()), this,
        SLOT(rotate()));

}
Example #22
0
/* Many execution paths may lead to this code so it needs to take appropriate
 * precausions to stuff like doc_view and doc_view->vs being NULL. */
enum frame_event_status
do_action(struct session *ses, enum main_action action_id, int verbose)
{
	enum frame_event_status status = FRAME_EVENT_OK;
	struct terminal *term = ses->tab->term;
	struct document_view *doc_view = current_frame(ses);
	struct link *link = NULL;

	if (action_id == -1) goto unknown_action;

	if (doc_view && doc_view->vs) {
		if (action_prefix_is_link_number(KEYMAP_MAIN, action_id)
		    && !try_jump_to_link_number(ses, doc_view))
			goto ignore_action;

		link = get_current_link(doc_view);

	} else if (action_requires_view_state(KEYMAP_MAIN, action_id)) {
		goto ignore_action;
	}

	if (action_requires_location(KEYMAP_MAIN, action_id)
	    && !have_location(ses))
		return FRAME_EVENT_OK;

	if (action_requires_link(KEYMAP_MAIN, action_id)
	    && !link)
		goto ignore_action;

	if (action_requires_form(KEYMAP_MAIN, action_id)
	    && (!link || !link_is_form(link)))
		goto ignore_action;

	if (!action_is_anonymous_safe(KEYMAP_MAIN, action_id)
	    && get_cmd_opt_bool("anonymous"))
		goto ignore_action;

	/* Please keep in alphabetical order for now. Later we can sort by most
	 * used or something. */
	switch (action_id) {
		case ACT_MAIN_ABORT_CONNECTION:
			abort_loading(ses, 1);
			print_screen_status(ses);
			break;

		case ACT_MAIN_ADD_BOOKMARK:
#ifdef CONFIG_BOOKMARKS
			launch_bm_add_doc_dialog(term, NULL, ses);
#endif
			break;
		case ACT_MAIN_ADD_BOOKMARK_LINK:
#ifdef CONFIG_BOOKMARKS
			launch_bm_add_link_dialog(term, NULL, ses);
#endif
			break;
		case ACT_MAIN_ADD_BOOKMARK_TABS:
#ifdef CONFIG_BOOKMARKS
			bookmark_terminal_tabs_dialog(term);
#endif
			break;

		case ACT_MAIN_AUTH_MANAGER:
			auth_manager(ses);
			break;

		case ACT_MAIN_BACKSPACE_PREFIX:

			if (!ses->kbdprefix.repeat_count) break;

			set_kbd_repeat_count(ses,
			                     ses->kbdprefix.repeat_count / 10);

			/* Keep send_event from resetting repeat_count. */
			status = FRAME_EVENT_SESSION_DESTROYED;

			break;

		case ACT_MAIN_BOOKMARK_MANAGER:
#ifdef CONFIG_BOOKMARKS
			bookmark_manager(ses);
#endif
			break;

		case ACT_MAIN_CACHE_MANAGER:
			cache_manager(ses);
			break;

		case ACT_MAIN_CACHE_MINIMIZE:
			shrink_memory(1);
			break;

		case ACT_MAIN_COOKIES_LOAD:
#ifdef CONFIG_COOKIES
			if (!get_opt_bool("cookies.save", NULL)) break;
			load_cookies();
#endif
			break;

		case ACT_MAIN_COOKIE_MANAGER:
#ifdef CONFIG_COOKIES
			cookie_manager(ses);
#endif
			break;

		case ACT_MAIN_COPY_CLIPBOARD:
			status = copy_current_link_to_clipboard(ses, doc_view, 0);
			break;

		case ACT_MAIN_DOCUMENT_INFO:
			document_info_dialog(ses);
			break;

		case ACT_MAIN_DOWNLOAD_MANAGER:
			download_manager(ses);
			break;

		case ACT_MAIN_EXMODE:
#ifdef CONFIG_EXMODE
			exmode_start(ses);
#endif
			break;

		case ACT_MAIN_FILE_MENU:
			activate_bfu_technology(ses, 0);
			break;

		case ACT_MAIN_FIND_NEXT:
			status = find_next(ses, doc_view, 1);
			break;

		case ACT_MAIN_FIND_NEXT_BACK:
			status = find_next(ses, doc_view, -1);
			break;

		case ACT_MAIN_FORGET_CREDENTIALS:
			free_auth();
			shrink_memory(1); /* flush caches */
			break;

		case ACT_MAIN_FORMHIST_MANAGER:
#ifdef CONFIG_FORMHIST
			formhist_manager(ses);
#endif
			break;

		case ACT_MAIN_FRAME_EXTERNAL_COMMAND:
			status = pass_uri_to_command(ses, doc_view,
			                             PASS_URI_FRAME);
			break;

		case ACT_MAIN_FRAME_NEXT:
			next_frame(ses, 1);
			draw_formatted(ses, 0);
			break;

		case ACT_MAIN_FRAME_MAXIMIZE:
			status = set_frame(ses, doc_view, 0);
			break;

		case ACT_MAIN_FRAME_PREV:
			next_frame(ses, -1);
			draw_formatted(ses, 0);
			break;

		case ACT_MAIN_GOTO_URL:
			goto_url_action(ses, NULL);
			break;

		case ACT_MAIN_GOTO_URL_CURRENT:
			goto_url_action(ses, get_current_url);
			break;

		case ACT_MAIN_GOTO_URL_CURRENT_LINK:
			goto_url_action(ses, get_current_link_url);
			break;

		case ACT_MAIN_GOTO_URL_HOME:
			goto_url_home(ses);
			break;

		case ACT_MAIN_HEADER_INFO:
			protocol_header_dialog(ses);
			break;

		case ACT_MAIN_HISTORY_MANAGER:
#ifdef CONFIG_GLOBHIST
			history_manager(ses);
#endif
			break;

		case ACT_MAIN_HISTORY_MOVE_BACK:
		{
			int count = int_max(1, eat_kbd_repeat_count(ses));

			go_history_by_n(ses, -count);
			break;
		}
		case ACT_MAIN_HISTORY_MOVE_FORWARD:
		{
			int count = int_max(1, eat_kbd_repeat_count(ses));

			go_history_by_n(ses, count);
			break;
		}
		case ACT_MAIN_JUMP_TO_LINK:
			break;

		case ACT_MAIN_KEYBINDING_MANAGER:
			keybinding_manager(ses);
			break;

		case ACT_MAIN_KILL_BACKGROUNDED_CONNECTIONS:
			abort_background_connections();
			break;

		case ACT_MAIN_LINK_DIALOG:
			open_link_dialog(ses);
			break;

		case ACT_MAIN_LINK_DOWNLOAD:
		case ACT_MAIN_LINK_DOWNLOAD_IMAGE:
		case ACT_MAIN_LINK_DOWNLOAD_RESUME:
			status = download_link(ses, doc_view, action_id);
			break;

		case ACT_MAIN_LINK_EXTERNAL_COMMAND:
			status = pass_uri_to_command(ses, doc_view,
			                             PASS_URI_LINK);
			break;

		case ACT_MAIN_LINK_FOLLOW:
			status = enter(ses, doc_view, 0);
			break;

		case ACT_MAIN_LINK_FOLLOW_RELOAD:
			status = enter(ses, doc_view, 1);
			break;

		case ACT_MAIN_LINK_INFO:
			link_info_dialog(ses);
			break;
			
		case ACT_MAIN_LINK_MENU:
			link_menu(term, NULL, ses);
			break;

		case ACT_MAIN_LINK_FORM_MENU:
			link_form_menu(ses);
			break;

		case ACT_MAIN_LUA_CONSOLE:
#ifdef CONFIG_SCRIPTING_LUA
			trigger_event_name("dialog-lua-console", ses);
#endif
			break;

		case ACT_MAIN_MARK_SET:
#ifdef CONFIG_MARKS
			ses->kbdprefix.mark = KP_MARK_SET;
			status = FRAME_EVENT_REFRESH;
#endif
			break;

		case ACT_MAIN_MARK_GOTO:
#ifdef CONFIG_MARKS
			/* TODO: Show promptly a menu (or even listbox?)
			 * with all the marks. But the next letter must
			 * still choose a mark directly! --pasky */
			ses->kbdprefix.mark = KP_MARK_GOTO;
			status = FRAME_EVENT_REFRESH;
#endif
			break;

		case ACT_MAIN_MENU:
			activate_bfu_technology(ses, -1);
			break;

		case ACT_MAIN_MOVE_CURRENT_TOP:
			status = move_current_top(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_CURSOR_UP:
			status = move_cursor_up(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_CURSOR_DOWN:
			status = move_cursor_down(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_CURSOR_LEFT:
			status = move_cursor_left(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_CURSOR_RIGHT:
			status = move_cursor_right(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_CURSOR_LINE_START:
			status = move_cursor_line_start(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_HALF_PAGE_DOWN:
			status = move_half_page_down(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_HALF_PAGE_UP:
			status = move_half_page_up(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_LINK_DOWN:
			status = move_link_down(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_LINK_DOWN_LINE:
			status = move_link_down_line(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_LINK_LEFT:
			status = move_link_left(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_LINK_LEFT_LINE:
			status = move_link_prev_line(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_LINK_NEXT:
			status = move_link_next(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_LINK_PREV:
			status = move_link_prev(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_LINK_RIGHT:
			status = move_link_right(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_LINK_RIGHT_LINE:
			status = move_link_next_line(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_LINK_UP:
			status = move_link_up(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_LINK_UP_LINE:
			status = move_link_up_line(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_PAGE_DOWN:
			status = move_page_down(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_PAGE_UP:
			status = move_page_up(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_DOCUMENT_START:
			status = move_document_start(ses, doc_view);
			break;

		case ACT_MAIN_MOVE_DOCUMENT_END:
			status = move_document_end(ses, doc_view);
			break;

		case ACT_MAIN_OPEN_LINK_IN_NEW_TAB:
			open_current_link_in_new_tab(ses, 0);
			break;

		case ACT_MAIN_OPEN_LINK_IN_NEW_TAB_IN_BACKGROUND:
			open_current_link_in_new_tab(ses, 1);
			break;

		case ACT_MAIN_OPEN_LINK_IN_NEW_WINDOW:
			open_in_new_window(term, send_open_in_new_window, ses);
			break;

		case ACT_MAIN_OPEN_NEW_TAB:
			open_uri_in_new_tab(ses, NULL, 0, 1);
			break;

		case ACT_MAIN_OPEN_NEW_TAB_IN_BACKGROUND:
			open_uri_in_new_tab(ses, NULL, 1, 1);
			break;

		case ACT_MAIN_OPEN_NEW_WINDOW:
			open_in_new_window(term, send_open_new_window, ses);
			break;

		case ACT_MAIN_OPEN_OS_SHELL:
			exec_shell(term);
			break;

		case ACT_MAIN_OPTIONS_MANAGER:
			options_manager(ses);
			break;

		case ACT_MAIN_QUIT:
			exit_prog(ses, 1);
			break;

		case ACT_MAIN_REALLY_QUIT:
			exit_prog(ses, 0);
			break;

		case ACT_MAIN_REDRAW:
			redraw_terminal_cls(term);
			break;

		case ACT_MAIN_RELOAD:
			reload(ses, CACHE_MODE_INCREMENT);
			break;

		case ACT_MAIN_RERENDER:
			draw_formatted(ses, 2);
			break;

		case ACT_MAIN_RESET_FORM:
			status = reset_form(ses, doc_view, 0);
			break;

		case ACT_MAIN_RESOURCE_INFO:
			resource_info(term);
			break;

		case ACT_MAIN_SAVE_AS:
			status = save_as(ses, doc_view, 0);
			break;

		case ACT_MAIN_SAVE_FORMATTED:
			status = save_formatted_dlg(ses, doc_view, 0);
			break;

		case ACT_MAIN_SAVE_OPTIONS:
			write_config(term);
			break;

		case ACT_MAIN_SAVE_URL_AS:
			save_url_as(ses);
			break;

		case ACT_MAIN_SCROLL_DOWN:
			status = scroll_down(ses, doc_view);
			break;

		case ACT_MAIN_SCROLL_LEFT:
			status = scroll_left(ses, doc_view);
			break;

		case ACT_MAIN_SCROLL_RIGHT:
			status = scroll_right(ses, doc_view);
			break;

		case ACT_MAIN_SCROLL_UP:
			status = scroll_up(ses, doc_view);
			break;

		case ACT_MAIN_SEARCH:
			status = search_dlg(ses, doc_view, 1);
			break;

		case ACT_MAIN_SEARCH_BACK:
			status = search_dlg(ses, doc_view, -1);
			break;

		case ACT_MAIN_SEARCH_TYPEAHEAD:
		case ACT_MAIN_SEARCH_TYPEAHEAD_LINK:
		case ACT_MAIN_SEARCH_TYPEAHEAD_TEXT:
		case ACT_MAIN_SEARCH_TYPEAHEAD_TEXT_BACK:
			status = search_typeahead(ses, doc_view, action_id);
			break;

		case ACT_MAIN_SHOW_TERM_OPTIONS:
			terminal_options(term, NULL, ses);
			break;

		case ACT_MAIN_SUBMIT_FORM:
			status = submit_form(ses, doc_view, 0);
			break;

		case ACT_MAIN_SUBMIT_FORM_RELOAD:
			status = submit_form(ses, doc_view, 1);
			break;

		case ACT_MAIN_TAB_CLOSE:
			close_tab(term, ses);
			status = FRAME_EVENT_SESSION_DESTROYED;
			break;

		case ACT_MAIN_TAB_CLOSE_ALL_BUT_CURRENT:
			close_all_tabs_but_current(ses);
			break;

		case ACT_MAIN_TAB_EXTERNAL_COMMAND:
			status = pass_uri_to_command(ses, doc_view,
			                             PASS_URI_TAB);
			break;

		case ACT_MAIN_TAB_MOVE_LEFT:
			move_current_tab(ses, -1);
			break;

		case ACT_MAIN_TAB_MOVE_RIGHT:
			move_current_tab(ses, 1);
			break;

		case ACT_MAIN_TAB_MENU:
			assert(ses->tab == get_current_tab(term));

			if (ses->status.show_tabs_bar)
				tab_menu(ses, ses->tab->xpos,
					 term->height - 1
					  - ses->status.show_status_bar,
					 1);
			else
				tab_menu(ses, 0, 0, 0);

			break;

		case ACT_MAIN_TAB_NEXT:
			switch_current_tab(ses, 1);
			break;

		case ACT_MAIN_TAB_PREV:
			switch_current_tab(ses, -1);
			break;

		case ACT_MAIN_TERMINAL_RESIZE:
			resize_terminal_dialog(term);
			break;

		case ACT_MAIN_TOGGLE_CSS:
#ifdef CONFIG_CSS
			toggle_document_option(ses, "document.css.enable");
#endif
			break;

		case ACT_MAIN_TOGGLE_DISPLAY_IMAGES:
			toggle_document_option(ses, "document.browse.images.show_as_links");
			break;

		case ACT_MAIN_TOGGLE_DISPLAY_TABLES:
			toggle_document_option(ses, "document.html.display_tables");
			break;

		case ACT_MAIN_TOGGLE_DOCUMENT_COLORS:
			toggle_document_option(ses, "document.colors.use_document_colors");
			break;

		case ACT_MAIN_TOGGLE_HTML_PLAIN:
			toggle_plain_html(ses, ses->doc_view, 0);
			break;

		case ACT_MAIN_TOGGLE_MOUSE:
#ifdef CONFIG_MOUSE
			toggle_mouse();
#endif
			break;

		case ACT_MAIN_TOGGLE_NUMBERED_LINKS:
			toggle_document_option(ses, "document.browse.links.numbering");
			break;

		case ACT_MAIN_TOGGLE_PLAIN_COMPRESS_EMPTY_LINES:
			toggle_document_option(ses, "document.plain.compress_empty_lines");
			break;

		case ACT_MAIN_TOGGLE_WRAP_TEXT:
			toggle_wrap_text(ses, ses->doc_view, 0);
			break;

		case ACT_MAIN_VIEW_IMAGE:
			status = view_image(ses, doc_view, 0);
			break;

		case ACT_MAIN_SCRIPTING_FUNCTION:
		case ACT_MAIN_NONE:
		case MAIN_ACTIONS:
		default:
unknown_action:
			if (verbose) {
				INTERNAL("No action handling defined for '%s'.",
					 get_action_name(KEYMAP_MAIN, action_id));
			}

			status = FRAME_EVENT_IGNORED;
	}

ignore_action:
	/* XXX: At this point the session may have been destroyed */

	if (status != FRAME_EVENT_SESSION_DESTROYED
	    && ses->insert_mode == INSERT_MODE_ON
	    && link != get_current_link(doc_view))
		ses->insert_mode = INSERT_MODE_OFF;

	if (status == FRAME_EVENT_REFRESH && doc_view)
		refresh_view(ses, doc_view, 0);

	return status;
}