gnome-control-center/capplets/keyboard/gnome-keyboard-properties-xkbpv.c

86 lines
2.8 KiB
C
Raw Normal View History

2004-07-13 23:11:34 +00:00
/* -*- mode: c; style: linux -*- */
/* gnome-keyboard-properties-xkb.c
* Copyright (C) 2003 Sergey V. Oudaltsov
*
* Written by: Sergey V. Oudaltsov <svu@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gnome.h>
#include <glade/glade.h>
#include "capplet-util.h"
#include "gnome-keyboard-properties-xkb.h"
#include "libkbdraw/keyboard-drawing.h"
2004-07-26 23:07:03 +00:00
static GtkWidget * previewWindow = NULL;
2004-07-28 00:18:35 +00:00
static gboolean click_on_X (GtkWidget *widget,
GdkEvent *event,
GladeXML *dialog)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("enable_preview")), FALSE);
/* stop processing! */
return TRUE;
}
static void
2004-07-28 00:18:35 +00:00
init_preview (GladeXML * dialog)
2004-07-13 23:11:34 +00:00
{
GtkWidget *kbdraw = keyboard_drawing_new ();
2004-07-26 23:07:03 +00:00
previewWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_destroy_with_parent (GTK_WINDOW (previewWindow), TRUE);
gtk_window_set_keep_above(GTK_WINDOW (previewWindow), TRUE);
gtk_window_set_resizable(GTK_WINDOW (previewWindow), TRUE);
gtk_window_set_skip_pager_hint(GTK_WINDOW (previewWindow), TRUE);
gtk_window_set_skip_taskbar_hint(GTK_WINDOW (previewWindow), TRUE);
gtk_window_set_default_size(GTK_WINDOW (previewWindow), 500, 300);
gtk_window_set_title(GTK_WINDOW (previewWindow), _("Keyboard layout preview"));
2004-07-13 23:11:34 +00:00
keyboard_drawing_set_track_group (KEYBOARD_DRAWING (kbdraw), TRUE);
keyboard_drawing_set_track_config (KEYBOARD_DRAWING (kbdraw), TRUE);
2004-07-28 00:58:01 +00:00
// show levels 1 and 2 - hoping that no more levels are used
keyboard_drawing_set_levels (KEYBOARD_DRAWING (kbdraw), 0, 1);
2004-07-26 23:07:03 +00:00
gtk_container_add (GTK_CONTAINER (previewWindow), kbdraw);
2004-07-28 00:18:35 +00:00
g_signal_connect (G_OBJECT (previewWindow), "delete-event",
G_CALLBACK (click_on_X), dialog);
2004-07-26 23:07:03 +00:00
}
void
preview_toggled (GladeXML * dialog, GtkWidget * button)
{
gboolean doShow = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
if (doShow && previewWindow == NULL)
2004-07-28 00:18:35 +00:00
init_preview (dialog);
2004-07-26 23:07:03 +00:00
if (doShow)
gtk_widget_show_all (previewWindow);
else
if (previewWindow != NULL)
gtk_widget_hide_all (previewWindow);
2004-07-13 23:11:34 +00:00
}