~paulliu/liblauncher/launchretvalue

« back to all changes in this revision

Viewing changes to launcher/launcher-session.c

  • Committer: Jason Smith
  • Date: 2010-03-12 17:16:09 UTC
  • mfrom: (96.1.2 liblauncher-async)
  • Revision ID: jason.smith@canonical.com-20100312171609-07je5bd99ldr2ytr
Merge async branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
{
52
52
  /* Application variables */
53
53
  WnckScreen *screen;
 
54
  GSList     *new_windows;
 
55
  int         callback_count;
54
56
};
55
57
 
56
58
enum
152
154
 */
153
155
 
154
156
static void
 
157
windows_updated_callback (LauncherApplication *application,
 
158
                          LauncherSession     *session)
 
159
{
 
160
  LauncherApplication    *new_app;
 
161
  LauncherAppman         *appman;
 
162
  LauncherSessionPrivate *priv;
 
163
  GSList                 *l, *found_windows = NULL;
 
164
  WnckWindow             *window;
 
165
 
 
166
  g_return_if_fail (LAUNCHER_IS_SESSION (session));
 
167
  g_return_if_fail (LAUNCHER_IS_APPLICATION (application));
 
168
  
 
169
  priv = session->priv;
 
170
  
 
171
  appman = launcher_appman_get_default ();
 
172
  
 
173
  for (l = priv->new_windows; l; l = l->next)
 
174
    {
 
175
      window = l->data;
 
176
      
 
177
      if (launcher_application_owns_window (application, window))
 
178
        {
 
179
          found_windows = g_slist_prepend (found_windows, window);
 
180
          if (g_slist_length (launcher_application_get_windows (application)) == 1)
 
181
            {
 
182
              g_signal_emit (session, _session_signals[APP_OPENED], 0, application);
 
183
            }
 
184
        }
 
185
    }
 
186
  
 
187
  for (l = found_windows; l; l = l->next)
 
188
    {
 
189
      priv->new_windows = g_slist_remove_all (priv->new_windows, l->data);
 
190
    }
 
191
  
 
192
  g_slist_free (found_windows);
 
193
  
 
194
  priv->callback_count--;
 
195
  
 
196
  if (priv->callback_count <= 0)
 
197
    {
 
198
      priv->callback_count = 0;
 
199
      
 
200
      for (l = priv->new_windows; l; l = l->next)
 
201
        {
 
202
          new_app = launcher_appman_get_application_for_wnck_window (appman, window);
 
203
          g_signal_emit (session, _session_signals[APP_OPENED], 0, new_app);
 
204
        }
 
205
      
 
206
      g_slist_free (priv->new_windows);
 
207
      priv->new_windows = NULL;
 
208
    }
 
209
}
 
210
 
 
211
static void
155
212
on_window_opened (WnckScreen      *screen,
156
213
                  WnckWindow      *window,
157
214
                  LauncherSession *session)
161
218
  LauncherAppman           *appman;
162
219
  GSequence                *applications;
163
220
  GSequenceIter            *iter;
164
 
  gboolean                  found = FALSE;
165
221
  
166
222
  g_return_if_fail (LAUNCHER_IS_SESSION (session));
167
223
  g_return_if_fail (WNCK_IS_WINDOW (window));
171
227
  
172
228
  priv = session->priv;
173
229
  
 
230
  priv->new_windows = g_slist_prepend (priv->new_windows, window);
 
231
  
174
232
  appman = launcher_appman_get_default ();
175
233
  applications = launcher_appman_get_applications (appman);
176
234
  
179
237
       iter = g_sequence_iter_next (iter))
180
238
    {
181
239
      app = g_sequence_get (iter);
182
 
      launcher_application_update_windows (app);
183
 
      
184
 
      found = launcher_application_owns_window (app, window);
185
 
      
186
 
      if (found)
187
 
        {
188
 
          if (g_slist_length (launcher_application_get_windows (app)) == 1)
189
 
            g_signal_emit (session, _session_signals[APP_OPENED], 0, app);
190
 
          break;
191
 
        }
192
 
    }
193
 
    
194
 
  if (!found)
195
 
    {
196
 
      app = launcher_appman_get_application_for_wnck_window (appman, window);
197
 
      g_signal_emit (session, _session_signals[APP_OPENED], 0, app);
 
240
      
 
241
      priv->callback_count++;
 
242
      launcher_application_update_windows_with_callback (app, 
 
243
                                                         (LauncherApplicationNotifyFinished) windows_updated_callback, 
 
244
                                                         session);
198
245
    }
199
246
}
200
247