static gboolean _timer (gpointer data) { CD_APPLET_ENTER; time_t t_cur = (time_t) time (NULL); if (t_cur >= myConfig.iShutdownTime) { cd_debug ("shutdown !\n"); if (g_iDesktopEnv == CAIRO_DOCK_KDE) cairo_dock_launch_command ("dbus-send --session --type=method_call --dest=org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout int32:0 int32:2 int32:2"); else cairo_dock_launch_command ("dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop"); myData.iSidTimer = 0; CD_APPLET_LEAVE (FALSE); // inutile de faire quoique ce soit d'autre, puisque l'ordi s'eteint. } else { cd_debug ("shutdown in %d minutes", (int) (myConfig.iShutdownTime - t_cur) / 60); CD_APPLET_SET_QUICK_INFO_ON_MY_ICON_PRINTF ("%dmn", (int) ceil ((double)(myConfig.iShutdownTime - t_cur) / 60.)); CD_APPLET_REDRAW_MY_ICON; if (t_cur >= myConfig.iShutdownTime - 60) gldi_dialog_show_temporary_with_icon (D_("Your computer will shut-down in 1 minute."), myIcon, myContainer, 8000, "same icon"); } CD_APPLET_LEAVE (TRUE); }
static void _cd_do_move_file (CDEntry *pEntry) { g_print ("%s (%s)\n", __func__, pEntry->cPath); GtkWidget* pFileChooserDialog = gtk_file_chooser_dialog_new ( D_("Pick up a directory"), GTK_WINDOW (g_pMainDock->pWidget), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_OK, GTK_RESPONSE_OK, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (pFileChooserDialog), FALSE); gtk_widget_show (pFileChooserDialog); int answer = gtk_dialog_run (GTK_DIALOG (pFileChooserDialog)); if (answer == GTK_RESPONSE_OK) { gchar *cDirPath = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (pFileChooserDialog)); gchar *cFileName = g_path_get_basename (pEntry->cPath); gchar *cNewFilePath = g_strdup_printf ("%s/%s", cDirPath, cFileName); g_return_if_fail (! g_file_test (cNewFilePath, G_FILE_TEST_EXISTS)); g_free (cFileName); g_free (cNewFilePath); gchar *cCommand = g_strdup_printf ("mv '%s' '%s'", pEntry->cPath, cDirPath); cairo_dock_launch_command (cCommand); g_free (cCommand); } gtk_widget_destroy (pFileChooserDialog); }
void cd_open_wm_config (void) { const gchar *cConfigTool = _get_config_tool (); if (cConfigTool != NULL) { gchar *cmd = g_strdup_printf ("which %s", cConfigTool); gchar *cResult = cairo_dock_launch_command_sync (cmd); g_free (cmd); if (cResult == NULL || *cResult != '/') { gchar *msg = g_strdup_printf (D_("You need to install '%s'"), cConfigTool); gldi_dialog_show_temporary_with_icon (msg, myIcon, myContainer, 6000, "same icon"); g_free (msg); } else { cairo_dock_launch_command (cConfigTool); } } else { gldi_dialog_show_temporary_with_icon (D_("No configuration tool is available."), myIcon, myContainer, 6000, "same icon"); } }
static void _cd_do_zip_folder (CDEntry *pEntry) { g_print ("%s (%s)\n", __func__, pEntry->cPath); gchar *cCommand = g_strdup_printf ("tar cfz '%s.tar.gz' '%s'", pEntry->cPath, pEntry->cPath); cairo_dock_launch_command (cCommand); g_free (cCommand); }
static void _cd_do_execute_command (CDEntry *pEntry) { gchar *cCommand = g_strdup_printf ("%s/calc.sh '%s'", MY_APPLET_SHARE_DATA_DIR, myData.sCurrentText->str); gchar *cResult = cairo_dock_launch_command_sync (cCommand); g_free (cCommand); if (cResult != NULL && strcmp (cResult, "0") != 0) { g_print (" resultat du calcul : '%s'\n", cResult); GtkClipboard *pClipBoard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); gtk_clipboard_set_text (pClipBoard, cResult, -1); Icon *pIcon = cairo_dock_get_dialogless_icon (); cairo_dock_show_temporary_dialog_with_icon (D_("The value %s has been copied into the clipboard."), pIcon, CAIRO_CONTAINER (g_pMainDock), 3000, MY_APPLET_SHARE_DATA_DIR"/"MY_APPLET_ICON_FILE, cResult); } else // le calcul n'a rien donne, on execute sans chercher. { g_print (" pas un calcul => on execute '%s'\n", myData.sCurrentText->str); cairo_dock_launch_command (myData.sCurrentText->str); } g_free (cResult); }
void cd_reload_wm (void) { const gchar *cCommand = _get_command (); if (cCommand != NULL) { cairo_dock_launch_command (cCommand); } }
static void _cd_do_mail_file (CDEntry *pEntry) { g_print ("%s (%s)\n", __func__, pEntry->cPath); gchar *cURI = g_filename_to_uri (pEntry->cPath, NULL, NULL); gchar *cCommand = g_strdup_printf ("thunderbird -compose \"attachment=%s\"", cURI); /// prendre aussi en compte les autres clients mail, et utiliser celui par defaut... cairo_dock_launch_command (cCommand); g_free (cCommand); g_free (cURI); }
gboolean _check_size_is_constant (GldiModuleInstance *myApplet, const gchar *cFilePath) { int iSize = cairo_dock_get_file_size (cFilePath); gchar *cCommand = g_strdup_printf ("ping 127.0.0.1 -i 0.2 -c 2"); // On fait un temps d'arret de 200ms cairo_dock_launch_command (cCommand); gchar *cResult = cairo_dock_launch_command_sync (cCommand); g_free (cCommand); g_free (cResult); gboolean bConstantSize = (iSize != 0 && iSize == myData.iCurrentFileSize); myData.iCurrentFileSize = iSize; return bConstantSize; }
static void cd_turn_composite_off (void) { if (myData.wmfb == NULL) // no fallback. { gldi_dialog_show_temporary_with_icon (D_("No fallback is available."), myIcon, myContainer, 6000, "same icon"); return; } // if not already launched, launch it. if (! _wm_is_running (myData.wmfb)) // not running { cairo_dock_launch_command (myData.wmfb->cCommand); g_timeout_add_seconds (2, _activate_composite_delayed, 0); // let the WM start for 2s. } else // already running, just toggle composite OFF. { if (myData.wmfb->activate_composite != NULL) myData.wmfb->activate_composite (FALSE); else gldi_dialog_show_temporary_with_icon (D_("No fallback is available."), myIcon, myContainer, 6000, "same icon"); } }
static void cd_turn_composite_on (void) { if (myData.wmc == NULL) // no compositor. { gldi_dialog_show_temporary_with_icon (D_("No compositor is available."), myIcon, myContainer, 6000, "same icon"); return; } // if not already launched, launch it. if (! _wm_is_running (myData.wmc)) // not running { cairo_dock_launch_command (myData.wmc->cCommand); g_timeout_add_seconds (2, _activate_composite_delayed, GINT_TO_POINTER (1)); // let the WM start for 2s. } else // already running, just toggle composite ON. { if (myData.wmc->activate_composite != NULL) myData.wmc->activate_composite (TRUE); else gldi_dialog_show_temporary_with_icon (D_("No compositor is available."), myIcon, myContainer, 6000, "same icon"); } }
void env_backend_logout (void) { cairo_dock_launch_command ("gnome-session-save --kill --gui"); }
static void _stop_xpenguins (GtkMenuItem *menu_item, gpointer *data) { cairo_dock_launch_command ("xpenguins-stop"); }
static gboolean init (gpointer *pData) { gchar *cResult = cairo_dock_launch_command_sync ("which locate"); gboolean bAvailable = (cResult != NULL && *cResult != '\0'); g_free (cResult); cd_debug ("locate available : %d", bAvailable); if (bAvailable) { gchar *cDirPath = g_strdup_printf ("%s/ScoobyDo", g_cCairoDockDataDir); if (! g_file_test (cDirPath, G_FILE_TEST_IS_DIR)) { if (g_mkdir (cDirPath, 7*8*8+7*8+5) != 0) { cd_warning ("couldn't create directory %s", cDirPath); g_free (cDirPath); return FALSE; } } gchar *cDataBase = g_strdup_printf ("%s/ScoobyDo.db", cDirPath); gchar *cLastUpdateFile = g_strdup_printf ("%s/.last-update", cDirPath); gboolean bNeedsUpdate = FALSE; if (! g_file_test (cDataBase, G_FILE_TEST_EXISTS)) { bNeedsUpdate = TRUE; } else { if (! g_file_test (cLastUpdateFile, G_FILE_TEST_EXISTS)) { bNeedsUpdate = TRUE; } else { gsize length = 0; gchar *cContent = NULL; g_file_get_contents (cLastUpdateFile, &cContent, &length, NULL); if (cContent == NULL || *cContent == '\0') { bNeedsUpdate = TRUE; } else { time_t iLastUpdateTime = atoll (cContent); time_t iCurrentTime = (time_t) time (NULL); if (iCurrentTime - iLastUpdateTime > 86400) { bNeedsUpdate = TRUE; } } g_free (cContent); } } if (bNeedsUpdate) { cairo_dock_launch_command (MY_APPLET_SHARE_DATA_DIR"/updatedb.sh"); gchar *cDate = g_strdup_printf ("%ld", time (NULL)); g_file_set_contents (cLastUpdateFile, cDate, -1, NULL); g_free (cDate); } g_free (cDataBase); g_free (cLastUpdateFile); g_free (cDirPath); } return bAvailable; }
void env_backend_setup_time (void) { cairo_dock_launch_command ("gksu time-admin"); }
gboolean cd_do_key_pressed (gpointer pUserData, GldiContainer *pContainer, guint iKeyVal, guint iModifierType, const gchar *string) { g_return_val_if_fail (cd_do_session_is_running (), GLDI_NOTIFICATION_LET_PASS); if (myData.sCurrentText == NULL) return GLDI_NOTIFICATION_LET_PASS; const gchar *cKeyName = gdk_keyval_name (iKeyVal); guint32 iUnicodeChar = gdk_keyval_to_unicode (iKeyVal); cd_debug ("+ cKeyName : %s (%c, %s)", cKeyName, iUnicodeChar, string); if (iKeyVal == GDK_KEY_Escape) // on clot la session. { cd_do_close_session (); } else if (iKeyVal == GDK_KEY_space && myData.iNbValidCaracters == 0) // pas d'espace en debut de chaine. { // on rejette. } else if (iKeyVal >= GDK_KEY_Shift_L && iKeyVal <= GDK_KEY_Hyper_R) // on n'ecrit pas les modificateurs. { // on rejette. } else if (iKeyVal == GDK_KEY_BackSpace) // on efface la derniere lettre. { if (myData.iNbValidCaracters > 0) { cd_debug ("on efface la derniere lettre de %s %d/%d", myData.sCurrentText->str, myData.iNbValidCaracters, myData.sCurrentText->len); if (myData.iNbValidCaracters == myData.sCurrentText->len) // pas de completion en cours => on efface la derniere lettre tapee. myData.iNbValidCaracters --; // on efface les lettres precedentes jusqu'a la derniere position validee. cd_do_delete_invalid_caracters (); // on relance la recherche. if (myData.pListingHistory == NULL) // recherche principale. { g_list_free (myData.pMatchingIcons); myData.pMatchingIcons = NULL; cd_do_search_matching_icons (); if (myData.pMatchingIcons == NULL && myData.sCurrentText->len > 0) // on n'a trouve aucun programme, on cherche des entrees. { if (myData.iSidLoadExternAppliIdle != 0) { g_source_remove (myData.iSidLoadExternAppliIdle); myData.iSidLoadExternAppliIdle = 0; } cd_do_launch_all_backends (); } else // on a trouve au moins un programme, on cache le listing des fichiers. { cd_do_hide_listing (); } } else // sous-recherche => on filtre. { cd_do_filter_current_listing (); } // on repositionne les caracteres et on anime tout ca. cd_do_launch_appearance_animation (); } } else if (iKeyVal == GDK_KEY_Tab) // completion. { if (myData.iNbValidCaracters > 0) { gboolean bPrevious = iModifierType & GDK_SHIFT_MASK; if (myData.pMatchingIcons != NULL) { cd_do_select_previous_next_matching_icon (!bPrevious); } else { // faire un truc ?... } } } else if (iKeyVal == GDK_KEY_Return) { cd_debug ("Enter (%s)", myData.cSearchText); if (myData.pMatchingIcons != NULL) // on a une appli a lancer. { Icon *pIcon = (myData.pCurrentMatchingElement ? myData.pCurrentMatchingElement->data : myData.pMatchingIcons->data); cairo_dock_launch_command (pIcon->cCommand); } else if (myData.pListing && myData.pListing->pCurrentEntry) // pas d'appli mais une entree => on l'execute. { CDEntry *pEntry = myData.pListing->pCurrentEntry->data; cd_debug ("on valide l'entree '%s ; %s'", pEntry->cName, pEntry->cPath); if (pEntry->execute) pEntry->execute (pEntry); else return GLDI_NOTIFICATION_INTERCEPT; } else if (myData.iNbValidCaracters > 0) // pas d'entree mais du texte => on l'execute tel quel. { cd_debug ("on execute '%s'", myData.sCurrentText->str); cairo_dock_launch_command (myData.sCurrentText->str); } if (!(iModifierType & GDK_CONTROL_MASK) && !(iModifierType & GDK_MOD1_MASK) && !(iModifierType & GDK_SHIFT_MASK)) cd_do_close_session (); } else if (iKeyVal == GDK_KEY_Left || iKeyVal == GDK_KEY_Right || iKeyVal == GDK_KEY_Up || iKeyVal == GDK_KEY_Down) { if (myData.pMatchingIcons != NULL) { cd_do_select_previous_next_matching_icon (iKeyVal == GDK_KEY_Right || iKeyVal == GDK_KEY_Down); } else if (myData.pListing != NULL && myData.pListing->pEntries != NULL) { if (iKeyVal == GDK_KEY_Down) { cd_do_select_prev_next_entry_in_listing (TRUE); // next } else if (iKeyVal == GDK_KEY_Up) { cd_do_select_prev_next_entry_in_listing (FALSE); // previous } else if (iKeyVal == GDK_KEY_Right) { cd_do_show_current_sub_listing (); } else if (iKeyVal == GDK_KEY_Left) { cd_do_show_previous_listing (); } } } else if (iKeyVal == GDK_KEY_Page_Down || iKeyVal == GDK_KEY_Page_Up || iKeyVal == GDK_KEY_Home || iKeyVal == GDK_KEY_End) { if (myData.pListing != NULL) { if (iKeyVal == GDK_KEY_Page_Down || iKeyVal == GDK_KEY_Page_Up) cd_do_select_prev_next_page_in_listing (iKeyVal == GDK_KEY_Page_Down); // TRUE <=> next page else cd_do_select_last_first_entry_in_listing (iKeyVal == GDK_KEY_End); // TRUE <=> last entry. } } else if (iKeyVal >= GDK_KEY_F1 && iKeyVal <= GDK_KEY_F9) { if (myData.pListing != NULL && gldi_container_is_visible (CAIRO_CONTAINER (myData.pListing))) { cd_debug ("modification du filtre : option n°%d", iKeyVal - GDK_KEY_F1); cd_do_activate_filter_option (iKeyVal - GDK_KEY_F1); cairo_dock_redraw_container (CAIRO_CONTAINER (myData.pListing)); } } else if (string) /// utiliser l'unichar ... { cd_debug ("string:'%s'", string); guint iNbNewChar = 0; if ((iModifierType & GDK_CONTROL_MASK) && iUnicodeChar == 'v') // CTRL+v { cd_debug ("CTRL+v\n"); GtkClipboard *pClipBoard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); gchar *cText = gtk_clipboard_wait_for_text (pClipBoard); // la main loop s'execute pendant ce temps. if (cText != NULL) { cd_debug ("clipboard : '%s'", cText); iNbNewChar = strlen (cText); /// penser a l'UTF-8 ... gchar *str = strchr (cText, '\r'); if (str) *str = '\0'; str = strchr (cText, '\n'); if (str) *str = '\0'; g_string_append (myData.sCurrentText, cText); cd_do_load_pending_caracters (); cd_do_launch_appearance_animation (); myData.iNbValidCaracters = myData.sCurrentText->len; // cela valide le texte colle ainsi que les lettres precedemment ajoutee par completion. } } else // on rajoute la lettre au mot { iNbNewChar = 1; g_string_append_c (myData.sCurrentText, *string); myData.iNbValidCaracters = myData.sCurrentText->len; // l'utilisateur valide la nouvelle lettre ainsi que celles precedemment ajoutee par completion. } // on cherche la liste des icones qui correspondent. if (myData.pListingHistory == NULL) { //if (! (myData.bFoundNothing || (myData.pListing && myData.pListing->pEntries))) // on n'est pas deja dans une recherche de fichiers if (myData.iNbValidCaracters == iNbNewChar || myData.pMatchingIcons != NULL) // 1er ajout de lettre ou precedente recherche d'icones fructueuse => on remet ca. { cd_do_search_matching_icons (); } // si on n'a trouve aucun lanceur, on lance la recherche dans les backends. if (myData.pMatchingIcons == NULL) { cd_do_launch_all_backends (); } } else { cd_do_filter_current_listing (); } // on rajoute une surface/texture pour la/les nouvelle(s) lettre(s). myData.iNbValidCaracters -= iNbNewChar; // le nouveau caractere n'est pas encore charge. cd_do_load_pending_caracters (); myData.iNbValidCaracters += iNbNewChar; // on repositionne les caracteres et on anime tout ca. cd_do_launch_appearance_animation (); } return GLDI_NOTIFICATION_INTERCEPT; }
static gboolean _on_click_module_tree_view (GtkTreeView *pTreeView, GdkEventButton* pButton, gpointer data) { //g_print ("%s ()\n", __func__); if ((pButton->button == 3 && pButton->type == GDK_BUTTON_RELEASE) // right-click || (pButton->button == 1 && pButton->type == GDK_2BUTTON_PRESS)) // double-click { cd_debug ("%s ()", __func__); // get the current selected line. GtkTreeSelection *pSelection = gtk_tree_view_get_selection (pTreeView); GtkTreeModel *pModel; GtkTreeIter iter; if (! gtk_tree_selection_get_selected (pSelection, &pModel, &iter)) return FALSE; gchar *cName = NULL, *cUri = NULL; guint id = 0; gtk_tree_model_get (pModel, &iter, CD_MODEL_NAME, &cName, CD_MODEL_URI, &cUri, CD_MODEL_ID, &id, -1); //launch or build the menu. gboolean bIsAppli = (strncmp (cUri, "application://", 14) == 0); if (pButton->button == 1) // double-click { if (bIsAppli) // an appli -> run it { gchar *tmp = strrchr (cUri, '.'); // remove the '.desktop' if (tmp) *tmp = '\0'; cairo_dock_launch_command (cUri+14); } else // a file -> open it { cairo_dock_fm_launch_uri (cUri); } g_free (cUri); } else // right-click { GtkWidget *pMenu = gldi_menu_new (NULL); g_free (myData.cCurrentUri); myData.cCurrentUri = cUri; if (!bIsAppli) { GList *pApps = cairo_dock_fm_list_apps_for_file (cUri); if (pApps != NULL) { GtkWidget *pSubMenu = CD_APPLET_ADD_SUB_MENU_WITH_IMAGE (D_("Open with"), pMenu, GLDI_ICON_NAME_OPEN); cd_folders_free_apps_list (myApplet); GList *a; gchar **pAppInfo; gchar *cIconPath; for (a = pApps; a != NULL; a = a->next) { pAppInfo = a->data; myData.pAppList = g_list_prepend (myData.pAppList, pAppInfo[1]); if (pAppInfo[2] != NULL) cIconPath = cairo_dock_search_icon_s_path (pAppInfo[2], cairo_dock_search_icon_size (GTK_ICON_SIZE_MENU)); else cIconPath = NULL; CD_APPLET_ADD_IN_MENU_WITH_STOCK_AND_DATA (pAppInfo[0], cIconPath, _cd_launch_with, pSubMenu, pAppInfo[1]); g_free (cIconPath); g_free (pAppInfo[0]); g_free (pAppInfo[2]); g_free (pAppInfo); } g_list_free (pApps); } CD_APPLET_ADD_IN_MENU_WITH_STOCK_AND_DATA (D_("Open parent folder"), GLDI_ICON_NAME_DIRECTORY, _cd_open_parent, pMenu, NULL); CD_APPLET_ADD_IN_MENU_WITH_STOCK_AND_DATA (D_("Copy the location"), GLDI_ICON_NAME_COPY, _cd_copy_location, pMenu, NULL); } CD_APPLET_ADD_IN_MENU_WITH_STOCK_AND_DATA (D_("Delete this event"), GLDI_ICON_NAME_REMOVE, _cd_delete_event, pMenu, GUINT_TO_POINTER (id)); gtk_widget_show_all (pMenu); gtk_menu_popup (GTK_MENU (pMenu), NULL, NULL, NULL, // popup on mouse. NULL, 1, gtk_get_current_event_time ()); } } return FALSE; }
gboolean _new_xml_to_conf (GldiModuleInstance *myApplet, gchar *cReceivedData) { gboolean bContinue = FALSE; if (cReceivedData && ((strncmp (cReceivedData, "file://", 7) == 0 && g_str_has_suffix (cReceivedData, ".xml")) \ || (strncmp (cReceivedData, "file://", 7) == 0 && g_str_has_suffix (cReceivedData, ".tar.gz")) \ || (strncmp (cReceivedData, "http://", 7) == 0 && g_str_has_suffix (cReceivedData, ".xml")) \ || (strncmp (cReceivedData, "http://", 7) == 0 && g_str_has_suffix (cReceivedData, ".tar.gz")))) { if (strncmp (cReceivedData, "file://", 7) == 0 && g_str_has_suffix (cReceivedData, ".xml")) // On laisse le fichier où il est et on ne crée pas de thème dans ~/.config/cairo-dock/doncky/ { cd_debug ("DONCKY-debug : local xml file -> Use it without any copy."); // ltrim( cReceivedData, "file:///" ); cReceivedData = g_filename_from_uri (cReceivedData, NULL, NULL);// FREE // g_strdup_printf("/%s", cReceivedData); bContinue = TRUE; } else // On crée un thème dans ~/.config/cairo-dock/doncky/ { if (strncmp (cReceivedData, "file://", 7) == 0) { cReceivedData = g_filename_from_uri (cReceivedData, NULL, NULL); // FREE } // On récupère le 1er champ -> nom du fichier /*g_strreverse (cTmpFileName); cTmpFileName = g_str_position (cTmpFileName, 1, '/'); g_strreverse (cTmpFileName);*/ gchar *cTmpFileName = g_path_get_basename (cReceivedData); // Récupération du nom du fichier sans l'extension gchar *cTmpThemeName = g_strdup (cTmpFileName); if (g_str_has_suffix(cReceivedData,".xml")) rtrim(cTmpThemeName,".xml"); else if (g_str_has_suffix(cReceivedData,".tar.gz")) { rtrim (cTmpThemeName, ".tar.gz"); } cd_debug ("DONCKY-debug : Theme name : %s", cTmpThemeName); // on cree le repertoire pour le theme. gchar *cDonckyThemesPath = g_strdup_printf ("%s/doncky", g_cCairoDockDataDir); gchar *cThemePath = g_strdup_printf ("%s/%s", cDonckyThemesPath, cTmpThemeName); if (! g_file_test (cThemePath, G_FILE_TEST_EXISTS)) { cd_debug ("DONCKY-debug : the folder '%s' doesn't exist -> We create it", cThemePath); if (! g_file_test (cDonckyThemesPath, G_FILE_TEST_EXISTS)) { cd_debug ("DONCKY-debug : the folder '%s' doesn't exist -> We create it", cDonckyThemesPath); if (g_mkdir (cDonckyThemesPath, 7*8*8+7*8+0) != 0) { cd_warning ("couldn't create directory '%s' !\nNo read history will be available.", cDonckyThemesPath); bContinue = FALSE; } } if (g_mkdir (cThemePath, 7*8*8+7*8+0) != 0) { cd_warning ("couldn't create directory '%s' !\nNo read history will be available.", cThemePath); bContinue = FALSE; } else bContinue = TRUE; } else { cd_debug ("DONCKY-debug : the folder '%s' exists -> give it a new name ...", cThemePath); gchar *cNewPath=NULL; int i=2; do { cNewPath = g_strdup_printf ("%s-%d", cThemePath, i); i ++; } while (g_file_test (cNewPath, G_FILE_TEST_EXISTS)); g_free (cThemePath); cThemePath = cNewPath; bContinue = TRUE; } if (bContinue) { if (strncmp (cReceivedData, "http://", 7) == 0) { gchar *cCommand = g_strdup_printf ("wget \"%s\" -O \"%s/%s\" -t 3 -T 4 30 /dev/null 2>&1", cReceivedData, cThemePath, cTmpFileName); cd_debug ("DONCKY-debug : Downloading the file ..."); cairo_dock_launch_command (cCommand); g_free (cCommand); } else // C'est donc un fichier local { gchar *cCommand = g_strdup_printf ("cp \"/%s\" \"%s/%s\"", cReceivedData, cThemePath, cTmpFileName); cairo_dock_launch_command (cCommand); g_free (cCommand); } g_free (cReceivedData); cReceivedData = g_strdup_printf("%s/%s", cThemePath, cTmpFileName); cd_debug ("DONCKY-debug : Waiting to complete \"%s\"...", cReceivedData); do { // waiting for the download to be completed cd_debug ("DONCKY-debug : Waiting to complete..."); }while (!_check_size_is_constant (myApplet, cReceivedData)); cd_debug ("DONCKY-debug : \"%s\" is ready (Downloaded size : %i octets)", cReceivedData, myData.iCurrentFileSize); if (g_str_has_suffix(cReceivedData,".tar.gz")) { gchar *cCommand = g_strdup_printf ("cd \"%s\" && tar -xzvf \"%s\"",cThemePath, cTmpFileName); cairo_dock_launch_command (cCommand); g_free (cCommand); // On re-définit le chemin du xml rtrim (cTmpFileName, ".tar.gz"); g_free (cReceivedData); cReceivedData = g_strdup_printf("%s/%s.xml", cThemePath, cTmpFileName); } } g_free (cDonckyThemesPath); g_free (cThemePath); g_free (cTmpFileName); g_free (cTmpThemeName); } if (bContinue) { cd_debug ("DONCKY-debug : \"%s\" was dropped", cReceivedData); cd_debug ("DONCKY-debug : This seems to be a valid XML File -> Let's continue..."); // on definit la nouvelle URL en conf. g_free (myConfig.cXmlFilePath); myConfig.cXmlFilePath = g_strdup (cReceivedData); cairo_dock_update_conf_file (CD_APPLET_MY_CONF_FILE, G_TYPE_STRING, "Configuration", "xml_filepath", myConfig.cXmlFilePath, G_TYPE_INVALID); // On l'ecrit dans le fichier de config cd_doncky_free_item_list (myApplet); cd_doncky_readxml (myApplet); // 2 times to allow xml files to modify the conf : cd_doncky_free_item_list (myApplet); cd_doncky_readxml (myApplet); return TRUE; } else return FALSE; } else { cd_debug ("DONCKY-debug : It doesn't seem to be a valid XML."); gldi_dialogs_remove_on_icon (myIcon); gldi_dialog_show_temporary_with_icon (D_("It doesn't seem to be a valid XML file."), myIcon, myContainer, 3000, // Suffisant MY_APPLET_SHARE_DATA_DIR"/"MY_APPLET_ICON_FILE); return FALSE; } }
void env_backend_show_system_monitor (void) { cairo_dock_launch_command ("gnome-system-monitor"); }