static void cb_comment_editlist_updated (EditableList * editlist) { gchar *string, *tmp; gint row, rows = editable_list_get_n_rows (editlist); g_return_if_fail (IS_EDITABLE_LIST (editlist)); if (config_changed->comment_key_list != config_prechanged->comment_key_list) g_free (config_changed->comment_key_list); config_changed->comment_key_list = NULL; string = g_strdup (""); for (row = 0; row < rows; row++) { CommentDataEntry *entry; gchar *dname_internal; entry = editable_list_get_row_data (editlist, row); if (!entry) continue; if (!entry->key || !*entry->key) continue; if (!entry->display_name || !*entry->display_name) continue; tmp = string; if (*string) { string = g_strconcat (string, "; ", NULL); g_free (tmp); tmp = string; } dname_internal = charset_internal_to_locale (entry->display_name); string = g_strconcat (string, entry->key, ",", dname_internal, ",", boolean_to_text (entry->enable), ",", boolean_to_text (entry->auto_val), ",", boolean_to_text (entry->display), NULL); g_free (dname_internal); g_free (tmp); tmp = NULL; } config_changed->comment_key_list = string; }
gchar * gimv_filename_to_locale (const gchar *filename) { return charset_internal_to_locale (filename); }
static void cb_open_image_by_script (GtkWidget * menuitem, ThumbView * tv) { ZAlbumCell *cell; GList *node; gchar *script, *cmd = NULL, *tmpstr = NULL, *user_cmd; g_return_if_fail (menuitem && tv); node = ZLIST (tv->album)->selection; if (!node) return; script = gtk_object_get_data (GTK_OBJECT (menuitem), "script"); if (!script || !script || !isexecutable (script)) goto ERROR; cmd = g_strdup (script); /* * create command string */ while (node) { cell = ZLIST_CELL_FROM_INDEX (ZLIST (thumbview->album), (guint) node->data); tmpstr = g_strconcat (cmd, " ", "\"", cell->name, "\"", NULL); g_free (cmd); cmd = tmpstr; node = g_list_next (node); } tmpstr = g_strconcat (cmd, " &", NULL); g_free (cmd); cmd = tmpstr; tmpstr = NULL; { tmpstr = cmd; cmd = charset_to_internal (cmd, conf.charset_filename, conf.charset_auto_detect_fn, conf.charset_filename_mode); g_free (tmpstr); tmpstr = NULL; if (conf.scripts_show_dialog) { user_cmd = dialog_textentry (_("Execute script"), _("Please enter options:"), cmd, NULL, 400, TEXT_ENTRY_WRAP_ENTRY | TEXT_ENTRY_CURSOR_TOP); } else { user_cmd = g_strdup (cmd); } g_free (cmd); cmd = NULL; tmpstr = user_cmd; user_cmd = charset_internal_to_locale (user_cmd); g_free (tmpstr); tmpstr = NULL; } /* * exec command */ if (user_cmd) { { /********** convert charset **********/ tmpstr = user_cmd; user_cmd = charset_internal_to_locale (user_cmd); g_free (tmpstr); tmpstr = NULL; } system (user_cmd); g_free (user_cmd); user_cmd = NULL; } ERROR: return; }
static void cb_open_image_by_external (GtkWidget * menuitem, ThumbView * tv) { GList *node; ZAlbumCell *cell; gint action; gchar *user_cmd, *cmd = NULL, *tmpstr = NULL, **pair; gboolean show_dialog = FALSE; g_return_if_fail (menuitem && tv); node = ZLIST (tv->album)->selection; if (!node) return; action = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (menuitem), "num")); /* * find command */ if (action < sizeof (conf.progs) / sizeof (conf.progs[0])) { pair = g_strsplit (conf.progs[action], ",", 3); if (!pair[1]) { g_strfreev (pair); return; } else { cmd = g_strdup (pair[1]); } if (pair[2] && !g_strcasecmp (pair[2], "TRUE")) show_dialog = TRUE; g_strfreev (pair); } else { return; } /* * create command string */ while (node) { cell = ZLIST_CELL_FROM_INDEX (ZLIST (thumbview->album), (guint) node->data); tmpstr = g_strconcat (cmd, " ", "\"", cell->name, "\"", NULL); g_free (cmd); cmd = tmpstr; node = g_list_next (node); } tmpstr = g_strconcat (cmd, " &", NULL); g_free (cmd); cmd = tmpstr; tmpstr = NULL; tmpstr = cmd; cmd = charset_to_internal (cmd, conf.charset_filename, conf.charset_auto_detect_fn, conf.charset_filename_mode); g_free (tmpstr); tmpstr = NULL; if (show_dialog) { user_cmd = dialog_textentry (_("Execute command"), _("Please enter options:"), cmd, NULL, 400, TEXT_ENTRY_WRAP_ENTRY | TEXT_ENTRY_CURSOR_TOP); } else { user_cmd = g_strdup (cmd); } g_free (cmd); cmd = NULL; /* * exec command */ if (user_cmd) { tmpstr = user_cmd; user_cmd = charset_internal_to_locale (user_cmd); g_free (tmpstr); tmpstr = NULL; system (user_cmd); g_free (user_cmd); } }