moving printing to libgnomekbd 2.21.4.1
svn path=/trunk/; revision=8334
This commit is contained in:
parent
7b3edf7275
commit
b639fb8fc6
6 changed files with 37 additions and 111 deletions
|
@ -1,3 +1,10 @@
|
|||
2007-12-17 Sergey Udaltsov <svu@gnome.org>
|
||||
|
||||
* gnome-keyboard-properties-xkblt.c, gnome-keyboard-properties-xkb.h,
|
||||
gnome-keyboard-properties-xkbpv.c,
|
||||
gnome-keyboard-properties-xkbltadd.c: moved printing to libgnomekbd
|
||||
(2.21.4.1)
|
||||
|
||||
2007-12-14 Jens Granseuer <jensgr@gmx.net>
|
||||
|
||||
* gnome-keyboard-properties-xkbpv.c:
|
||||
|
|
|
@ -91,10 +91,6 @@ extern void xkb_layout_preview_update (GladeXML * chooser_dialog);
|
|||
extern void xkb_layout_preview_set_drawing_layout (GtkWidget *kbdraw,
|
||||
const gchar *id);
|
||||
|
||||
extern void xkb_layout_preview_print (GtkWidget *kbdraw,
|
||||
GtkWindow *parent_window,
|
||||
const gchar *id);
|
||||
|
||||
extern gchar *xkb_layout_chooser_get_selected_id (GladeXML *
|
||||
chooser_dialog);
|
||||
|
||||
|
|
|
@ -29,12 +29,13 @@
|
|||
#include <gconf/gconf-client.h>
|
||||
#include <glade/glade.h>
|
||||
|
||||
#include "capplet-util.h"
|
||||
|
||||
#include <libgnomekbd/gkbd-desktop-config.h>
|
||||
#include <libgnomekbd/gkbd-keyboard-drawing.h>
|
||||
|
||||
#include "capplet-util.h"
|
||||
#include "gnome-keyboard-properties-xkb.h"
|
||||
|
||||
|
||||
#define SEL_LAYOUT_TREE_COL_DESCRIPTION 0
|
||||
#define SEL_LAYOUT_TREE_COL_DEFAULT 1
|
||||
#define SEL_LAYOUT_TREE_COL_ID 2
|
||||
|
@ -356,15 +357,17 @@ xkb_layouts_prepare_selected_tree (GladeXML * dialog,
|
|||
dialog);
|
||||
}
|
||||
|
||||
gchar *xkb_layout_description_utf8 (const gchar *visible)
|
||||
gchar *
|
||||
xkb_layout_description_utf8 (const gchar * visible)
|
||||
{
|
||||
char *l, *sl, *v, *sv;
|
||||
char *v1, *utf_visible;
|
||||
if (gkbd_keyboard_config_get_descriptions (config_registry, visible,
|
||||
&sl, &l, &sv, &v))
|
||||
if (gkbd_keyboard_config_get_descriptions
|
||||
(config_registry, visible, &sl, &l, &sv, &v))
|
||||
visible = gkbd_keyboard_config_format_full_layout (l, v);
|
||||
v1 = g_strdup (visible);
|
||||
utf_visible = g_locale_to_utf8 (g_strstrip (v1), -1, NULL, NULL, NULL);
|
||||
utf_visible =
|
||||
g_locale_to_utf8 (g_strstrip (v1), -1, NULL, NULL, NULL);
|
||||
g_free (v1);
|
||||
return utf_visible;
|
||||
}
|
||||
|
@ -449,11 +452,14 @@ print_selected_layout (GtkWidget * button, GladeXML * dialog)
|
|||
const gchar *id = g_slist_nth_data (layouts_list, idx);
|
||||
|
||||
GtkWidget *window = WID ("keyboard_dialog");
|
||||
GtkWidget *kbdraw = xkb_layout_preview_create_widget (NULL);
|
||||
GtkWidget *kbdraw =
|
||||
xkb_layout_preview_create_widget (NULL);
|
||||
g_object_ref_sink (kbdraw);
|
||||
gtk_widget_set_parent (kbdraw, window);
|
||||
xkb_layout_preview_set_drawing_layout (kbdraw, id);
|
||||
xkb_layout_preview_print (kbdraw, GTK_WINDOW (window), id);
|
||||
gkbd_keyboard_drawing_print (GKBD_KEYBOARD_DRAWING
|
||||
(kbdraw), GTK_WINDOW (window),
|
||||
id);
|
||||
g_object_unref (kbdraw);
|
||||
|
||||
clear_xkb_elements_list (layouts_list);
|
||||
|
|
|
@ -30,10 +30,10 @@
|
|||
#include <gnome.h>
|
||||
#include <glade/glade.h>
|
||||
|
||||
#include "capplet-util.h"
|
||||
|
||||
#include <libgnomekbd/gkbd-keyboard-drawing.h>
|
||||
#include <libgnomekbd/gkbd-util.h>
|
||||
|
||||
#include "capplet-util.h"
|
||||
#include "gnome-keyboard-properties-xkb.h"
|
||||
|
||||
#define GROUP_SWITCHERS_GROUP "grp"
|
||||
|
@ -361,9 +361,14 @@ xkb_layout_chooser_print (GladeXML * chooser_dialog)
|
|||
GtkWidget *chooser = CWID ("xkb_layout_chooser");
|
||||
GtkWidget *kbdraw =
|
||||
GTK_WIDGET (g_object_get_data (G_OBJECT (chooser), "kbdraw"));
|
||||
const char *id = xkb_layout_chooser_get_selected_id (chooser_dialog);
|
||||
xkb_layout_preview_print (kbdraw,
|
||||
GTK_WINDOW (CWID ("xkb_layout_chooser")), id);
|
||||
const char *id =
|
||||
xkb_layout_chooser_get_selected_id (chooser_dialog);
|
||||
char *descr = xkb_layout_description_utf8 (id);
|
||||
gkbd_keyboard_drawing_print (GKBD_KEYBOARD_DRAWING (kbdraw),
|
||||
GTK_WINDOW (CWID
|
||||
("xkb_layout_chooser")),
|
||||
descr);
|
||||
g_free (descr);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -431,7 +436,8 @@ xkb_layout_choose (GladeXML * dialog)
|
|||
gtk_widget_show_all (kbdraw);
|
||||
gtk_button_box_set_child_secondary (GTK_BUTTON_BOX
|
||||
(CWID ("hbtnBox")),
|
||||
CWID ("btnPrint"), TRUE);
|
||||
CWID ("btnPrint"),
|
||||
TRUE);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
|
|
|
@ -28,11 +28,11 @@
|
|||
#include <gnome.h>
|
||||
#include <glade/glade.h>
|
||||
|
||||
#include "capplet-util.h"
|
||||
|
||||
#include "gnome-keyboard-properties-xkb.h"
|
||||
#include <libgnomekbd/gkbd-keyboard-drawing.h>
|
||||
|
||||
#include "capplet-util.h"
|
||||
#include "gnome-keyboard-properties-xkb.h"
|
||||
|
||||
#ifdef HAVE_X11_EXTENSIONS_XKB_H
|
||||
#include "X11/XKBlib.h"
|
||||
/**
|
||||
|
@ -128,92 +128,3 @@ xkb_layout_preview_set_drawing_layout (GtkWidget * kbdraw, const gchar * id)
|
|||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
GtkWidget *kbdraw;
|
||||
const gchar *id;
|
||||
} XkbLayoutPreviewPrintData;
|
||||
|
||||
|
||||
static void
|
||||
xkb_layout_preview_begin_print (GtkPrintOperation *operation,
|
||||
GtkPrintContext *context,
|
||||
XkbLayoutPreviewPrintData *data)
|
||||
{
|
||||
gtk_print_operation_set_n_pages (operation, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
xkb_layout_preview_draw_page (GtkPrintOperation *operation,
|
||||
GtkPrintContext *context,
|
||||
gint page_nr,
|
||||
XkbLayoutPreviewPrintData *data)
|
||||
{
|
||||
cairo_t *cr = gtk_print_context_get_cairo_context (context);
|
||||
PangoLayout *layout = gtk_print_context_create_pango_layout (context);
|
||||
PangoFontDescription *desc =
|
||||
pango_font_description_from_string ("sans 8");
|
||||
gdouble width = gtk_print_context_get_width (context);
|
||||
gdouble height = gtk_print_context_get_height (context);
|
||||
gdouble dpi_x = gtk_print_context_get_dpi_x (context);
|
||||
gdouble dpi_y = gtk_print_context_get_dpi_y (context);
|
||||
gchar *header, *description;
|
||||
|
||||
gtk_print_operation_set_unit (operation, GTK_PIXELS);
|
||||
|
||||
description = xkb_layout_description_utf8 (data->id);
|
||||
header = g_strdup_printf
|
||||
(_("Keyboard layout \"%s\"\n"
|
||||
"Copyright © X.Org Foundation and "
|
||||
"XKeyboardConfig contributors\n"
|
||||
"For licensing see package metadata"), description);
|
||||
g_free (description);
|
||||
pango_layout_set_markup (layout, header, -1);
|
||||
pango_layout_set_font_description (layout, desc);
|
||||
pango_font_description_free (desc);
|
||||
pango_layout_set_width (layout, pango_units_from_double (width));
|
||||
pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
|
||||
cairo_set_source_rgb (cr, 0, 0, 0);
|
||||
cairo_move_to (cr, 0, 0);
|
||||
pango_cairo_show_layout (cr, layout);
|
||||
|
||||
gkbd_keyboard_drawing_render (GKBD_KEYBOARD_DRAWING (data->kbdraw),
|
||||
cr, layout,
|
||||
0.0, 0.0, width, height, dpi_x, dpi_y);
|
||||
|
||||
g_object_unref (layout);
|
||||
}
|
||||
|
||||
void
|
||||
xkb_layout_preview_print (GtkWidget *kbdraw, GtkWindow *parent_window,
|
||||
const gchar *id)
|
||||
{
|
||||
GtkPrintOperation *print;
|
||||
GtkPrintOperationResult res;
|
||||
static GtkPrintSettings *settings = NULL;
|
||||
XkbLayoutPreviewPrintData data = { kbdraw, id };
|
||||
|
||||
print = gtk_print_operation_new ();
|
||||
|
||||
if (settings != NULL)
|
||||
gtk_print_operation_set_print_settings (print, settings);
|
||||
|
||||
g_signal_connect (print, "begin_print",
|
||||
G_CALLBACK (xkb_layout_preview_begin_print), &data);
|
||||
g_signal_connect (print, "draw_page",
|
||||
G_CALLBACK (xkb_layout_preview_draw_page), &data);
|
||||
|
||||
res = gtk_print_operation_run (print,
|
||||
GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
|
||||
parent_window,
|
||||
NULL);
|
||||
|
||||
if (res == GTK_PRINT_OPERATION_RESULT_APPLY) {
|
||||
if (settings != NULL)
|
||||
g_object_unref (settings);
|
||||
settings = gtk_print_operation_get_print_settings (print);
|
||||
g_object_ref (settings);
|
||||
}
|
||||
|
||||
g_object_unref (print);
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ CAPPLET_LIBS="$CAPPLET_LIBS $XCURSOR_LIBS"
|
|||
dnl ==============
|
||||
dnl gswitchit
|
||||
dnl ==============
|
||||
PKG_CHECK_MODULES(LIBGNOMEKBD, [libgnomekbd >= 2.21.4 libxklavier >= 3.3])
|
||||
PKG_CHECK_MODULES(LIBGNOMEKBD, [libgnomekbd >= 2.21.4.1 libxklavier >= 3.3])
|
||||
AC_SUBST(LIBGNOMEKBD_CFLAGS)
|
||||
AC_SUBST(LIBGNOMEKBD_LIBS)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue