~jgonzalezdr/cairo-dock-plug-ins/suspend-workaround-applet_3.3

« back to all changes in this revision

Viewing changes to System-Monitor/src/applet-top.c

  • Committer: Fabrice Rey
  • Date: 2013-05-19 17:26:37 UTC
  • Revision ID: fabounet03@gmail.com-20130519172637-cc4oyb5q3z0jd139
Here is quite a huge commit; it's "just" to update to the new core API

Show diffs side-by-side

added added

removed removed

Lines of Context:
236
236
 
237
237
static gboolean _cd_sysmonitor_update_top_list (CDTopSharedMemory *pSharedMemory)
238
238
{
239
 
        CairoDockModuleInstance *myApplet = pSharedMemory->pApplet;
 
239
        GldiModuleInstance *myApplet = pSharedMemory->pApplet;
240
240
        CD_APPLET_ENTER;
241
241
        
242
242
        // determine the max length of process names.
317
317
        {
318
318
                myData.iNbProcesses = g_hash_table_size (pSharedMemory->pProcessTable);
319
319
                gchar *cTitle = g_strdup_printf ("  [ Top %d / %d ] :", pSharedMemory->iNbDisplayedProcesses, myData.iNbProcesses);
320
 
                cairo_dock_set_dialog_message (myData.pTopDialog, cTitle);
 
320
                gldi_dialog_set_message (myData.pTopDialog, cTitle);
321
321
                g_free (cTitle);
322
322
        }
323
323
        
335
335
        g_timer_destroy (pSharedMemory->pTopClock);
336
336
        g_free (pSharedMemory);
337
337
}
338
 
static void cd_sysmonitor_launch_top_task (CairoDockModuleInstance *myApplet)
 
338
static void cd_sysmonitor_launch_top_task (GldiModuleInstance *myApplet)
339
339
{
340
340
        g_return_if_fail (myData.pTopTask == NULL);
341
341
        
361
361
{
362
362
        _cd_sysmonitor_insert_process_in_top_list (pSharedMemory, pProcess);
363
363
}
364
 
static void _on_change_order (int iClickedButton, GtkWidget *pInteractiveWidget, CairoDockModuleInstance *myApplet, CairoDialog *pDialog)
 
364
static void _on_change_order (int iClickedButton, GtkWidget *pInteractiveWidget, GldiModuleInstance *myApplet, CairoDialog *pDialog)
365
365
{
366
366
        if (iClickedButton == 2 || iClickedButton == -2)  // 'close' button or Escape, just return and let the dialog be destroyed.
367
367
        {
385
385
                
386
386
                cairo_dock_launch_task_delayed (myData.pTopTask, 1000. * myConfig.iProcessCheckInterval);  // restart the task with a delay equal to the interval, to keep the measure accurate.
387
387
        }
388
 
        cairo_dock_dialog_reference (pDialog);  // keep the dialog alive.
 
388
        gldi_object_ref (GLDI_OBJECT (pDialog));  // keep the dialog alive.
389
389
}
390
 
static void _on_dialog_destroyed (CairoDockModuleInstance *myApplet)
 
390
static void _on_dialog_destroyed (GldiModuleInstance *myApplet)
391
391
{
392
392
        // discard the 'top' task.
393
393
        cairo_dock_discard_task (myData.pTopTask);
396
396
        // no more dialog.
397
397
        myData.pTopDialog = NULL;
398
398
}
399
 
void cd_sysmonitor_start_top_dialog (CairoDockModuleInstance *myApplet)
 
399
void cd_sysmonitor_start_top_dialog (GldiModuleInstance *myApplet)
400
400
{
401
401
        g_return_if_fail (myData.pTopDialog == NULL);
402
 
        cairo_dock_remove_dialog_if_any (myIcon);
 
402
        gldi_dialogs_remove_on_icon (myIcon);
403
403
        // build an interactive widget that will be used to display the top list.
404
404
        gchar *cTitle = g_strdup_printf ("  [ Top %d ] :", myConfig.iNbDisplayedProcesses);
405
405
        GtkWidget *pInteractiveWidget = _gtk_vbox_new (0);
408
408
                myConfig.pTopTextDescription->iSize * myConfig.iNbDisplayedProcesses);  // approximatif au depart.
409
409
        
410
410
        // build the dialog.
411
 
        CairoDialogAttribute attr;
412
 
        memset (&attr, 0, sizeof (CairoDialogAttribute));
 
411
        CairoDialogAttr attr;
 
412
        memset (&attr, 0, sizeof (CairoDialogAttr));
413
413
        attr.cText = cTitle;
414
414
        attr.cImageFilePath = MY_APPLET_SHARE_DATA_DIR"/"MY_APPLET_ICON_FILE;
415
415
        attr.pInteractiveWidget = pInteractiveWidget;
418
418
        attr.pFreeDataFunc = (GFreeFunc) _on_dialog_destroyed;
419
419
        const gchar *cButtons[] = {MY_APPLET_SHARE_DATA_DIR"/button-cpu.svg", MY_APPLET_SHARE_DATA_DIR"/button-ram.svg", "cancel", NULL};
420
420
        attr.cButtonsImage = cButtons;
421
 
        myData.pTopDialog = cairo_dock_build_dialog (&attr, myIcon, myContainer);
 
421
        attr.pIcon = myIcon;
 
422
        attr.pContainer = myContainer;
 
423
        myData.pTopDialog = gldi_dialog_new (&attr);
422
424
        
423
425
        g_free (cTitle);
424
426
        g_return_if_fail (myData.pTopDialog != NULL);