Example #1
0
GLADE_CB void
on_delete_clicked                      (GtkToolButton   *toolbutton,
                                        gpointer         user_data)
{
	GList *ptr;

	if(GFMFile.trees.vars == NULL)
		return;

	ctree_selection_get();

	for(ptr = gfm_widget.sel1; ptr; ptr = ptr->next)
	{
		VarEntry *ve = (VarEntry *)ptr->data;

		ticalcs_dirlist_ve_del(GFMFile.trees.vars, ve);
	}

	for(ptr = gfm_widget.sel2; ptr; ptr = ptr->next)
	{
		VarEntry *ve = (VarEntry *)ptr->data;

		ticalcs_dirlist_ve_del(GFMFile.trees.apps, ve);
	}

	ctree_selection_destroy();

	ctree_refresh();

	enable_save(TRUE);
}
Example #2
0
GLADE_CB void
on_new_clicked                         (GtkToolButton   *toolbutton,
                                        gpointer         user_data)
{
	CalcModel model;
	int result;
	
	result = msgbox_three(_("TiGroup"), _("Single/Group"), _("File type?"));
	if(!result)
		return;

	model = msgbox_model();
	if(!model)
		return;

	file_create(result == MSGBOX_BUTTON1 ? TIFILE_TIGROUP : TIFILE_GROUP, model);

	g_free(GFMFile.filename);
	GFMFile.filename = NULL;
	enable_save(FALSE);
	enable_tree(TRUE);

	ctree_refresh();
	labels_refresh();
}
Example #3
0
GLADE_CB void
on_add_clicked                         (GtkToolButton   *toolbutton,
                                        gpointer         user_data)
{
	char **array, **ptr;
	CalcModel model;
	FileContent *content;
	int ret;
	unsigned int i;

	array = create_fsels(inst_paths.home_dir, "", "*.*");
	if(array == NULL)
		return;

	for(ptr = array; *ptr; ptr++)
	{
		char *fn = *ptr;

		if(tifiles_file_is_tigroup(fn))
		{
			msgbox_one(MSGBOX_ERROR, _("Importing of TiGroup files is not allowed."));
			return;
		}

		model = tifiles_file_get_model(fn);
		if(!tifiles_calc_are_compat(GFMFile.model, model))
		{
			msgbox_one(MSGBOX_ERROR, _("File is not compatible with current target."));
			return;
		}

		content = tifiles_content_create_regular(model);
		ret = tifiles_file_read_regular(fn, content);

		for(i = 0; i < content->num_entries; i++)
		{
			VarEntry *ve = content->entries[i];

			if(ticalcs_dirlist_ve_exist(GFMFile.trees.vars, ve))
			{
				msgbox_one(MSGBOX_ERROR, _("The entry already exists. Skipped!"));
				continue;
			}

			ticalcs_dirlist_ve_add(GFMFile.trees.vars, ve);
		}

		ret = tifiles_content_delete_regular(content);
	}

	enable_save(TRUE);
	enable_tree(TRUE);

	ctree_refresh();
	labels_refresh();
}
Example #4
0
GLADE_CB void
on_save_clicked                        (GtkToolButton   *toolbutton,
                                        gpointer         user_data)
{
	gchar *fn = NULL, *ext = NULL;
	gchar *filename = NULL;

	if(GFMFile.filename != NULL)
		filename = g_strdup(GFMFile.filename);

	if(GFMFile.type & TIFILE_TIGROUP)
	{
		ext = g_strdup("*.tig");
	}
	else if(GFMFile.type & TIFILE_GROUP)
	{
		if(ticalcs_dirlist_ve_count(GFMFile.trees.vars) > 1)
		{
			// Group file
			ext = g_strconcat("*.", tifiles_vartype2fext(GFMFile.model, 0x00), NULL);
			ext[4] = 'g';
		}
		else if(ticalcs_dirlist_ve_count(GFMFile.trees.vars) == 1)
		{
			// Single file
			GNode *parent, *child;
			VarEntry *ve;

			parent = g_node_nth_child(GFMFile.trees.vars, 0);
			child = g_node_nth_child(parent, 0);
			ve = (VarEntry *) (child->data);

			filename = g_strconcat(ticonv_varname_to_filename(GFMFile.model, ve->name, ve->type), ".", 
				tifiles_vartype2fext(GFMFile.model, ve->type), NULL);
			ext = g_strconcat("*.", tifiles_vartype2fext(GFMFile.model, ve->type), NULL);
		}
		else
		{
			g_free(filename);
			return;
		}
	}

	fn = (char *)create_fsel(inst_paths.home_dir, filename, ext, TRUE);
	if(fn == NULL)
		return;
	g_free(filename);
	g_free(ext);

	file_save(fn);

	g_free(GFMFile.filename);
	GFMFile.filename = g_strdup(fn);

	enable_save(FALSE);
}
Example #5
0
notepad::notepad() : QWidget(NULL)
{
  QVBoxLayout* top_layout = new QVBoxLayout(this);
  m_we = new QPlainTextEdit(this);

  QHBoxLayout* hbl = new QHBoxLayout;
  top_layout->addLayout(hbl);

//  m_save_button = new QPushButton(tr("Save"));

  QToolBar* toolbar = new QToolBar();
  toolbar->setIconSize(QSize(16,16));
  toolbar->setFloatable(true);
  m_action_save = toolbar->addAction(tr("Save"), this, SLOT(save()));
  
  top_layout->addWidget(toolbar);
  top_layout->addWidget(m_we);
//  hbl->addWidget(m_save_button);
//  hbl->setStretchFactor(m_save_button, 0);
//  hbl->addStretch(1);

  QIcon ico_cut(UI_ICON(FT_ICON16_EDIT_CUT));
  QIcon ico_copy(UI_ICON(FT_ICON16_EDIT_COPY));
  QIcon ico_paste(UI_ICON(FT_ICON16_EDIT_PASTE));
  QIcon ico_undo(UI_ICON(FT_ICON16_UNDO));
  QIcon ico_redo(UI_ICON(FT_ICON16_REDO));
  toolbar->addSeparator();

  toolbar->addAction(ico_cut, tr("Cut"), m_we, SLOT(cut()));
  toolbar->addAction(ico_copy, tr("Copy"), m_we, SLOT(copy()));
  toolbar->addAction(ico_paste, tr("Paste"), m_we, SLOT(paste()));
  toolbar->addAction(ico_undo, tr("Undo"), m_we, SLOT(undo()));
  toolbar->addAction(ico_redo, tr("Redo"), m_we, SLOT(redo()));

  //  connect(m_save_button, SIGNAL(clicked()), this, SLOT(save()));
  load();
  disable_save();

  m_timer = new QTimer(this);
  connect(m_timer, SIGNAL(timeout()), this, SLOT(auto_save()));
  m_timer->start(60*1000); // auto-save every minute

  connect(m_we, SIGNAL(textChanged()), this, SLOT(enable_save()));

  setWindowTitle(tr("Global Notepad"));
  setWindowIcon(UI_ICON(ICON16_NOTEPAD));
  resize(640, 400);
}
Example #6
0
GLADE_CB void
on_open_clicked                        (GtkToolButton   *toolbutton,
                                        gpointer         user_data)
{
	gchar *fn;

	if(user_data == NULL)
	{
		if(GFMFile.contents.group || GFMFile.contents.tigroup)
		{
			int result = msgbox_two(MSGBOX_YESNO, _("Do you want to save previous file?"));
			if(result == MSGBOX_YES)
				on_save_clicked(toolbutton,user_data);
		}

		fn = (char *)create_fsel(inst_paths.home_dir, "", "*.73?;*.82?;*.83?;*.8X?;*.85?;*.86?;*.89?;*.92?;*.9x?;*.V2?;*.tig", FALSE);
		if(fn == NULL)
			return;
	}
	else
	{
		// command line
		fn = (char *)user_data;
	}

	if(tifiles_file_is_tigroup(fn))
		GFMFile.type = TIFILE_TIGROUP;
	else if(tifiles_file_is_regular(fn))
		GFMFile.type = TIFILE_GROUP;
	else
		return;

	file_load(fn);

	g_free(GFMFile.filename);
	GFMFile.filename = g_strdup(fn);

	enable_save(FALSE);
	enable_tree(TRUE);

	ctree_refresh();
	labels_refresh();

	g_free(inst_paths.home_dir);
	inst_paths.home_dir = g_path_get_dirname(GFMFile.filename);
}
Example #7
0
/* The Main Interface Launcher */
int launch_gfmgui(void)
{
    GladeXML *xml;
    GtkWidget *widget;

    // Load the GFM Dialog from gfm.glade
    xml = glade_xml_new(paths_build_glade("gfm.glade"), "gfm_dbox", NULL);

    // Glade File Error
    if (!xml)
        g_error("Failure GFM GUI (%s)!\n", __FILE__);
		
    // Connect The Symbols
    glade_xml_signal_autoconnect(xml);
		
    // Retrieve the dialog widget
    widget = glade_xml_get_widget(xml, "gfm_dbox");

    // Global Widget Access
	gfm_widget.tree = glade_xml_get_widget(xml, "treeview1");
	gfm_widget.model = glade_xml_get_widget(xml, "label6");
	gfm_widget.entries = glade_xml_get_widget(xml, "label7");
	gfm_widget.comment = glade_xml_get_widget(xml, "button1");
	gfm_widget.ram = glade_xml_get_widget(xml, "label9");
	gfm_widget.flash = glade_xml_get_widget(xml, "label10");
	gfm_widget.save = glade_xml_get_widget(xml, "toolbutton3");
	//gfm_widget.test = glade_xml_get_widget(xml, "label11");
	gfm_widget.pbar = glade_xml_get_widget(xml, "progressbar1");

	// Inits global vars
	enable_save(FALSE);
	enable_tree(FALSE);

	// Show the Widget
	ctree_init();
    gtk_widget_show(widget);

	if(cmdline_get() != NULL)
		on_open_clicked(NULL, (gpointer)cmdline_get());

    // Return
    return 0;
}
Example #8
0
static void renderer_edited(GtkCellRendererText * cell,
			    const gchar * path_string,
			    const gchar * new_text, gpointer user_data)
{
	GtkTreeModel *model = GTK_TREE_MODEL(tree);
	GtkTreePath *path = gtk_tree_path_new_from_string(path_string);
	GtkTreeIter iter;
	const char *old_text;
	VarEntry *ve;
	gchar *str;
	VarEntry *arg;

	if (!gtk_tree_model_get_iter(model, &iter, path))
		return;

	gtk_tree_model_get(model, &iter, COLUMN_NAME, &old_text, -1);
	gtk_tree_model_get(model, &iter, COLUMN_DATA, &ve, -1);

	// tokenize and check for existence
	str = ticonv_varname_tokenize(GFMFile.model, new_text, ve->type);
	arg = tifiles_ve_dup(ve);
	if(strlen(str) > 8)
		str[8] = '\0';
	strcpy(arg->name, str);
	ticonv_varname_free(str);

	if(ticalcs_dirlist_ve_exist(GFMFile.trees.vars, arg))
	{
		msgbox_one(MSGBOX_INFO, _("The name already exists. Please choose another one..."));
		tifiles_ve_delete(arg);
		return;
	}

	// update entry
	strcpy(ve->name, arg->name);
	tifiles_ve_delete(arg);

	gtk_tree_store_set(tree, &iter, COLUMN_NAME, new_text, -1);
	gtk_tree_path_free(path);

	enable_save(TRUE);
}