~ubuntu-branches/ubuntu/oneiric/xfce4-indicator-plugin/oneiric-proposed

« back to all changes in this revision

Viewing changes to panel-plugin/indicator.c

  • Committer: Bazaar Package Importer
  • Author(s): Lionel Le Folgoc
  • Date: 2011-03-08 21:16:44 UTC
  • Revision ID: james.westby@ubuntu.com-20110308211644-7t9dc0sd4cusdvxh
Tags: 0.2.0-0ubuntu4
* debian/patches:
  - xubuntu_exclude-modules.patch: add a blacklist option. Some modules are
    unneeded/redundant/badly work on Xubuntu (e.g. appmenu), so give the
    possibility to ignore them.
  - series: add this patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include "indicator.h"
32
32
 
33
33
/* default settings */
34
 
#define DEFAULT_SETTING1 NULL
35
 
#define DEFAULT_SETTING2 1
36
 
#define DEFAULT_SETTING3 FALSE
 
34
#define DEFAULT_EXCLUDED_MODULES NULL
37
35
 
38
36
/* prototypes */
39
37
static void
75
73
    {
76
74
      /* save the settings */
77
75
      DBG(".");
78
 
      if (indicator->setting1)
79
 
        xfce_rc_write_entry    (rc, "setting1", indicator->setting1);
80
 
 
81
 
      xfce_rc_write_int_entry  (rc, "setting2", indicator->setting2);
82
 
      xfce_rc_write_bool_entry (rc, "setting3", indicator->setting3);
 
76
      if (indicator->excluded_modules)
 
77
        xfce_rc_write_list_entry (rc, "Exclude",
 
78
                                  indicator->excluded_modules, NULL);
83
79
 
84
80
      /* close the rc file */
85
81
      xfce_rc_close (rc);
86
82
    }
87
83
}
88
 
 
 
84
#endif
89
85
 
90
86
 
91
87
static void
93
89
{
94
90
  XfceRc      *rc;
95
91
  gchar       *file;
96
 
  const gchar *value;
97
92
 
98
93
  /* get the plugin config file location */
99
 
  file = xfce_panel_plugin_save_location (indicator->plugin, TRUE);
 
94
  file = xfce_panel_plugin_lookup_rc_file (indicator->plugin);
100
95
 
101
96
  if (G_LIKELY (file != NULL))
102
97
    {
109
104
      if (G_LIKELY (rc != NULL))
110
105
        {
111
106
          /* read the settings */
112
 
          value = xfce_rc_read_entry (rc, "setting1", DEFAULT_SETTING1);
113
 
          indicator->setting1 = g_strdup (value);
114
 
 
115
 
          indicator->setting2 = xfce_rc_read_int_entry (rc, "setting2", DEFAULT_SETTING2);
116
 
          indicator->setting3 = xfce_rc_read_bool_entry (rc, "setting3", DEFAULT_SETTING3);
 
107
          indicator->excluded_modules = xfce_rc_read_list_entry (rc, "Exclude", NULL);
117
108
 
118
109
          /* cleanup */
119
110
          xfce_rc_close (rc);
126
117
  /* something went wrong, apply default values */
127
118
  DBG ("Applying default settings");
128
119
 
129
 
  indicator->setting1 = g_strdup (DEFAULT_SETTING1);
130
 
  indicator->setting2 = DEFAULT_SETTING2;
131
 
  indicator->setting3 = DEFAULT_SETTING3;
 
120
  indicator->excluded_modules = DEFAULT_EXCLUDED_MODULES;
132
121
}
133
 
#endif
134
122
 
135
123
 
136
124
static IndicatorPlugin *
189
177
  //g_signal_connect_after(indicator->menu, "expose-event", G_CALLBACK(menu_on_expose), menu);
190
178
  gtk_container_set_border_width(GTK_CONTAINER(indicator->menu), 0);
191
179
 
 
180
  /* get the list of excluded modules */
 
181
  indicator_read (indicator);
192
182
  
193
183
  /* load 'em */
194
184
  if (g_file_test(INDICATOR_DIR, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
195
185
    GDir * dir = g_dir_open(INDICATOR_DIR, 0, NULL);
196
186
 
197
187
    const gchar * name;
 
188
    guint i, length;
 
189
    gboolean match = FALSE;
 
190
 
 
191
    length = g_strv_length (indicator->excluded_modules);
198
192
    while ((name = g_dir_read_name(dir)) != NULL) {
 
193
      for (i = 0; i < length; ++i) {
 
194
        if (match = (g_strcmp0 (name, indicator->excluded_modules[i]) == 0))
 
195
          break;
 
196
      }
 
197
 
 
198
      if (G_UNLIKELY (match)) {
 
199
        g_debug ("Excluding module: %s", name);
 
200
        continue;
 
201
      }
 
202
 
199
203
      if (load_module(name, indicator->menu))
200
204
        indicators_loaded++;
201
205
    }
229
233
    gtk_widget_destroy (dialog);
230
234
 
231
235
  /* free the plugin structure */
 
236
  g_strfreev (indicator->excluded_modules);
232
237
  panel_slice_free (IndicatorPlugin, indicator);
233
238
}
234
239