Esempio n. 1
0
void
MyDialogs::CheckSaved()
{
    int retcode;

    if (dirty > 0) {

        retcode = QMessageBox::warning(0, "The Fish",
                                       "There are unsaved changes. "
                                       "Quit anyway?\n\n",
                                       "Yes",
                                       "No", 0, 0, 1 );

        if (retcode == 0) {

            save_geometry();
            thefish->exit(0);

        }

    } else {

        save_geometry();
        thefish->exit(0);

    }

}
Esempio n. 2
0
bool Dialog::_onDeleteEvent(GdkEventAny */*event*/)
{
    save_geometry();
    _user_hidden = true;

    return false;
}
Esempio n. 3
0
void
Dialog::onShutdown()
{
    save_geometry();
    _user_hidden = true;
    _behavior->onShutdown();
}
Esempio n. 4
0
Dialog::~Dialog()
{
    if (Inkscape::NSApplication::Application::getNewGui())
    {
        _desktop_activated_connection.disconnect();
        _dialogs_hidden_connection.disconnect();
        _dialogs_unhidden_connection.disconnect();
        _shutdown_connection.disconnect();
    }

    save_geometry();
    delete _behavior;
    _behavior = 0;
}
Esempio n. 5
0
clan::DomElement GridObject::to_element(clan::DomDocument &doc)
{
	clan::GUIComponent *comp = get_first_child();

	std::string type = comp->get_tag_name();

	clan::DomElement e = doc.create_element(comp->get_tag_name());
	std::string comp_class;
	comp->get_class(comp_class);

	e.set_attribute("class", comp_class);
	e.set_attribute("id", comp->get_id());
	e.set_attribute_bool("enabled", comp->is_enabled());

	if (!pos_equation_x.empty())
		e.set_attribute("eq-x", pos_equation_x);
	if (!pos_equation_y.empty())
		e.set_attribute("eq-y", pos_equation_y);
	if (!pos_equation_x2.empty())
		e.set_attribute("eq-x2", pos_equation_x2);
	if (!pos_equation_y2.empty())
		e.set_attribute("eq-y2", pos_equation_y2);

	if (type == "button")
	{
		clan::PushButton *co = dynamic_cast<clan::PushButton*>(comp);
		e.set_attribute("text", co->get_text());
	}
	else if (comp->get_tag_name() == "checkbox")
	{
		clan::CheckBox *co = dynamic_cast<clan::CheckBox*>(comp);
		e.set_attribute("text", co->get_text());
	}
	else if (comp->get_tag_name() == "radiobutton")
	{
		clan::RadioButton *co = dynamic_cast<clan::RadioButton*>(comp);
		e.set_attribute("text", co->get_text());
		e.set_attribute("group", co->get_group_name());
	}
	else if (comp->get_tag_name() == "label")
	{
		clan::Label *co = dynamic_cast<clan::Label*>(comp);
		e.set_attribute("text", co->get_text());
	}
	else if (comp->get_tag_name() == "lineedit")
	{
		clan::LineEdit *co = dynamic_cast<clan::LineEdit*>(comp);
		e.set_attribute("text", co->get_text());
	}
	else if (comp->get_tag_name() == "textedit")
	{
		clan::TextEdit *co = dynamic_cast<clan::TextEdit*>(comp);
		e.set_attribute("text", co->get_text());
	}
	else if (comp->get_tag_name() == "menubar")
	{
		// clan::MenuBar *co = dynamic_cast<clan::MenuBar*>(comp);
	}
	else if (comp->get_tag_name() == "statusbar")
	{
		// clan::StatusBar *co = dynamic_cast<clan::StatusBar*>(comp);
	}
	else if (comp->get_tag_name() == "toolbar")
	{
		// clan::ToolBar *co = dynamic_cast<clan::ToolBar*>(comp);
	}
	else if (comp->get_tag_name() == "imageview")
	{
		// clan::ImageView *co = dynamic_cast<clan::ImageView*>(comp);
	}
	else if (comp->get_tag_name() == "listview")
	{
		clan::ListView *co = dynamic_cast<clan::ListView*>(comp);
		save_listview(e, co);
	}
	else if (comp->get_tag_name() == "slider")
	{
		clan::Slider *co = dynamic_cast<clan::Slider*>(comp);
		e.set_attribute("min", clan::StringHelp::int_to_text(co->get_min()));
		e.set_attribute("max", clan::StringHelp::int_to_text(co->get_max()));
		e.set_attribute("ticks", clan::StringHelp::int_to_text(co->get_tick_count()));
		e.set_attribute("page_step", clan::StringHelp::int_to_text(co->get_page_step()));
	}
	else if (comp->get_tag_name() == "tab")
	{
		clan::Tab *co = dynamic_cast<clan::Tab*>(comp);

		clan::GUIComponent *child = co->get_first_child();
		while (child != 0)
		{
			if (child->get_tag_name() == "tabpage")
			{
				clan::TabPage *tab_page = dynamic_cast<clan::TabPage*>(child);
				clan::DomElement tabpage_element = doc.create_element("tabpage");
				tabpage_element.set_attribute("label", tab_page->get_label());

				clan::GUIComponent *tabpage_child = child->get_first_child();
				while (tabpage_child != 0)
				{
					if (tabpage_child->get_tag_name() == "object")
					{
						GridObject *object_comp = dynamic_cast<GridObject*>(tabpage_child);
						clan::DomElement tabpage_child_element = object_comp->to_element(doc);
						tabpage_element.append_child(tabpage_child_element);
					}

					tabpage_child = tabpage_child->get_next_sibling();
				}

				e.append_child(tabpage_element);
			}

			child = child->get_next_sibling();
		}
		
	}
	else if (comp->get_tag_name() == "frame")
	{
		clan::Frame *co = dynamic_cast<clan::Frame*>(comp);
		e.set_attribute("text", co->get_header_text());

		clan::GUIComponent *child = co->get_first_child();
		while (child != 0)
		{
			if (child->get_tag_name() == "object")
			{
				GridObject *object_comp = dynamic_cast<GridObject*>(child);
				clan::DomElement frame_child_element = object_comp->to_element(doc);
				e.append_child(frame_child_element);
			}

			child = child->get_next_sibling();
		}

	}
	else if (comp->get_tag_name() == "spin")
	{
		// clan::Spin *co = dynamic_cast<clan::Spin*>(comp);
	}
	else if (comp->get_tag_name() == "combobox")
	{
		// clan::ComboBox *co = dynamic_cast<clan::ComboBox*>(comp);
	}
	else // custom component
	{
		// CustomComponent *co = dynamic_cast<CustomComponent*>(comp);
	}

	save_anchors(e,comp);
	save_geometry(e,comp); // write geom="..." attribute

	return e;
}
Esempio n. 6
0
Dialog::~Dialog()
{
    save_geometry();
    delete _behavior;
    _behavior = 0;
}
Esempio n. 7
0
/* Save user preferences to ~/.xdvirc. If `backup_only' is True,
   it only writes to ~/.xdvirc.tmp and does not remove this temporary
   file (this is used for synchronization between several xdvi instances).
*/
Boolean
save_user_preferences(Boolean full_save)
{
    char testbuf[1024];
    char *xdvirc_name;
    char *tmpname;
    FILE *from_fp, *to_fp;
    int fd;

    if (resource.no_init_file
	|| m_user_db == NULL) /* nothing to do */
	return True;
    
    if (resource.remember_windowsize)
	save_geometry();
    
    xdvirc_name = get_xdvirc_path(xdvirc_filename);

    if ((to_fp = fopen(xdvirc_name, "r")) != NULL) {
	TRACE_GUI((stderr, "~/.xdvirc exists, checking file contents ..."));
	if (fgets(testbuf, 1024, to_fp) != NULL &&
	    memcmp(testbuf, xdvirc_signature_line, strlen(xdvirc_signature_line)) != 0) {
	    popup_message(globals.widgets.top_level,
			  MSG_WARN,
			  "Xdvi uses the file ~/.xdvirc to save the preferences set via "
			  "the menu bar or the preferences dialog (in the Motif version only). "
			  "To avoid overwriting files created by the user, the first line of the "
			  "file is compared with a special signature line. If that signature line "
			  "is not found, the preferences won't be written. Your file doesn't seem "
			  "to contain that signature line. You should move the file to a safe location, "
			  "and then try to quit xdvi again.",
			  /* message */
			  "The file `%s' was apparently not written by xdvi(k). "
			  "Please move or delete this file first, then try to exit xdvi again. ",
			  xdvirc_name);
	    return False;
	}
	fclose(to_fp);
    }

    /* don't use xdvi_temp_fd here, since XrmPutFileDatabase()
       closes the FILE*, creating a temp race */
    tmpname = xstrdup(xdvirc_name);
    tmpname = xstrcat(tmpname, ".tmp");

    /* since XrmPutFileDatabase doesn't give a useful error message if it fails,
       check that creating the file works beforehand. The file is created with 0600 permissions. */
    if ((fd = try_open_mode(tmpname, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR)) < 0) {
	XDVI_ERROR((stderr, "Could not save preferences!\nOpening %s for writing failed: %s", tmpname, strerror(errno)));
	return True;
    }
    close(fd);
    
    XrmPutFileDatabase(m_user_db, tmpname);

    if (full_save) {
	if ((from_fp = try_fopen(tmpname, "r")) == NULL) {
	    XDVI_ERROR((stderr, "Could not save preferences!\nOpening %s for reading failed: %s", tmpname, strerror(errno)));
	    return True;
	}
	
	/* again, create the file with 600 permissions */
	if ((fd = try_open_mode(xdvirc_name, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) < 0) {
	    XDVI_ERROR((stderr, "Could not save preferences!\nOpening %s for writing failed: %s", xdvirc_name, strerror(errno)));
	    return True;
	}
	
	if ((to_fp = fdopen(fd, "w")) == NULL) {
	    XDVI_ERROR((stderr, "Could not save preferences!\nfdopen for %s for writing failed: %s", xdvirc_name, strerror(errno)));
	    return True;
	}
	
	if (fputs(xdvirc_signature_line, to_fp) == EOF
	    || fputs(xdvirc_header, to_fp) == EOF
	    || !copy_fp(from_fp, to_fp)) {
	    XDVI_ERROR((stderr, "Could not save preferences!\nError writing to %s: %s", xdvirc_name, strerror(errno)));
	}

	fclose(from_fp);
	fclose(to_fp);
    }
    
    free(xdvirc_name);

    if (full_save)
	unlink(tmpname);
    free(tmpname);

    return True;
}