source: trunk/third/gnome-applets/gswitchit/switch.c @ 21373

Revision 21373, 1.9 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r21372, which included commits to RCS files with non-trunk default branches.
Line 
1/*
2 *  This program is free software; you can redistribute it and/or modify
3 *  it under the terms of the GNU General Public License as published by
4 *  the Free Software Foundation; either version 2 of the License, or
5 *  (at your option) any later version.
6 *
7 *  This program is distributed in the hope that it will be useful,
8 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
9 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 *  GNU Library General Public License for more details.
11 *
12 *  You should have received a copy of the GNU General Public License
13 *  along with this program; if not, write to the Free Software
14 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15 */
16
17#include "config.h"
18
19#include <gdk/gdkx.h>
20#include <gnome.h>
21
22#include "gswitchit-applet.h"
23
24extern gboolean
25gkb_factory (PanelApplet * applet, const gchar * iid, gpointer data);
26
27static gboolean
28GKBAppletNew (PanelApplet * applet)
29{
30        fprintf (stderr, "No xkb found, fallback to gkb\n");
31        return gkb_factory (applet, "OAFIID:GNOME_KeyboardApplet", NULL);
32}
33
34static gboolean
35CheckXKB (void)
36{
37        gboolean have_xkb = FALSE;
38        int opcode, errorBase, major, minor, xkbEventBase;
39
40        gdk_error_trap_push ();
41        have_xkb = XkbQueryExtension (GDK_DISPLAY (),
42                                      &opcode, &xkbEventBase, &errorBase,
43                                      &major, &minor)
44            && XkbUseExtension (GDK_DISPLAY (), &major, &minor);
45        XSync (GDK_DISPLAY (), FALSE);
46        gdk_error_trap_pop ();
47
48        return have_xkb;
49}
50
51static gboolean
52KeyboardAppletFactory (PanelApplet * applet,
53                       const gchar * iid, gpointer data)
54{
55        if (!strcmp (iid, "OAFIID:GNOME_KeyboardApplet")) {
56                if (CheckXKB ())
57                        return GSwitchItAppletNew (applet);
58                else
59                        return GKBAppletNew (applet);
60        }
61        return TRUE;
62}
63
64PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_KeyboardApplet_Factory", PANEL_TYPE_APPLET, "gswitchit", "0", KeyboardAppletFactory, NULL)   //data
Note: See TracBrowser for help on using the repository browser.