~ubuntu-branches/ubuntu/wily/gnome-applets/wily

« back to all changes in this revision

Viewing changes to null_applet/null_applet.c

  • Committer: Package Import Robot
  • Author(s): Dmitry Shachnev
  • Date: 2014-11-19 19:57:51 UTC
  • mfrom: (1.10.22)
  • Revision ID: package-import@ubuntu.com-20141119195751-gqirgm99dewik39n
Tags: 3.14.0-1~svn1
* New upstream release.
* Update (build-)dependencies for new version.
  - Require new GLib and libpanel-applet.
  - Switch from Python 2 to Python 3.
  - Drop GConf.
* Remove --enable-mixer-applet configure flag.
* Remove obsolete gnome-applets.gconf-defaults file.
* Update applet list in package description.
* Move Python modules to a private location.
* Use dh_python3.
* Use NEWS file as upstream changelog.
* Bump Standards-Version to 3.9.6, no changes needed.
* Update Homepage URL.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: C; c-basic-offset: 4 -*-
2
 
 * Null Applet - The Applet Deprecation Applet
3
 
 * Copyright (c) 2004, Davyd Madeley
4
 
 *
5
 
 * This library is free software; you can redistribute it and/or
6
 
 * modify it under the terms of the GNU General Public
7
 
 * License as published by the Free Software Foundation; either
8
 
 * version 2 of the License, or (at your option) any later version.
9
 
 *
10
 
 * This program is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 * GNU General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public License
16
 
 * along with this program; if not, write to the Free Software
17
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
 
 *
19
 
 * Author:
20
 
 *   Davyd Madeley <davyd@madeley.id.au>
21
 
 */
22
 
 
23
 
#ifdef HAVE_CONFIG_H
24
 
#include <config.h>
25
 
#endif
26
 
 
27
 
#include <glib/gi18n-lib.h>
28
 
#include <gtk/gtk.h>
29
 
#include <gconf/gconf-client.h>
30
 
#include "null_applet.h"
31
 
 
32
 
GType null_applet_get_type (void);
33
 
G_DEFINE_TYPE(NullApplet, null_applet, PANEL_TYPE_APPLET)
34
 
 
35
 
static void
36
 
null_applet_class_init (NullAppletClass *klass)
37
 
{
38
 
}
39
 
 
40
 
static void
41
 
null_applet_init (NullApplet *applet)
42
 
{
43
 
}
44
 
 
45
 
static inline void
46
 
insert_oafiids (GHashTable *hash_table)
47
 
{
48
 
        /*
49
 
         * Add OAFIID's and descriptions of deprecated applets here
50
 
         */
51
 
        g_hash_table_insert (hash_table,
52
 
                             "OAFIID:GNOME_MailcheckApplet", _("Inbox Monitor"));
53
 
        g_hash_table_insert (hash_table,
54
 
                             "OAFIID:GNOME_CDPlayerApplet", _("CD Player"));
55
 
        g_hash_table_insert (hash_table,
56
 
                             "OAFIID:GNOME_MixerApplet_Factory", _("Volume Control"));
57
 
        g_hash_table_insert (hash_table,
58
 
                             "OAFIID:GNOME_MixerApplet", _("Volume Control"));
59
 
        g_hash_table_insert (hash_table,
60
 
                             "OAFIID:GNOME_KeyboardApplet", _("Keyboard Indicator"));
61
 
}
62
 
 
63
 
static void
64
 
response_cb (GtkWidget *dialog, gint arg1, gpointer user_data)
65
 
{
66
 
        gtk_widget_destroy (dialog);
67
 
}
68
 
 
69
 
static char
70
 
*get_all_applets (void)
71
 
