~cairo-dock-team/ubuntu/precise/cairo-dock/3.0.0.0beta1

« back to all changes in this revision

Viewing changes to src/gldit/cairo-dock-data-renderer.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2011-03-17 14:08:48 UTC
  • mfrom: (1.1.14 upstream)
  • Revision ID: james.westby@ubuntu.com-20110317140848-b8efysl4ynhjm87k
Tags: 2.3.0~1-0ubuntu1
* New Upstream Version (LP: #723994)
* Upstream short ChangeLog:
 - Updated translations
 - Updated the integration of the new versions of kwin and compiz
 - Updated default theme
 - Fixed a few bugs
 - Updated the man
* debian/control:
 - Added suggests apps for cairo-dock-core (needed by the default theme)
 - Updated the description (from launchpad.net/cairo-dock)
 - Added cairo-dock-plug-ins as a new suggestion for cairo-dock-core
* debian/patches:
 - Updated the default theme to use default apps of Ubuntu Natty 
* Switch to dpkg-source 3.0 (quilt) format
* Removed the desktop-file-category patch (sync with debian packages)
* debian/rules:
 - Added a CMake flag to disable the gtk grip
 - No longer used simple-patchsys
* Updated the debian/watch

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include <string.h>
22
22
#include <math.h>
23
23
 
24
 
#include "../config.h"
 
24
#include "gldi-config.h"
25
25
#include "cairo-dock-log.h"
26
26
#include "cairo-dock-backends-manager.h"
27
27
#include "cairo-dock-notifications.h"
31
31
#include "cairo-dock-surface-factory.h"
32
32
#include "cairo-dock-draw.h"
33
33
#include "cairo-dock-container.h"
34
 
#include "cairo-dock-icons.h"
35
 
#include "cairo-dock-load.h"
 
34
#include "cairo-dock-icon-factory.h"
 
35
#include "cairo-dock-icon-facility.h"
 
36
#include "cairo-dock-image-buffer.h"
36
37
#include "cairo-dock-config.h"
37
38
#include "cairo-dock-keyfile-utilities.h"
38
39
#include "cairo-dock-packages.h"
39
 
#include "cairo-dock-internal-labels.h"
40
40
#include "cairo-dock-gauge.h"
41
41
#include "cairo-dock-graph.h"
42
42
#include "cairo-dock-data-renderer.h"
43
43
 
44
44
extern gboolean g_bUseOpenGL;
45
 
extern CairoContainer *g_pPrimaryContainer;
46
 
extern gchar *g_cExtrasDirPath;
47
45
 
48
46
#define cairo_dock_set_data_renderer_on_icon(pIcon, pRenderer) (pIcon)->pDataRenderer = pRenderer
49
47
#define CD_MIN_TEXT_WITH 24
50
48
 
51
 
static CairoDockGLFont *s_pFont = NULL;
52
 
 
53
 
#define _init_data_renderer_font(...) s_pFont = cairo_dock_load_textured_font ("Monospace Bold 12", 0, 184)  // on va jusqu'a ø
54
 
 
55
 
CairoDockGLFont *cairo_dock_get_default_data_renderer_font (void)
56
 
{
57
 
        if (s_pFont == NULL)
58
 
                _init_data_renderer_font ();
59
 
        return s_pFont;
60
 
}
61
 
 
62
 
void cairo_dock_unload_default_data_renderer_font (void)
63
 
{
64
 
        cairo_dock_free_gl_font (s_pFont);
65
 
        s_pFont = NULL;
66
 
}
67
 
 
68
 
 
69
 
CairoDataRenderer *cairo_dock_new_data_renderer (const gchar *cRendererName)
70
 
{
71
 
        CairoDockDataRendererRecord *pRecord = cairo_dock_get_data_renderer_record (cRendererName);
72
 
        g_return_val_if_fail (pRecord != NULL && pRecord->iStructSize != 0, NULL);
73
 
        
74
 
        if (g_pPrimaryContainer && s_pFont == NULL)
75
 
        {
76
 
                _init_data_renderer_font ();
77
 
        }
78
 
        
79
 
        CairoDataRenderer *pRenderer = g_malloc0 (pRecord->iStructSize);
80
 
        memcpy (&pRenderer->interface, &pRecord->interface, sizeof (CairoDataRendererInterface));
81
 
        return pRenderer;
82
 
}
83
 
 
84
49
static void _cairo_dock_init_data_renderer (CairoDataRenderer *pRenderer, CairoContainer *pContainer, CairoDataRendererAttribute *pAttribute)
85
50
{
86
51
        //\_______________ On alloue la structure des donnees.
437
402
        if (pRenderer->pLabels != NULL)
438
403
        {
439
404
                CairoDockLabelDescription textDescription;
440
 
                cairo_dock_copy_label_description (&textDescription, &myLabels.quickInfoTextDescription);
 
405
                cairo_dock_copy_label_description (&textDescription, &myIconsParam.quickInfoTextDescription);
441
406
                
442
407
                CairoDataRendererText *pLabel;
443
408
                cairo_surface_t *pSurface;
506
471
        if (CAIRO_DOCK_CONTAINER_IS_OPENGL (pContainer) && pRenderer->interface.render_opengl)
507
472
        {
508
473
                bLoadTextures = TRUE;
509
 
                cairo_dock_register_notification_on_icon (pIcon, CAIRO_DOCK_UPDATE_ICON_SLOW,
 
474
                cairo_dock_register_notification_on_object (pIcon,
 
475
                        NOTIFICATION_UPDATE_ICON_SLOW,
510
476
                        (CairoDockNotificationFunc) cairo_dock_update_icon_data_renderer_notification,
511
477
                        CAIRO_DOCK_RUN_AFTER, NULL);  // pour l'affichage fluide.
512
478
        }
647
613
{
648
614
        CairoDataRenderer *pRenderer = cairo_dock_get_icon_data_renderer (pIcon);
649
615
        
650
 
        cairo_dock_remove_notification_func_on_icon (pIcon, CAIRO_DOCK_UPDATE_ICON_SLOW, (CairoDockNotificationFunc) cairo_dock_update_icon_data_renderer_notification, NULL);
 
616
        cairo_dock_remove_notification_func_on_object (pIcon, NOTIFICATION_UPDATE_ICON_SLOW, (CairoDockNotificationFunc) cairo_dock_update_icon_data_renderer_notification, NULL);
651
617
        
652
618
        cairo_dock_free_data_renderer (pRenderer);
653
619
        cairo_dock_set_data_renderer_on_icon (pIcon, NULL);
763
729
}
764
730
 
765
731
 
766
 
 
767
 
  /////////////////////////////////////////////////
768
 
 /////////////// LIST OF THEMES  /////////////////
769
 
/////////////////////////////////////////////////
770
 
GHashTable *cairo_dock_list_available_themes_for_data_renderer (const gchar *cRendererName)
771
 
{
772
 
        CairoDockDataRendererRecord *pRecord = cairo_dock_get_data_renderer_record (cRendererName);
773
 
        g_return_val_if_fail (pRecord != NULL, NULL);
774
 
        
775
 
        if (pRecord->cThemeDirName == NULL && pRecord->cDistantThemeDirName == NULL)
776
 
                return NULL;
777
 
        gchar *cGaugeShareDir = g_strdup_printf ("%s/%s", CAIRO_DOCK_SHARE_DATA_DIR, pRecord->cThemeDirName);
778
 
        gchar *cGaugeUserDir = g_strdup_printf ("%s/%s", g_cExtrasDirPath, pRecord->cThemeDirName);
779
 
        GHashTable *pGaugeTable = cairo_dock_list_packages (cGaugeShareDir, cGaugeUserDir, pRecord->cDistantThemeDirName);
780
 
        
781
 
        g_free (cGaugeShareDir);
782
 
        g_free (cGaugeUserDir);
783
 
        return pGaugeTable;
784
 
}
785
 
 
786
 
 
787
 
gchar *cairo_dock_get_data_renderer_theme_path (const gchar *cRendererName, const gchar *cThemeName, CairoDockPackageType iType)  // utile pour DBus aussi.
788
 
{
789
 
        CairoDockDataRendererRecord *pRecord = cairo_dock_get_data_renderer_record (cRendererName);
790
 
        g_return_val_if_fail (pRecord != NULL, NULL);
791
 
        
792
 
        if (pRecord->cThemeDirName == NULL && pRecord->cDistantThemeDirName == NULL)
793
 
                return NULL;
794
 
        
795
 
        const gchar *cGaugeShareDir = g_strdup_printf ("%s/%s", CAIRO_DOCK_SHARE_DATA_DIR, pRecord->cThemeDirName);
796
 
        gchar *cGaugeUserDir = g_strdup_printf ("%s/%s", g_cExtrasDirPath, pRecord->cThemeDirName);
797
 
        gchar *cGaugePath = cairo_dock_get_package_path (cThemeName, cGaugeShareDir, cGaugeUserDir, pRecord->cDistantThemeDirName, iType);
798
 
        g_free (cGaugeUserDir);
799
 
        return cGaugePath;
800
 
}
801
 
 
802
 
gchar *cairo_dock_get_package_path_for_data_renderer (const gchar *cRendererName, const gchar *cAppletConfFilePath, GKeyFile *pKeyFile, const gchar *cGroupName, const gchar *cKeyName, gboolean *bFlushConfFileNeeded, const gchar *cDefaultThemeName)
803
 
{
804
 
        CairoDockDataRendererRecord *pRecord = cairo_dock_get_data_renderer_record (cRendererName);
805
 
        g_return_val_if_fail (pRecord != NULL, NULL);
806
 
        
807
 
        gchar *cChosenThemeName = cairo_dock_get_string_key_value (pKeyFile, cGroupName, cKeyName, bFlushConfFileNeeded, cDefaultThemeName, NULL, NULL);
808
 
        if (cChosenThemeName == NULL)
809
 
                cChosenThemeName = g_strdup (pRecord->cDefaultTheme);
810
 
        
811
 
        CairoDockPackageType iType = cairo_dock_extract_package_type_from_name (cChosenThemeName);
812
 
        gchar *cGaugePath = cairo_dock_get_data_renderer_theme_path (cRendererName, cChosenThemeName, iType);
813
 
        
814
 
        if (cGaugePath == NULL)  // theme introuvable.
815
 
                cGaugePath = g_strdup_printf (CAIRO_DOCK_SHARE_DATA_DIR"/%s/%s", pRecord->cThemeDirName, pRecord->cDefaultTheme);
816
 
        
817
 
        if (iType != CAIRO_DOCK_ANY_PACKAGE)
818
 
        {
819
 
                g_key_file_set_string (pKeyFile, cGroupName, cKeyName, cChosenThemeName);
820
 
                cairo_dock_write_keys_to_file (pKeyFile, cAppletConfFilePath);
821
 
        }
822
 
        cd_debug ("Theme de la jauge : %s", cGaugePath);
823
 
        g_free (cChosenThemeName);
824
 
        return cGaugePath;
825
 
}
826
 
 
827
 
 
828
 
void cairo_dock_register_built_in_data_renderers (void)
 
732
void cairo_dock_register_built_in_data_renderers (void)  /// merge with init.
829
733
{
830
734
        cairo_dock_register_data_renderer_graph ();
831
735
        cairo_dock_register_data_renderer_gauge ();