~indicator-multiload/indicator-multiload/trunk

« back to all changes in this revision

Viewing changes to src/utils.vala

  • Committer: Michael Hofmann
  • Date: 2011-08-10 23:25:38 UTC
  • mto: This revision was merged to the branch mainline in revision 34.
  • Revision ID: mh21@piware.de-20110810232538-0os7v2l6o6sw83f8
Restructuring the settings a bit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 ******************************************************************************/
18
18
 
19
19
namespace Utils {
20
 
    public static string uifile;
 
20
    public string uifile;
21
21
 
22
22
    public double max(double[] data) {
23
23
        if (data.length == 0)
54
54
            ++index;
55
55
        }
56
56
        if (index < 0)
57
 
            return ngettext("%u byte", "%u bytes", 
 
57
            return ngettext("%u byte", "%u bytes",
58
58
                    (ulong)val).printf((uint)val);
59
59
        // 4 significant digits
60
60
        var pattern = _(units[index]).replace("{}",
91
91
        return pattern.printf(val);
92
92
    }
93
93
 
94
 
    public Object get_ui(string objectid, Object signalhandlers, 
 
94
    public Object get_ui(string objectid, Object signalhandlers,
95
95
            string[] additional = {}, out Gtk.Builder builder = null) {
96
96
        builder = new Gtk.Builder();
97
97
        string[] ids = additional;
106
106
        return builder.get_object(objectid);
107
107
    }
108
108
 
109
 
    public FixedGSettings.Settings globalsettings() {
110
 
        return new FixedGSettings.Settings("de.mh21.indicator.multiload");
 
109
    public FixedGSettings.Settings generalsettings() {
 
110
        return new FixedGSettings.Settings("de.mh21.indicator.multiload.general");
111
111
    }
112
112
 
113
113
    public FixedGSettings.Settings graphsettings(string graphid) {
114
114
        if (graphid.has_prefix("custom"))
115
115
            return new FixedGSettings.Settings.with_path
116
 
                ("de.mh21.indicator.multiload.graph", 
117
 
                 @"/apps/indicators/multiload/$graphid/");
 
116
                ("de.mh21.indicator.multiload.graph",
 
117
                 @"/apps/indicators/multiload/graphs/$graphid/");
118
118
        return new FixedGSettings.Settings
119
119
            (@"de.mh21.indicator.multiload.graphs.$graphid");
120
120
    }
121
121
 
122
 
    public FixedGSettings.Settings tracesettings(string graphid, 
 
122
    public FixedGSettings.Settings tracesettings(string graphid,
123
123
            string traceid) {
124
124
        if (traceid.has_prefix("custom"))
125
125
            return new FixedGSettings.Settings.with_path
126
126
                ("de.mh21.indicator.multiload.trace",
127
 
                 @"/apps/indicators/multiload/$graphid/$traceid/");
 
127
                 @"/apps/indicators/multiload/graphs/$graphid/$traceid/");
128
128
        return new FixedGSettings.Settings
129
129
            (@"de.mh21.indicator.multiload.traces.$traceid");
130
130
    }
139
139
        return false;
140
140
    }
141
141
 
142
 
    public Variant set_settings_color(Value value, VariantType expected_type, 
 
142
    public Variant set_settings_color(Value value, VariantType expected_type,
143
143
            void *user_data)
144
144
    {
145
145
        Gdk.Color color = *(Gdk.Color*)value.get_boxed();