Ejemplo n.º 1
0
void handle_file_ide (gchar *filename, gint line)
{
  if (! filename || ! cur_tea_project)
     return;
 
  gchar *cmd = g_strconcat (cur_tea_project->dir_source, filename, NULL);
 
  gint i = get_n_page_by_filename (cmd);

  if (i != -1)
     {
      gtk_notebook_set_current_page (GTK_NOTEBOOK(notebook1), i);
      if (get_page_text ())
          doc_select_line (cur_text_doc, line); 
      return;
     } 

  if (! g_file_test (cmd, G_FILE_TEST_EXISTS))
     return;
 
  else
      {
       if (! get_page_text() )
          cur_settings.selected_enc = ch_str (cur_settings.selected_enc, "UTF-8");
       else
           cur_settings.selected_enc = ch_str (cur_settings.selected_enc, cur_text_doc->encoding);

       cur_text_doc = open_file_std (cmd);
       doc_select_line (cur_text_doc, line);
      }
}
Ejemplo n.º 2
0
void handle_file (gchar const *filename, gint mode)
{
	if (! filename)
		return;

	gchar *cmd = NULL;

	gint i = get_n_page_by_filename (filename);

	if (i != -1)
	{
		gtk_notebook_set_current_page (GTK_NOTEBOOK(notebook1), i);
		return;
	} 

	if (! g_file_test (filename, G_FILE_TEST_EXISTS))
		return;

	if (is_image (filename))
	{
		if (mode != 0)
		{
			cmd = g_strdup_printf (confile.ext_pic_editor, filename);
			if(system (cmd) == -1){printf("\n");}
			g_free (cmd);
			return;
		}

	if (confile.use_ext_image_viewer)
	{
		cmd = g_strdup_printf (confile.ext_pic_editor, filename);
		if(system (cmd) == -1){printf("\n");}
			g_free(cmd);
				return;
	}
	else  
		create_wnd_imgviewer (filename);

	return;
	}
  
	if (! get_page_text() )
		cur_settings.selected_enc = ch_str (cur_settings.selected_enc, confile.default_charset);
	else
		cur_settings.selected_enc = ch_str (cur_settings.selected_enc, cur_text_doc->encoding);

	open_file_std (filename);
}
Ejemplo n.º 3
0
void tea_proj_save_as (t_tea_project *p, gchar *name)
{
    if (! p)
        return;

    if (! name)
        return;

    p->project_file_name = ch_str (p->project_file_name, name);

    GList *l = NULL;

    gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(buffer_projet), "\nProeject file name :\n", -1);
    gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(buffer_projet), p->project_file_name, -1);
    gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(buffer_projet), "\n\n", -1);
    gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(buffer_projet), "\nfile_executable=", -1);
    gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(buffer_projet), p->file_executable, -1);
    gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(buffer_projet), "\nproject_name=", -1);
    gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(buffer_projet), p->project_name, -1);
    gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(buffer_projet), "\ndir_makefile=", -1);
    gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(buffer_projet), p->dir_makefile, -1);
    gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(buffer_projet), "\ndir_source=", -1);
    gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(buffer_projet), p->dir_source, -1);

    l = add_to_glist_combined_str (l, "file_executable", p->file_executable);
    l = add_to_glist_combined_str (l, "project_name", p->project_name);
    l = add_to_glist_combined_str (l, "project_file_name", p->project_file_name);
    l = add_to_glist_combined_str (l, "dir_makefile", p->dir_makefile);
    l = add_to_glist_combined_str (l, "dir_source", p->dir_source);

    glist_save_to_file (l, p->project_file_name);
    g_list_free (l);
}
Ejemplo n.º 4
0
//Leafpad code by Tarot Osuji <*****@*****.**>
//modified by roxton
gchar *detect_charset_zh(const gchar *text)
{
	guint8 c = *text;
	gchar *charset = g_strdup ("GB2312");
	
	while ((c = *text++) != '\0') {
		if (c >= 0x81 && c <= 0x87) {
			charset = ch_str (charset, "GB18030");
			break;
		}
		else if (c >= 0x88 && c <= 0xA0) {
			c = *text++;
			if ((c >= 0x30 && c <= 0x39) || (c >= 0x80 && c <= 0xA0)) {
				charset = ch_str (charset, "GB18030");
				break;
			} //else GBK/Big5-HKSCS cannot determine
		}
		else if ((c >= 0xA1 && c <= 0xC6) || (c >= 0xC9 && c <= 0xF9)) {
			c = *text++;
			if (c >= 0x40 && c <= 0x7E)
				charset = ch_str ("Big5", charset);
			else if ((c >= 0x30 && c <= 0x39) || (c >= 0x80 && c <= 0xA0)) {
				charset = ch_str (charset, "GB18030");
				break;
			}
		}
		else if (c >= 0xC7) {
			c = *text++;
			if ((c >= 0x30 && c <= 0x39) || (c >= 0x80 && c <= 0xA0)) {
				charset = ch_str (charset, "GB18030");
				break;
			}
		}
	}
	
	return charset;
}
Ejemplo n.º 5
0
t_tea_project* tea_proj_open (gchar *name)
{
    t_tea_project *r = tea_proj_new ();
    GHashTable *ht = load_file_to_hashtable (name);

    r->project_name = ht_get_gchar_value (ht, "project_name", "noname");
    r->project_file_name = ch_str (r->project_file_name, name);
    r->dir_makefile = ht_get_gchar_value (ht, "dir_makefile", "noname");
    r->dir_source = ht_get_gchar_value (ht, "dir_source", "noname");
    r->file_executable = ht_get_gchar_value (ht, "file_executable", "noname");

    gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(filechooserwidget2) ,r->dir_source);

    g_hash_table_destroy (ht);
    return r;
}
Ejemplo n.º 6
0
gchar *detect_charset_ja(const gchar *text)
{
   if (enc_is_iso_2022_jp (text))
      return g_strdup ("ISO-2022-JP-2");

   if ( g_utf8_validate (text, -1, 0) )
      return g_strdup ("UTF-8");

	guint8 c = *text;
	gchar *charset = NULL;
	
	while (charset == NULL && (c = *text++) != '\0') {
		if (c >= 0x81 && c <= 0x9F) {
			if (c == 0x8E) /* SS2 */ {
				c = *text++;
				if ((c >= 0x40 && c <= 0xA0) || (c >= 0xE0 && c <= 0xFC))
					charset = ch_str (charset, "Shift_JIS");
			}
			else if (c == 0x8F) /* SS3 */ {
				c = *text++;
				if (c >= 0x40 && c <= 0xA0)
					charset = ch_str (charset, "Shift_JIS");
				else if (c >= 0xFD)
					break;
			}
			else
				charset = ch_str (charset, "Shift_JIS");
		}
		else if (c >= 0xA1 && c <= 0xDF) {
			c = *text++;
			if (c <= 0x9F)
				charset = ch_str (charset, "Shift_JIS");
			else if (c >= 0xFD)
				break;
		}
		else if (c >= 0xE0 && c <= 0xEF) {
			c = *text++;
			if (c >= 0x40 && c <= 0xA0)
				charset = ch_str (charset, "Shift_JIS");
			else if (c >= 0xFD)
				break;
		}
		else if (c >= 0xF0)
			break;
	}
	
	if (! charset)
		charset = ch_str (charset, "EUC-JP");
	
	return charset;
}
Ejemplo n.º 7
0
void handle_file_enc (gchar *filename, gchar *enc)
{
	if (! filename)
		return;

	gint i = get_n_page_by_filename (filename);

	if (i != -1)
	{
		gtk_notebook_set_current_page (GTK_NOTEBOOK(notebook1), i);
		return;
	} 

	if (! g_file_test (filename, G_FILE_TEST_EXISTS))
		return;

	cur_settings.selected_enc = ch_str (cur_settings.selected_enc, enc);

	open_file_std (filename);
}