예제 #1
0
gchar *
gimv_filename_to_internal (const gchar *filename)
{
	return charset_to_internal (filename,
                               conf.charset_filename,
                               conf.charset_auto_detect_fn,
                               conf.charset_filename_mode);
}
예제 #2
0
파일: thumbview.c 프로젝트: gentoo/pornview
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;
}
예제 #3
0
파일: thumbview.c 프로젝트: gentoo/pornview
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);
    }
}