133
133
pLabel = gtk_label_new (NULL);
134
134
gtk_label_set_use_markup (GTK_LABEL (pLabel), TRUE);
135
g_string_printf (sInfo, "<u>Size</u> : %lld bytes", iSize);
135
g_string_printf (sInfo, "<u>Size</u> : %"G_GUINT64_FORMAT" bytes", iSize);
136
136
if (iSize > 1024*1024)
137
g_string_append_printf (sInfo, " (%.1f Mo)", 1. * iSize / 1024 / 1024);
137
g_string_append_printf (sInfo, " (%.1f MB)", 1. * iSize / 1024 / 1024);
138
138
else if (iSize > 1024)
139
g_string_append_printf (sInfo, " (%.1f Ko)", 1. * iSize / 1024);
139
g_string_append_printf (sInfo, " (%.1f KB)", 1. * iSize / 1024);
140
140
gtk_label_set_markup (GTK_LABEL (pLabel), sInfo->str);
141
141
gtk_container_add (GTK_CONTAINER (pVBox), pLabel);
428
428
CD_APPLET_ON_BUILD_MENU_END
431
static void _on_answer_import (int iClickedButton, GtkWidget *pInteractiveWidget, const gchar *cReceivedData, CairoDialog *pDialog)
432
gchar *cReceivedData;
436
static void _on_answer_import (int iClickedButton, GtkWidget *pInteractiveWidget, CDDropData *data, CairoDialog *pDialog)
433
438
cd_debug ("%s (%d)", __func__, iClickedButton);
439
const gchar *cReceivedData = data->cReceivedData;
440
double fOrder = data->fOrder;
434
441
gboolean bImportFiles = (iClickedButton == 0 || iClickedButton == -1); // ok or Enter.
443
// add a new conf file for the "Folders" module, with proper values.
436
444
CairoDockModule *pModule = cairo_dock_find_module_from_name ("Folders");
437
445
g_return_if_fail (pModule != NULL);
440
448
cairo_dock_update_conf_file (cConfFilePath,
441
449
G_TYPE_STRING, "Configuration", "dir path", cReceivedData,
442
450
G_TYPE_BOOLEAN, "Configuration", "show files", bImportFiles,
451
G_TYPE_DOUBLE, "Icon", "order", fOrder,
454
// instanciate the module from this conf file.
445
455
CairoDockModuleInstance *pNewInstance = cairo_dock_instanciate_module (pModule, cConfFilePath); // prend le 'cConfFilePath'.
446
456
if (pNewInstance != NULL && pNewInstance->pDock)
448
458
cairo_dock_update_dock_size (pNewInstance->pDock);
461
// show a success message on the new icon.
451
462
if (pNewInstance != NULL)
452
463
cairo_dock_show_temporary_dialog_with_icon (D_("The folder has been imported."),
453
464
pNewInstance->pIcon, pNewInstance->pContainer,
455
466
MY_APPLET_SHARE_DATA_DIR"/"MY_APPLET_ICON_FILE); // not "same icon" because the icon may not be loaded yet (eg. stack or emblem icon).
468
// if the module has just been activated for the first time, write it down so that it is loaded on the next startup.
457
469
if (pModule->pInstancesList && pModule->pInstancesList->next == NULL) // module nouvellement active.
459
471
cairo_dock_write_active_modules ();
474
static void _free_dialog_data (CDDropData *data)
476
g_free (data->cReceivedData);
462
479
gboolean cd_folders_on_drop_data (gpointer data, const gchar *cReceivedData, Icon *icon, double fOrder, CairoContainer *pContainer)
464
481
//g_print ("Folders received '%s'\n", cReceivedData);
466
482
if (icon != NULL || fOrder == CAIRO_DOCK_LAST_ORDER) // drop on an icon or outside of icons.
467
483
return CAIRO_DOCK_LET_PASS_NOTIFICATION;
475
491
if (g_file_test (cPath, G_FILE_TEST_IS_DIR)) // it's a folder, let's add a new instance of the applet that will handle it.
477
//g_print (" ajout d'un repertoire...\n");
493
// search the closest icon to the drop point (we want to place the dialog on it).
494
GList *pIconsList = NULL, *ic;
495
if (CAIRO_DOCK_IS_DOCK (pContainer))
496
pIconsList = CAIRO_DOCK (pContainer)->icons;
497
else if (CAIRO_DOCK_IS_DESKLET (pContainer))
498
pIconsList = CAIRO_DESKLET (pContainer)->icons;
500
for (ic = pIconsList; ic != NULL; ic = ic->next)
503
if (icon->fOrder > fOrder)
480
511
if (CAIRO_DOCK_IS_DOCK (pContainer))
481
icon = cairo_dock_get_dialogless_icon_full (CAIRO_DOCK (pContainer));
512
pIcon = cairo_dock_get_dialogless_icon_full (CAIRO_DOCK (pContainer));
483
icon = cairo_dock_get_dialogless_icon ();
514
pIcon = cairo_dock_get_dialogless_icon ();
517
// ask the user whether (s)he wants to import the folder's content.
518
CDDropData *data = g_new0 (CDDropData, 1);
519
data->cReceivedData = g_strdup (cReceivedData);
520
data->fOrder = fOrder;
485
521
cairo_dock_show_dialog_full (D_("Do you want to import the content of the folder too?"),
488
524
MY_APPLET_SHARE_DATA_DIR"/"MY_APPLET_ICON_FILE,
490
526
(CairoDockActionOnAnswerFunc) _on_answer_import,
491
g_strdup (cReceivedData),
528
(GFreeFunc)_free_dialog_data);
494
530
return CAIRO_DOCK_INTERCEPT_NOTIFICATION;