[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: New prerelease out.



On Friday 23 July 2004 01:37, Lars Clausen wrote:
> I'm putting out this pre2 release now not so much because
Hello, 
Some notes:
1. Please remove app/diaconv.c from po/POFILES.in
2. file /usr/share/dia/shapes/Network/patch-panel.png missing

There is attached patch for fix filename encoding issues in 
filedialog, Diagram's name, recent_files. I assume diagram and 
recent_files functions operates with filename in filesystem 
encoding. I check for memory leak issues (pair 
g_filename_from/to_utf8 - g_free), it works for me in such 
problematic russian locale.
Please check and commit it. It will be beautyful for release.

-- 
Lav
Vitaly Lipatov
Russia, Saint-Petersburg
GNU! ALT Linux Team! LaTeX! LyX!


diff -urNa /home/lav/work/build/BUILD/dia-0.94/app/app_procs.c app/app_procs.c
--- /home/lav/work/build/BUILD/dia-0.94/app/app_procs.c	2004-07-08 00:47:15 +0400
+++ app/app_procs.c	2004-07-23 13:43:39 +0400
@@ -577,7 +577,10 @@
   made_conversions = handle_all_diagrams(files, export_file_name,
 					 export_file_format, size);
   if (dia_is_interactive && files == NULL) {
-    Diagram *diagram = new_diagram (_("Diagram1.dia"));
+    gchar *filename = g_filename_from_utf8(_("Diagram1.dia"), -1, NULL, NULL, NULL);
+    Diagram *diagram = new_diagram (filename);
+    g_free(filename);
+	
 	      
     if (diagram != NULL) {
       diagram_update_extents(diagram);
diff -urNa /home/lav/work/build/BUILD/dia-0.94/app/diagram.c app/diagram.c
--- /home/lav/work/build/BUILD/dia-0.94/app/diagram.c	2004-07-02 00:31:45 +0400
+++ app/diagram.c	2004-07-23 13:02:21 +0400
@@ -141,7 +141,8 @@
 
   if (dia->filename != NULL)
     g_free(dia->filename);
-  dia->filename = g_strdup(filename);
+  /* All Diagram functions assumes filename in filesystem encoding */
+  dia->filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
   
   dia->unsaved = TRUE;
   dia->mollified = FALSE;
@@ -1274,7 +1275,7 @@
   char *title;
   
   g_free(dia->filename);
-  dia->filename = g_strdup(filename);
+  dia->filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
 
   title = diagram_get_name(dia);
 
diff -urNa /home/lav/work/build/BUILD/dia-0.94/app/filedlg.c app/filedlg.c
--- /home/lav/work/build/BUILD/dia-0.94/app/filedlg.c	2004-07-23 00:51:43 +0400
+++ app/filedlg.c	2004-07-23 13:42:13 +0400
@@ -175,6 +175,7 @@
   if (!opendlg) {
     DDisplay *ddisp;
     Diagram *dia = NULL;
+    gchar *filename = NULL;
     
     ddisp = ddisplay_active();
     if (ddisp) {
@@ -183,9 +184,12 @@
     opendlg = gtk_file_selection_new(_("Open Diagram"));
     gtk_window_set_role(GTK_WINDOW(opendlg), "open_diagram");
     gtk_window_set_position(GTK_WINDOW(opendlg), GTK_WIN_POS_MOUSE);
-    gtk_file_selection_set_filename(GTK_FILE_SELECTION(opendlg),
-				    dia && dia->filename ? dia->filename
-				    : "." G_DIR_SEPARATOR_S);
+    if (dia && dia->filename)
+      filename = g_filename_from_utf8(dia->filename, -1, NULL, NULL, NULL);
+    if (filename == NULL)
+      filename = g_strdup("." G_DIR_SEPARATOR_S);
+    gtk_file_selection_set_filename(GTK_FILE_SELECTION(opendlg), filename);
+    g_free(filename);
     g_signal_connect_swapped(
 		GTK_OBJECT(GTK_FILE_SELECTION(opendlg)->cancel_button),
 	    "clicked", G_CALLBACK(file_dialog_hide),
@@ -249,9 +253,8 @@
     GtkWidget *dialog = NULL;
     char buffer[300];
     char *utf8filename = NULL;
-
     if (!g_utf8_validate(filename, -1, NULL)) {
-      utf8filename = g_locale_to_utf8(filename, -1, NULL, NULL, NULL);
+      utf8filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
       if (utf8filename == NULL) {
 	message_warning(_("Some characters in the filename are neither UTF-8 nor your local encoding.\nSome things will break."));
       }
@@ -293,6 +296,7 @@
 {
   DDisplay *ddisp;
   Diagram *dia;
+  gchar *filename = NULL;
 
   ddisp = ddisplay_active();
   if (!ddisp) return;
@@ -338,9 +342,12 @@
     if (GTK_WIDGET_VISIBLE(savedlg))
       return;
   }
-  gtk_file_selection_set_filename(GTK_FILE_SELECTION(savedlg),
-				  dia->filename ? dia->filename
-				  : "." G_DIR_SEPARATOR_S);
+  if (dia && dia->filename)
+    filename = g_filename_from_utf8(dia->filename, -1, NULL, NULL, NULL);
+  if (filename == NULL)
+    filename = g_strdup("." G_DIR_SEPARATOR_S);
+  gtk_file_selection_set_filename(GTK_FILE_SELECTION(savedlg), filename);
+  g_free(filename);
   gtk_object_set_user_data(GTK_OBJECT(savedlg), dia);
   diagram_add_related_dialog(dia, savedlg);
   g_object_ref(dia); 
@@ -475,6 +482,7 @@
   DDisplay *ddisp;
   Diagram *dia;
   GtkWidget *export_menu, *export_item;
+  gchar *filename = NULL;
 
   ddisp = ddisplay_active();
   if (!ddisp) return;
@@ -484,9 +492,12 @@
     exportdlg = gtk_file_selection_new(_("Export Diagram"));
     gtk_window_set_role(GTK_WINDOW(exportdlg), "export_diagram");
     gtk_window_set_position(GTK_WINDOW(exportdlg), GTK_WIN_POS_MOUSE);
-    gtk_file_selection_set_filename(GTK_FILE_SELECTION(exportdlg),
-				    dia->filename ? dia->filename
-				    : "." G_DIR_SEPARATOR_S);
+    if (dia && dia->filename)
+      filename = g_filename_from_utf8(dia->filename, -1, NULL, NULL, NULL);
+    if (filename == NULL)
+      filename = g_strdup("." G_DIR_SEPARATOR_S);
+    gtk_file_selection_set_filename(GTK_FILE_SELECTION(exportdlg), filename);
+	g_free(filename);
     g_signal_connect_swapped(
 		GTK_OBJECT(GTK_FILE_SELECTION(exportdlg)->cancel_button),
 	    "clicked", G_CALLBACK(file_dialog_hide),
@@ -531,9 +542,12 @@
   gtk_widget_set_sensitive(exportdlg, TRUE);
   if (GTK_WIDGET_VISIBLE(exportdlg))
     return;
-  gtk_file_selection_set_filename(GTK_FILE_SELECTION(exportdlg),
-				  dia->filename ? dia->filename
-				  : "." G_DIR_SEPARATOR_S);
+  if (dia && dia->filename)
+    filename = g_filename_from_utf8(dia->filename, -1, NULL, NULL, NULL);
+  if (filename == NULL)
+    filename = g_strdup("." G_DIR_SEPARATOR_S);
+  gtk_file_selection_set_filename(GTK_FILE_SELECTION(exportdlg), filename);
+  g_free(filename);
   export_menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(export_omenu));
   export_item = gtk_menu_get_active(GTK_MENU(export_menu));
   if (export_item)
diff -urNa /home/lav/work/build/BUILD/dia-0.94/app/recent_files.c app/recent_files.c
--- /home/lav/work/build/BUILD/dia-0.94/app/recent_files.c	2004-06-07 17:13:48 +0400
+++ app/recent_files.c	2004-07-23 13:35:40 +0400
@@ -100,12 +100,6 @@
     GtkAccelGroup *accel_group;
     
     basename = g_path_get_basename(filename);
-    /* g_strdelimit does not copy.*/
-    g_strdelimit(basename, "_", '\\');
-    escaped  = g_strescape(basename, NULL);
-    g_free(basename);
-    basename = escaped;
-    g_strdelimit(basename, "\\", '_');
     
     label = g_strdup_printf("%d. %s", pos+1, basename);
     item = gtk_menu_item_new_with_label(label);
@@ -169,9 +163,11 @@
 recent_file_history_add(const char *fname)
 {
     gchar *absname = dia_get_absolute_filename(fname);
+	gchar *filename = g_filename_to_utf8(absname, -1, NULL, NULL, NULL);
     recent_file_history_clear_menu();
-    persistent_list_add("recent-files", absname);
+    persistent_list_add("recent-files", filename);
     g_free(absname);
+    g_free(filename);
     
     recent_file_history_make_menu();
 }
@@ -197,10 +193,12 @@
 recent_file_history_remove (const char *fname) 
 {
     gchar *absname = dia_get_absolute_filename(fname);
+	gchar *filename = g_filename_to_utf8(absname, -1, NULL, NULL, NULL);
     recent_file_history_clear_menu();
 
-    persistent_list_remove("recent-files", absname);
+    persistent_list_remove("recent-files", filename);
     g_free(absname);
+    g_free(filename);
 
     recent_file_history_make_menu();
 }
@@ -210,7 +208,7 @@
 {
 	DiaImportFilter *ifilter = NULL;
 	Diagram *diagram = NULL;
-	gchar *filename = (gchar *)data;
+	gchar *filename = g_filename_from_utf8((gchar *)data, -1, NULL, NULL, NULL);
 
 	ifilter = filter_guess_import_filter(filename);
 	
@@ -221,4 +219,5 @@
 	    new_display(diagram);
 	} else
 	    recent_file_history_remove (filename);
+	g_free(filename);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] Mail converted by Mofo Magic and the Flying D

 
All trademarks and copyrights are the property of their respective owners.

Other Directory Sites: SeekWonder | Directory Owners Forum

GuideSMACK