~ubuntu-branches/ubuntu/wily/window-picker-applet/wily

« back to all changes in this revision

Viewing changes to src/applet.c

  • Committer: Bazaar Package Importer
  • Author(s): Neil J. Patel
  • Date: 2008-10-13 19:43:13 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20081013194313-f917g00xy2jcguuj
Tags: 0.4.0-0ubuntu1
New upstream release (LP: #283355)

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
#include <panel-applet.h>
32
32
#include <panel-applet-gconf.h>
 
33
#include <gconf/gconf-client.h>
33
34
 
34
35
#include "task-list.h"
35
36
#include "task-title.h"
36
37
 
 
38
#define SHOW_WIN_KEY "show_all_windows"
 
39
 
37
40
typedef struct 
38
41
{
39
 
  GtkWidget    *image;
 
42
  GtkWidget    *tasks;
40
43
  GtkWidget    *applet;
41
44
  
42
 
} GoHomeApp;
 
45
} WinPickerApp;
43
46
 
44
47
static void cw_panel_background_changed (PanelApplet               *applet,
45
48
                                         PanelAppletBackgroundType  type,
69
72
        NULL
70
73
};
71
74
 
 
75
static void
 
76
on_show_all_windows_changed (GConfClient *client,
 
77
                             guint        conn_id,
 
78
                             GConfEntry  *entry,
 
79
                             gpointer     data)
 
80
{
 
81
  WinPickerApp *app;
 
82
  gboolean show_windows = TRUE;
 
83
 
 
84
  app = (WinPickerApp*)data;
 
85
 
 
86
  show_windows = panel_applet_gconf_get_bool (PANEL_APPLET (app->applet),
 
87
                                              SHOW_WIN_KEY, NULL);
 
88
 
 
89
  g_object_set (app->tasks, "show_all_windows", show_windows, NULL);
 
90
}
 
91
 
72
92
static gboolean
73
93
cw_applet_fill (PanelApplet *applet, 
74
94
                const gchar *iid, 
75
95
                gpointer     data)
76
96
{
77
97
  WnckScreen *screen;
78
 
  GoHomeApp *app;
 
98
  WinPickerApp *app;
79
99
  GtkWidget *eb, *tasks, *title;
 
100
  GError *error = NULL;
 
101
  gchar *key;
80
102
  
81
103
  if (strcmp (iid, "OAFIID:GNOME_WindowPicker") != 0)
82
104
                return FALSE;
85
107
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
86
108
  textdomain (GETTEXT_PACKAGE);
87
109
 
88
 
  app = g_slice_new0 (GoHomeApp);
 
110
  app = g_slice_new0 (WinPickerApp);
89
111
  screen = wnck_screen_get_default ();
90
112
 
 
113
  /* Gconf prefs */
 
114
  panel_applet_add_preferences (applet, 
 
115
                                "/schemas/apps/window-picker-applet/prefs",
 
116
                                &error);
 
117
  if (error)
 
118
  {
 
119
    g_warning ("%s", error->message);
 
120
    g_error_free (error);
 
121
  }
 
122
 
 
123
  key = panel_applet_gconf_get_full_key (applet, SHOW_WIN_KEY);
 
124
  gconf_client_notify_add (gconf_client_get_default (), key,
 
125
                           on_show_all_windows_changed, app,
 
126
                           NULL, NULL);
 
127
  g_free (key);
 
128
 
91
129
  app->applet = GTK_WIDGET (applet);
92
130
  gtk_container_set_border_width (GTK_CONTAINER (applet), 0);
93
131
 
95
133
        gtk_container_add (GTK_CONTAINER (applet), eb);
96
134
  gtk_container_set_border_width (GTK_CONTAINER (eb), 0);
97
135
 
98
 
  tasks = task_list_new ();
 
136
  tasks = app->tasks = task_list_new ();
99
137
  gtk_box_pack_start (GTK_BOX (eb), tasks, FALSE, FALSE, 0);
100
138
 
101
139
  title = task_title_new ();
103
141
 
104
142
  gtk_widget_show_all (GTK_WIDGET (applet));
105
143
        
 
144
  on_show_all_windows_changed (NULL, 0, NULL, app);
106
145
                
107
146
  /* Signals */
108
147
        g_signal_connect (applet, "change-background",