void cairo_dock_write_keys_to_file (GKeyFile *pKeyFile, const gchar *cConfFilePath) { cd_debug ("%s (%s)", __func__, cConfFilePath); GError *erreur = NULL; gchar *cDirectory = g_path_get_dirname (cConfFilePath); if (! g_file_test (cDirectory, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_EXECUTABLE)) { g_mkdir_with_parents (cDirectory, 7*8*8+7*8+5); } g_free (cDirectory); gsize length=0; gchar *cNewConfFileContent = g_key_file_to_data (pKeyFile, &length, &erreur); if (erreur != NULL) { cd_warning ("Error while fetching data : %s", erreur->message); g_error_free (erreur); return ; } g_return_if_fail (cNewConfFileContent != NULL && *cNewConfFileContent != '\0'); g_file_set_contents (cConfFilePath, cNewConfFileContent, length, &erreur); if (erreur != NULL) { cd_warning ("Error while writing data to %s : %s", cConfFilePath, erreur->message); g_error_free (erreur); return ; } g_free (cNewConfFileContent); }
static CDBookmarkItem *_parse_bookmarks (const gchar *cFilePath) { gsize length = 0; gchar *cBookmarksContent = NULL; g_file_get_contents (cFilePath, &cBookmarksContent, &length, NULL); if (cBookmarksContent == NULL) { cd_warning ("can't read bookmarks"); return NULL; } gchar *str = g_strstr_len (cBookmarksContent, -1, "<DL>"); if (!str) { cd_warning ("empty bookmarks"); return NULL; } CDBookmarkItem *pRootItem = g_new0 (CDBookmarkItem, 1); pRootItem->pSubItems = _parse_folder (str+4, &str); g_free (cBookmarksContent); return pRootItem; }
static void _get_theme (void) { // get the user images first, as they overwrite the theme. if (myConfig.cEmptyUserImage != NULL) { gchar *cPath = cairo_dock_search_icon_s_path (myConfig.cEmptyUserImage, CAIRO_DOCK_DEFAULT_ICON_SIZE); if (! g_file_test (cPath, G_FILE_TEST_EXISTS)) { g_free (myConfig.cEmptyUserImage); myConfig.cEmptyUserImage = NULL; } g_free (cPath); } if (myConfig.cFullUserImage != NULL) { gchar *cPath = cairo_dock_search_icon_s_path (myConfig.cFullUserImage, CAIRO_DOCK_DEFAULT_ICON_SIZE); if (! g_file_test (cPath, G_FILE_TEST_EXISTS)) { g_free (myConfig.cFullUserImage); myConfig.cFullUserImage = NULL; } g_free (cPath); } // if a theme is defined, and user images are not defined, use the theme. if (myConfig.cThemePath != NULL) { if (myConfig.cEmptyUserImage == NULL) { myConfig.cEmptyUserImage = g_strdup_printf ("%s/%s", myConfig.cThemePath, "trashcan_empty.svg"); if (! g_file_test (myConfig.cEmptyUserImage, G_FILE_TEST_EXISTS)) { g_free (myConfig.cEmptyUserImage); myConfig.cEmptyUserImage = g_strdup_printf ("%s/%s", myConfig.cThemePath, "trashcan_empty.png"); if (! g_file_test (myConfig.cEmptyUserImage, G_FILE_TEST_EXISTS)) // no svg nor png, use the default theme. { g_free (myConfig.cEmptyUserImage); myConfig.cEmptyUserImage = g_strdup (MY_APPLET_SHARE_DATA_DIR"/themes/default/trashcan_empty.svg"); cd_warning ("using the default theme for Dustbin, as neither the user image (%s) nor the theme (%s) are valid", myConfig.cEmptyUserImage, myConfig.cThemePath); } } } if (myConfig.cFullUserImage == NULL) { myConfig.cFullUserImage = g_strdup_printf ("%s/%s", myConfig.cThemePath, "trashcan_full.svg"); if (! g_file_test (myConfig.cFullUserImage, G_FILE_TEST_EXISTS)) { g_free (myConfig.cFullUserImage); myConfig.cFullUserImage = g_strdup_printf ("%s/%s", myConfig.cThemePath, "trashcan_full.png"); if (! g_file_test (myConfig.cFullUserImage, G_FILE_TEST_EXISTS)) { g_free (myConfig.cFullUserImage); myConfig.cFullUserImage = g_strdup (MY_APPLET_SHARE_DATA_DIR"/themes/default/trashcan_full.svg"); cd_warning ("using the default theme for Dustbin, as neither the user image (%s) nor the theme (%s) are valid", myConfig.cFullUserImage, myConfig.cThemePath); } } } } }
static void _on_got_song_infos (DBusGProxy *proxy, DBusGProxyCall *call_id, GldiModuleInstance *myApplet) { cd_debug ("=== %s ()", __func__); CD_APPLET_ENTER; s_pGetSongInfosCall = NULL; GHashTable *pMetadata = NULL; GValue v = G_VALUE_INIT; GError *erreur = NULL; dbus_g_proxy_end_call (proxy, call_id, &erreur, G_TYPE_VALUE, &v, G_TYPE_INVALID); if (erreur != NULL) { cd_warning ("couldn't get MPRIS song infos (%s)\n", erreur->message); g_error_free (erreur); pMetadata = NULL; } else { if (G_VALUE_HOLDS_BOXED (&v)) { pMetadata = g_value_get_boxed (&v); // since we don't destroy the value, we'll take care of the hash-table when we're done with it. } } if (pMetadata != NULL) { _extract_metadata (pMetadata); g_hash_table_destroy (pMetadata); } else { cd_warning (" can't get song properties"); g_free (myData.cPlayingUri); myData.cPlayingUri = NULL; g_free (myData.cTitle); myData.cTitle = NULL; g_free (myData.cAlbum); myData.cAlbum = NULL; g_free (myData.cArtist); myData.cArtist = NULL; g_free (myData.cCoverPath); myData.cCoverPath = NULL; myData.iSongLength = 0; myData.iTrackNumber = 0; myData.cover_exist = FALSE; } cd_musicplayer_update_icon (); cd_musicplayer_relaunch_handler (); CD_APPLET_LEAVE (); }
void cd_shortcuts_rename_one_bookmark (const gchar *cURI, const gchar *cName, GldiModuleInstance *myApplet) { g_return_if_fail (cURI != NULL); cd_message ("%s (%s, %s)", __func__, cURI, cName); gchar *cContent = NULL; gsize length=0; GError *erreur = NULL; g_file_get_contents (myData.cBookmarksURI, &cContent, &length, &erreur); if (erreur != NULL) { cd_warning ("while trying to read bookmarks file : %s", erreur->message); g_error_free (erreur); } else { gchar **cBookmarksList = g_strsplit (cContent, "\n", -1); g_free (cContent); gchar *cOneBookmark, *str; int i = 0; for (i = 0; cBookmarksList[i] != NULL; i ++) { cOneBookmark = cBookmarksList[i]; if (*cOneBookmark == '\0' || *cOneBookmark == '#') continue; str = strchr (cOneBookmark, ' '); if ((str && strncmp (cOneBookmark, cURI, str - cOneBookmark) == 0) || (!str && strcmp (cOneBookmark, cURI) == 0)) { cBookmarksList[i] = g_strdup_printf ("%s %s", cURI, cName); g_free (cOneBookmark); break; } } if (cBookmarksList[i] == NULL) { cd_warning ("bookmark '%s' not found", cURI); } else { cContent = g_strjoinv ("\n", cBookmarksList); g_file_set_contents (myData.cBookmarksURI, cContent, -1, &erreur); if (erreur != NULL) { cd_warning ("while trying to write bookmarks file : %s", erreur->message); g_error_free (erreur); } g_free (cContent); } g_strfreev (cBookmarksList); } }
static void _post_initialize_opengl_backend (G_GNUC_UNUSED GtkWidget *pWidget, GldiContainer *pContainer) // initialisation necessitant un contexte opengl. { g_return_if_fail (!s_bInitialized); if (! gldi_gl_container_make_current (pContainer)) return ; s_bInitialized = TRUE; g_openglConfig.bNonPowerOfTwoAvailable = _check_gl_extension ("GL_ARB_texture_non_power_of_two"); g_openglConfig.bFboAvailable = _check_gl_extension ("GL_EXT_framebuffer_object"); if (!g_openglConfig.bFboAvailable) cd_warning ("No FBO support, some applets will be invisible if placed inside the dock."); g_openglConfig.bNonPowerOfTwoAvailable = _check_gl_extension ("GL_ARB_texture_non_power_of_two"); g_openglConfig.bAccumBufferAvailable = _check_gl_extension ("GL_SUN_slice_accum"); GLfloat fMaximumAnistropy = 0.; if (_check_gl_extension ("GL_EXT_texture_filter_anisotropic")) { glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &fMaximumAnistropy); glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, fMaximumAnistropy); } const gchar *cVersion = (const gchar *) glGetString (GL_VERSION); const gchar *cVendor = (const gchar *) glGetString (GL_VENDOR); const gchar *cRenderer = (const gchar *) glGetString (GL_RENDERER); cd_message ("OpenGL config summary :\n - bNonPowerOfTwoAvailable : %d\n - bFboAvailable : %d\n - direct rendering : %d\n - bTextureFromPixmapAvailable : %d\n - bAccumBufferAvailable : %d\n - Anisotroy filtering level max : %.1f\n - OpenGL version: %s\n - OpenGL vendor: %s\n - OpenGL renderer: %s\n\n", g_openglConfig.bNonPowerOfTwoAvailable, g_openglConfig.bFboAvailable, !g_openglConfig.bIndirectRendering, g_openglConfig.bTextureFromPixmapAvailable, g_openglConfig.bAccumBufferAvailable, fMaximumAnistropy, cVersion, cVendor, cRenderer); // we need a context to use glGetString, this is why we did it now if (! s_bForceOpenGL && _is_blacklisted (cVersion, cVendor, cRenderer)) { cd_warning ("%s 'cairo-dock -o'\n" " OpenGL Version: %s\n OpenGL Vendor: %s\n OpenGL Renderer: %s", "The OpenGL backend will be deactivated. Note that you can force " "this OpenGL backend by launching the dock with this command:", cVersion, cVendor, cRenderer); gldi_gl_backend_deactivate (); } }
static inline gboolean _window_overlaps_dock (GtkAllocation *pWindowGeometry, gboolean bIsHidden, CairoDock *pDock) { if (pWindowGeometry->width != 0 && pWindowGeometry->height != 0) { int iDockX, iDockY, iDockWidth, iDockHeight; if (pDock->container.bIsHorizontal) { iDockWidth = pDock->iMinDockWidth; iDockHeight = pDock->iMinDockHeight; iDockX = pDock->container.iWindowPositionX + (pDock->container.iWidth - iDockWidth)/2; iDockY = pDock->container.iWindowPositionY + (pDock->container.bDirectionUp ? pDock->container.iHeight - pDock->iMinDockHeight : 0); } else { iDockWidth = pDock->iMinDockHeight; iDockHeight = pDock->iMinDockWidth; iDockX = pDock->container.iWindowPositionY + (pDock->container.bDirectionUp ? pDock->container.iHeight - pDock->iMinDockHeight : 0); iDockY = pDock->container.iWindowPositionX + (pDock->container.iWidth - iDockHeight)/2; } if (! bIsHidden && pWindowGeometry->x < iDockX + iDockWidth && pWindowGeometry->x + pWindowGeometry->width > iDockX && pWindowGeometry->y < iDockY + iDockHeight && pWindowGeometry->y + pWindowGeometry->height > iDockY) { return TRUE; } } else { cd_warning (" unknown window geometry"); } return FALSE; }
GList * cd_shortcuts_list_drives (CDSharedMemory *pSharedMemory) { GList *pIconList = NULL; gchar *cFullURI = NULL; //\_______________________ Get the list of mount points. pIconList = cairo_dock_fm_list_directory (CAIRO_DOCK_FM_VFS_ROOT, CAIRO_DOCK_FM_SORT_BY_NAME, CD_DRIVE_GROUP, FALSE, 100, &cFullURI); cd_message (" cFullURI : %s", cFullURI); if (pIconList == NULL) { cd_warning ("couldn't detect any drives"); // continue: for bookmarks } /// TODO: if ! bListBookmarks, then we should add the Home in the drives list, to have the disk space information... pSharedMemory->cDisksURI = cFullURI; //\_______________________ Initialize disk usages. Icon *pIcon; GList *ic; for (ic = pIconList; ic != NULL; ic = ic->next) { pIcon = ic->data; _init_disk_usage (pIcon, pSharedMemory->pApplet); } return pIconList; }
static gchar *_get_bookmarks_path (void) { gchar *cPath = g_strdup_printf ("%s/.mozilla/firefox", g_getenv ("HOME")); GError *erreur = NULL; GDir *dir = g_dir_open (cPath, 0, &erreur); if (erreur != NULL) { cd_warning (erreur->message); g_error_free (erreur); g_free (cPath); return NULL; } gchar *cBookmarks = NULL; const gchar *cFileName; do { cFileName = g_dir_read_name (dir); if (cFileName == NULL) break ; cBookmarks = g_strdup_printf ("%s/%s/bookmarks.html", cPath, cFileName); if (g_file_test (cBookmarks, G_FILE_TEST_EXISTS)) break; // on en prend qu'un. else { g_free (cBookmarks); cBookmarks = NULL; } } while (1); g_dir_close (dir); g_free (cPath); return cBookmarks; }
static gboolean get_config (GKeyFile *pKeyFile, CairoConfigTaskBar *pTaskBar) { gboolean bFlushConfFileNeeded = FALSE; pTaskBar->bShowAppli = cairo_dock_get_boolean_key_value (pKeyFile, "TaskBar", "show applications", &bFlushConfFileNeeded, TRUE, "Applications", NULL); ///pTaskBar->bUniquePid = cairo_dock_get_boolean_key_value (pKeyFile, "TaskBar", "unique PID", &bFlushConfFileNeeded, FALSE, "Applications", NULL); pTaskBar->bGroupAppliByClass = cairo_dock_get_boolean_key_value (pKeyFile, "TaskBar", "group by class", &bFlushConfFileNeeded, TRUE, "Applications", NULL); pTaskBar->cGroupException = cairo_dock_get_string_key_value (pKeyFile, "TaskBar", "group exception", &bFlushConfFileNeeded, "pidgin;xchat", NULL, NULL); if (pTaskBar->cGroupException) { int i; for (i = 0; pTaskBar->cGroupException[i] != '\0'; i ++) pTaskBar->cGroupException[i] = g_ascii_tolower (pTaskBar->cGroupException[i]); } pTaskBar->iAppliMaxNameLength = cairo_dock_get_integer_key_value (pKeyFile, "TaskBar", "max name length", &bFlushConfFileNeeded, 15, "Applications", NULL); pTaskBar->bMinimizeOnClick = cairo_dock_get_boolean_key_value (pKeyFile, "TaskBar", "minimize on click", &bFlushConfFileNeeded, TRUE, "Applications", NULL); pTaskBar->bCloseAppliOnMiddleClick = cairo_dock_get_boolean_key_value (pKeyFile, "TaskBar", "close on middle click", &bFlushConfFileNeeded, TRUE, "Applications", NULL); pTaskBar->bHideVisibleApplis = cairo_dock_get_boolean_key_value (pKeyFile, "TaskBar", "hide visible", &bFlushConfFileNeeded, FALSE, "Applications", NULL); pTaskBar->fVisibleAppliAlpha = cairo_dock_get_double_key_value (pKeyFile, "TaskBar", "visibility alpha", &bFlushConfFileNeeded, .35, "Applications", NULL); // >0 <=> les fenetres minimisees sont transparentes. if (pTaskBar->bHideVisibleApplis && pTaskBar->fVisibleAppliAlpha < 0) pTaskBar->fVisibleAppliAlpha = 0.; // on inhibe ce parametre, puisqu'il ne sert alors a rien. else if (pTaskBar->fVisibleAppliAlpha > .6) pTaskBar->fVisibleAppliAlpha = .6; else if (pTaskBar->fVisibleAppliAlpha < -.6) pTaskBar->fVisibleAppliAlpha = -.6; pTaskBar->bAppliOnCurrentDesktopOnly = cairo_dock_get_boolean_key_value (pKeyFile, "TaskBar", "current desktop only", &bFlushConfFileNeeded, FALSE, "Applications", NULL); pTaskBar->bDemandsAttentionWithDialog = cairo_dock_get_boolean_key_value (pKeyFile, "TaskBar", "demands attention with dialog", &bFlushConfFileNeeded, TRUE, "Applications", NULL); pTaskBar->iDialogDuration = cairo_dock_get_integer_key_value (pKeyFile, "TaskBar", "duration", &bFlushConfFileNeeded, 2, NULL, NULL); pTaskBar->cAnimationOnDemandsAttention = cairo_dock_get_string_key_value (pKeyFile, "TaskBar", "animation on demands attention", &bFlushConfFileNeeded, "fire", NULL, NULL); gchar *cForceDemandsAttention = cairo_dock_get_string_key_value (pKeyFile, "TaskBar", "force demands attention", &bFlushConfFileNeeded, "pidgin;xchat", NULL, NULL); pTaskBar->cForceDemandsAttention = g_ascii_strdown (cForceDemandsAttention, -1); g_free (cForceDemandsAttention); pTaskBar->cAnimationOnActiveWindow = cairo_dock_get_string_key_value (pKeyFile, "TaskBar", "animation on active window", &bFlushConfFileNeeded, "wobbly", NULL, NULL); pTaskBar->bMixLauncherAppli = cairo_dock_get_boolean_key_value (pKeyFile, "TaskBar", "mix launcher appli", &bFlushConfFileNeeded, TRUE, NULL, NULL); pTaskBar->bDrawIndicatorOnAppli = cairo_dock_get_boolean_key_value (pKeyFile, "TaskBar", "indic on appli", &bFlushConfFileNeeded, FALSE, NULL, NULL); pTaskBar->bOverWriteXIcons = cairo_dock_get_boolean_key_value (pKeyFile, "TaskBar", "overwrite xicon", &bFlushConfFileNeeded, TRUE, NULL, NULL); pTaskBar->cOverwriteException = cairo_dock_get_string_key_value (pKeyFile, "TaskBar", "overwrite exception", &bFlushConfFileNeeded, "pidgin;xchat", NULL, NULL); if (pTaskBar->cOverwriteException) { int i; for (i = 0; pTaskBar->cOverwriteException[i] != '\0'; i ++) pTaskBar->cOverwriteException[i] = g_ascii_tolower (pTaskBar->cOverwriteException[i]); } pTaskBar->bShowThumbnail = cairo_dock_get_boolean_key_value (pKeyFile, "TaskBar", "window thumbnail", &bFlushConfFileNeeded, TRUE, NULL, NULL); if (pTaskBar->bShowThumbnail && ! cairo_dock_xcomposite_is_available ()) { cd_warning ("Sorry but either your X server does not have the XComposite extension, or your version of Cairo-Dock was not built with the support of XComposite.\n You can't have window thumbnails in the dock"); pTaskBar->bShowThumbnail = FALSE; } return bFlushConfFileNeeded; }
void gldi_desklet_add_interactive_widget_with_margin (CairoDesklet *pDesklet, GtkWidget *pInteractiveWidget, int iRightMargin) { g_return_if_fail (pDesklet != NULL && pInteractiveWidget != NULL); if (pDesklet->pInteractiveWidget != NULL || gtk_bin_get_child (GTK_BIN (pDesklet->container.pWidget)) != NULL) { cd_warning ("This desklet already has an interactive widget !"); return; } //gtk_container_add (GTK_CONTAINER (pDesklet->container.pWidget), pInteractiveWidget); GtkWidget *pHBox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_container_add (GTK_CONTAINER (pDesklet->container.pWidget), pHBox); gtk_box_pack_start (GTK_BOX (pHBox), pInteractiveWidget, TRUE, TRUE, 0); pDesklet->pInteractiveWidget = pInteractiveWidget; if (iRightMargin != 0) { GtkWidget *pMarginBox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); g_object_set (pMarginBox, "width-request", iRightMargin, NULL); gtk_box_pack_start (GTK_BOX (pHBox), pMarginBox, FALSE, FALSE, 0); // a tester ... } gtk_widget_show_all (pHBox); }
static void upload (const gchar *cText, gchar *cLocalDir, gboolean bAnonymous, gint iLimitRate, gchar **cResultUrls, GError **pError) { if (cText == NULL || *cText == '\0') { g_set_error (pError, 1, 1, D_("Your text is empty and couldn't be uploaded to this server")); return; } GError *erreur = NULL; // http://pastebin.com/api gchar *cResult = cairo_dock_get_url_data_with_post (URL, FALSE, &erreur, "api_option", OPTION, "api_user_key", "", // guest "api_paste_private", bAnonymous ? "1" : "0", // unlisted or public "api_paste_name", bAnonymous ? "" : g_getenv ("USER"), "api_paste_expire_date", EXPIRE, "api_paste_format", FORMAT, "api_dev_key", DEV_KEY, "api_paste_code", cText, NULL); if (erreur) { cd_warning (erreur->message); g_error_free (erreur); DND2SHARE_SET_GENERIC_ERROR_WEBSITE ("Pastebin.com"); } else { cd_debug (" --> got '%s'", cResult); if (cResult == NULL || ! g_str_has_prefix (cResult, "http")) DND2SHARE_SET_GENERIC_ERROR_WEBSITE ("Pastebin.com"); else cResultUrls[0] = cResult; } }
static void _vfs_backend_mount_callback (gpointer pObject, GAsyncResult *res, gpointer *data) //static void _vfs_backend_mount_callback (gboolean succeeded, char *error, char *detailed_error, gpointer *data) { cd_message ("%s (%d)", __func__, GPOINTER_TO_INT (data[1])); CairoDockFMMountCallback pCallback = data[0]; GError *erreur = NULL; gboolean bSuccess; if (GPOINTER_TO_INT (data[1]) == 1) bSuccess = (g_file_mount_mountable_finish (G_FILE (pObject), res, &erreur) != NULL); //bSuccess = (g_volume_mount_finish (G_VOLUME (pObject), res, &erreur)); else if (GPOINTER_TO_INT (data[1]) == 0) bSuccess = g_mount_unmount_finish (G_MOUNT (pObject), res, &erreur); else bSuccess = g_mount_eject_finish (G_MOUNT (pObject), res, &erreur); if (erreur != NULL) { cd_warning ("Attention : %s", erreur->message); g_error_free (erreur); } cd_message ("(un)mount fini -> %d", bSuccess); pCallback (GPOINTER_TO_INT (data[1]) == 1, bSuccess, data[2], data[3], data[4]); //g_free (data[2]); //g_object_unref (pObject); //g_free (data); }
gboolean vfs_backend_move_file (const gchar *cURI, const gchar *cDirectoryURI) { g_return_val_if_fail (cURI != NULL, FALSE); cd_message (" %s -> %s", cURI, cDirectoryURI); GFile *pFile = (*cURI == '/' ? g_file_new_for_path (cURI) : g_file_new_for_uri (cURI)); gchar *cFileName = g_file_get_basename (pFile); gchar *cNewFileURI = g_strconcat (cDirectoryURI, "/", cFileName, NULL); // un peu moyen mais bon... GFile *pDestinationFile = (*cNewFileURI == '/' ? g_file_new_for_path (cNewFileURI) : g_file_new_for_uri (cNewFileURI)); g_free (cNewFileURI); g_free (cFileName); GError *erreur = NULL; gboolean bSuccess = g_file_move (pFile, pDestinationFile, G_FILE_COPY_NOFOLLOW_SYMLINKS, NULL, NULL, // GFileProgressCallback NULL, // data &erreur); if (erreur != NULL) { cd_warning ("Attention : %s", erreur->message); g_error_free (erreur); } g_object_unref (pFile); g_object_unref (pDestinationFile); return bSuccess; }
void vfs_backend_add_monitor (const gchar *cURI, gboolean bDirectory, CairoDockFMMonitorCallback pCallback, gpointer user_data) { g_return_if_fail (cURI != NULL); GError *erreur = NULL; GFileMonitor *pMonitor; GFile *pFile = (*cURI == '/' ? g_file_new_for_path (cURI) : g_file_new_for_uri (cURI)); if (bDirectory) pMonitor = g_file_monitor_directory (pFile, G_FILE_MONITOR_WATCH_MOUNTS, NULL, &erreur); else pMonitor = g_file_monitor_file (pFile, G_FILE_MONITOR_WATCH_MOUNTS, NULL, &erreur); //g_object_unref (pFile); if (erreur != NULL) { cd_warning ("Attention : couldn't add monitor on '%s' (%d) [%s]", cURI, bDirectory, erreur->message); g_error_free (erreur); return ; } gpointer *data = g_new0 (gpointer, 3); data[0] = pCallback; data[1] = user_data; data[2] = pMonitor; g_signal_connect (G_OBJECT (pMonitor), "changed", G_CALLBACK (_on_monitor_changed), data); g_hash_table_insert (s_hMonitorHandleTable, g_strdup (cURI), data); cd_message (">>> moniteur ajoute sur %s (%x)", cURI, user_data); }
/* Recupere tout chaque seconde (aucun signal). */ static void cd_exaile_read_data (void) { if (! myData.dbus_enable) { cd_warning ("couldn't connect to bus"); return; } if (! myData.bIsRunning) cd_musicplayer_dbus_detect_player (); if (myData.bIsRunning) { g_print ("Exaile is running\n"); cd_exaile_getSongInfos (); if (myData.iPlayingStatus == PLAYER_PLAYING && cairo_dock_strings_differ (myData.cRawTitle, myData.cPreviousRawTitle)) cd_exaile_getCoverPath (); else if (myData.iPlayingStatus == PLAYER_STOPPED) // en pause le temps et la chanson reste constants. { myData.iCurrentTime = 0; } cd_message (" myData.iCurrentTime <- %d", __func__, myData.iCurrentTime); } else { cd_debug ("MP : lecteur non ouvert"); myData.iPlayingStatus = PLAYER_NONE; } }
gboolean cd_keybinder_bind (const char *keystring, CDBindkeyHandler handler, gpointer user_data) { Binding *binding; gboolean success; if (!keystring) return FALSE; binding = g_new0 (Binding, 1); binding->keystring = g_strdup (keystring); binding->handler = handler; binding->user_data = user_data; /* Sets the binding's keycode and modifiers */ cd_debug ("%s", keystring); success = do_grab_key (binding); if (success) { bindings = g_slist_prepend (bindings, binding); } else { cd_warning ("couldnt bind %s", keystring); g_free (binding->keystring); g_free (binding); } return success; }
static void _on_got_playing_status (DBusGProxy *proxy, DBusGProxyCall *call_id, GldiModuleInstance *myApplet) { cd_debug ("=== %s ()", __func__); CD_APPLET_ENTER; s_pGetStatusCall = NULL; gchar *cStatus = NULL; GValue v = G_VALUE_INIT; GError *erreur = NULL; dbus_g_proxy_end_call (proxy, call_id, &erreur, G_TYPE_VALUE, &v, G_TYPE_INVALID); if (erreur != NULL) { cd_warning ("couldn't get MPRIS status (%s)\n", erreur->message); g_error_free (erreur); } else { if (G_VALUE_HOLDS_STRING (&v)) { cStatus = (gchar*)g_value_get_string (&v); myData.iPlayingStatus = _extract_status (cStatus); g_free (cStatus); // since we don't destroy the value, we destroy its content. } } cd_mpris2_getSongInfos_async (); CD_APPLET_LEAVE (); }
static void cd_quodlibet_getSongInfos (void) { GHashTable *data_list = NULL; if (dbus_g_proxy_call (myData.dbus_proxy_player, "CurrentSong", NULL, G_TYPE_INVALID, QL_DBUS_TYPE_SONG_METADATA, &data_list, G_TYPE_INVALID)) { _extract_metadata (data_list); g_hash_table_destroy (data_list); } else { cd_warning ("MP : Can't get song properties"); g_free (myData.cPlayingUri); myData.cPlayingUri = NULL; g_free (myData.cTitle); myData.cTitle = NULL; g_free (myData.cAlbum); myData.cAlbum = NULL; g_free (myData.cArtist); myData.cArtist = NULL; g_free (myData.cCoverPath); myData.cCoverPath = NULL; myData.iSongLength = 0; myData.iTrackNumber = 0; myData.cover_exist = FALSE; } }
gchar *cairo_dock_get_chosen_theme (gchar *cConfFile, gboolean *bUseThemeBehaviour, gboolean *bUseThemeLaunchers) { GError *erreur = NULL; GKeyFile *pKeyFile = g_key_file_new (); g_key_file_load_from_file (pKeyFile, cConfFile, G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, &erreur); if (erreur != NULL) { cd_warning ("Attention : %s", erreur->message); g_error_free (erreur); return NULL; } gchar *cThemeName = g_key_file_get_string (pKeyFile, "Themes", "chosen theme", &erreur); if (erreur != NULL) { cd_warning ("Attention : %s", erreur->message); g_error_free (erreur); return NULL; } if (cThemeName != NULL && *cThemeName == '\0') { g_free (cThemeName); cThemeName = NULL; } *bUseThemeBehaviour = g_key_file_get_boolean (pKeyFile, "Themes", "use theme behaviour", &erreur); if (erreur != NULL) { cd_warning ("Attention : %s", erreur->message); g_error_free (erreur); g_free (cThemeName); return NULL; } *bUseThemeLaunchers = g_key_file_get_boolean (pKeyFile, "Themes", "use theme launchers", &erreur); if (erreur != NULL) { cd_warning ("Attention : %s", erreur->message); g_error_free (erreur); g_free (cThemeName); return NULL; } g_key_file_free (pKeyFile); return cThemeName; }
GList *cd_shortcuts_list_bookmarks (gchar *cBookmarkFilePath, GldiModuleInstance *myApplet) { GList *pBookmarkIconList = NULL; Icon *pNewIcon; double fCurrentOrder = 0.; // Home gchar *cHome = g_strdup_printf ("file://%s", g_getenv ("HOME")); pNewIcon = _cd_shortcuts_get_icon (cHome, D_("Home Folder"), fCurrentOrder++); if (pNewIcon != NULL) { _init_disk_usage (pNewIcon, myApplet); CDDiskUsage *pDiskUsage = CD_APPLET_GET_MY_ICON_DATA (pNewIcon); if (pDiskUsage) // so that this bookmark will never be considered old, and therefore removed. pDiskUsage->iLastCheckTime = 1e9; pBookmarkIconList = g_list_append (pBookmarkIconList, pNewIcon); } else g_free (cHome); gchar *cContent = NULL; gsize length = 0; GError *erreur = NULL; g_file_get_contents (cBookmarkFilePath, &cContent, &length, &erreur); if (erreur != NULL) { cd_warning ("Attention: %s\n no bookmark will be available", erreur->message); g_error_free (erreur); } else { gchar **cBookmarksList = g_strsplit (cContent, "\n", -1); g_free (cContent); gchar *cOneBookmark; const gchar *cUserName; int i = 0; for (i = 0; cBookmarksList[i] != NULL; i ++) { cUserName = _get_custom_name_and_uri (cBookmarksList[i], &cOneBookmark); if (*cOneBookmark != '\0' && *cOneBookmark != '#') { cd_message (" + 1 bookmark : %s", cOneBookmark); pNewIcon = _cd_shortcuts_get_icon (cOneBookmark, cUserName, fCurrentOrder++); if (pNewIcon) pBookmarkIconList = g_list_append (pBookmarkIconList, pNewIcon); else g_free (cOneBookmark); } else { g_free (cOneBookmark); } } g_free (cBookmarksList); } return pBookmarkIconList; }
void cairo_dock_activate_modules_from_list (gchar **cActiveModuleList, CairoDock *pDock, double fTime) { if (cActiveModuleList == NULL) return ; GError *erreur = NULL; gchar *cModuleName; CairoDockModule *pModule; int i = 0, iOrder = 0; while (cActiveModuleList[i] != NULL) { cModuleName = cActiveModuleList[i]; //g_print (" + %s\n", cModuleName); pModule = g_hash_table_lookup (s_hModuleTable, cModuleName); if (pModule != NULL) { pModule->fLastLoadingTime = fTime; if (! pModule->bActive) { Icon *pIcon = cairo_dock_activate_module (pModule, pDock, &erreur); if (erreur != NULL) { cd_warning ("Attention : %s", erreur->message); g_error_free (erreur); erreur = NULL; } if (pIcon != NULL) { if (pIcon->fOrder == CAIRO_DOCK_LAST_ORDER) pIcon->fOrder = g_list_length (pDock->icons); // pas optimise, mais oblige de leur donner un numero distinct pour chacun, y compris quand on en active seulement 1. iOrder ++; if (CAIRO_DOCK_IS_DOCK (pModule->pContainer)) cairo_dock_insert_icon_in_dock (pIcon, CAIRO_DOCK (pModule->pContainer), ! CAIRO_DOCK_UPDATE_DOCK_SIZE, ! CAIRO_DOCK_ANIMATE_ICON, CAIRO_DOCK_APPLY_RATIO, g_bUseSeparator); } } else { /*CairoDock *pMyDock = NULL; Icon *pIcon = NULL; if (CAIRO_DOCK_IS_DOCK (pModule->pContainer)) { pIcon = cairo_dock_find_icon_from_module (pModule, pModule->pContainer); pMyDock = CAIRO_DOCK (pModule->pContainer); pIcon->fWidth /= pMyDock->fRatio; pIcon->fHeight /= pMyDock->fRatio; }*/ cairo_dock_reload_module (pModule, FALSE); /*if (pMyDock != NULL && pIcon != NULL) { pIcon->fWidth *= pMyDock->fRatio; pIcon->fHeight *= pMyDock->fRatio; }*/ } } i ++; } }
static void _set_metacity_composite (gboolean bActive) { int r; if (bActive) r = system ("gconftool-2 -s '/apps/metacity/general/compositing_manager' --type bool true"); else r = system ("gconftool-2 -s '/apps/metacity/general/compositing_manager' --type bool false"); if (r < 0) cd_warning ("Not able to launch this command: gconftool-2"); }
static void _set_xfwm_composite (gboolean bActive) { int r; if (bActive) r = system ("xfconf-query -c xfwm4 -p '/general/use_compositing' -t 'bool' -s 'true'"); else r = system ("xfconf-query -c xfwm4 -p '/general/use_compositing' -t 'bool' -s 'false'"); if (r < 0) cd_warning ("Not able to launch this command: xfconf-query"); }
static void _set_kwin_composite (gboolean bActive) { int r; if (bActive) r = system ("if test \"`qdbus org.kde.kwin /KWin compositingActive`\" = \"false\";then qdbus org.kde.kwin /KWin toggleCompositing; fi"); // not active, so activating else r = system ("if test \"`qdbus org.kde.kwin /KWin compositingActive`\" = \"true\"; then qdbus org.kde.kwin /KWin toggleCompositing; fi"); // active, so deactivating if (r < 0) cd_warning ("Not able to launch this command: qdbus"); }
void xgamma_set_gamma (XF86VidModeGamma *pGamma) { g_return_if_fail (pGamma != NULL); const Display *dpy = cairo_dock_get_Xdisplay (); g_return_if_fail (XF86VidModeSetGamma != NULL); if (!XF86VidModeSetGamma(dpy, DefaultScreen (dpy), pGamma)) { cd_warning ("Xgamma : unable to set gamma correction"); } }
void gldi_icon_insert_in_container (Icon *pIcon, GldiContainer *pContainer, gboolean bAnimateIcon) { g_return_if_fail (pContainer->iface.insert_icon != NULL); // the container must handle icons if (cairo_dock_get_icon_container (pIcon) != NULL) // the icon must not be in a container yet { cd_warning ("This icon (%s) is already inside a container !", pIcon->cName); return; } cairo_dock_set_icon_container (pIcon, pContainer); // set the container already, the icon might need it to set its size. pContainer->iface.insert_icon (pContainer, pIcon, bAnimateIcon); }
void cd_amarok1_control (MyPlayerControl pControl, const gchar *cFile) { //Permet d'effectuer les actions de bases sur le lecteur GError *erreur = NULL; if (pControl != PLAYER_JUMPBOX && pControl != PLAYER_SHUFFLE && pControl != PLAYER_REPEAT && pControl != PLAYER_ENQUEUE) { g_free (myData.cRawTitle); myData.cRawTitle = NULL; //Reset the title to detect it for sure ;) } gchar *cCommand = NULL; switch (pControl) { case PLAYER_PREVIOUS : cCommand = "dcop amarok player prev"; break; case PLAYER_PLAY_PAUSE : cCommand = "dcop amarok player playPause"; break; case PLAYER_STOP : cCommand = "dcop amarok player stop"; break; case PLAYER_NEXT : cCommand = "dcop amarok player next"; break; case PLAYER_SHUFFLE : cCommand = "dcop amarok playlist shufflePlaylist"; break; case PLAYER_REPEAT : cCommand = g_strdup_printf("dcop amarok player enableRepeatPlaylist %s", cd_dcop_get_boolean("dcop amarok player repeatPlaylistStatu") ? "true" : "false"); /*recuperer le boolean "dcop amarok player repeatPlaylistStatus" puis lancer : "dcop amarok player enableRepeatPlaylist false/true"*/ break; case PLAYER_ENQUEUE : if (cFile != NULL) cCommand = g_strdup_printf ("dcop amarok playlist addMediaList [ \"%s\" ]", cFile); break; default : return; break; } cd_debug ("Handler Amarok 1.4: will use '%s'", cCommand); g_spawn_command_line_async (cCommand, &erreur); if (pControl == PLAYER_ENQUEUE) g_free (cCommand); if (erreur != NULL) { cd_warning ("Attention : when trying to execute command : %s", erreur->message); g_error_free (erreur); CD_APPLET_MAKE_TEMPORARY_EMBLEM_CLASSIC (CAIRO_DOCK_EMBLEM_ERROR, CAIRO_DOCK_EMBLEM_UPPER_LEFT, 5000); } }
// TODO: remove that when Mesa 10.1 will be used by most people static gboolean _is_blacklisted (const gchar *cVersion, const gchar *cVendor, const gchar *cRenderer) { g_return_val_if_fail (cVersion && cVendor && cRenderer, FALSE); if (strstr (cRenderer, "Mesa DRI Intel(R) Ivybridge Mobile") != NULL && (strstr (cVersion, "Mesa 9") != NULL // affect all versions <= 10.0 || strstr (cVersion, "Mesa 10.0") != NULL) && strstr (cVendor, "Intel Open Source Technology Center") != NULL) { cd_warning ("This card is blacklisted due to a bug with your video drivers: Intel 4000 HD Ivybridge Mobile.\n Please install Mesa >= 10.1"); return TRUE; } return FALSE; }
double xgamma_get_gamma (XF86VidModeGamma *pGamma) { g_return_val_if_fail (pGamma != NULL, 1); const Display *dpy = cairo_dock_get_Xdisplay (); g_return_val_if_fail (XF86VidModeGetGamma != NULL, 1.); if (!XF86VidModeGetGamma (dpy, DefaultScreen (dpy), pGamma)) { cd_warning ("Xgamma : unable to query gamma correction"); return 1.; } return (pGamma->red + pGamma->blue + pGamma->green) / 3; }