~ubuntu-branches/ubuntu/trusty/pcmanfm/trusty-proposed

« back to all changes in this revision

Viewing changes to src/vfs/vfs-execute.c

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Lee
  • Date: 2008-09-26 10:19:20 UTC
  • mfrom: (4.1.5 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080926101920-cfldybkmwgwrtv9u
Tags: 0.5-3
* Correct spellings,  03_correct_spelling.dpatch (Closes:498794) 
* Code in some files are taken from other projects, added these
  informations into copyright file. (Closes:499678)
* Applied 04_defaut_terminal.dpatch to support x-terminal-emulator
  alternative. (Closes:497494) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
*  C Implementation: vfs-execute
3
3
*
4
 
* Description: 
 
4
* Description:
5
5
*
6
6
*
7
7
* Author: Hong Jen Yee (PCMan) <pcman.tw (AT) gmail.com>, (C) 2006
114
114
    char** new_env = envp;
115
115
    int i, n_env = 0;
116
116
    char* display_name;
117
 
    int display_index = -1;
118
 
    time_t cur_time;
 
117
    int display_index = -1, startup_id_index = -1;
119
118
 
120
119
    if ( ! envp )
121
120
        envp = environ;
122
121
 
123
 
    while ( envp[ n_env ] )
124
 
        ++n_env;
 
122
    n_env = g_strv_length(envp);
125
123
 
126
 
    new_env = g_new( char*, n_env + 2 );
 
124
    new_env = g_new0( char*, n_env + 4 );
127
125
    for ( i = 0; i < n_env; ++i )
128
126
    {
129
 
        if ( strncmp( envp[ i ], "DISPLAY=", 8 ) == 0 )
 
127
        /* g_debug( "old envp[%d] = \"%s\"" , i, envp[i]); */
 
128
        if ( 0 == strncmp( envp[ i ], "DISPLAY=", 8 ) )
130
129
            display_index = i;
131
 
        else if ( strncmp( envp[ i ], "DESKTOP_STARTUP_ID=", 19 ) )
132
 
            new_env[ i ] = g_strdup( envp[ i ] );
 
130
        else
 
131
        {
 
132
            if ( 0 == strncmp( envp[ i ], "DESKTOP_STARTUP_ID=", 19 ) )
 
133
                startup_id_index = i;
 
134
            new_env[i] = g_strdup( envp[ i ] );
 
135
        }
133
136
    }
134
137
 
135
138
    display = sn_display_new ( GDK_SCREEN_XDISPLAY ( screen ),
156
159
        sn_launcher_context_initiate( ctx, g_get_prgname(),
157
160
                                      argv[ 0 ], gtk_get_current_event_time() /*cur_time*/ );
158
161
 
159
 
        setup_func = sn_launcher_context_setup_child_process;
160
 
        new_env[ i++ ] = g_strconcat( "DESKTOP_STARTUP_ID=",
 
162
        setup_func = (GSpawnChildSetupFunc) sn_launcher_context_setup_child_process;
 
163
        if( startup_id_index >= 0 )
 
164
            g_free( new_env[i] );
 
165
        else
 
166
            startup_id_index = i++;
 
167
        new_env[ startup_id_index ] = g_strconcat( "DESKTOP_STARTUP_ID=",
161
168
                                      sn_launcher_context_get_startup_id ( ctx ), NULL );
162
169
    }
163
170
 
166
173
    if ( display_index >= 0 )
167
174
        new_env[ display_index ] = g_strconcat( "DISPLAY=", display_name, NULL );
168
175
    else
169
 
    {
170
 
        ++n_env;
171
176
        new_env[ i++ ] = g_strconcat( "DISPLAY=", display_name, NULL );
172
 
    }
 
177
 
173
178
    g_free( display_name );
174
179
    new_env[ i ] = NULL;
175
180
 
179
184
                         NULL, NULL,
180
185
                         NULL, err );
181
186
 
 
187
    /* for debugging */
 
188
#if 0
 
189
    g_debug( "debug vfs_execute_on_screen(): flags: %d, display_index=%d", flags, display_index );
 
190
    for( i = 0; argv[i]; ++i ) {
 
191
        g_debug( "argv[%d] = \"%s\"" , i, argv[i] );
 
192
    }
 
193
    for( i = 0; i < n_env /*new_env[i]*/; ++i ) {
 
194
        g_debug( "new_env[%d] = \"%s\"" , i, new_env[i] );
 
195
    }
 
196
    if( ret )
 
197
        g_debug( "the program was executed without error" );
 
198
    else
 
199
        g_debug( "launch failed: %s", (*err)->message );
 
200
#endif
 
201
 
182
202
    g_strfreev( new_env );
183
203
 
184
204
    if ( G_LIKELY ( ctx ) )
185
205
    {
186
206
        if ( G_LIKELY ( ret ) )
187
 
            g_timeout_add ( 30 * 1000, sn_timeout, ctx );
 
207
            g_timeout_add ( 20 * 1000, sn_timeout, ctx );
188
208
        else
189
209
        {
190
210
            sn_launcher_context_complete ( ctx );