{
72
 
        GConfClient *client;
73
 
        GError *error;
74
 
        GSList *list, *l;
75
 
        char *key, *oafiid, *name;
76
 
        GHashTable *hash_table;
77
 
        GString *string;
78
 
 
79
 
        error = NULL;
80
 
        hash_table = g_hash_table_new (g_str_hash, g_str_equal);
81
 
        insert_oafiids (hash_table);
82
 
 
83
 
        string = g_string_new ("");
84
 
 
85
 
        client = gconf_client_get_default ();
86
 
 
87
 
        gconf_client_suggest_sync (client, NULL);
88
 
        
89
 
        list = gconf_client_all_dirs (client,
90
 
                "/apps/panel/applets",
91
 
                &error);
92
 
 
93
 
        if (error)
94
 
        {
95
 
                g_warning ("Error: %s", error->message);
96
 
                g_error_free (error);
97
 
                error = NULL;
98
 
        }
99
 
 
100
 
        for (l = list; l; l = l->next)
101
 
        {
102
 
            key = g_strdup_printf ("%s/bonobo_iid", (gchar *)l->data);
103
 
                oafiid = gconf_client_get_string (client, key, &error);
104
 
                if (error)
105
 
                {
106
 
                        g_warning ("Error: %s", error->message);
107
 
                        g_error_free (error);
108
 
                        error = NULL;
109
 
                }
110
 
                g_free (key);
111
 
        
112
 
                if (oafiid)
113
 
                {
114
 
                        name = g_hash_table_lookup (hash_table, oafiid);
115
 
                        if (name)
116
 
                        {
117
 
                                gconf_client_recursive_unset (client, l->data,
118
 
                                        GCONF_UNSET_INCLUDING_SCHEMA_NAMES,
119
 
                                        &error);
120
 
                                if (error)
121
 
                                {
122
 
                                        g_warning ("Error: %s", error->message);
123
 
                                        g_error_free (error);
124
 
                                        error = NULL;
125
 
                                }
126
 
                                g_string_append_printf (string,
127
 
                                                "    • %s\n", name);
128
 
                        }
129
 
                        g_free (oafiid);
130
 
                }
131
 
                g_free (l->data);
132
 
        }
133
 
 
134
 
        g_slist_free (list);
135
 
        g_hash_table_destroy (hash_table);
136
 
        
137
 
        return g_string_free (string, FALSE);
138
 
}
139
 
 
140
 
static gboolean
141
 
applet_factory (PanelApplet *applet,
142
 
                const char  *iid,
143
 
                gpointer     user_data)
144
 
{
145
 
        char *applet_list;
146
 
        GtkWidget *dialog;
147
 
 
148
 
        if (!g_str_equal (iid, "NullApplet"))
149
 
            return FALSE;
150
 
 
151
 
        applet_list = get_all_applets ();
152
 
 
153
 
        dialog = gtk_message_dialog_new_with_markup (NULL,
154
 
                        GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
155
 
                        GTK_MESSAGE_INFO, GTK_BUTTONS_OK,
156
 
                        "<span size=\"large\" weight=\"bold\">%s</span>"
157
 
                        "\n\n%s\n\n%s\n%s\n%s",
158
 
                        _("Some panel items are no longer available"),
159
 
                        _("One or more panel items (also referred to as applets"
160
 
                          ") are no longer available in the GNOME desktop."),
161
 
                        _("These items will now be removed from your "
162
 
                          "configuration:"),
163
 
                        applet_list,
164
 
                        _("You will not receive this message again.")
165
 
                        );
166
 
 
167
 
        g_free (applet_list);
168
 
 
169
 
        g_signal_connect (G_OBJECT (dialog), "response",
170
 
                        G_CALLBACK (response_cb), applet);
171
 
        
172
 
        gtk_widget_show_all (dialog);
173
 
                
174
 
        return TRUE;
175
 
}
176
 
 
177
 
PANEL_APPLET_OUT_PROCESS_FACTORY ("NullApplet",
178
 
                                  TYPE_NULL_APPLET,
179
 
                                  applet_factory,
180
 
                                  NULL)