~ubuntu-core-dev/update-notifier/ubuntu

« back to all changes in this revision

Viewing changes to src/crash.c

  • Committer: Michael Vogt
  • Date: 2011-01-04 11:37:59 UTC
  • Revision ID: michael.vogt@ubuntu.com-20110104113759-dhrq048pjcxrkfjy
honor the /apps/update-notifier/auto_launch gconf key, if that is
set never display a notifcation area icon but instead always fire
up apport, if set, do the opposite and always show notifcation
area icon and never fire up apport automatically

Show diffs side-by-side

added added

removed removed

Lines of Context:
134
134
   static gboolean first_run = TRUE;
135
135
   gboolean system_crashes;
136
136
   g_debug("crashreport_check\n");
137
 
   
 
137
 
138
138
   // don't do anything if no apport-gtk is installed
139
139
   if(!g_file_test(CRASHREPORT_REPORT_APP, G_FILE_TEST_IS_EXECUTABLE))
140
140
      return FALSE;
167
167
   system_crashes = check_system_crashes();
168
168
   crashreports_found = !exitcode || system_crashes;
169
169
 
 
170
   // in autolaunch mode, just open windows, 
 
171
   gboolean autolaunch = gconf_client_get_bool((GConfClient*) ta->user_data,
 
172
                                               GCONF_KEY_AUTO_LAUNCH, NULL); 
 
173
   if (autolaunch) {
 
174
      if (crashreports_found > 0) {
 
175
         g_debug("autolaunch mode, just running apport now");
 
176
         crashreports_found=0;
 
177
         run_apport(ta);
 
178
         return TRUE;
 
179
      } else
 
180
         return FALSE;
 
181
   }
 
182
 
 
183
   // non-autolaunch will always use the notification area
170
184
   gboolean visible = gtk_status_icon_get_visible(ta->tray_icon);
171
185
 
172
 
   // normal operation
173
 
 
174
 
   // crashreport found and first run: show notification bubble and
175
 
   // return
176
 
   if((crashreports_found > 0) && (system_crashes || first_run)) {
 
186
   // crashreport found 
 
187
   if(crashreports_found > 0 && !visible) {
177
188
      gtk_status_icon_set_tooltip(ta->tray_icon,
178
189
                                  _("Crash report detected"));
179
190
      gtk_status_icon_set_visible(ta->tray_icon, TRUE);
181
192
       * if we've just logged in */
182
193
      g_timeout_add(5000, (GSourceFunc)(show_notification), ta);
183
194
   }
184
 
   // crashreport found and already visible
185
 
   else if((crashreports_found > 0) && !(system_crashes || first_run)) {
186
 
      run_apport(ta);
187
 
      // if apport was run, we don't care anymore and hide the icon
188
 
      crashreports_found=0;
189
 
   }
190
195
 
191
196
   // no crashreports, but visible
192
197
   if((crashreports_found == 0) && visible) {
193
198
      hide_crash_applet(ta);
194
199
   }
195
200
 
196
 
   // special case for unity (and generally stuff that lacks a 
197
 
   // notification area, if the icon can not be embedded we just
198
 
   // fire up apport regardless in-your-face
199
 
   // WARNING: this needs to be *after* the normal operation
200
 
   //          and the event loop needs to be flushed, otherwise
201
 
   //          gtk_status_icon_is_embedded() will return FALSE
202
 
   while (gtk_events_pending())
203
 
      gtk_main_iteration();
204
 
   if (!gtk_status_icon_is_embedded (ta->tray_icon) && 
205
 
       crashreports_found > 0) {
206
 
      g_debug("unity handler");
207
 
      crashreports_found=0;
208
 
      run_apport(ta);
209
 
      return TRUE;
210
 
   }
211
 
 
212
 
 
213
201
   first_run = FALSE;
214
202
   return TRUE;
215
203
}