[Xfce4-commits] [panel-plugins/xfce4-xkb-plugin] 04/06: Update code style
noreply at xfce.org
noreply at xfce.org
Thu Jun 22 09:54:42 CEST 2017
This is an automated email from the git hooks/post-receive script.
n i n e t l s p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository panel-plugins/xfce4-xkb-plugin.
commit d6cdb45e45f1c498c4d13cdb71aea19a03314d33
Author: Viktor Odintsev <zakhams at gmail.com>
Date: Thu Jun 22 01:10:53 2017 +0300
Update code style
---
panel-plugin/xkb-cairo.c | 363 +++++++--------
panel-plugin/xkb-cairo.h | 42 +-
panel-plugin/xkb-dialog.c | 366 +++++++--------
panel-plugin/xkb-dialog.h | 2 +-
panel-plugin/xkb-keyboard.c | 1032 +++++++++++++++++++++--------------------
panel-plugin/xkb-keyboard.h | 2 +-
panel-plugin/xkb-plugin.c | 861 ++++++++++++++++++----------------
panel-plugin/xkb-properties.h | 30 +-
panel-plugin/xkb-util.c | 88 ++--
panel-plugin/xkb-util.h | 10 +-
panel-plugin/xkb-xfconf.c | 387 +++++++++-------
panel-plugin/xkb-xfconf.h | 3 -
12 files changed, 1656 insertions(+), 1530 deletions(-)
diff --git a/panel-plugin/xkb-cairo.c b/panel-plugin/xkb-cairo.c
index dee4abb..106f1aa 100644
--- a/panel-plugin/xkb-cairo.c
+++ b/panel-plugin/xkb-cairo.c
@@ -30,263 +30,254 @@
#define XKB_PREFERRED_FONT "Courier New, Courier 10 Pitch, Monospace Bold"
+
+
void
-xkb_cairo_draw_flag (cairo_t *cr,
+xkb_cairo_draw_flag (cairo_t *cr,
const GdkPixbuf *image,
- gint actual_width,
- gint actual_height,
- gint variant_markers_count,
- guint max_variant_markers_count,
- guint scale)
+ gint actual_width,
+ gint actual_height,
+ gint variant_markers_count,
+ guint max_variant_markers_count,
+ guint scale)
{
- double scalex, scaley;
- gint i, width, height;
- double layoutx, layouty, img_width, img_height;
- double radius, diameter;
- guint spacing;
+ double scalex, scaley;
+ gint i, x, y, width, height;
+ double layoutx, layouty, img_width, img_height;
+ double radius, diameter;
+ guint spacing;
- g_assert (cr != NULL);
- g_assert (image != NULL);
+ g_assert (image != NULL);
- width = gdk_pixbuf_get_width (image);
- height = gdk_pixbuf_get_height (image);
+ width = gdk_pixbuf_get_width (image);
+ height = gdk_pixbuf_get_height (image);
- scalex = (double) (actual_width - 4) / width;
- scaley = (double) (actual_height - 4) / height;
+ scalex = (double) (actual_width - 4) / width;
+ scaley = (double) (actual_height - 4) / height;
- scalex *= scale / 100.0;
- scaley *= scale / 100.0;
+ scalex *= scale / 100.0;
+ scaley *= scale / 100.0;
- img_width = width * scalex;
- img_height = height * scaley;
+ img_width = width * scalex;
+ img_height = height * scaley;
- DBG ("scale x/y: %.3f/%.3f, dim w/h: %d/%d, scaled w/h: %.1f/%.1f",
- scalex, scaley, width, height, scalex*width, scaley*height);
+ DBG ("scale x/y: %.3f/%.3f, dim w/h: %d/%d, scaled w/h: %.1f/%.1f",
+ scalex, scaley, width, height, scalex * width, scaley * height);
- layoutx = (actual_width - img_width) / 2;
- layouty = (actual_height - img_height) / 2;
- cairo_translate (cr, layoutx, layouty);
+ layoutx = (actual_width - img_width) / 2;
+ layouty = (actual_height - img_height) / 2;
+ cairo_translate (cr, layoutx, layouty);
- cairo_save (cr);
+ cairo_save (cr);
- cairo_scale (cr, scalex, scaley);
- gdk_cairo_set_source_pixbuf (cr, image, 0, 0);
- cairo_paint (cr);
+ cairo_scale (cr, scalex, scaley);
+ gdk_cairo_set_source_pixbuf (cr, image, 0, 0);
+ cairo_paint (cr);
- cairo_restore (cr);
+ cairo_restore (cr);
- DBG ("actual width/height: %d/%d; img w/h: %.1f/%.1f; markers: %d, max markers: %d",
- actual_width, actual_height, img_width, img_height,
- variant_markers_count, max_variant_markers_count);
- DBG ("layout x/y: %.1f/%.1f", layoutx, layouty);
+ DBG ("actual width/height: %d/%d; img w/h: %.1f/%.1f; markers: %d, max markers: %d",
+ actual_width, actual_height, img_width, img_height,
+ variant_markers_count, max_variant_markers_count);
+ DBG ("layout x/y: %.1f/%.1f", layoutx, layouty);
- if (variant_markers_count > 0)
+ if (variant_markers_count > 0)
{
- diameter = 5.0;
- spacing = 1;
+ diameter = 5.0;
+ spacing = 1;
- /* check if the flag is too small to draw variant markers inside it */
- if ((diameter + spacing) * (max_variant_markers_count-1) > img_width - 2)
+ /* check if the flag is too small to draw variant markers inside it */
+ if ((diameter + spacing) * (max_variant_markers_count-1) > img_width - 2)
{
- /* draw markers below the flag */
- diameter = 4;
- spacing = 0;
- layoutx = actual_width / 2 + (max_variant_markers_count - 2) * diameter / 2;
- layouty = (actual_height + img_height) / 2 + diameter + 1;
- DBG ("small flag");
+ /* draw markers below the flag */
+ diameter = 4;
+ spacing = 0;
+ layoutx = actual_width / 2 + (max_variant_markers_count - 2) * diameter / 2;
+ layouty = (actual_height + img_height) / 2 + diameter + 1;
+ DBG ("small flag");
}
- else
+ else
{
- /* draw markers inside the flag */
- spacing = 1;
- layoutx += img_width - diameter / 2 - 1;
- layouty += img_height - diameter / 2 - 1;
- DBG ("large flag");
+ /* draw markers inside the flag */
+ spacing = 1;
+ layoutx += img_width - diameter / 2 - 1;
+ layouty += img_height - diameter / 2 - 1;
+ DBG ("large flag");
}
- radius = diameter / 2.0;
+ radius = diameter / 2.0;
+
+ if (layouty > actual_height - radius)
+ layouty = actual_height - radius;
- if (layouty > actual_height - radius)
- layouty = actual_height - radius;
- if (layoutx > actual_width - radius)
- layoutx = actual_width - radius;
+ if (layoutx > actual_width - radius)
+ layoutx = actual_width - radius;
}
- /* draw variant_markers_count circles */
- for (i = 0; i < variant_markers_count; i++)
+ /* draw variant_markers_count circles */
+ for (i = 0; i < variant_markers_count; i++)
{
- gint x, y;
+ cairo_set_source_rgb (cr, 0, 0, 0);
- cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+ cairo_set_line_width (cr, 1);
- cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
- cairo_set_line_width (cr, 1);
+ x = layoutx - (diameter + spacing) * i + 0.5;
+ y = layouty;
- x = layoutx - (diameter + spacing) * i + 0.5;
- y = layouty;
+ DBG ("variant center x/y: %d/%d, diameter: %.1f, spacing: %d",
+ x, y, diameter, spacing);
+ cairo_arc (cr, x, y, radius, 0, 2 * G_PI);
- DBG ("variant center x/y: %d/%d, diameter: %.1f, spacing: %d",
- x, y, diameter, spacing);
- cairo_arc (cr, x, y, radius, 0, 2 * G_PI);
-
- cairo_set_source_rgb (cr, 0, 0, 0);
- cairo_fill_preserve (cr);
- cairo_set_source_rgb (cr, 1, 1, 1);
- cairo_stroke (cr);
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_fill_preserve (cr);
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_stroke (cr);
}
}
+
+
void
-xkb_cairo_draw_label (cairo_t *cr,
+xkb_cairo_draw_label (cairo_t *cr,
const gchar *group_name,
- gint actual_width,
- gint actual_height,
- gint variant_markers_count,
- guint scale,
- GdkRGBA rgba)
+ gint actual_width,
+ gint actual_height,
+ gint variant_markers_count,
+ guint scale,
+ GdkRGBA rgba)
{
- gchar *normalized_group_name;
- gint pango_width, pango_height;
- double layoutx, layouty, text_width, text_height;
- double scalex, scaley;
- gint i;
- double radius, diameter;
+ gchar *normalized_group_name;
+ gint pango_width, pango_height;
+ double layoutx, layouty, text_width, text_height;
+ double scalex, scaley;
+ gint i, x, y;
+ double radius, diameter;
+ PangoLayout *layout;
+ PangoFontDescription *desc;
- PangoLayout *layout;
- PangoFontDescription *desc;
+ DBG ("actual width/height: %d/%d; markers: %d",
+ actual_width, actual_height, variant_markers_count);
- g_assert (cr != NULL);
+ normalized_group_name = xkb_util_normalize_group_name (group_name, FALSE);
- DBG ("actual width/height: %d/%d; markers: %d",
- actual_width, actual_height, variant_markers_count);
+ if (!normalized_group_name)
+ return;
- normalized_group_name = xkb_util_normalize_group_name (group_name, FALSE);
+ layout = pango_cairo_create_layout (cr);
- if (!normalized_group_name)
- return;
+ pango_layout_set_text (layout, normalized_group_name, -1);
- layout = pango_cairo_create_layout (cr);
+ desc = pango_font_description_from_string ( XKB_PREFERRED_FONT );
+ pango_layout_set_font_description (layout, desc);
+ pango_font_description_free (desc);
- pango_layout_set_text (layout, normalized_group_name, -1);
+ gdk_cairo_set_source_rgba (cr, &rgba);
+ pango_layout_get_pixel_size (layout, &pango_width, &pango_height);
+ DBG ("pango_width/height: %d/%d", pango_width, pango_height);
- desc = pango_font_description_from_string ( XKB_PREFERRED_FONT );
- pango_layout_set_font_description (layout, desc);
- pango_font_description_free (desc);
+ scalex = scaley = scale / 100.0;
- gdk_cairo_set_source_rgba (cr, &rgba);
- pango_layout_get_pixel_size (layout, &pango_width, &pango_height);
- DBG ("pango_width/height: %d/%d", pango_width, pango_height);
+ DBG ("txt size scale x/y: %.2f/%.2f", scalex, scaley);
- scalex = scaley = scale / 100.0;
+ text_height = actual_height * scaley;
+ scaley = text_height / pango_height;
+ radius = (text_height < 32) ? 1.2 : 2.5;
+ diameter = 2 * radius;
- DBG ("txt size scale x/y: %.2f/%.2f", scalex, scaley);
+ text_width = actual_width * scalex;
+ if (actual_width - text_width < 3 + variant_markers_count * diameter)
+ text_width = actual_width - 3 - (variant_markers_count) * diameter;
+ else if (scale >= 99.5)
+ text_width -= 3;
- text_height = actual_height * scaley;
- scaley = text_height / pango_height;
- radius = (text_height < 32) ? 1.2 : 2.5;
- diameter = 2 * radius;
+ scalex = text_width/pango_width;
- text_width = actual_width * scalex;
- if (actual_width - text_width < 3 + variant_markers_count * diameter)
- {
- text_width = actual_width - 3 - (variant_markers_count) * diameter;
- }
- else if (scale >= 99.5)
- {
- text_width -= 3;
- }
-
- scalex = text_width/pango_width;
+ layoutx = (actual_width - (text_width + (variant_markers_count ? 3:0) +
+ variant_markers_count * diameter)) / 2;
+ layouty = (actual_height - text_height) / 2;
- layoutx = (actual_width -
- (text_width + (variant_markers_count ? 3:0) +
- variant_markers_count * diameter)) / 2;
- layouty = (actual_height - text_height) / 2;
+ DBG ("text_width/height: %.2f/%.2f", text_width, text_height);
+ DBG ("layout x/y: %.2f/%.2f scale x/y: %.2f/%.2f, radius: %.2f",
+ layoutx, layouty, scalex, scaley, radius);
- DBG ("text_width/height: %.2f/%.2f", text_width, text_height);
- DBG ("layout x/y: %.2f/%.2f scale x/y: %.2f/%.2f, radius: %.2f",
- layoutx, layouty, scalex, scaley, radius);
+ cairo_save (cr);
+ cairo_move_to (cr, layoutx, layouty);
+ cairo_scale (cr, scalex, scaley);
+ pango_cairo_show_layout (cr, layout);
+ cairo_restore (cr);
- cairo_save (cr);
- cairo_move_to (cr, layoutx, layouty);
- cairo_scale (cr, scalex, scaley);
- pango_cairo_show_layout (cr, layout);
- cairo_restore (cr);
-
- for (i = 0; i < variant_markers_count; i++)
+ for (i = 0; i < variant_markers_count; i++)
{
- cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
- cairo_set_line_width (cr, 1);
- cairo_arc (cr,
- layoutx + text_width + 3 + (diameter * i),
- layouty + text_height - (text_height / 5),
- radius, 0, 2 * G_PI
- );
- cairo_fill (cr);
+ x = layoutx + text_width + 3 + (diameter * i);
+ y = layouty + text_height - (text_height / 5);
+
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+ cairo_set_line_width (cr, 1);
+ cairo_arc (cr, x, y, radius, 0, 2 * G_PI);
+ cairo_fill (cr);
}
- g_free (normalized_group_name);
- g_object_unref (layout);
+ g_free (normalized_group_name);
+ g_object_unref (layout);
}
+
+
void
-xkb_cairo_draw_label_system (cairo_t *cr,
- const gchar *group_name,
- gint actual_width,
- gint actual_height,
- gint variant_markers_count,
+xkb_cairo_draw_label_system (cairo_t *cr,
+ const gchar *group_name,
+ gint actual_width,
+ gint actual_height,
+ gint variant_markers_count,
const PangoFontDescription *desc,
- GdkRGBA rgba)
+ GdkRGBA rgba)
{
- gchar *normalized_group_name;
- gint pango_width, pango_height;
- double layoutx, layouty;
- gint i;
- double radius, diameter;
- PangoLayout *layout;
+ gchar *normalized_group_name;
+ gint pango_width, pango_height;
+ double layoutx, layouty;
+ gint i, x, y;
+ double radius, diameter;
+ PangoLayout *layout;
- g_assert (cr != NULL);
+ DBG ("actual width/height: %d/%d; markers: %d",
+ actual_width, actual_height, variant_markers_count);
- DBG ("actual width/height: %d/%d; markers: %d",
- actual_width, actual_height, variant_markers_count);
+ normalized_group_name = xkb_util_normalize_group_name (group_name, TRUE);
- normalized_group_name = xkb_util_normalize_group_name (group_name, TRUE);
+ if (!normalized_group_name)
+ return;
- if (!normalized_group_name)
- return;
+ layout = pango_cairo_create_layout (cr);
- layout = pango_cairo_create_layout (cr);
+ pango_layout_set_text (layout, normalized_group_name, -1);
+ pango_layout_set_font_description (layout, desc);
- pango_layout_set_text (layout, normalized_group_name, -1);
- pango_layout_set_font_description (layout, desc);
+ gdk_cairo_set_source_rgba (cr, &rgba);
+ pango_layout_get_pixel_size (layout, &pango_width, &pango_height);
+ DBG ("pango_width/height: %d/%d", pango_width, pango_height);
- gdk_cairo_set_source_rgba (cr, &rgba);
- pango_layout_get_pixel_size (layout, &pango_width, &pango_height);
- DBG ("pango_width/height: %d/%d", pango_width, pango_height);
+ layoutx = (double) (actual_width - pango_width) / 2;
+ layouty = (actual_height - pango_height) / 2;
+ radius = pango_height / 10;
+ diameter = 2 * radius;
- layoutx = (double) (actual_width - pango_width) / 2;
- layouty = (actual_height - pango_height) / 2;
- radius = pango_height / 10;
- diameter = 2 * radius;
+ DBG ("layout x/y: %.2f/%.2f, radius: %.2f", layoutx, layouty, radius);
- DBG ("layout x/y: %.2f/%.2f, radius: %.2f", layoutx, layouty, radius);
+ cairo_move_to (cr, layoutx, layouty);
+ pango_cairo_show_layout (cr, layout);
- cairo_move_to (cr, layoutx, layouty);
- pango_cairo_show_layout (cr, layout);
-
- for (i = 0; i < variant_markers_count; i++)
+ for (i = 0; i < variant_markers_count; i++)
{
- cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
- cairo_set_line_width (cr, 1);
- cairo_arc (cr,
- layoutx + (pango_width - (2 * variant_markers_count - 2) * diameter) / 2
- + 2 * diameter * i,
- layouty + pango_height + radius,
- radius, 0, 2 * G_PI
- );
- cairo_fill (cr);
+ x = layoutx + (pango_width - (2 * variant_markers_count - 2) * diameter) / 2 + 2 * diameter * i;
+ y = layouty + pango_height + radius;
+
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+ cairo_set_line_width (cr, 1);
+ cairo_arc (cr, x, y, radius, 0, 2 * G_PI);
+ cairo_fill (cr);
}
- g_free (normalized_group_name);
- g_object_unref (layout);
+ g_free (normalized_group_name);
+ g_object_unref (layout);
}
diff --git a/panel-plugin/xkb-cairo.h b/panel-plugin/xkb-cairo.h
index e6ff6d4..f6dbcd5 100644
--- a/panel-plugin/xkb-cairo.h
+++ b/panel-plugin/xkb-cairo.h
@@ -30,28 +30,28 @@
#include <cairo/cairo.h>
#include <pango/pangocairo.h>
-void xkb_cairo_draw_flag (cairo_t *cr,
- const GdkPixbuf *image,
- gint actual_width,
- gint actual_height,
- gint variant_markers_count,
- guint max_variant_markers_count,
- guint scale);
+void xkb_cairo_draw_flag (cairo_t *cr,
+ const GdkPixbuf *image,
+ gint actual_width,
+ gint actual_height,
+ gint variant_markers_count,
+ guint max_variant_markers_count,
+ guint scale);
-void xkb_cairo_draw_label (cairo_t *cr,
- const gchar *group_name,
- gint actual_width,
- gint actual_height,
- gint variant_markers_count,
- guint scale,
- GdkRGBA rgba);
+void xkb_cairo_draw_label (cairo_t *cr,
+ const gchar *group_name,
+ gint actual_width,
+ gint actual_height,
+ gint variant_markers_count,
+ guint scale,
+ GdkRGBA rgba);
-void xkb_cairo_draw_label_system (cairo_t *cr,
- const gchar *group_name,
- gint actual_width,
- gint actual_height,
- gint variant_markers_count,
- const PangoFontDescription *desc,
- GdkRGBA rgba);
+void xkb_cairo_draw_label_system (cairo_t *cr,
+ const gchar *group_name,
+ gint actual_width,
+ gint actual_height,
+ gint variant_markers_count,
+ const PangoFontDescription *desc,
+ GdkRGBA rgba);
#endif
diff --git a/panel-plugin/xkb-dialog.c b/panel-plugin/xkb-dialog.c
index 5a3f8c7..001b581 100644
--- a/panel-plugin/xkb-dialog.c
+++ b/panel-plugin/xkb-dialog.c
@@ -35,13 +35,15 @@
typedef struct
{
- XfcePanelPlugin *plugin;
- GtkWidget *display_scale_range;
+ XfcePanelPlugin *plugin;
+ GtkWidget *display_scale_range;
} DialogInstance;
+
+
static void
-xkb_dialog_on_settings_close (GtkDialog *dialog,
- gint response,
+xkb_dialog_on_settings_close (GtkDialog *dialog,
+ gint response,
DialogInstance *instance)
{
xfce_panel_plugin_unblock_menu (instance->plugin);
@@ -49,200 +51,198 @@ xkb_dialog_on_settings_close (GtkDialog *dialog,
g_free (instance);
}
+
+
static void
-xkb_dialog_on_display_type_changed (GtkComboBox *cb,
+xkb_dialog_on_display_type_changed (GtkComboBox *cb,
DialogInstance *instance)
{
gint active = gtk_combo_box_get_active (cb);
gtk_widget_set_sensitive (instance->display_scale_range,
- active == DISPLAY_TYPE_IMAGE || active == DISPLAY_TYPE_TEXT);
+ active == DISPLAY_TYPE_IMAGE || active == DISPLAY_TYPE_TEXT);
}
+
+
void
xkb_dialog_configure_plugin (XfcePanelPlugin *plugin,
- XkbXfconf *config)
+ XkbXfconf *config)
{
- GtkWidget *settings_dialog;
- GtkWidget *display_type_combo;
- GtkWidget *display_name_combo;
- GtkWidget *display_scale_range;
- GtkWidget *display_tooltip_icon_switch;
- GtkWidget *group_policy_combo;
- GtkWidget *vbox, *frame, *bin, *grid, *label;
- gint grid_vertical;
- DialogInstance *instance;
-
- xfce_panel_plugin_block_menu (plugin);
-
- instance = g_new0 (DialogInstance, 1);
- instance->plugin = plugin;
-
- settings_dialog = xfce_titled_dialog_new_with_buttons (_("Keyboard Layouts"),
- NULL, 0, "gtk-close", GTK_RESPONSE_OK, NULL);
- gtk_window_set_icon_name (GTK_WINDOW (settings_dialog), "xfce4-settings");
-
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
- gtk_box_set_homogeneous (GTK_BOX (vbox), FALSE);
- gtk_widget_set_margin_start (vbox, 8);
- gtk_widget_set_margin_end (vbox, 8);
- gtk_widget_set_margin_top (vbox, 8);
- gtk_widget_set_margin_bottom (vbox, 8);
- gtk_widget_show (vbox);
- gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (settings_dialog))), vbox);
-
- grid_vertical = 0;
-
- frame = xfce_gtk_frame_box_new (_("Appearance"), &bin);
- gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 2);
-
- grid = gtk_grid_new ();
- gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
- gtk_grid_set_column_spacing (GTK_GRID (grid), 18);
- gtk_grid_set_row_homogeneous (GTK_GRID (grid), TRUE);
- gtk_widget_set_size_request (grid, -1, -1);
- gtk_container_add (GTK_CONTAINER (bin), grid);
-
- label = gtk_label_new (_("Show layout as:"));
- gtk_label_set_xalign (GTK_LABEL (label), 0.f);
- gtk_widget_set_hexpand (label, TRUE);
- gtk_grid_attach (GTK_GRID (grid), label, 0, grid_vertical, 1, 1);
-
- display_type_combo = gtk_combo_box_text_new ();
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (display_type_combo), _("image"));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (display_type_combo), _("text"));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (display_type_combo), _("system"));
- gtk_widget_set_size_request (display_type_combo, 230, -1);
- gtk_grid_attach (GTK_GRID (grid), display_type_combo, 1, grid_vertical, 1, 1);
-
- grid_vertical++;
-
- label = gtk_label_new (_("Layout name:"));
- gtk_label_set_xalign (GTK_LABEL (label), 0.f);
- gtk_widget_set_hexpand (label, TRUE);
- gtk_grid_attach (GTK_GRID (grid), label, 0, grid_vertical, 1, 1);
-
- display_name_combo = gtk_combo_box_text_new ();
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (display_name_combo), _("country"));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (display_name_combo), _("language"));
- gtk_widget_set_size_request (display_name_combo, 230, -1);
- gtk_grid_attach (GTK_GRID (grid), display_name_combo, 1, grid_vertical, 1, 1);
-
- grid_vertical++;
-
- label = gtk_label_new (_("Widget size:"));
- gtk_label_set_xalign (GTK_LABEL (label), 0.f);
- gtk_widget_set_hexpand (label, TRUE);
- gtk_grid_attach (GTK_GRID (grid), label, 0, grid_vertical, 1, 1);
-
- display_scale_range = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
- DISPLAY_SCALE_MIN, DISPLAY_SCALE_MAX, 1);
- instance->display_scale_range = display_scale_range;
- gtk_scale_set_value_pos (GTK_SCALE (display_scale_range), GTK_POS_RIGHT);
- gtk_widget_set_size_request (display_scale_range, 230, -1);
- gtk_grid_attach (GTK_GRID (grid), display_scale_range, 1, grid_vertical, 1, 1);
-
- grid_vertical++;
-
- label = gtk_label_new (_("Tooltip icon:"));
- gtk_label_set_xalign (GTK_LABEL (label), 0.f);
- gtk_widget_set_hexpand (label, TRUE);
- gtk_grid_attach (GTK_GRID (grid), label, 0, grid_vertical, 1, 1);
-
- display_tooltip_icon_switch = gtk_switch_new ();
- gtk_widget_set_halign (display_tooltip_icon_switch, GTK_ALIGN_END);
- gtk_widget_set_valign (display_tooltip_icon_switch, GTK_ALIGN_CENTER);
- gtk_grid_attach (GTK_GRID (grid), display_tooltip_icon_switch, 1, grid_vertical, 1, 1);
-
- grid_vertical = 0;
-
- frame = xfce_gtk_frame_box_new (_("Behavior"), &bin);
- gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 2);
-
- grid = gtk_grid_new ();
- gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
- gtk_grid_set_column_spacing (GTK_GRID (grid), 18);
- gtk_grid_set_row_homogeneous (GTK_GRID (grid), TRUE);
- gtk_widget_set_size_request (grid, -1, -1);
- gtk_container_add (GTK_CONTAINER (bin), grid);
-
- label = gtk_label_new (_("Manage layout:"));
- gtk_label_set_xalign (GTK_LABEL (label), 0.f);
- gtk_widget_set_hexpand (label, TRUE);
- gtk_grid_attach (GTK_GRID (grid), label, 0, grid_vertical, 1, 1);
-
- group_policy_combo = gtk_combo_box_text_new ();
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (group_policy_combo), _("globally"));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (group_policy_combo), _("per window"));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (group_policy_combo), _("per application"));
- gtk_widget_set_size_request (group_policy_combo, 230, -1);
- gtk_grid_attach (GTK_GRID (grid), group_policy_combo, 1, grid_vertical, 1, 1);
-
- gtk_widget_show_all (vbox);
-
- g_signal_connect ((gpointer) settings_dialog, "response",
- G_CALLBACK (xkb_dialog_on_settings_close), instance);
-
- /* enable or disable display_scale_range depending on display type */
- g_signal_connect (display_type_combo, "changed",
- G_CALLBACK (xkb_dialog_on_display_type_changed), instance);
- xkb_dialog_on_display_type_changed (GTK_COMBO_BOX (display_type_combo), instance);
-
- g_object_bind_property (G_OBJECT (config), DISPLAY_TYPE,
- G_OBJECT (display_type_combo),
- "active", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
-
- g_object_bind_property (G_OBJECT (config), DISPLAY_NAME,
- G_OBJECT (display_name_combo),
- "active", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
-
- g_object_bind_property (G_OBJECT (config), DISPLAY_SCALE,
- G_OBJECT (gtk_range_get_adjustment (GTK_RANGE (display_scale_range))),
- "value", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
-
- g_object_bind_property (G_OBJECT (config), DISPLAY_TOOLTIP_ICON,
- G_OBJECT (display_tooltip_icon_switch),
- "active", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
-
- g_object_bind_property (G_OBJECT (config), GROUP_POLICY,
- G_OBJECT (group_policy_combo),
- "active", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
-
- gtk_widget_show (settings_dialog);
+ GtkWidget *settings_dialog;
+ GtkWidget *display_type_combo;
+ GtkWidget *display_name_combo;
+ GtkWidget *display_scale_range;
+ GtkWidget *display_tooltip_icon_switch;
+ GtkWidget *group_policy_combo;
+ GtkWidget *vbox, *frame, *bin, *grid, *label;
+ gint grid_vertical;
+ DialogInstance *instance;
+
+ xfce_panel_plugin_block_menu (plugin);
+
+ instance = g_new0 (DialogInstance, 1);
+ instance->plugin = plugin;
+
+ settings_dialog = xfce_titled_dialog_new_with_buttons (_("Keyboard Layouts"),
+ NULL, 0, "gtk-close",
+ GTK_RESPONSE_OK, NULL);
+ gtk_window_set_icon_name (GTK_WINDOW (settings_dialog), "xfce4-settings");
+
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
+ gtk_box_set_homogeneous (GTK_BOX (vbox), FALSE);
+ gtk_widget_set_margin_start (vbox, 8);
+ gtk_widget_set_margin_end (vbox, 8);
+ gtk_widget_set_margin_top (vbox, 8);
+ gtk_widget_set_margin_bottom (vbox, 8);
+ gtk_widget_show (vbox);
+ gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (settings_dialog))), vbox);
+
+ grid_vertical = 0;
+
+ frame = xfce_gtk_frame_box_new (_("Appearance"), &bin);
+ gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 2);
+
+ grid = gtk_grid_new ();
+ gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
+ gtk_grid_set_column_spacing (GTK_GRID (grid), 18);
+ gtk_grid_set_row_homogeneous (GTK_GRID (grid), TRUE);
+ gtk_widget_set_size_request (grid, -1, -1);
+ gtk_container_add (GTK_CONTAINER (bin), grid);
+
+ label = gtk_label_new (_("Show layout as:"));
+ gtk_label_set_xalign (GTK_LABEL (label), 0.f);
+ gtk_widget_set_hexpand (label, TRUE);
+ gtk_grid_attach (GTK_GRID (grid), label, 0, grid_vertical, 1, 1);
+
+ display_type_combo = gtk_combo_box_text_new ();
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (display_type_combo), _("image"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (display_type_combo), _("text"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (display_type_combo), _("system"));
+ gtk_widget_set_size_request (display_type_combo, 230, -1);
+ gtk_grid_attach (GTK_GRID (grid), display_type_combo, 1, grid_vertical, 1, 1);
+
+ grid_vertical++;
+
+ label = gtk_label_new (_("Layout name:"));
+ gtk_label_set_xalign (GTK_LABEL (label), 0.f);
+ gtk_widget_set_hexpand (label, TRUE);
+ gtk_grid_attach (GTK_GRID (grid), label, 0, grid_vertical, 1, 1);
+
+ display_name_combo = gtk_combo_box_text_new ();
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (display_name_combo), _("country"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (display_name_combo), _("language"));
+ gtk_widget_set_size_request (display_name_combo, 230, -1);
+ gtk_grid_attach (GTK_GRID (grid), display_name_combo, 1, grid_vertical, 1, 1);
+
+ grid_vertical++;
+
+ label = gtk_label_new (_("Widget size:"));
+ gtk_label_set_xalign (GTK_LABEL (label), 0.f);
+ gtk_widget_set_hexpand (label, TRUE);
+ gtk_grid_attach (GTK_GRID (grid), label, 0, grid_vertical, 1, 1);
+
+ display_scale_range = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
+ DISPLAY_SCALE_MIN, DISPLAY_SCALE_MAX, 1);
+ instance->display_scale_range = display_scale_range;
+ gtk_scale_set_value_pos (GTK_SCALE (display_scale_range), GTK_POS_RIGHT);
+ gtk_widget_set_size_request (display_scale_range, 230, -1);
+ gtk_grid_attach (GTK_GRID (grid), display_scale_range, 1, grid_vertical, 1, 1);
+
+ grid_vertical++;
+
+ label = gtk_label_new (_("Tooltip icon:"));
+ gtk_label_set_xalign (GTK_LABEL (label), 0.f);
+ gtk_widget_set_hexpand (label, TRUE);
+ gtk_grid_attach (GTK_GRID (grid), label, 0, grid_vertical, 1, 1);
+
+ display_tooltip_icon_switch = gtk_switch_new ();
+ gtk_widget_set_halign (display_tooltip_icon_switch, GTK_ALIGN_END);
+ gtk_widget_set_valign (display_tooltip_icon_switch, GTK_ALIGN_CENTER);
+ gtk_grid_attach (GTK_GRID (grid), display_tooltip_icon_switch, 1, grid_vertical, 1, 1);
+
+ grid_vertical = 0;
+
+ frame = xfce_gtk_frame_box_new (_("Behavior"), &bin);
+ gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 2);
+
+ grid = gtk_grid_new ();
+ gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
+ gtk_grid_set_column_spacing (GTK_GRID (grid), 18);
+ gtk_grid_set_row_homogeneous (GTK_GRID (grid), TRUE);
+ gtk_widget_set_size_request (grid, -1, -1);
+ gtk_container_add (GTK_CONTAINER (bin), grid);
+
+ label = gtk_label_new (_("Manage layout:"));
+ gtk_label_set_xalign (GTK_LABEL (label), 0.f);
+ gtk_widget_set_hexpand (label, TRUE);
+ gtk_grid_attach (GTK_GRID (grid), label, 0, grid_vertical, 1, 1);
+
+ group_policy_combo = gtk_combo_box_text_new ();
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (group_policy_combo), _("globally"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (group_policy_combo), _("per window"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (group_policy_combo), _("per application"));
+ gtk_widget_set_size_request (group_policy_combo, 230, -1);
+ gtk_grid_attach (GTK_GRID (grid), group_policy_combo, 1, grid_vertical, 1, 1);
+
+ gtk_widget_show_all (vbox);
+
+ g_signal_connect ((gpointer) settings_dialog, "response",
+ G_CALLBACK (xkb_dialog_on_settings_close), instance);
+
+ g_signal_connect (display_type_combo, "changed",
+ G_CALLBACK (xkb_dialog_on_display_type_changed), instance);
+ xkb_dialog_on_display_type_changed (GTK_COMBO_BOX (display_type_combo), instance);
+
+ g_object_bind_property (G_OBJECT (config), DISPLAY_TYPE,
+ G_OBJECT (display_type_combo),
+ "active", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+
+ g_object_bind_property (G_OBJECT (config), DISPLAY_NAME,
+ G_OBJECT (display_name_combo),
+ "active", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+
+ g_object_bind_property (G_OBJECT (config), DISPLAY_SCALE,
+ G_OBJECT (gtk_range_get_adjustment (GTK_RANGE (display_scale_range))),
+ "value", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+
+ g_object_bind_property (G_OBJECT (config), DISPLAY_TOOLTIP_ICON,
+ G_OBJECT (display_tooltip_icon_switch),
+ "active", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+
+ g_object_bind_property (G_OBJECT (config), GROUP_POLICY,
+ G_OBJECT (group_policy_combo),
+ "active", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+
+ gtk_widget_show (settings_dialog);
}
+
+
void
xkb_dialog_about_show (void)
{
- GtkWidget *about;
- GdkPixbuf *icon;
-
- const gchar* authors[] = {
- "Alexander Iliev <sasoiliev at mamul.org>",
- "Gauvain Pocentek <gauvainpocentek at gmail.com>",
- "Igor Slepchin <igor.slepchin at gmail.com>",
- NULL
+ GdkPixbuf *icon;
+
+ const gchar* authors[] =
+ {
+ "Alexander Iliev <sasoiliev at mamul.org>",
+ "Gauvain Pocentek <gauvainpocentek at gmail.com>",
+ "Igor Slepchin <igor.slepchin at gmail.com>",
+ NULL
};
- icon = xfce_panel_pixbuf_from_source ("preferences-desktop-keyboard", NULL, 32);
- about = gtk_about_dialog_new ();
- gtk_about_dialog_set_program_name (GTK_ABOUT_DIALOG (about),
- _("Keyboard Layouts Plugin"));
- gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (about),
- PACKAGE_VERSION);
- gtk_about_dialog_set_logo (GTK_ABOUT_DIALOG (about),
- icon);
- gtk_about_dialog_set_license (GTK_ABOUT_DIALOG (about),
- xfce_get_license_text (XFCE_LICENSE_TEXT_GPL));
- gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG (about),
- (const gchar**) authors);
- gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG (about),
- _("Allows you to configure and use multiple keyboard layouts."));
- gtk_about_dialog_set_website (GTK_ABOUT_DIALOG (about),
- "http://goodies.xfce.org/");
- gtk_about_dialog_set_website_label (GTK_ABOUT_DIALOG (about),
- _("Other plugins available here"));
- gtk_dialog_run (GTK_DIALOG (about));
- gtk_widget_destroy (about);
- if (icon)
- g_object_unref (G_OBJECT (icon));
+ icon = xfce_panel_pixbuf_from_source ("preferences-desktop-keyboard", NULL, 32);
+
+ gtk_show_about_dialog (NULL,
+ "logo", icon,
+ "program-name", _("Keyboard Layouts Plugin"),
+ "version", PACKAGE_VERSION,
+ "comments", _("Allows you to configure and use multiple keyboard layouts."),
+ "website", "https://goodies.xfce.org/projects/panel-plugins/xfce4-xkb-plugin",
+ "license", xfce_get_license_text (XFCE_LICENSE_TEXT_GPL),
+ "authors", authors,
+ NULL);
+
+ if (icon)
+ g_object_unref (G_OBJECT (icon));
}
diff --git a/panel-plugin/xkb-dialog.h b/panel-plugin/xkb-dialog.h
index 7305794..83ef677 100644
--- a/panel-plugin/xkb-dialog.h
+++ b/panel-plugin/xkb-dialog.h
@@ -31,7 +31,7 @@
#include "xkb-xfconf.h"
void xkb_dialog_configure_plugin (XfcePanelPlugin *plugin,
- XkbXfconf *config);
+ XkbXfconf *config);
void xkb_dialog_about_show (void);
#endif
diff --git a/panel-plugin/xkb-keyboard.c b/panel-plugin/xkb-keyboard.c
index 42295e3..26f2338 100644
--- a/panel-plugin/xkb-keyboard.c
+++ b/panel-plugin/xkb-keyboard.c
@@ -33,820 +33,852 @@
typedef struct
{
- gchar *country_name;
- gint country_index;
- gchar *language_name;
- gint language_index;
- gchar *variant;
- gchar *pretty_layout_name;
- GdkPixbuf *display_pixbuf;
- GdkPixbuf *tooltip_pixbuf;
+ gchar *country_name;
+ gint country_index;
+ gchar *language_name;
+ gint language_index;
+ gchar *variant;
+ gchar *pretty_layout_name;
+ GdkPixbuf *display_pixbuf;
+ GdkPixbuf *tooltip_pixbuf;
} XkbGroupData;
struct _XkbKeyboardClass
{
- GObjectClass __parent__;
+ GObjectClass __parent__;
};
struct _XkbKeyboard
{
- GObject __parent__;
+ GObject __parent__;
- XklEngine *engine;
- XklConfigRec *last_config_rec;
+ XklEngine *engine;
+ XklConfigRec *last_config_rec;
- WnckScreen *wnck_screen;
+ WnckScreen *wnck_screen;
- guint config_timeout_id;
+ guint config_timeout_id;
- XkbGroupData *group_data;
+ XkbGroupData *group_data;
- XkbGroupPolicy group_policy;
+ XkbGroupPolicy group_policy;
- GHashTable *application_map;
- GHashTable *window_map;
+ GHashTable *application_map;
+ GHashTable *window_map;
- guint current_window_id;
- guint current_application_id;
+ guint current_window_id;
+ guint current_application_id;
- gint group_count;
- gint current_group;
+ gint group_count;
+ gint current_group;
- gulong active_window_changed_handler_id;
- gulong application_closed_handler_id;
- gulong window_closed_handler_id;
+ gulong active_window_changed_handler_id;
+ gulong application_closed_handler_id;
+ gulong window_closed_handler_id;
};
-static void xkb_keyboard_active_window_changed (WnckScreen *screen,
- WnckWindow *previously_active_window,
- XkbKeyboard *keyboard);
-static void xkb_keyboard_application_closed (WnckScreen *screen,
- WnckApplication *application,
- XkbKeyboard *keyboard);
-static void xkb_keyboard_window_closed (WnckScreen *screen,
- WnckWindow *window,
- XkbKeyboard *keyboard);
-
-static void xkb_keyboard_xkl_state_changed (XklEngine *engine,
- XklEngineStateChange change,
- gint group,
- gboolean restore,
- gpointer user_data);
-
-static void xkb_keyboard_xkl_config_changed (XklEngine *engine,
- gpointer user_data);
-
-static GdkFilterReturn xkb_keyboard_handle_xevent (GdkXEvent * xev,
- GdkEvent * event,
- gpointer user_data);
-
-static void xkb_keyboard_free (XkbKeyboard *keyboard);
-static void xkb_keyboard_finalize (GObject *object);
-static gboolean xkb_keyboard_update_from_xkl (XkbKeyboard *keyboard);
-static void xkb_keyboard_initialize_xkb_options (XkbKeyboard *keyboard,
- const XklConfigRec *config_rec);
+static void xkb_keyboard_active_window_changed (WnckScreen *screen,
+ WnckWindow *previously_active_window,
+ XkbKeyboard *keyboard);
+static void xkb_keyboard_application_closed (WnckScreen *screen,
+ WnckApplication *application,
+ XkbKeyboard *keyboard);
+static void xkb_keyboard_window_closed (WnckScreen *screen,
+ WnckWindow *window,
+ XkbKeyboard *keyboard);
+
+static void xkb_keyboard_xkl_state_changed (XklEngine *engine,
+ XklEngineStateChange change,
+ gint group,
+ gboolean restore,
+ XkbKeyboard *keyboard);
+
+static void xkb_keyboard_xkl_config_changed (XklEngine *engine,
+ XkbKeyboard *keyboard);
+
+static GdkFilterReturn xkb_keyboard_handle_xevent (GdkXEvent *xev,
+ GdkEvent *event,
+ gpointer user_data);
+
+static void xkb_keyboard_free (XkbKeyboard *keyboard);
+static void xkb_keyboard_finalize (GObject *object);
+static gboolean xkb_keyboard_update_from_xkl (XkbKeyboard *keyboard);
+static void xkb_keyboard_initialize_xkb_options (XkbKeyboard *keyboard,
+ const XklConfigRec *config_rec);
enum
{
- STATE_CHANGED,
- LAST_SIGNAL
+ STATE_CHANGED,
+ LAST_SIGNAL
};
-static guint xkb_keyboard_signals [LAST_SIGNAL] = { 0, };
+static guint xkb_keyboard_signals[LAST_SIGNAL] = { 0, };
G_DEFINE_TYPE (XkbKeyboard, xkb_keyboard, G_TYPE_OBJECT)
+
+
static void
xkb_keyboard_class_init (XkbKeyboardClass *klass)
{
- GObjectClass *gobject_class;
+ GObjectClass *gobject_class;
- gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->finalize = xkb_keyboard_finalize;
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = xkb_keyboard_finalize;
- xkb_keyboard_signals[STATE_CHANGED] =
- g_signal_new (g_intern_static_string ("state-changed"),
- G_TYPE_FROM_CLASS (gobject_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+ xkb_keyboard_signals[STATE_CHANGED] =
+ g_signal_new (g_intern_static_string ("state-changed"),
+ G_TYPE_FROM_CLASS (gobject_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
}
+
+
static void
xkb_keyboard_init (XkbKeyboard *keyboard)
{
- keyboard->engine = NULL;
- keyboard->last_config_rec = NULL;
+ keyboard->engine = NULL;
+ keyboard->last_config_rec = NULL;
- keyboard->config_timeout_id = 0;
+ keyboard->config_timeout_id = 0;
- keyboard->group_data = NULL;
- keyboard->group_policy = GROUP_POLICY_GLOBAL;
+ keyboard->group_data = NULL;
+ keyboard->group_policy = GROUP_POLICY_GLOBAL;
- keyboard->application_map = NULL;
- keyboard->window_map = NULL;
+ keyboard->application_map = NULL;
+ keyboard->window_map = NULL;
- keyboard->current_window_id = 0;
- keyboard->current_application_id = 0;
+ keyboard->current_window_id = 0;
+ keyboard->current_application_id = 0;
- keyboard->group_count = 0;
- keyboard->current_group = 0;
+ keyboard->group_count = 0;
+ keyboard->current_group = 0;
- keyboard->active_window_changed_handler_id = 0;
- keyboard->application_closed_handler_id = 0;
- keyboard->window_closed_handler_id = 0;
+ keyboard->active_window_changed_handler_id = 0;
+ keyboard->application_closed_handler_id = 0;
+ keyboard->window_closed_handler_id = 0;
}
+
+
XkbKeyboard *
xkb_keyboard_new (XkbGroupPolicy group_policy)
{
- XkbKeyboard *keyboard;
+ XkbKeyboard *keyboard;
- keyboard = g_object_new (TYPE_XKB_KEYBOARD, NULL);
+ keyboard = g_object_new (TYPE_XKB_KEYBOARD, NULL);
- keyboard->group_policy = group_policy;
+ keyboard->group_policy = group_policy;
- keyboard->engine = xkl_engine_get_instance (gdk_x11_get_default_xdisplay ());
+ keyboard->engine = xkl_engine_get_instance (gdk_x11_get_default_xdisplay ());
- keyboard->wnck_screen = wnck_screen_get_default ();
+ keyboard->wnck_screen = wnck_screen_get_default ();
- if (keyboard->engine)
+ if (keyboard->engine)
{
- xkb_keyboard_update_from_xkl (keyboard);
-
- xkl_engine_set_group_per_toplevel_window (keyboard->engine, FALSE);
-
- xkl_engine_start_listen (keyboard->engine, XKLL_TRACK_KEYBOARD_STATE);
-
- g_signal_connect (keyboard->engine,
- "X-state-changed",
- G_CALLBACK (xkb_keyboard_xkl_state_changed),
- keyboard);
- g_signal_connect (keyboard->engine,
- "X-config-changed",
- G_CALLBACK (xkb_keyboard_xkl_config_changed),
- keyboard);
- gdk_window_add_filter (NULL, xkb_keyboard_handle_xevent, keyboard);
-
- keyboard->active_window_changed_handler_id =
- g_signal_connect (G_OBJECT (keyboard->wnck_screen), "active-window-changed",
- G_CALLBACK (xkb_keyboard_active_window_changed), keyboard);
- keyboard->application_closed_handler_id =
- g_signal_connect (G_OBJECT (keyboard->wnck_screen), "application-closed",
- G_CALLBACK (xkb_keyboard_application_closed), keyboard);
- keyboard->window_closed_handler_id =
- g_signal_connect (G_OBJECT (keyboard->wnck_screen), "window-closed",
- G_CALLBACK (xkb_keyboard_window_closed), keyboard);
+ xkb_keyboard_update_from_xkl (keyboard);
+
+ xkl_engine_set_group_per_toplevel_window (keyboard->engine, FALSE);
+
+ xkl_engine_start_listen (keyboard->engine, XKLL_TRACK_KEYBOARD_STATE);
+
+ g_signal_connect (keyboard->engine,
+ "X-state-changed",
+ G_CALLBACK (xkb_keyboard_xkl_state_changed),
+ keyboard);
+ g_signal_connect (keyboard->engine,
+ "X-config-changed",
+ G_CALLBACK (xkb_keyboard_xkl_config_changed),
+ keyboard);
+
+ gdk_window_add_filter (NULL, xkb_keyboard_handle_xevent, keyboard);
+
+ keyboard->active_window_changed_handler_id =
+ g_signal_connect (G_OBJECT (keyboard->wnck_screen),
+ "active-window-changed",
+ G_CALLBACK (xkb_keyboard_active_window_changed),
+ keyboard);
+ keyboard->application_closed_handler_id =
+ g_signal_connect (G_OBJECT (keyboard->wnck_screen),
+ "application-closed",
+ G_CALLBACK (xkb_keyboard_application_closed),
+ keyboard);
+ keyboard->window_closed_handler_id =
+ g_signal_connect (G_OBJECT (keyboard->wnck_screen),
+ "window-closed",
+ G_CALLBACK (xkb_keyboard_window_closed),
+ keyboard);
}
- return keyboard;
+ return keyboard;
}
+
+
gboolean
xkb_keyboard_get_initialized (XkbKeyboard *keyboard)
{
- g_return_val_if_fail (IS_XKB_KEYBOARD (keyboard), FALSE);
- return G_LIKELY (keyboard->engine != NULL);
+ g_return_val_if_fail (IS_XKB_KEYBOARD (keyboard), FALSE);
+
+ return G_LIKELY (keyboard->engine != NULL);
}
+
+
static gchar *
xkb_keyboard_xkb_description (XklConfigItem *config_item)
{
- gchar *ci_description;
- gchar *description;
+ gchar *ci_description;
+ gchar *description;
- ci_description = g_strstrip (config_item->description);
+ ci_description = g_strstrip (config_item->description);
- if (ci_description[0] == 0)
- description = g_strdup (config_item->name);
- else
- description = g_strdup (ci_description);
+ if (ci_description[0] == 0)
+ description = g_strdup (config_item->name);
+ else
+ description = g_strdup (ci_description);
- return description;
+ return description;
}
+
+
static gchar*
xkb_keyboard_create_pretty_layout_name (XklConfigRegistry *registry,
- XklConfigItem *config_item,
- gchar *layout_name,
- gchar *layout_variant)
+ XklConfigItem *config_item,
+ gchar *layout_name,
+ gchar *layout_variant)
{
- gchar *pretty_layout_name;
+ gchar *pretty_layout_name;
- g_snprintf (config_item->name, sizeof (config_item->name),
- "%s", layout_variant);
- if (xkl_config_registry_find_variant (registry, layout_name, config_item))
+ g_snprintf (config_item->name, sizeof (config_item->name),
+ "%s", layout_variant);
+ if (xkl_config_registry_find_variant (registry, layout_name, config_item))
{
- pretty_layout_name = xkb_keyboard_xkb_description (config_item);
+ pretty_layout_name = xkb_keyboard_xkb_description (config_item);
}
- else
+ else
{
- g_snprintf (config_item->name, sizeof (config_item->name),
- "%s", layout_name);
- if (xkl_config_registry_find_layout (registry, config_item))
- {
- pretty_layout_name = xkb_keyboard_xkb_description (config_item);
- }
- else
- {
- pretty_layout_name = xkb_util_get_layout_string (layout_name,
- layout_variant);
- }
+ g_snprintf (config_item->name, sizeof (config_item->name),
+ "%s", layout_name);
+ if (xkl_config_registry_find_layout (registry, config_item))
+ pretty_layout_name = xkb_keyboard_xkb_description (config_item);
+ else
+ pretty_layout_name = xkb_util_get_layout_string (layout_name, layout_variant);
}
- return pretty_layout_name;
+ return pretty_layout_name;
}
+
+
static gchar *
xkb_keyboard_obtain_language_name (XklConfigRegistry *registry,
- XklConfigItem *config_item,
- gchar *layout_name)
+ XklConfigItem *config_item,
+ gchar *layout_name)
{
- g_snprintf (config_item->name, sizeof (config_item->name),
- "%s", layout_name);
-
- if (xkl_config_registry_find_layout (registry, config_item))
- {
- return g_strdup (config_item->short_description);
- }
+ g_snprintf (config_item->name, sizeof (config_item->name),
+ "%s", layout_name);
+ if (xkl_config_registry_find_layout (registry, config_item))
+ return g_strdup (config_item->short_description);
+ else
return g_strdup (layout_name);
}
+
+
static void
-xkb_keyboard_initialize_xkb_options (XkbKeyboard *keyboard,
+xkb_keyboard_initialize_xkb_options (XkbKeyboard *keyboard,
const XklConfigRec *config_rec)
{
- GHashTable *country_indexes, *language_indexes;
- gchar **group;
- gint val, i;
- gpointer pval;
- gchar *imgfilename;
- XklConfigRegistry *registry;
- XklConfigItem *config_item;
+ GHashTable *country_indexes, *language_indexes;
+ gchar **group;
+ gint val, i;
+ gpointer pval;
+ gchar *imgfilename;
+ XklConfigRegistry *registry;
+ XklConfigItem *config_item;
- xkb_keyboard_free (keyboard);
+ xkb_keyboard_free (keyboard);
- group = config_rec->layouts;
- keyboard->group_count = 0;
- while (*group)
+ group = config_rec->layouts;
+ keyboard->group_count = 0;
+ while (*group)
{
- group++;
- keyboard->group_count++;
+ group++;
+ keyboard->group_count++;
}
- keyboard->window_map = g_hash_table_new (g_direct_hash, NULL);
- keyboard->application_map = g_hash_table_new (g_direct_hash, NULL);
- keyboard->group_data = (XkbGroupData *) g_new0 (XkbGroupData,
- keyboard->group_count);
- country_indexes = g_hash_table_new (g_str_hash, g_str_equal);
- language_indexes = g_hash_table_new (g_str_hash, g_str_equal);
+ keyboard->window_map = g_hash_table_new (g_direct_hash, NULL);
+ keyboard->application_map = g_hash_table_new (g_direct_hash, NULL);
+ keyboard->group_data = (XkbGroupData *) g_new0 (XkbGroupData, keyboard->group_count);
+ country_indexes = g_hash_table_new (g_str_hash, g_str_equal);
+ language_indexes = g_hash_table_new (g_str_hash, g_str_equal);
- registry = xkl_config_registry_get_instance (keyboard->engine);
- xkl_config_registry_load (registry, FALSE);
- config_item = xkl_config_item_new ();
+ registry = xkl_config_registry_get_instance (keyboard->engine);
+ xkl_config_registry_load (registry, FALSE);
+ config_item = xkl_config_item_new ();
- for (i = 0; i < keyboard->group_count; i++)
+ for (i = 0; i < keyboard->group_count; i++)
{
- XkbGroupData *group_data = &keyboard->group_data[i];
- RsvgHandle *handle;
-
- group_data->country_name = g_strdup (config_rec->layouts[i]);
-
- group_data->variant = (config_rec->variants[i] == NULL)
- ? g_strdup ("") : g_strdup (config_rec->variants[i]);
-
- group_data->pretty_layout_name = xkb_keyboard_create_pretty_layout_name (registry,
- config_item, group_data->country_name, group_data->variant);
-
- group_data->language_name = xkb_keyboard_obtain_language_name (registry,
- config_item, group_data->country_name);
-
- #define MODIFY_INDEXES(table, name, index) \
- pval = g_hash_table_lookup ( \
- table, \
- group_data->name \
- ); \
- val = (pval != NULL) ? GPOINTER_TO_INT (pval) : 0; \
- val++; \
- group_data->index = val; \
- g_hash_table_insert ( \
- table, \
- group_data->name, \
- GINT_TO_POINTER (val) \
- );
-
- MODIFY_INDEXES (country_indexes, country_name, country_index);
- MODIFY_INDEXES (language_indexes, language_name, language_index);
-
- #undef MODIFY_INDEXES
-
- imgfilename = xkb_util_get_flag_filename (group_data->country_name);
- handle = rsvg_handle_new_from_file (imgfilename, NULL);
- if (handle)
+ XkbGroupData *group_data = &keyboard->group_data[i];
+ RsvgHandle *handle;
+
+ group_data->country_name = g_strdup (config_rec->layouts[i]);
+
+ group_data->variant = (config_rec->variants[i] == NULL)
+ ? g_strdup ("") : g_strdup (config_rec->variants[i]);
+
+ group_data->pretty_layout_name =
+ xkb_keyboard_create_pretty_layout_name (registry,
+ config_item,
+ group_data->country_name,
+ group_data->variant);
+
+ group_data->language_name =
+ xkb_keyboard_obtain_language_name (registry,
+ config_item,
+ group_data->country_name);
+
+ #define MODIFY_INDEXES(table, name, index) \
+ pval = g_hash_table_lookup (table, group_data->name); \
+ val = (pval != NULL) ? GPOINTER_TO_INT (pval) : 0; \
+ val++; \
+ group_data->index = val; \
+ g_hash_table_insert (table, group_data->name, GINT_TO_POINTER (val));
+
+ MODIFY_INDEXES (country_indexes, country_name, country_index);
+ MODIFY_INDEXES (language_indexes, language_name, language_index);
+
+ #undef MODIFY_INDEXES
+
+ imgfilename = xkb_util_get_flag_filename (group_data->country_name);
+ handle = rsvg_handle_new_from_file (imgfilename, NULL);
+ if (handle)
{
- group_data->display_pixbuf = rsvg_handle_get_pixbuf (handle);
- group_data->tooltip_pixbuf = gdk_pixbuf_scale_simple (group_data->display_pixbuf,
- 30, 22, GDK_INTERP_BILINEAR);
- rsvg_handle_close (handle, NULL);
- g_object_unref (handle);
+ group_data->display_pixbuf = rsvg_handle_get_pixbuf (handle);
+ group_data->tooltip_pixbuf = gdk_pixbuf_scale_simple (group_data->display_pixbuf,
+ 30, 22, GDK_INTERP_BILINEAR);
+ rsvg_handle_close (handle, NULL);
+ g_object_unref (handle);
}
- g_free (imgfilename);
+ g_free (imgfilename);
}
- g_object_unref (config_item);
- g_object_unref (registry);
- g_hash_table_destroy (country_indexes);
- g_hash_table_destroy (language_indexes);
+
+ g_object_unref (config_item);
+ g_object_unref (registry);
+ g_hash_table_destroy (country_indexes);
+ g_hash_table_destroy (language_indexes);
}
+
+
static void
xkb_keyboard_free (XkbKeyboard *keyboard)
{
- gint i;
+ gint i;
+ XkbGroupData *group_data;
- if (keyboard->window_map)
- g_hash_table_destroy (keyboard->window_map);
+ if (keyboard->window_map)
+ g_hash_table_destroy (keyboard->window_map);
- if (keyboard->application_map)
- g_hash_table_destroy (keyboard->application_map);
+ if (keyboard->application_map)
+ g_hash_table_destroy (keyboard->application_map);
- if (keyboard->group_data)
+ if (keyboard->group_data)
{
- for (i = 0; i < keyboard->group_count; i++)
+ for (i = 0; i < keyboard->group_count; i++)
{
- XkbGroupData *group_data = &keyboard->group_data[i];
- g_free (group_data->country_name);
- g_free (group_data->language_name);
- g_free (group_data->variant);
- g_free (group_data->pretty_layout_name);
+ group_data = &keyboard->group_data[i];
- if (group_data->display_pixbuf)
- g_object_unref (group_data->display_pixbuf);
+ g_free (group_data->country_name);
+ g_free (group_data->language_name);
+ g_free (group_data->variant);
+ g_free (group_data->pretty_layout_name);
- if (group_data->tooltip_pixbuf)
- g_object_unref (group_data->tooltip_pixbuf);
+ if (group_data->display_pixbuf)
+ g_object_unref (group_data->display_pixbuf);
+
+ if (group_data->tooltip_pixbuf)
+ g_object_unref (group_data->tooltip_pixbuf);
}
- g_free (keyboard->group_data);
+
+ g_free (keyboard->group_data);
}
}
+
+
static void
xkb_keyboard_finalize (GObject *object)
{
- XkbKeyboard *keyboard = XKB_KEYBOARD (object);
+ XkbKeyboard *keyboard = XKB_KEYBOARD (object);
- if (keyboard->engine)
+ if (keyboard->engine)
{
- xkl_engine_stop_listen (keyboard->engine, XKLL_TRACK_KEYBOARD_STATE);
- g_object_unref (keyboard->engine);
+ xkl_engine_stop_listen (keyboard->engine, XKLL_TRACK_KEYBOARD_STATE);
+ g_object_unref (keyboard->engine);
- gdk_window_remove_filter (NULL, xkb_keyboard_handle_xevent, keyboard);
+ gdk_window_remove_filter (NULL, xkb_keyboard_handle_xevent, keyboard);
}
- xkb_keyboard_free (keyboard);
+ xkb_keyboard_free (keyboard);
- if (keyboard->last_config_rec != NULL)
- g_object_unref (keyboard->last_config_rec);
+ if (keyboard->last_config_rec != NULL)
+ g_object_unref (keyboard->last_config_rec);
- if (keyboard->config_timeout_id != 0)
- g_source_remove (keyboard->config_timeout_id);
+ if (keyboard->config_timeout_id != 0)
+ g_source_remove (keyboard->config_timeout_id);
- if (keyboard->active_window_changed_handler_id > 0)
- g_signal_handler_disconnect (keyboard->wnck_screen, keyboard->active_window_changed_handler_id);
+ if (keyboard->active_window_changed_handler_id > 0)
+ g_signal_handler_disconnect (keyboard->wnck_screen, keyboard->active_window_changed_handler_id);
- if (keyboard->application_closed_handler_id > 0)
- g_signal_handler_disconnect (keyboard->wnck_screen, keyboard->application_closed_handler_id);
+ if (keyboard->application_closed_handler_id > 0)
+ g_signal_handler_disconnect (keyboard->wnck_screen, keyboard->application_closed_handler_id);
- if (keyboard->window_closed_handler_id > 0)
- g_signal_handler_disconnect (keyboard->wnck_screen, keyboard->window_closed_handler_id);
+ if (keyboard->window_closed_handler_id > 0)
+ g_signal_handler_disconnect (keyboard->wnck_screen, keyboard->window_closed_handler_id);
- G_OBJECT_CLASS (xkb_keyboard_parent_class)->finalize (object);
+ G_OBJECT_CLASS (xkb_keyboard_parent_class)->finalize (object);
}
+
+
gboolean
-xkb_keyboard_set_group (XkbKeyboard *keyboard, gint group)
+xkb_keyboard_set_group (XkbKeyboard *keyboard,
+ gint group)
{
- g_return_val_if_fail (IS_XKB_KEYBOARD (keyboard), FALSE);
+ g_return_val_if_fail (IS_XKB_KEYBOARD (keyboard), FALSE);
- if (G_UNLIKELY (keyboard->engine == NULL || group < 0 || group >= keyboard->group_count))
- {
- return FALSE;
- }
+ if (G_UNLIKELY (keyboard->engine == NULL || group < 0 || group >= keyboard->group_count))
+ return FALSE;
- xkl_engine_lock_group (keyboard->engine, group);
- keyboard->current_group = group;
+ xkl_engine_lock_group (keyboard->engine, group);
+ keyboard->current_group = group;
- return TRUE;
+ return TRUE;
}
+
+
gboolean
xkb_keyboard_next_group (XkbKeyboard *keyboard)
{
- g_return_val_if_fail (IS_XKB_KEYBOARD (keyboard), FALSE);
+ g_return_val_if_fail (IS_XKB_KEYBOARD (keyboard), FALSE);
- if (G_UNLIKELY (keyboard->engine == NULL))
- {
- return FALSE;
- }
+ if (G_UNLIKELY (keyboard->engine == NULL))
+ return FALSE;
- xkl_engine_lock_group (keyboard->engine,
- xkl_engine_get_next_group (keyboard->engine));
+ xkl_engine_lock_group (keyboard->engine, xkl_engine_get_next_group (keyboard->engine));
- return TRUE;
+ return TRUE;
}
+
+
gboolean
xkb_keyboard_prev_group (XkbKeyboard *keyboard)
{
- g_return_val_if_fail (IS_XKB_KEYBOARD (keyboard), FALSE);
+ g_return_val_if_fail (IS_XKB_KEYBOARD (keyboard), FALSE);
- if (G_UNLIKELY (keyboard->engine == NULL))
- {
- return FALSE;
- }
+ if (G_UNLIKELY (keyboard->engine == NULL))
+ return FALSE;
- xkl_engine_lock_group (keyboard->engine,
- xkl_engine_get_prev_group (keyboard->engine));
+ xkl_engine_lock_group (keyboard->engine, xkl_engine_get_prev_group (keyboard->engine));
- return TRUE;
+ return TRUE;
}
+
+
void
-xkb_keyboard_set_group_policy (XkbKeyboard *keyboard,
- XkbGroupPolicy group_policy)
+xkb_keyboard_set_group_policy (XkbKeyboard *keyboard,
+ XkbGroupPolicy group_policy)
{
- g_return_if_fail (IS_XKB_KEYBOARD (keyboard));
- keyboard->group_policy = group_policy;
+ g_return_if_fail (IS_XKB_KEYBOARD (keyboard));
+
+ keyboard->group_policy = group_policy;
}
+
+
static gboolean
-xkb_keyboard_xkl_config_rec_equals (const XklConfigRec * rec1,
- const XklConfigRec * rec2)
-{
- gint i = 0;
-
- g_return_val_if_fail (XKL_IS_CONFIG_REC (rec1), FALSE);
- g_return_val_if_fail (XKL_IS_CONFIG_REC (rec2), FALSE);
-
- #define STRING_ARRAYS_NOT_EQUAL_RETURN(array1, array2) \
- for (i = 0; array1[i] || array2[i]; i++) \
- { \
- if (!array1[i] || !array2[i] || \
- g_ascii_strcasecmp (array1[i], array2[i]) != 0) \
- { \
- return FALSE; \
- } \
- }
+xkb_keyboard_xkl_config_rec_equals (const XklConfigRec *rec1,
+ const XklConfigRec *rec2)
+{
+ gint i;
- STRING_ARRAYS_NOT_EQUAL_RETURN (rec1->layouts, rec2->layouts);
- STRING_ARRAYS_NOT_EQUAL_RETURN (rec1->variants, rec2->variants);
+ g_return_val_if_fail (XKL_IS_CONFIG_REC (rec1), FALSE);
+ g_return_val_if_fail (XKL_IS_CONFIG_REC (rec2), FALSE);
- #undef STRING_ARRAYS_NOT_EQUAL_RETURN
+ #define STRING_ARRAYS_NOT_EQUAL_RETURN(array1, array2) \
+ for (i = 0; array1[i] || array2[i]; i++) \
+ { \
+ if (!array1[i] || !array2[i] || g_ascii_strcasecmp (array1[i], array2[i]) != 0) \
+ return FALSE; \
+ }
- return TRUE;
+ STRING_ARRAYS_NOT_EQUAL_RETURN (rec1->layouts, rec2->layouts);
+ STRING_ARRAYS_NOT_EQUAL_RETURN (rec1->variants, rec2->variants);
+
+ #undef STRING_ARRAYS_NOT_EQUAL_RETURN
+
+ return TRUE;
}
+
+
static gboolean
xkb_keyboard_update_from_xkl (XkbKeyboard *keyboard)
{
- XklConfigRec *config_rec;
+ XklConfigRec *config_rec;
- config_rec = xkl_config_rec_new ();
- xkl_config_rec_get_from_server (config_rec, keyboard->engine);
+ config_rec = xkl_config_rec_new ();
+ xkl_config_rec_get_from_server (config_rec, keyboard->engine);
- if (keyboard->last_config_rec == NULL ||
- !xkb_keyboard_xkl_config_rec_equals (config_rec, keyboard->last_config_rec))
+ if (keyboard->last_config_rec == NULL ||
+ !xkb_keyboard_xkl_config_rec_equals (config_rec, keyboard->last_config_rec))
{
- xkb_keyboard_initialize_xkb_options (keyboard, config_rec);
+ xkb_keyboard_initialize_xkb_options (keyboard, config_rec);
- if (keyboard->last_config_rec != NULL)
- g_object_unref (keyboard->last_config_rec);
+ if (keyboard->last_config_rec != NULL)
+ g_object_unref (keyboard->last_config_rec);
- keyboard->last_config_rec = config_rec;
+ keyboard->last_config_rec = config_rec;
- return TRUE;
+ return TRUE;
}
- else
+ else
{
- g_object_unref (config_rec);
+ g_object_unref (config_rec);
- return FALSE;
+ return FALSE;
}
}
+
+
static void
xkb_keyboard_active_window_changed (WnckScreen *screen,
WnckWindow *previously_active_window,
XkbKeyboard *keyboard)
{
- gint group = 0;
- gpointer key, value;
- GHashTable *hashtable = NULL;
- guint id = 0;
- WnckWindow *window;
- guint window_id, application_id;
+ gint group = 0;
+ gpointer key, value;
+ GHashTable *hashtable = NULL;
+ guint id = 0;
+ WnckWindow *window;
+ guint window_id, application_id;
- g_return_if_fail (IS_XKB_KEYBOARD (keyboard));
+ g_return_if_fail (IS_XKB_KEYBOARD (keyboard));
- window = wnck_screen_get_active_window (screen);
+ window = wnck_screen_get_active_window (screen);
- if (!WNCK_IS_WINDOW (window))
- return;
+ if (!WNCK_IS_WINDOW (window))
+ return;
- window_id = wnck_window_get_xid (window);
- application_id = wnck_window_get_pid (window);
+ window_id = wnck_window_get_xid (window);
+ application_id = wnck_window_get_pid (window);
- switch (keyboard->group_policy)
+ switch (keyboard->group_policy)
{
- case GROUP_POLICY_GLOBAL:
- return;
-
- case GROUP_POLICY_PER_WINDOW:
- hashtable = keyboard->window_map;
- id = window_id;
- keyboard->current_window_id = id;
- break;
-
- case GROUP_POLICY_PER_APPLICATION:
- hashtable = keyboard->application_map;
- id = application_id;
- keyboard->current_application_id = id;
- break;
+ case GROUP_POLICY_GLOBAL:
+ return;
+
+ case GROUP_POLICY_PER_WINDOW:
+ hashtable = keyboard->window_map;
+ id = window_id;
+ keyboard->current_window_id = id;
+ break;
+
+ case GROUP_POLICY_PER_APPLICATION:
+ hashtable = keyboard->application_map;
+ id = application_id;
+ keyboard->current_application_id = id;
+ break;
}
- if (g_hash_table_lookup_extended (hashtable, GINT_TO_POINTER (id), &key, &value))
- {
- group = GPOINTER_TO_INT (value);
- }
- else
- {
- g_hash_table_insert (hashtable,
- GINT_TO_POINTER (id),
- GINT_TO_POINTER (group));
- }
+ if (g_hash_table_lookup_extended (hashtable, GINT_TO_POINTER (id), &key, &value))
+ group = GPOINTER_TO_INT (value);
+ else
+ g_hash_table_insert (hashtable, GINT_TO_POINTER (id), GINT_TO_POINTER (group));
- xkb_keyboard_set_group (keyboard, group);
+ xkb_keyboard_set_group (keyboard, group);
}
+
+
static void
xkb_keyboard_application_closed (WnckScreen *screen,
WnckApplication *application,
XkbKeyboard *keyboard)
{
- guint application_id;
+ guint application_id;
- g_return_if_fail (IS_XKB_KEYBOARD (keyboard));
+ g_return_if_fail (IS_XKB_KEYBOARD (keyboard));
- application_id = wnck_application_get_pid (application);
+ application_id = wnck_application_get_pid (application);
- switch (keyboard->group_policy)
+ switch (keyboard->group_policy)
{
- case GROUP_POLICY_GLOBAL:
- case GROUP_POLICY_PER_WINDOW:
- return;
-
- case GROUP_POLICY_PER_APPLICATION:
- g_hash_table_remove (
- keyboard->application_map,
- GINT_TO_POINTER (application_id)
- );
+ case GROUP_POLICY_GLOBAL:
+ case GROUP_POLICY_PER_WINDOW:
+ break;
- break;
+ case GROUP_POLICY_PER_APPLICATION:
+ g_hash_table_remove (keyboard->application_map, GINT_TO_POINTER (application_id));
+ break;
}
}
+
+
static void
xkb_keyboard_window_closed (WnckScreen *screen,
WnckWindow *window,
XkbKeyboard *keyboard)
{
- guint window_id;
+ guint window_id;
- g_return_if_fail (IS_XKB_KEYBOARD (keyboard));
+ g_return_if_fail (IS_XKB_KEYBOARD (keyboard));
- window_id = wnck_window_get_xid (window);
+ window_id = wnck_window_get_xid (window);
- switch (keyboard->group_policy)
+ switch (keyboard->group_policy)
{
- case GROUP_POLICY_GLOBAL:
- case GROUP_POLICY_PER_APPLICATION:
- return;
+ case GROUP_POLICY_GLOBAL:
+ case GROUP_POLICY_PER_APPLICATION:
+ break;
- case GROUP_POLICY_PER_WINDOW:
- g_hash_table_remove (
- keyboard->window_map,
- GINT_TO_POINTER (window_id)
- );
-
- break;
+ case GROUP_POLICY_PER_WINDOW:
+ g_hash_table_remove (keyboard->window_map, GINT_TO_POINTER (window_id));
+ break;
}
}
+
+
gint
xkb_keyboard_get_group_count (XkbKeyboard *keyboard)
{
- g_return_val_if_fail (IS_XKB_KEYBOARD (keyboard), 0);
+ g_return_val_if_fail (IS_XKB_KEYBOARD (keyboard), 0);
- return keyboard->group_count;
+ return keyboard->group_count;
}
+
+
guint
xkb_keyboard_get_max_group_count (XkbKeyboard *keyboard)
{
- g_return_val_if_fail (IS_XKB_KEYBOARD (keyboard), 0);
+ g_return_val_if_fail (IS_XKB_KEYBOARD (keyboard), 0);
- if (G_UNLIKELY (keyboard->engine == NULL))
- {
- return 0;
- }
+ if (G_UNLIKELY (keyboard->engine == NULL))
+ return 0;
- return xkl_engine_get_max_num_groups(keyboard->engine);
+ return xkl_engine_get_max_num_groups(keyboard->engine);
}
+
+
const gchar*
-xkb_keyboard_get_group_name (XkbKeyboard *keyboard,
- XkbDisplayName display_name,
- gint group)
+xkb_keyboard_get_group_name (XkbKeyboard *keyboard,
+ XkbDisplayName display_name,
+ gint group)
{
- XkbGroupData *group_data;
+ XkbGroupData *group_data;
- g_return_val_if_fail (IS_XKB_KEYBOARD (keyboard), NULL);
+ g_return_val_if_fail (IS_XKB_KEYBOARD (keyboard), NULL);
- if (group == -1)
- group = xkb_keyboard_get_current_group (keyboard);
+ if (group == -1)
+ group = xkb_keyboard_get_current_group (keyboard);
- if (G_UNLIKELY (group < 0 || group >= keyboard->group_count))
- return NULL;
+ if (G_UNLIKELY (group < 0 || group >= keyboard->group_count))
+ return NULL;
- group_data = &keyboard->group_data[group];
+ group_data = &keyboard->group_data[group];
- switch (display_name)
+ switch (display_name)
{
- case DISPLAY_NAME_COUNTRY:
- return group_data->country_name;
+ case DISPLAY_NAME_COUNTRY:
+ return group_data->country_name;
- case DISPLAY_NAME_LANGUAGE:
- return group_data->language_name;
+ case DISPLAY_NAME_LANGUAGE:
+ return group_data->language_name;
- default:
- return "";
+ default:
+ return "";
}
}
+
+
gint
-xkb_keyboard_get_variant_index (XkbKeyboard *keyboard,
- XkbDisplayName display_name,
- gint group)
+xkb_keyboard_get_variant_index (XkbKeyboard *keyboard,
+ XkbDisplayName display_name,
+ gint group)
{
- XkbGroupData *group_data;
+ XkbGroupData *group_data;
- g_return_val_if_fail (IS_XKB_KEYBOARD (keyboard), 0);
+ g_return_val_if_fail (IS_XKB_KEYBOARD (keyboard), 0);
- if (group == -1)
- group = xkb_keyboard_get_current_group (keyboard);
+ if (group == -1)
+ group = xkb_keyboard_get_current_group (keyboard);
- if (G_UNLIKELY (group < 0 || group >= keyboard->group_count))
- return 0;
+ if (G_UNLIKELY (group < 0 || group >= keyboard->group_count))
+ return 0;
- group_data = &keyboard->group_data[group];
+ group_data = &keyboard->group_data[group];
- switch (display_name)
+ switch (display_name)
{
- case DISPLAY_NAME_COUNTRY:
- return group_data->country_index - 1;
+ case DISPLAY_NAME_COUNTRY:
+ return group_data->country_index - 1;
- case DISPLAY_NAME_LANGUAGE:
- return group_data->language_index - 1;
+ case DISPLAY_NAME_LANGUAGE:
+ return group_data->language_index - 1;
- default:
- return 0;
+ default:
+ return 0;
}
}
+
+
static void
-xkb_keyboard_xkl_state_changed (XklEngine *engine,
- XklEngineStateChange change,
- gint group,
- gboolean restore,
- gpointer user_data)
+xkb_keyboard_xkl_state_changed (XklEngine *engine,
+ XklEngineStateChange change,
+ gint group,
+ gboolean restore,
+ XkbKeyboard *keyboard)
{
- XkbKeyboard *keyboard = user_data;
-
- if (change == GROUP_CHANGED)
+ if (change == GROUP_CHANGED)
{
- keyboard->current_group = group;
+ keyboard->current_group = group;
- switch (keyboard->group_policy)
+ switch (keyboard->group_policy)
{
- case GROUP_POLICY_GLOBAL:
- break;
-
- case GROUP_POLICY_PER_WINDOW:
- g_hash_table_insert (
- keyboard->window_map,
- GINT_TO_POINTER (keyboard->current_window_id),
- GINT_TO_POINTER (group)
- );
- break;
-
- case GROUP_POLICY_PER_APPLICATION:
- g_hash_table_insert (
- keyboard->application_map,
- GINT_TO_POINTER (keyboard->current_application_id),
- GINT_TO_POINTER (group)
- );
- break;
+ case GROUP_POLICY_GLOBAL:
+ break;
+
+ case GROUP_POLICY_PER_WINDOW:
+ g_hash_table_insert (keyboard->window_map,
+ GINT_TO_POINTER (keyboard->current_window_id),
+ GINT_TO_POINTER (group));
+ break;
+
+ case GROUP_POLICY_PER_APPLICATION:
+ g_hash_table_insert (keyboard->application_map,
+ GINT_TO_POINTER (keyboard->current_application_id),
+ GINT_TO_POINTER (group));
+ break;
}
- g_signal_emit (G_OBJECT (keyboard),
- xkb_keyboard_signals [STATE_CHANGED],
- 0, FALSE);
+ g_signal_emit (G_OBJECT (keyboard),
+ xkb_keyboard_signals[STATE_CHANGED],
+ 0, FALSE);
}
}
+
+
static gboolean
xkb_keyboard_xkl_config_changed_timeout (gpointer user_data)
{
- XkbKeyboard *keyboard = user_data;
- gboolean updated;
+ XkbKeyboard *keyboard = user_data;
+ gboolean updated;
- updated = xkb_keyboard_update_from_xkl (keyboard);
+ updated = xkb_keyboard_update_from_xkl (keyboard);
- if (updated)
+ if (updated)
{
- xkb_keyboard_set_group (keyboard, 0);
+ xkb_keyboard_set_group (keyboard, 0);
- g_signal_emit (G_OBJECT (keyboard),
- xkb_keyboard_signals [STATE_CHANGED],
- 0, TRUE);
+ g_signal_emit (G_OBJECT (keyboard),
+ xkb_keyboard_signals[STATE_CHANGED],
+ 0, TRUE);
}
- keyboard->config_timeout_id = 0;
+ keyboard->config_timeout_id = 0;
- return G_SOURCE_REMOVE;
+ return G_SOURCE_REMOVE;
}
+
+
static void
-xkb_keyboard_xkl_config_changed (XklEngine *engine,
- gpointer user_data)
+xkb_keyboard_xkl_config_changed (XklEngine *engine,
+ XkbKeyboard *keyboard)
{
- XkbKeyboard *keyboard = user_data;
-
- if (keyboard->config_timeout_id != 0)
- g_source_remove (keyboard->config_timeout_id);
+ if (keyboard->config_timeout_id != 0)
+ g_source_remove (keyboard->config_timeout_id);
- keyboard->config_timeout_id = g_timeout_add (100, xkb_keyboard_xkl_config_changed_timeout, keyboard);
+ keyboard->config_timeout_id = g_timeout_add (100, xkb_keyboard_xkl_config_changed_timeout, keyboard);
}
+
+
static GdkFilterReturn
-xkb_keyboard_handle_xevent (GdkXEvent * xev, GdkEvent * event, gpointer user_data)
+xkb_keyboard_handle_xevent (GdkXEvent *xev,
+ GdkEvent *event,
+ gpointer user_data)
{
- XkbKeyboard *keyboard = user_data;
- XEvent *xevent = (XEvent *) xev;
+ XkbKeyboard *keyboard = user_data;
+ XEvent *xevent = (XEvent *) xev;
- xkl_engine_filter_events (keyboard->engine, xevent);
+ xkl_engine_filter_events (keyboard->engine, xevent);
- return GDK_FILTER_CONTINUE;
+ return GDK_FILTER_CONTINUE;
}
+
+
GdkPixbuf *
xkb_keyboard_get_pixbuf (XkbKeyboard *keyboard,
- gboolean tooltip,
- gint group)
+ gboolean tooltip,
+ gint group)
{
- g_return_val_if_fail (IS_XKB_KEYBOARD (keyboard), NULL);
+ g_return_val_if_fail (IS_XKB_KEYBOARD (keyboard), NULL);
- if (group == -1)
- group = xkb_keyboard_get_current_group (keyboard);
+ if (group == -1)
+ group = xkb_keyboard_get_current_group (keyboard);
- if (G_UNLIKELY (group < 0 || group >= keyboard->group_count))
- return 0;
+ if (G_UNLIKELY (group < 0 || group >= keyboard->group_count))
+ return 0;
- if (tooltip)
- return keyboard->group_data[group].tooltip_pixbuf;
- else
- return keyboard->group_data[group].display_pixbuf;
+ if (tooltip)
+ return keyboard->group_data[group].tooltip_pixbuf;
+ else
+ return keyboard->group_data[group].display_pixbuf;
}
+
+
gchar*
xkb_keyboard_get_pretty_layout_name (XkbKeyboard *keyboard,
- gint group)
+ gint group)
{
- g_return_val_if_fail (IS_XKB_KEYBOARD (keyboard), NULL);
+ g_return_val_if_fail (IS_XKB_KEYBOARD (keyboard), NULL);
- if (group == -1)
- group = xkb_keyboard_get_current_group (keyboard);
+ if (group == -1)
+ group = xkb_keyboard_get_current_group (keyboard);
- if (G_UNLIKELY (group < 0 || group >= keyboard->group_count))
- return 0;
+ if (G_UNLIKELY (group < 0 || group >= keyboard->group_count))
+ return 0;
- return keyboard->group_data[group].pretty_layout_name;
+ return keyboard->group_data[group].pretty_layout_name;
}
+
+
gint
xkb_keyboard_get_current_group (XkbKeyboard *keyboard)
{
- g_return_val_if_fail (IS_XKB_KEYBOARD (keyboard), 0);
- return keyboard->current_group;
+ g_return_val_if_fail (IS_XKB_KEYBOARD (keyboard), 0);
+
+ return keyboard->current_group;
}
diff --git a/panel-plugin/xkb-keyboard.h b/panel-plugin/xkb-keyboard.h
index 26aee84..3b960f7 100644
--- a/panel-plugin/xkb-keyboard.h
+++ b/panel-plugin/xkb-keyboard.h
@@ -44,7 +44,7 @@ typedef struct _XkbKeyboard XkbKeyboard;
GType xkb_keyboard_get_type (void) G_GNUC_CONST;
-XkbKeyboard *xkb_keyboard_new (XkbGroupPolicy group_policy);
+XkbKeyboard *xkb_keyboard_new (XkbGroupPolicy group_policy);
gboolean xkb_keyboard_get_initialized (XkbKeyboard *keyboard);
void xkb_keyboard_set_group_policy (XkbKeyboard *keyboard,
diff --git a/panel-plugin/xkb-plugin.c b/panel-plugin/xkb-plugin.c
index a807564..45b28e4 100644
--- a/panel-plugin/xkb-plugin.c
+++ b/panel-plugin/xkb-plugin.c
@@ -39,27 +39,26 @@
typedef struct
{
- XkbPlugin *plugin;
- gint group;
+ XkbPlugin *plugin;
+ gint group;
} MenuItemData;
struct _XkbPluginClass
{
- XfcePanelPluginClass __parent__;
+ XfcePanelPluginClass __parent__;
};
struct _XkbPlugin
{
- XfcePanelPlugin __parent__;
+ XfcePanelPlugin __parent__;
- XkbXfconf *config;
- XkbKeyboard *keyboard;
-
- /* widgets */
- GtkWidget *btn;
- GtkWidget *layout_image;
- GtkWidget *popup;
- MenuItemData *popup_user_data;
+ XkbXfconf *config;
+ XkbKeyboard *keyboard;
+
+ GtkWidget *button;
+ GtkWidget *layout_image;
+ GtkWidget *popup;
+ MenuItemData *popup_user_data;
};
/* ------------------------------------------------------------------ *
@@ -68,9 +67,9 @@ struct _XkbPlugin
static void xkb_plugin_construct (XfcePanelPlugin *plugin);
static void xkb_plugin_orientation_changed (XfcePanelPlugin *plugin,
- GtkOrientation orientation);
+ GtkOrientation orientation);
static gboolean xkb_plugin_size_changed (XfcePanelPlugin *plugin,
- gint size);
+ gint size);
static void xkb_plugin_free_data (XfcePanelPlugin *plugin);
static void xkb_plugin_about_show (XfcePanelPlugin *plugin);
static void xkb_plugin_configure_plugin (XfcePanelPlugin *plugin);
@@ -79,49 +78,47 @@ static void xkb_plugin_configure_plugin (XfcePanelPlugin *plugin
* XKB Stuff *
* ----------------------------------------------------------------- */
-static void xkb_plugin_state_changed (XkbKeyboard *keyboard,
- gboolean config_changed,
- gpointer user_data);
-
-static gboolean xkb_plugin_calculate_sizes (XkbPlugin *plugin,
- GtkOrientation orientation,
- gint panel_size);
-
-static void xkb_plugin_popup_menu_populate (XkbPlugin *plugin);
-static void xkb_plugin_popup_menu_destroy (XkbPlugin *plugin);
-static void xkb_plugin_popup_menu_show (GtkButton *btn,
- GdkEventButton *event,
- XkbPlugin *plugin);
-static void xkb_plugin_popup_menu_deactivate (gpointer data,
- GtkMenuShell *menu_shell);
-
-static void xkb_plugin_refresh_gui (XkbPlugin *plugin);
-
-static void xkb_plugin_configure_layout (GtkWidget *widget,
- gpointer user_data);
-
-static gboolean xkb_plugin_button_clicked (GtkButton *btn,
- GdkEventButton *event,
- gpointer data);
-static gboolean xkb_plugin_button_scrolled (GtkWidget *btn,
- GdkEventScroll *event,
- gpointer data);
-
-static gboolean xkb_plugin_set_tooltip (GtkWidget *widget,
- gint x,
- gint y,
- gboolean keyboard_mode,
- GtkTooltip *tooltip,
- XkbPlugin *plugin);
-
-static gboolean xkb_plugin_layout_image_draw (GtkWidget *widget,
- cairo_t *cr,
- XkbPlugin *plugin);
-
-static void xkb_plugin_display_type_changed (XkbPlugin *plugin);
-static void xkb_plugin_display_name_changed (XkbPlugin *plugin);
-static void xkb_plugin_display_scale_changed (XkbPlugin *plugin);
-static void xkb_plugin_group_policy_changed (XkbPlugin *plugin);
+static void xkb_plugin_state_changed (XkbPlugin *plugin,
+ gboolean config_changed);
+
+static gboolean xkb_plugin_calculate_sizes (XkbPlugin *plugin,
+ GtkOrientation orientation,
+ gint panel_size);
+
+static void xkb_plugin_popup_menu_populate (XkbPlugin *plugin);
+static void xkb_plugin_popup_menu_destroy (XkbPlugin *plugin);
+static void xkb_plugin_popup_menu_show (GtkButton *button,
+ GdkEventButton *event,
+ XkbPlugin *plugin);
+static void xkb_plugin_popup_menu_deactivate (XkbPlugin *plugin,
+ GtkMenuShell *menu_shell);
+
+static void xkb_plugin_refresh_gui (XkbPlugin *plugin);
+
+static void xkb_plugin_configure_layout (GtkWidget *widget);
+
+static gboolean xkb_plugin_button_clicked (GtkButton *button,
+ GdkEventButton *event,
+ XkbPlugin *plugin);
+static gboolean xkb_plugin_button_scrolled (GtkWidget *button,
+ GdkEventScroll *event,
+ XkbPlugin *plugin);
+
+static gboolean xkb_plugin_set_tooltip (GtkWidget *widget,
+ gint x,
+ gint y,
+ gboolean keyboard_mode,
+ GtkTooltip *tooltip,
+ XkbPlugin *plugin);
+
+static gboolean xkb_plugin_layout_image_draw (GtkWidget *widget,
+ cairo_t *cr,
+ XkbPlugin *plugin);
+
+static void xkb_plugin_display_type_changed (XkbPlugin *plugin);
+static void xkb_plugin_display_name_changed (XkbPlugin *plugin);
+static void xkb_plugin_display_scale_changed (XkbPlugin *plugin);
+static void xkb_plugin_group_policy_changed (XkbPlugin *plugin);
/* ================================================================== *
* Implementation *
@@ -129,529 +126,595 @@ static void xkb_plugin_group_policy_changed (XkbPlugin *plugin);
XFCE_PANEL_DEFINE_PLUGIN (XkbPlugin, xkb_plugin)
+
+
static void
xkb_plugin_class_init (XkbPluginClass *klass)
{
- XfcePanelPluginClass *plugin_class;
-
- plugin_class = XFCE_PANEL_PLUGIN_CLASS (klass);
- plugin_class->construct = xkb_plugin_construct;
- plugin_class->free_data = xkb_plugin_free_data;
- plugin_class->about = xkb_plugin_about_show;
- plugin_class->configure_plugin = xkb_plugin_configure_plugin;
- plugin_class->orientation_changed = xkb_plugin_orientation_changed;
- plugin_class->size_changed = xkb_plugin_size_changed;
+ XfcePanelPluginClass *plugin_class;
+
+ plugin_class = XFCE_PANEL_PLUGIN_CLASS (klass);
+ plugin_class->construct = xkb_plugin_construct;
+ plugin_class->free_data = xkb_plugin_free_data;
+ plugin_class->about = xkb_plugin_about_show;
+ plugin_class->configure_plugin = xkb_plugin_configure_plugin;
+ plugin_class->orientation_changed = xkb_plugin_orientation_changed;
+ plugin_class->size_changed = xkb_plugin_size_changed;
}
+
+
static void
xkb_plugin_init (XkbPlugin *plugin)
{
- plugin->config = NULL;
- plugin->keyboard = NULL;
+ plugin->config = NULL;
+ plugin->keyboard = NULL;
- plugin->btn = NULL;
- plugin->layout_image = NULL;
- plugin->popup = NULL;
- plugin->popup_user_data = NULL;
+ plugin->button = NULL;
+ plugin->layout_image = NULL;
+ plugin->popup = NULL;
+ plugin->popup_user_data = NULL;
}
+
+
static void
xkb_plugin_construct (XfcePanelPlugin *plugin)
{
- XkbPlugin *xkb_plugin;
- GtkWidget *configure_layouts;
- GtkCssProvider *css_provider;
-
- xkb_plugin = XKB_PLUGIN (plugin);
-
- xkb_plugin->config = xkb_xfconf_new (xfce_panel_plugin_get_property_base (plugin));
- g_signal_connect_swapped (G_OBJECT (xkb_plugin->config), "notify::" DISPLAY_TYPE,
- G_CALLBACK (xkb_plugin_display_type_changed), xkb_plugin);
- g_signal_connect_swapped (G_OBJECT (xkb_plugin->config), "notify::" DISPLAY_NAME,
- G_CALLBACK (xkb_plugin_display_name_changed), xkb_plugin);
- g_signal_connect_swapped (G_OBJECT (xkb_plugin->config), "notify::" DISPLAY_SCALE,
- G_CALLBACK (xkb_plugin_display_scale_changed), xkb_plugin);
- g_signal_connect_swapped (G_OBJECT (xkb_plugin->config), "notify::" GROUP_POLICY,
- G_CALLBACK (xkb_plugin_group_policy_changed), xkb_plugin);
-
- xkb_plugin->btn = gtk_button_new ();
- gtk_button_set_relief (GTK_BUTTON (xkb_plugin->btn), GTK_RELIEF_NONE);
- gtk_container_add (GTK_CONTAINER (plugin), xkb_plugin->btn);
- xfce_panel_plugin_add_action_widget (plugin, xkb_plugin->btn);
- gtk_widget_add_events (xkb_plugin->btn, GDK_SCROLL_MASK);
-
- /* remove padding inside button */
- css_provider = gtk_css_provider_new ();
- gtk_css_provider_load_from_data (css_provider, ".xfce4-panel button {padding: 0;}", -1, NULL);
- gtk_style_context_add_provider (GTK_STYLE_CONTEXT (gtk_widget_get_style_context (GTK_WIDGET (xkb_plugin->btn))),
- GTK_STYLE_PROVIDER (css_provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
- g_object_unref (css_provider);
-
- gtk_widget_show (xkb_plugin->btn);
- g_signal_connect (xkb_plugin->btn, "button-press-event",
- G_CALLBACK (xkb_plugin_button_clicked), xkb_plugin);
- g_signal_connect (xkb_plugin->btn, "button-release-event",
- G_CALLBACK (xkb_plugin_button_clicked), xkb_plugin);
- g_signal_connect (xkb_plugin->btn, "scroll-event",
- G_CALLBACK (xkb_plugin_button_scrolled), xkb_plugin);
-
- g_object_set (G_OBJECT (xkb_plugin->btn), "has-tooltip", TRUE, NULL);
- g_signal_connect (xkb_plugin->btn, "query-tooltip",
- G_CALLBACK (xkb_plugin_set_tooltip), xkb_plugin);
-
- xkb_plugin->layout_image = gtk_image_new ();
- gtk_container_add (GTK_CONTAINER (xkb_plugin->btn), xkb_plugin->layout_image);
- g_signal_connect (G_OBJECT (xkb_plugin->layout_image), "draw",
- G_CALLBACK (xkb_plugin_layout_image_draw), xkb_plugin);
- gtk_widget_show (GTK_WIDGET (xkb_plugin->layout_image));
-
- xkb_plugin->keyboard = xkb_keyboard_new (xkb_xfconf_get_group_policy (xkb_plugin->config));
-
- g_signal_connect (G_OBJECT (xkb_plugin->keyboard), "state-changed",
- G_CALLBACK (xkb_plugin_state_changed), xkb_plugin);
-
- if (xkb_keyboard_get_initialized (xkb_plugin->keyboard))
+ XkbPlugin *xkb_plugin;
+ GtkWidget *configure_layouts;
+ GtkCssProvider *css_provider;
+
+ xkb_plugin = XKB_PLUGIN (plugin);
+
+ xkb_plugin->config = xkb_xfconf_new (xfce_panel_plugin_get_property_base (plugin));
+
+ g_signal_connect_swapped (G_OBJECT (xkb_plugin->config),
+ "notify::" DISPLAY_TYPE,
+ G_CALLBACK (xkb_plugin_display_type_changed),
+ xkb_plugin);
+ g_signal_connect_swapped (G_OBJECT (xkb_plugin->config),
+ "notify::" DISPLAY_NAME,
+ G_CALLBACK (xkb_plugin_display_name_changed),
+ xkb_plugin);
+ g_signal_connect_swapped (G_OBJECT (xkb_plugin->config),
+ "notify::" DISPLAY_SCALE,
+ G_CALLBACK (xkb_plugin_display_scale_changed),
+ xkb_plugin);
+ g_signal_connect_swapped (G_OBJECT (xkb_plugin->config),
+ "notify::" GROUP_POLICY,
+ G_CALLBACK (xkb_plugin_group_policy_changed),
+ xkb_plugin);
+
+ xkb_plugin->button = gtk_button_new ();
+ gtk_button_set_relief (GTK_BUTTON (xkb_plugin->button), GTK_RELIEF_NONE);
+ gtk_container_add (GTK_CONTAINER (plugin), xkb_plugin->button);
+ xfce_panel_plugin_add_action_widget (plugin, xkb_plugin->button);
+ gtk_widget_add_events (xkb_plugin->button, GDK_SCROLL_MASK);
+
+ /* remove padding inside button */
+ css_provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (css_provider, ".xfce4-panel button {padding: 0;}", -1, NULL);
+ gtk_style_context_add_provider (GTK_STYLE_CONTEXT (gtk_widget_get_style_context (GTK_WIDGET (xkb_plugin->button))),
+ GTK_STYLE_PROVIDER (css_provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ g_object_unref (css_provider);
+
+ gtk_widget_show (xkb_plugin->button);
+ g_signal_connect (xkb_plugin->button,
+ "button-press-event",
+ G_CALLBACK (xkb_plugin_button_clicked),
+ xkb_plugin);
+ g_signal_connect (xkb_plugin->button,
+ "button-release-event",
+ G_CALLBACK (xkb_plugin_button_clicked),
+ xkb_plugin);
+ g_signal_connect (xkb_plugin->button,
+ "scroll-event",
+ G_CALLBACK (xkb_plugin_button_scrolled),
+ xkb_plugin);
+
+ g_object_set (G_OBJECT (xkb_plugin->button), "has-tooltip", TRUE, NULL);
+ g_signal_connect (xkb_plugin->button,
+ "query-tooltip",
+ G_CALLBACK (xkb_plugin_set_tooltip),
+ xkb_plugin);
+
+ xkb_plugin->layout_image = gtk_image_new ();
+ gtk_container_add (GTK_CONTAINER (xkb_plugin->button), xkb_plugin->layout_image);
+ g_signal_connect (G_OBJECT (xkb_plugin->layout_image),
+ "draw",
+ G_CALLBACK (xkb_plugin_layout_image_draw),
+ xkb_plugin);
+ gtk_widget_show (GTK_WIDGET (xkb_plugin->layout_image));
+
+ xkb_plugin->keyboard = xkb_keyboard_new (xkb_xfconf_get_group_policy (xkb_plugin->config));
+
+ g_signal_connect_swapped (G_OBJECT (xkb_plugin->keyboard),
+ "state-changed",
+ G_CALLBACK (xkb_plugin_state_changed),
+ xkb_plugin);
+
+ if (xkb_keyboard_get_initialized (xkb_plugin->keyboard))
{
- xkb_plugin_refresh_gui (xkb_plugin);
- xkb_plugin_popup_menu_populate (xkb_plugin);
+ xkb_plugin_refresh_gui (xkb_plugin);
+ xkb_plugin_popup_menu_populate (xkb_plugin);
}
- xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8");
+ xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8");
- xfce_panel_plugin_menu_show_configure (plugin);
- xfce_panel_plugin_menu_show_about (plugin);
+ xfce_panel_plugin_menu_show_configure (plugin);
+ xfce_panel_plugin_menu_show_about (plugin);
- xfce_panel_plugin_set_small (plugin, TRUE);
+ xfce_panel_plugin_set_small (plugin, TRUE);
- configure_layouts = gtk_menu_item_new_with_label (_("Keyboard settings"));
- gtk_widget_show (configure_layouts);
- xfce_panel_plugin_menu_insert_item (plugin, GTK_MENU_ITEM (configure_layouts));
+ configure_layouts = gtk_menu_item_new_with_label (_("Keyboard settings"));
+ gtk_widget_show (configure_layouts);
+ xfce_panel_plugin_menu_insert_item (plugin, GTK_MENU_ITEM (configure_layouts));
- g_signal_connect (G_OBJECT (configure_layouts), "activate",
- G_CALLBACK (xkb_plugin_configure_layout), NULL);
+ g_signal_connect (G_OBJECT (configure_layouts),
+ "activate",
+ G_CALLBACK (xkb_plugin_configure_layout),
+ NULL);
}
+
+
static void
xkb_plugin_orientation_changed (XfcePanelPlugin *plugin,
- GtkOrientation orientation)
+ GtkOrientation orientation)
{
- xkb_plugin_calculate_sizes (XKB_PLUGIN (plugin),
- orientation, xfce_panel_plugin_get_size (plugin));
+ xkb_plugin_calculate_sizes (XKB_PLUGIN (plugin),
+ orientation,
+ xfce_panel_plugin_get_size (plugin));
}
+
+
static gboolean
xkb_plugin_size_changed (XfcePanelPlugin *plugin,
- gint size)
+ gint size)
{
- return xkb_plugin_calculate_sizes (XKB_PLUGIN (plugin),
- xfce_panel_plugin_get_orientation (plugin), size);
+ return xkb_plugin_calculate_sizes (XKB_PLUGIN (plugin),
+ xfce_panel_plugin_get_orientation (plugin),
+ size);
}
+
+
static void
xkb_plugin_free_data (XfcePanelPlugin *plugin)
{
- XkbPlugin *xkb_plugin = XKB_PLUGIN (plugin);
+ XkbPlugin *xkb_plugin = XKB_PLUGIN (plugin);
- xkb_plugin_popup_menu_destroy (xkb_plugin);
- gtk_widget_destroy (xkb_plugin->layout_image);
- gtk_widget_destroy (xkb_plugin->btn);
+ xkb_plugin_popup_menu_destroy (xkb_plugin);
+ gtk_widget_destroy (xkb_plugin->layout_image);
+ gtk_widget_destroy (xkb_plugin->button);
- g_object_unref (G_OBJECT (xkb_plugin->keyboard));
- g_object_unref (G_OBJECT (xkb_plugin->config));
+ g_object_unref (G_OBJECT (xkb_plugin->keyboard));
+ g_object_unref (G_OBJECT (xkb_plugin->config));
}
+
+
static void
xkb_plugin_about_show (XfcePanelPlugin *plugin)
{
- xkb_dialog_about_show ();
+ xkb_dialog_about_show ();
}
+
+
static void
xkb_plugin_configure_plugin (XfcePanelPlugin *plugin)
{
- XkbPlugin *xkb_plugin = XKB_PLUGIN (plugin);
+ XkbPlugin *xkb_plugin = XKB_PLUGIN (plugin);
- xkb_dialog_configure_plugin (plugin, xkb_plugin->config);
+ xkb_dialog_configure_plugin (plugin, xkb_plugin->config);
}
-/* ----------------- xkb plugin stuff -----------------------*/
+
static void
-xkb_plugin_state_changed (XkbKeyboard *keyboard,
- gboolean config_changed,
- gpointer user_data)
+xkb_plugin_state_changed (XkbPlugin *plugin,
+ gboolean config_changed)
{
- XkbPlugin *plugin = user_data;
-
- xkb_plugin_refresh_gui (plugin);
+ xkb_plugin_refresh_gui (plugin);
- if (config_changed)
- {
- xkb_plugin_popup_menu_populate (plugin);
- }
+ if (config_changed)
+ xkb_plugin_popup_menu_populate (plugin);
}
+
+
static void
xkb_plugin_set_group (GtkMenuItem *item,
- gpointer data)
+ gpointer data)
{
- MenuItemData *item_data = data;
- xkb_keyboard_set_group (item_data->plugin->keyboard, item_data->group);
+ MenuItemData *item_data = data;
+
+ xkb_keyboard_set_group (item_data->plugin->keyboard, item_data->group);
}
+
+
static gboolean
-xkb_plugin_calculate_sizes (XkbPlugin *plugin,
- GtkOrientation orientation,
- gint panel_size)
+xkb_plugin_calculate_sizes (XkbPlugin *plugin,
+ GtkOrientation orientation,
+ gint panel_size)
{
- guint nrows;
- gint hsize, vsize;
- gboolean proportional;
- XkbDisplayType display_type;
-
- display_type = xkb_xfconf_get_display_type (plugin->config);
- nrows = xfce_panel_plugin_get_nrows (XFCE_PANEL_PLUGIN (plugin));
- panel_size /= nrows;
- proportional = nrows > 1 || display_type == DISPLAY_TYPE_SYSTEM;
- TRACE ("calculate_sizes(%p: %d,%d)", plugin, panel_size, nrows);
-
- switch (orientation)
+ guint nrows;
+ gint hsize, vsize;
+ gboolean proportional;
+ XkbDisplayType display_type;
+
+ display_type = xkb_xfconf_get_display_type (plugin->config);
+ nrows = xfce_panel_plugin_get_nrows (XFCE_PANEL_PLUGIN (plugin));
+ panel_size /= nrows;
+ proportional = nrows > 1 || display_type == DISPLAY_TYPE_SYSTEM;
+ TRACE ("calculate_sizes(%p: %d,%d)", plugin, panel_size, nrows);
+
+ switch (orientation)
{
- case GTK_ORIENTATION_HORIZONTAL:
- vsize = panel_size;
- if (proportional)
- {
- hsize = panel_size;
- }
- else
- {
- hsize = (int) (1.33 * panel_size);
- }
-
- gtk_widget_set_size_request (plugin->btn, hsize, vsize);
- break;
- case GTK_ORIENTATION_VERTICAL:
- hsize = panel_size;
- if (proportional)
- {
- vsize = panel_size;
- }
- else
- {
- vsize = (int) (0.75 * panel_size);
- }
- if (vsize < 10) vsize = 10;
-
- gtk_widget_set_size_request (plugin->btn, hsize, vsize);
- break;
- default:
- break;
+ case GTK_ORIENTATION_HORIZONTAL:
+ vsize = panel_size;
+
+ if (proportional)
+ hsize = panel_size;
+ else
+ hsize = (int) (1.33 * panel_size);
+
+ gtk_widget_set_size_request (plugin->button, hsize, vsize);
+ break;
+
+ case GTK_ORIENTATION_VERTICAL:
+ hsize = panel_size;
+
+ if (proportional)
+ vsize = panel_size;
+ else
+ vsize = (int) (0.75 * panel_size);
+
+ if (vsize < 10)
+ vsize = 10;
+
+ gtk_widget_set_size_request (plugin->button, hsize, vsize);
+ break;
+
+ default:
+ break;
}
- DBG ("size requested: h/v (%p: %d/%d), proportional: %d",
- plugin, hsize, vsize, proportional);
+ DBG ("size requested: h/v (%p: %d/%d), proportional: %d",
+ plugin, hsize, vsize, proportional);
- xkb_plugin_refresh_gui (plugin);
- return TRUE;
+ xkb_plugin_refresh_gui (plugin);
+ return TRUE;
}
+
+
static void
xkb_plugin_popup_menu_destroy (XkbPlugin *plugin)
{
- if (plugin->popup != NULL)
+ if (plugin->popup != NULL)
{
- gtk_menu_popdown (GTK_MENU (plugin->popup));
- gtk_menu_detach (GTK_MENU (plugin->popup));
- g_free (plugin->popup_user_data);
- plugin->popup_user_data = NULL;
- plugin->popup = NULL;
+ gtk_menu_popdown (GTK_MENU (plugin->popup));
+ gtk_menu_detach (GTK_MENU (plugin->popup));
+ g_free (plugin->popup_user_data);
+ plugin->popup_user_data = NULL;
+ plugin->popup = NULL;
}
}
+
+
static void
xkb_plugin_popup_menu_populate (XkbPlugin *plugin)
{
- gint i, group_count;
- gchar *layout_string;
- GtkWidget *menu_item;
+ gint i, group_count;
+ gchar *layout_string;
+ GtkWidget *menu_item;
- if (G_UNLIKELY (plugin == NULL)) return;
+ if (G_UNLIKELY (plugin == NULL))
+ return;
- group_count = xkb_keyboard_get_group_count (plugin->keyboard);
+ group_count = xkb_keyboard_get_group_count (plugin->keyboard);
- xkb_plugin_popup_menu_destroy (plugin);
- plugin->popup = gtk_menu_new ();
- plugin->popup_user_data = g_new0 (MenuItemData, group_count);
+ xkb_plugin_popup_menu_destroy (plugin);
+ plugin->popup = gtk_menu_new ();
+ plugin->popup_user_data = g_new0 (MenuItemData, group_count);
- for (i = 0; i < group_count; i++)
+ for (i = 0; i < group_count; i++)
{
- layout_string = xkb_keyboard_get_pretty_layout_name (plugin->keyboard, i);
+ layout_string = xkb_keyboard_get_pretty_layout_name (plugin->keyboard, i);
- menu_item = gtk_menu_item_new_with_label (layout_string);
+ menu_item = gtk_menu_item_new_with_label (layout_string);
- plugin->popup_user_data[i].plugin = plugin;
- plugin->popup_user_data[i].group = i;
+ plugin->popup_user_data[i].plugin = plugin;
+ plugin->popup_user_data[i].group = i;
- g_signal_connect (G_OBJECT (menu_item), "activate",
- G_CALLBACK (xkb_plugin_set_group), &plugin->popup_user_data[i]);
+ g_signal_connect (G_OBJECT (menu_item),
+ "activate",
+ G_CALLBACK (xkb_plugin_set_group),
+ &plugin->popup_user_data[i]);
- gtk_widget_show (menu_item);
- gtk_menu_shell_append (GTK_MENU_SHELL (plugin->popup), menu_item);
+ gtk_widget_show (menu_item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (plugin->popup), menu_item);
}
- g_signal_connect_swapped (GTK_MENU_SHELL (plugin->popup), "deactivate",
- G_CALLBACK (xkb_plugin_popup_menu_deactivate), plugin);
+ g_signal_connect_swapped (GTK_MENU_SHELL (plugin->popup),
+ "deactivate",
+ G_CALLBACK (xkb_plugin_popup_menu_deactivate),
+ plugin);
- gtk_menu_attach_to_widget (GTK_MENU (plugin->popup), plugin->btn, NULL);
+ gtk_menu_attach_to_widget (GTK_MENU (plugin->popup), plugin->button, NULL);
}
+
+
static void
-xkb_plugin_popup_menu_show (GtkButton *btn,
+xkb_plugin_popup_menu_show (GtkButton *button,
GdkEventButton *event,
- XkbPlugin *plugin)
+ XkbPlugin *plugin)
{
- gtk_widget_set_state_flags (GTK_WIDGET (btn), GTK_STATE_FLAG_CHECKED, FALSE);
+ gtk_widget_set_state_flags (GTK_WIDGET (button), GTK_STATE_FLAG_CHECKED, FALSE);
#if GTK_CHECK_VERSION(3, 22, 0)
- gtk_menu_popup_at_widget (GTK_MENU (plugin->popup), GTK_WIDGET (btn),
- GDK_GRAVITY_NORTH_WEST, GDK_GRAVITY_NORTH_WEST, (GdkEvent *) event);
+ gtk_menu_popup_at_widget (GTK_MENU (plugin->popup), GTK_WIDGET (button),
+ GDK_GRAVITY_NORTH_WEST, GDK_GRAVITY_NORTH_WEST, (GdkEvent *) event);
#else
- gtk_menu_popup (GTK_MENU (plugin->popup), NULL, NULL,
- xfce_panel_plugin_position_menu, xkb_plugin_get_plugin (plugin),
- 0, event->time);
+ gtk_menu_popup (GTK_MENU (plugin->popup), NULL, NULL,
+ xfce_panel_plugin_position_menu, xkb_plugin_get_plugin (plugin),
+ 0, event->time);
#endif
}
+
+
static void
-xkb_plugin_popup_menu_deactivate (gpointer data,
+xkb_plugin_popup_menu_deactivate (XkbPlugin *plugin,
GtkMenuShell *menu_shell)
{
- XkbPlugin *plugin = data;
-
- g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell));
+ g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell));
- gtk_widget_unset_state_flags (GTK_WIDGET (plugin->btn), GTK_STATE_FLAG_CHECKED);
+ gtk_widget_unset_state_flags (GTK_WIDGET (plugin->button), GTK_STATE_FLAG_CHECKED);
}
+
+
static void
xkb_plugin_refresh_gui (XkbPlugin *plugin)
{
- GdkDisplay * display;
- GtkAllocation allocation;
+ GdkDisplay *display;
+ GtkAllocation allocation;
- gtk_widget_get_allocation (GTK_WIDGET (plugin->btn), &allocation);
+ gtk_widget_get_allocation (GTK_WIDGET (plugin->button), &allocation);
- /* Part of the image may remain visible after display type change */
- gtk_widget_queue_draw_area (plugin->btn, 0, 0,
- allocation.width, allocation.height);
+ /* Part of the image may remain visible after display type change */
+ gtk_widget_queue_draw_area (plugin->button, 0, 0, allocation.width, allocation.height);
- display = gdk_display_get_default();
- if (display)
- {
- gtk_tooltip_trigger_tooltip_query(display);
- }
+ display = gdk_display_get_default ();
+ if (display)
+ gtk_tooltip_trigger_tooltip_query (display);
}
+
+
static void
-xkb_plugin_configure_layout (GtkWidget *widget,
- gpointer user_data)
+xkb_plugin_configure_layout (GtkWidget *widget)
{
- gchar *desktop_file = xfce_resource_lookup (XFCE_RESOURCE_DATA,
- "applications/xfce-keyboard-settings.desktop");
+ gchar *desktop_file;
+ GError *error = NULL;
+ gchar **argv;
+ gboolean succeed;
- GarconMenuItem *item = garcon_menu_item_new_for_path (desktop_file);
- if (item)
- {
- GError *error = NULL;
- gchar **argv;
- gboolean succeed;
- g_shell_parse_argv (garcon_menu_item_get_command (item), NULL, &argv, &error);
- succeed = xfce_spawn_on_screen (gtk_widget_get_screen (GTK_WIDGET (widget)),
- garcon_menu_item_get_path (item),
- argv, NULL, G_SPAWN_SEARCH_PATH,
- garcon_menu_item_supports_startup_notification (item),
- gtk_get_current_event_time (),
- garcon_menu_item_get_icon_name (item),
- &error);
- g_strfreev (argv);
- garcon_menu_item_unref (item);
- g_assert (succeed);
+ desktop_file = xfce_resource_lookup (XFCE_RESOURCE_DATA,
+ "applications/xfce-keyboard-settings.desktop");
+
+ GarconMenuItem *item = garcon_menu_item_new_for_path (desktop_file);
+ if (item)
+ {
+ g_shell_parse_argv (garcon_menu_item_get_command (item), NULL, &argv, &error);
+ succeed = xfce_spawn_on_screen (gtk_widget_get_screen (GTK_WIDGET (widget)),
+ garcon_menu_item_get_path (item),
+ argv, NULL, G_SPAWN_SEARCH_PATH,
+ garcon_menu_item_supports_startup_notification (item),
+ gtk_get_current_event_time (),
+ garcon_menu_item_get_icon_name (item),
+ &error);
+ g_strfreev (argv);
+ garcon_menu_item_unref (item);
+ g_assert (succeed);
}
- g_free (desktop_file);
+
+ g_free (desktop_file);
}
+
+
static gboolean
-xkb_plugin_button_clicked (GtkButton *btn,
+xkb_plugin_button_clicked (GtkButton *button,
GdkEventButton *event,
- gpointer data)
+ XkbPlugin *plugin)
{
- XkbPlugin *plugin;
- gboolean released, display_popup;
+ gboolean released, display_popup;
- if (event->button == 1)
+ if (event->button == 1)
{
- plugin = data;
-
- released = event->type == GDK_BUTTON_RELEASE;
- display_popup = xkb_keyboard_get_group_count (plugin->keyboard) > 2;
+ released = event->type == GDK_BUTTON_RELEASE;
+ display_popup = xkb_keyboard_get_group_count (plugin->keyboard) > 2;
- if (display_popup && !released)
+ if (display_popup && !released)
{
- xkb_plugin_popup_menu_show (btn, event, data);
- return TRUE;
+ xkb_plugin_popup_menu_show (button, event, plugin);
+ return TRUE;
}
- if (!display_popup && released)
+ if (!display_popup && released)
{
- xkb_keyboard_next_group (plugin->keyboard);
- return FALSE;
+ xkb_keyboard_next_group (plugin->keyboard);
+ return FALSE;
}
}
- return FALSE;
+
+ return FALSE;
}
+
+
static gboolean
-xkb_plugin_button_scrolled (GtkWidget *btn,
+xkb_plugin_button_scrolled (GtkWidget *button,
GdkEventScroll *event,
- gpointer data)
+ XkbPlugin *plugin)
{
- XkbPlugin *plugin = data;
-
- switch (event->direction)
+ switch (event->direction)
{
- case GDK_SCROLL_UP:
- case GDK_SCROLL_RIGHT:
- xkb_keyboard_next_group (plugin->keyboard);
- return TRUE;
- case GDK_SCROLL_DOWN:
- case GDK_SCROLL_LEFT:
- xkb_keyboard_prev_group (plugin->keyboard);
- return TRUE;
- default:
- return FALSE;
+ case GDK_SCROLL_UP:
+ case GDK_SCROLL_RIGHT:
+ xkb_keyboard_next_group (plugin->keyboard);
+ return TRUE;
+
+ case GDK_SCROLL_DOWN:
+ case GDK_SCROLL_LEFT:
+ xkb_keyboard_prev_group (plugin->keyboard);
+ return TRUE;
+
+ default:
+ return FALSE;
}
- return FALSE;
+ return FALSE;
}
+
+
static gboolean
-xkb_plugin_set_tooltip (GtkWidget *widget,
- gint x,
- gint y,
- gboolean keyboard_mode,
+xkb_plugin_set_tooltip (GtkWidget *widget,
+ gint x,
+ gint y,
+ gboolean keyboard_mode,
GtkTooltip *tooltip,
- XkbPlugin *plugin)
+ XkbPlugin *plugin)
{
- gchar *layout_name;
- GdkPixbuf *pixbuf;
+ gchar *layout_name;
+ GdkPixbuf *pixbuf;
- if (xkb_xfconf_get_display_tooltip_icon (plugin->config))
+ if (xkb_xfconf_get_display_tooltip_icon (plugin->config))
{
- pixbuf = xkb_keyboard_get_pixbuf (plugin->keyboard, TRUE, -1);
- gtk_tooltip_set_icon (tooltip, pixbuf);
+ pixbuf = xkb_keyboard_get_pixbuf (plugin->keyboard, TRUE, -1);
+ gtk_tooltip_set_icon (tooltip, pixbuf);
}
- layout_name = xkb_keyboard_get_pretty_layout_name (plugin->keyboard, -1);
+ layout_name = xkb_keyboard_get_pretty_layout_name (plugin->keyboard, -1);
- gtk_tooltip_set_text (tooltip, layout_name);
+ gtk_tooltip_set_text (tooltip, layout_name);
- return TRUE;
+ return TRUE;
}
+
+
static gboolean
xkb_plugin_layout_image_draw (GtkWidget *widget,
- cairo_t *cr,
+ cairo_t *cr,
XkbPlugin *plugin)
{
- const gchar *group_name;
- gint variant_index;
- GdkPixbuf *pixbuf;
- GtkAllocation allocation;
- GtkStyleContext *style_ctx;
- GtkStateFlags state;
- PangoFontDescription *desc;
- GdkRGBA rgba;
- gint actual_hsize, actual_vsize;
- XkbDisplayType display_type;
- XkbDisplayName display_name;
- gint display_scale;
-
- display_type = xkb_xfconf_get_display_type (plugin->config);
- display_name = xkb_xfconf_get_display_name (plugin->config);
- display_scale = xkb_xfconf_get_display_scale (plugin->config);
-
- gtk_widget_get_allocation (GTK_WIDGET (widget), &allocation);
- actual_hsize = allocation.width;
- actual_vsize = allocation.height;
-
- state = gtk_widget_get_state_flags (GTK_WIDGET (plugin->btn));
- style_ctx = gtk_widget_get_style_context (GTK_WIDGET (plugin->btn));
- gtk_style_context_get_color (style_ctx, state, &rgba);
-
- group_name = xkb_keyboard_get_group_name (plugin->keyboard, display_name, -1);
- pixbuf = xkb_keyboard_get_pixbuf (plugin->keyboard, FALSE, -1);
- variant_index = xkb_keyboard_get_variant_index (plugin->keyboard, display_name, -1);
-
- if (pixbuf == NULL && display_type == DISPLAY_TYPE_IMAGE)
- display_type = DISPLAY_TYPE_TEXT;
-
- DBG ("img_exposed: actual h/v (%d/%d)",
- actual_hsize, actual_vsize);
-
- switch (display_type)
+ const gchar *group_name;
+ gint variant_index;
+ GdkPixbuf *pixbuf;
+ GtkAllocation allocation;
+ GtkStyleContext *style_ctx;
+ GtkStateFlags state;
+ PangoFontDescription *desc;
+ GdkRGBA rgba;
+ gint actual_hsize, actual_vsize;
+ XkbDisplayType display_type;
+ XkbDisplayName display_name;
+ gint display_scale;
+
+ display_type = xkb_xfconf_get_display_type (plugin->config);
+ display_name = xkb_xfconf_get_display_name (plugin->config);
+ display_scale = xkb_xfconf_get_display_scale (plugin->config);
+
+ gtk_widget_get_allocation (GTK_WIDGET (widget), &allocation);
+ actual_hsize = allocation.width;
+ actual_vsize = allocation.height;
+
+ state = gtk_widget_get_state_flags (GTK_WIDGET (plugin->button));
+ style_ctx = gtk_widget_get_style_context (GTK_WIDGET (plugin->button));
+ gtk_style_context_get_color (style_ctx, state, &rgba);
+
+ group_name = xkb_keyboard_get_group_name (plugin->keyboard, display_name, -1);
+ pixbuf = xkb_keyboard_get_pixbuf (plugin->keyboard, FALSE, -1);
+ variant_index = xkb_keyboard_get_variant_index (plugin->keyboard, display_name, -1);
+
+ if (pixbuf == NULL && display_type == DISPLAY_TYPE_IMAGE)
+ display_type = DISPLAY_TYPE_TEXT;
+
+ DBG ("img_exposed: actual h/v (%d/%d)", actual_hsize, actual_vsize);
+
+ switch (display_type)
{
- case DISPLAY_TYPE_IMAGE:
- xkb_cairo_draw_flag (cr, pixbuf,
- actual_hsize, actual_vsize,
- variant_index,
- xkb_keyboard_get_max_group_count (plugin->keyboard),
- display_scale
- );
- break;
- case DISPLAY_TYPE_TEXT:
- xkb_cairo_draw_label (cr, group_name,
- actual_hsize, actual_vsize,
- variant_index,
- display_scale,
- rgba
- );
- break;
- case DISPLAY_TYPE_SYSTEM:
- gtk_style_context_get (style_ctx, state, "font", &desc, NULL);
- xkb_cairo_draw_label_system (cr, group_name,
- actual_hsize, actual_vsize,
- variant_index,
- desc, rgba
- );
- break;
+ case DISPLAY_TYPE_IMAGE:
+ xkb_cairo_draw_flag (cr, pixbuf,
+ actual_hsize, actual_vsize,
+ variant_index,
+ xkb_keyboard_get_max_group_count (plugin->keyboard),
+ display_scale);
+ break;
+
+ case DISPLAY_TYPE_TEXT:
+ xkb_cairo_draw_label (cr, group_name,
+ actual_hsize, actual_vsize,
+ variant_index,
+ display_scale,
+ rgba);
+ break;
+
+ case DISPLAY_TYPE_SYSTEM:
+ gtk_style_context_get (style_ctx, state, "font", &desc, NULL);
+
+ xkb_cairo_draw_label_system (cr, group_name,
+ actual_hsize, actual_vsize,
+ variant_index,
+ desc, rgba);
+ break;
}
- return FALSE;
+ return FALSE;
}
+
+
static void
xkb_plugin_display_type_changed (XkbPlugin *plugin)
{
- xkb_plugin_calculate_sizes (plugin,
- xfce_panel_plugin_get_orientation (XFCE_PANEL_PLUGIN (plugin)),
- xfce_panel_plugin_get_size (XFCE_PANEL_PLUGIN (plugin)));
+ xkb_plugin_calculate_sizes (plugin,
+ xfce_panel_plugin_get_orientation (XFCE_PANEL_PLUGIN (plugin)),
+ xfce_panel_plugin_get_size (XFCE_PANEL_PLUGIN (plugin)));
}
+
+
static void
xkb_plugin_display_name_changed (XkbPlugin *plugin)
{
- xkb_plugin_refresh_gui (plugin);
+ xkb_plugin_refresh_gui (plugin);
}
+
+
static void
xkb_plugin_display_scale_changed (XkbPlugin *plugin)
{
- xkb_plugin_refresh_gui (plugin);
+ xkb_plugin_refresh_gui (plugin);
}
+
+
static void
xkb_plugin_group_policy_changed (XkbPlugin *plugin)
{
- xkb_keyboard_set_group_policy (plugin->keyboard,
- xkb_xfconf_get_group_policy (plugin->config));
+ xkb_keyboard_set_group_policy (plugin->keyboard,
+ xkb_xfconf_get_group_policy (plugin->config));
}
diff --git a/panel-plugin/xkb-properties.h b/panel-plugin/xkb-properties.h
index d9b61a5..37d6d7e 100644
--- a/panel-plugin/xkb-properties.h
+++ b/panel-plugin/xkb-properties.h
@@ -26,33 +26,33 @@
#ifndef _XKB_PROPERTIES_H_
#define _XKB_PROPERTIES_H_
-#define DISPLAY_TYPE "display-type"
-#define DISPLAY_NAME "display-name"
-#define DISPLAY_SCALE "display-scale"
-#define DISPLAY_TOOLTIP_ICON "display-tooltip-icon"
-#define GROUP_POLICY "group-policy"
+#define DISPLAY_TYPE "display-type"
+#define DISPLAY_NAME "display-name"
+#define DISPLAY_SCALE "display-scale"
+#define DISPLAY_TOOLTIP_ICON "display-tooltip-icon"
+#define GROUP_POLICY "group-policy"
typedef enum
{
- DISPLAY_TYPE_IMAGE = 0,
- DISPLAY_TYPE_TEXT = 1,
- DISPLAY_TYPE_SYSTEM = 2
+ DISPLAY_TYPE_IMAGE = 0,
+ DISPLAY_TYPE_TEXT = 1,
+ DISPLAY_TYPE_SYSTEM = 2
} XkbDisplayType;
typedef enum
{
- DISPLAY_NAME_COUNTRY = 0,
- DISPLAY_NAME_LANGUAGE = 1,
+ DISPLAY_NAME_COUNTRY = 0,
+ DISPLAY_NAME_LANGUAGE = 1,
} XkbDisplayName;
-#define DISPLAY_SCALE_MIN 0
-#define DISPLAY_SCALE_MAX 100
+#define DISPLAY_SCALE_MIN 0
+#define DISPLAY_SCALE_MAX 100
typedef enum
{
- GROUP_POLICY_GLOBAL = 0,
- GROUP_POLICY_PER_WINDOW = 1,
- GROUP_POLICY_PER_APPLICATION = 2
+ GROUP_POLICY_GLOBAL = 0,
+ GROUP_POLICY_PER_WINDOW = 1,
+ GROUP_POLICY_PER_APPLICATION = 2
} XkbGroupPolicy;
#endif
diff --git a/panel-plugin/xkb-util.c b/panel-plugin/xkb-util.c
index 11a7179..d467fb4 100644
--- a/panel-plugin/xkb-util.c
+++ b/panel-plugin/xkb-util.c
@@ -27,80 +27,80 @@
#include "xkb-util.h"
+
+
gchar*
xkb_util_get_flag_filename (const gchar* group_name)
{
- gchar* filename;
+ gchar* filename;
- if (!group_name)
- return NULL;
+ if (!group_name)
+ return NULL;
- filename = g_strconcat (g_get_user_data_dir (), "/", FLAGSRELDIR, "/", group_name, ".svg", NULL);
+ filename = g_strconcat (g_get_user_data_dir (), "/", FLAGSRELDIR, "/", group_name, ".svg", NULL);
- if (!g_file_test (filename, G_FILE_TEST_EXISTS))
+ if (!g_file_test (filename, G_FILE_TEST_EXISTS))
{
- g_free (filename);
- filename = g_strconcat (DATADIR, "/", FLAGSRELDIR, "/", group_name, ".svg", NULL);
+ g_free (filename);
+ filename = g_strconcat (DATADIR, "/", FLAGSRELDIR, "/", group_name, ".svg", NULL);
}
- return filename;
+ return filename;
}
+
+
gchar*
-xkb_util_get_layout_string (const gchar *group_name, const gchar *variant)
+xkb_util_get_layout_string (const gchar *group_name,
+ const gchar *variant)
{
- gchar *layout;
+ gchar *layout;
- if (!group_name)
- return NULL;
+ if (!group_name)
+ return NULL;
- if (variant && strlen (variant) > 0)
- {
- layout = g_strconcat (group_name, " (", variant, ")", NULL);
- }
- else
- {
- layout = g_strconcat (group_name, NULL);
- }
+ if (variant && strlen (variant) > 0)
+ layout = g_strconcat (group_name, " (", variant, ")", NULL);
+ else
+ layout = g_strconcat (group_name, NULL);
- return layout;
+ return layout;
}
+
+
gchar*
-xkb_util_normalize_group_name (const gchar* group_name, const gboolean capitalize)
+xkb_util_normalize_group_name (const gchar *group_name,
+ gboolean capitalize)
{
- const gchar *c;
- gchar *result;
- gint cut_length;
- gint index_of_na = -1;
+ const gchar *c;
+ gchar *result;
+ gint cut_length;
+ gint index_of_na = -1;
- if (!group_name)
- return NULL;
+ if (!group_name)
+ return NULL;
- cut_length = strlen (group_name);
+ cut_length = strlen (group_name);
- if (cut_length > 3)
+ if (cut_length > 3)
{
- for (c = group_name; *c; c++)
+ for (c = group_name; *c; c++)
{
- if (!((*c >= 'a' && *c <= 'z') || (*c >= 'A' && *c <= 'Z')))
+ if (!((*c >= 'a' && *c <= 'z') || (*c >= 'A' && *c <= 'Z')))
{
- index_of_na = c - group_name;
- break;
+ index_of_na = c - group_name;
+ break;
}
}
- cut_length = (index_of_na != -1 && index_of_na <= 3) ? index_of_na : 3;
+ cut_length = (index_of_na != -1 && index_of_na <= 3) ? index_of_na : 3;
}
- if (capitalize)
- {
- result = g_ascii_strup (group_name, cut_length);
- }
- else
- {
- result = g_strndup (group_name, cut_length);
- }
+ if (capitalize)
+ result = g_ascii_strup (group_name, cut_length);
+ else
+ result = g_strndup (group_name, cut_length);
- return result;
+ return result;
}
diff --git a/panel-plugin/xkb-util.h b/panel-plugin/xkb-util.h
index 4ce4665..ed1efb1 100644
--- a/panel-plugin/xkb-util.h
+++ b/panel-plugin/xkb-util.h
@@ -28,11 +28,11 @@
#include <glib.h>
-gchar* xkb_util_get_flag_filename (const gchar* group_name);
+gchar* xkb_util_get_flag_filename (const gchar *group_name);
-gchar* xkb_util_get_layout_string (const gchar* group_name,
- const gchar* variant);
-gchar* xkb_util_normalize_group_name (const gchar* group_name,
- const gboolean capitalize);
+gchar* xkb_util_get_layout_string (const gchar *group_name,
+ const gchar *variant);
+gchar* xkb_util_normalize_group_name (const gchar *group_name,
+ gboolean capitalize);
#endif
diff --git a/panel-plugin/xkb-xfconf.c b/panel-plugin/xkb-xfconf.c
index 83c6ec5..036cd34 100644
--- a/panel-plugin/xkb-xfconf.c
+++ b/panel-plugin/xkb-xfconf.c
@@ -5,9 +5,6 @@
* Parts of this program comes from the XfKC tool:
* Copyright (C) 2006 Gauvain Pocentek <gauvainpocentek at gmail.com>
*
- * A part of this file comes from the gnome keyboard capplet (control-center):
- * Copyright (C) 2003 Sergey V. Oudaltsov <svu at 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)
@@ -51,258 +48,304 @@ static void xkb_xfconf_set_property (GObject *object,
struct _XkbXfconfClass
{
- GObjectClass __parent__;
+ GObjectClass __parent__;
};
struct _XkbXfconf
{
- GObject __parent__;
+ GObject __parent__;
- XkbDisplayType display_type;
- XkbDisplayName display_name;
- guint display_scale;
- gboolean display_tooltip_icon;
- XkbGroupPolicy group_policy;
+ XkbDisplayType display_type;
+ XkbDisplayName display_name;
+ guint display_scale;
+ gboolean display_tooltip_icon;
+ XkbGroupPolicy group_policy;
};
enum
{
- PROP_0,
- PROP_DISPLAY_TYPE,
- PROP_DISPLAY_NAME,
- PROP_DISPLAY_SCALE,
- PROP_DISPLAY_TOOLTIP_ICON,
- PROP_GROUP_POLICY,
- N_PROPERTIES,
+ PROP_0,
+ PROP_DISPLAY_TYPE,
+ PROP_DISPLAY_NAME,
+ PROP_DISPLAY_SCALE,
+ PROP_DISPLAY_TOOLTIP_ICON,
+ PROP_GROUP_POLICY,
+ N_PROPERTIES,
};
enum
{
- CONFIGURATION_CHANGED,
- LAST_SIGNAL
+ CONFIGURATION_CHANGED,
+ LAST_SIGNAL
};
-static guint xkb_xfconf_signals [LAST_SIGNAL] = { 0, };
+static guint xkb_xfconf_signals[LAST_SIGNAL] = { 0, };
G_DEFINE_TYPE (XkbXfconf, xkb_xfconf, G_TYPE_OBJECT)
+
+
static void
xkb_xfconf_class_init (XkbXfconfClass *klass)
{
- GObjectClass *gobject_class;
-
- gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->finalize = xkb_xfconf_finalize;
- gobject_class->get_property = xkb_xfconf_get_property;
- gobject_class->set_property = xkb_xfconf_set_property;
-
- g_object_class_install_property (gobject_class, PROP_DISPLAY_TYPE,
- g_param_spec_uint (DISPLAY_TYPE, NULL, NULL,
- DISPLAY_TYPE_IMAGE, DISPLAY_TYPE_SYSTEM, DEFAULT_DISPLAY_TYPE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class, PROP_DISPLAY_NAME,
- g_param_spec_uint (DISPLAY_NAME, NULL, NULL,
- DISPLAY_NAME_COUNTRY, DISPLAY_NAME_LANGUAGE, DEFAULT_DISPLAY_NAME,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class, PROP_DISPLAY_SCALE,
- g_param_spec_uint (DISPLAY_SCALE, NULL, NULL,
- DISPLAY_SCALE_MIN, DISPLAY_SCALE_MAX, DEFAULT_DISPLAY_SCALE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class, PROP_DISPLAY_TOOLTIP_ICON,
- g_param_spec_boolean (DISPLAY_TOOLTIP_ICON, NULL, NULL,
- DEFAULT_DISPLAY_TOOLTIP_ICON,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class, PROP_GROUP_POLICY,
- g_param_spec_uint (GROUP_POLICY, NULL, NULL,
- GROUP_POLICY_GLOBAL, GROUP_POLICY_PER_APPLICATION, DEFAULT_GROUP_POLICY,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- xkb_xfconf_signals[CONFIGURATION_CHANGED] =
- g_signal_new (g_intern_static_string ("configuration-changed"),
- G_TYPE_FROM_CLASS (gobject_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ GObjectClass *gobject_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = xkb_xfconf_finalize;
+ gobject_class->get_property = xkb_xfconf_get_property;
+ gobject_class->set_property = xkb_xfconf_set_property;
+
+ g_object_class_install_property (gobject_class, PROP_DISPLAY_TYPE,
+ g_param_spec_uint (DISPLAY_TYPE, NULL, NULL,
+ DISPLAY_TYPE_IMAGE,
+ DISPLAY_TYPE_SYSTEM,
+ DEFAULT_DISPLAY_TYPE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_DISPLAY_NAME,
+ g_param_spec_uint (DISPLAY_NAME, NULL, NULL,
+ DISPLAY_NAME_COUNTRY,
+ DISPLAY_NAME_LANGUAGE,
+ DEFAULT_DISPLAY_NAME,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_DISPLAY_SCALE,
+ g_param_spec_uint (DISPLAY_SCALE, NULL, NULL,
+ DISPLAY_SCALE_MIN,
+ DISPLAY_SCALE_MAX,
+ DEFAULT_DISPLAY_SCALE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_DISPLAY_TOOLTIP_ICON,
+ g_param_spec_boolean (DISPLAY_TOOLTIP_ICON, NULL, NULL,
+ DEFAULT_DISPLAY_TOOLTIP_ICON,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_GROUP_POLICY,
+ g_param_spec_uint (GROUP_POLICY, NULL, NULL,
+ GROUP_POLICY_GLOBAL,
+ GROUP_POLICY_PER_APPLICATION,
+ DEFAULT_GROUP_POLICY,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ xkb_xfconf_signals[CONFIGURATION_CHANGED] =
+ g_signal_new (g_intern_static_string ("configuration-changed"),
+ G_TYPE_FROM_CLASS (gobject_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
+
+
static void
xkb_xfconf_init (XkbXfconf *config)
{
- config->display_type = DEFAULT_DISPLAY_TYPE;
- config->display_name = DEFAULT_DISPLAY_NAME;
- config->display_scale = DEFAULT_DISPLAY_SCALE;
- config->display_tooltip_icon = DEFAULT_DISPLAY_TOOLTIP_ICON;
- config->group_policy = DEFAULT_GROUP_POLICY;
+ config->display_type = DEFAULT_DISPLAY_TYPE;
+ config->display_name = DEFAULT_DISPLAY_NAME;
+ config->display_scale = DEFAULT_DISPLAY_SCALE;
+ config->display_tooltip_icon = DEFAULT_DISPLAY_TOOLTIP_ICON;
+ config->group_policy = DEFAULT_GROUP_POLICY;
}
+
+
static void
xkb_xfconf_finalize (GObject *object)
{
- xfconf_shutdown ();
- G_OBJECT_CLASS (xkb_xfconf_parent_class)->finalize (object);
+ xfconf_shutdown ();
+ G_OBJECT_CLASS (xkb_xfconf_parent_class)->finalize (object);
}
+
+
static void
-xkb_xfconf_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+xkb_xfconf_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- XkbXfconf *config = XKB_XFCONF (object);
+ XkbXfconf *config = XKB_XFCONF (object);
- switch (prop_id)
+ switch (prop_id)
{
- case PROP_DISPLAY_TYPE:
- g_value_set_uint (value, config->display_type);
- break;
- case PROP_DISPLAY_NAME:
- g_value_set_uint (value, config->display_name);
- break;
- case PROP_DISPLAY_SCALE:
- g_value_set_uint (value, config->display_scale);
- break;
- case PROP_DISPLAY_TOOLTIP_ICON:
- g_value_set_boolean (value, config->display_tooltip_icon);
- break;
- case PROP_GROUP_POLICY:
- g_value_set_uint (value, config->group_policy);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case PROP_DISPLAY_TYPE:
+ g_value_set_uint (value, config->display_type);
+ break;
+
+ case PROP_DISPLAY_NAME:
+ g_value_set_uint (value, config->display_name);
+ break;
+
+ case PROP_DISPLAY_SCALE:
+ g_value_set_uint (value, config->display_scale);
+ break;
+
+ case PROP_DISPLAY_TOOLTIP_ICON:
+ g_value_set_boolean (value, config->display_tooltip_icon);
+ break;
+
+ case PROP_GROUP_POLICY:
+ g_value_set_uint (value, config->group_policy);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
+
+
static void
-xkb_xfconf_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+xkb_xfconf_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- XkbXfconf *config = XKB_XFCONF (object);
- guint val_uint;
- gboolean val_boolean;
+ XkbXfconf *config = XKB_XFCONF (object);
+ guint val_uint;
+ gboolean val_boolean;
- switch (prop_id)
+ switch (prop_id)
{
- case PROP_DISPLAY_TYPE:
- val_uint = g_value_get_uint (value);
- if (config->display_type != val_uint)
- {
- config->display_type = val_uint;
- g_object_notify (G_OBJECT (config), DISPLAY_TYPE);
- g_signal_emit (G_OBJECT (config), xkb_xfconf_signals [CONFIGURATION_CHANGED], 0);
- }
- break;
- case PROP_DISPLAY_NAME:
- val_uint = g_value_get_uint (value);
- if (config->display_name != val_uint)
- {
- config->display_name = val_uint;
- g_object_notify (G_OBJECT (config), DISPLAY_NAME);
- g_signal_emit (G_OBJECT (config), xkb_xfconf_signals [CONFIGURATION_CHANGED], 0);
- }
- break;
- case PROP_DISPLAY_SCALE:
- val_uint = g_value_get_uint (value);
- if (config->display_scale != val_uint)
- {
- config->display_scale = val_uint;
- g_object_notify (G_OBJECT (config), DISPLAY_SCALE);
- g_signal_emit (G_OBJECT (config), xkb_xfconf_signals [CONFIGURATION_CHANGED], 0);
- }
- break;
- case PROP_DISPLAY_TOOLTIP_ICON:
- val_boolean = g_value_get_boolean (value);
- if (config->display_tooltip_icon != val_boolean)
- {
- config->display_tooltip_icon = val_boolean;
- g_object_notify (G_OBJECT (config), DISPLAY_TOOLTIP_ICON);
- g_signal_emit (G_OBJECT (config), xkb_xfconf_signals [CONFIGURATION_CHANGED], 0);
- }
- break;
- case PROP_GROUP_POLICY:
- val_uint = g_value_get_uint (value);
- if (config->group_policy != val_uint)
- {
- config->group_policy = val_uint;
- g_object_notify (G_OBJECT (config), GROUP_POLICY);
- g_signal_emit (G_OBJECT (config), xkb_xfconf_signals [CONFIGURATION_CHANGED], 0);
- }
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case PROP_DISPLAY_TYPE:
+ val_uint = g_value_get_uint (value);
+ if (config->display_type != val_uint)
+ {
+ config->display_type = val_uint;
+ g_object_notify (G_OBJECT (config), DISPLAY_TYPE);
+ g_signal_emit (G_OBJECT (config), xkb_xfconf_signals[CONFIGURATION_CHANGED], 0);
+ }
+ break;
+
+ case PROP_DISPLAY_NAME:
+ val_uint = g_value_get_uint (value);
+ if (config->display_name != val_uint)
+ {
+ config->display_name = val_uint;
+ g_object_notify (G_OBJECT (config), DISPLAY_NAME);
+ g_signal_emit (G_OBJECT (config), xkb_xfconf_signals[CONFIGURATION_CHANGED], 0);
+ }
+ break;
+
+ case PROP_DISPLAY_SCALE:
+ val_uint = g_value_get_uint (value);
+ if (config->display_scale != val_uint)
+ {
+ config->display_scale = val_uint;
+ g_object_notify (G_OBJECT (config), DISPLAY_SCALE);
+ g_signal_emit (G_OBJECT (config), xkb_xfconf_signals[CONFIGURATION_CHANGED], 0);
+ }
+ break;
+
+ case PROP_DISPLAY_TOOLTIP_ICON:
+ val_boolean = g_value_get_boolean (value);
+ if (config->display_tooltip_icon != val_boolean)
+ {
+ config->display_tooltip_icon = val_boolean;
+ g_object_notify (G_OBJECT (config), DISPLAY_TOOLTIP_ICON);
+ g_signal_emit (G_OBJECT (config), xkb_xfconf_signals[CONFIGURATION_CHANGED], 0);
+ }
+ break;
+
+ case PROP_GROUP_POLICY:
+ val_uint = g_value_get_uint (value);
+ if (config->group_policy != val_uint)
+ {
+ config->group_policy = val_uint;
+ g_object_notify (G_OBJECT (config), GROUP_POLICY);
+ g_signal_emit (G_OBJECT (config), xkb_xfconf_signals[CONFIGURATION_CHANGED], 0);
+ }
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
+
+
XkbDisplayType
xkb_xfconf_get_display_type (XkbXfconf *config)
{
- g_return_val_if_fail (IS_XKB_XFCONF (config), DEFAULT_DISPLAY_TYPE);
- return config->display_type;
+ g_return_val_if_fail (IS_XKB_XFCONF (config), DEFAULT_DISPLAY_TYPE);
+ return config->display_type;
}
+
+
XkbDisplayName
xkb_xfconf_get_display_name (XkbXfconf *config)
{
- g_return_val_if_fail (IS_XKB_XFCONF (config), DEFAULT_DISPLAY_NAME);
- return config->display_name;
+ g_return_val_if_fail (IS_XKB_XFCONF (config), DEFAULT_DISPLAY_NAME);
+ return config->display_name;
}
+
+
guint
xkb_xfconf_get_display_scale (XkbXfconf *config)
{
- g_return_val_if_fail (IS_XKB_XFCONF (config), DEFAULT_DISPLAY_SCALE);
- return config->display_scale;
+ g_return_val_if_fail (IS_XKB_XFCONF (config), DEFAULT_DISPLAY_SCALE);
+ return config->display_scale;
}
+
+
gboolean
xkb_xfconf_get_display_tooltip_icon (XkbXfconf *config)
{
- g_return_val_if_fail (IS_XKB_XFCONF (config), DEFAULT_DISPLAY_TOOLTIP_ICON);
- return config->display_tooltip_icon;
+ g_return_val_if_fail (IS_XKB_XFCONF (config), DEFAULT_DISPLAY_TOOLTIP_ICON);
+ return config->display_tooltip_icon;
}
+
+
XkbGroupPolicy
xkb_xfconf_get_group_policy (XkbXfconf *config)
{
- g_return_val_if_fail (IS_XKB_XFCONF (config), DEFAULT_GROUP_POLICY);
- return config->group_policy;
+ g_return_val_if_fail (IS_XKB_XFCONF (config), DEFAULT_GROUP_POLICY);
+ return config->group_policy;
}
+
+
XkbXfconf *
xkb_xfconf_new (const gchar *property_base)
{
- XkbXfconf *config;
- XfconfChannel *channel;
- gchar *property;
+ XkbXfconf *config;
+ XfconfChannel *channel;
+ gchar *property;
- config = g_object_new (TYPE_XKB_XFCONF, NULL);
+ config = g_object_new (TYPE_XKB_XFCONF, NULL);
- if (xfconf_init (NULL))
+ if (xfconf_init (NULL))
{
- channel = xfconf_channel_get ("xfce4-panel");
+ channel = xfconf_channel_get ("xfce4-panel");
- property = g_strconcat (property_base, "/" DISPLAY_TYPE, NULL);
- xfconf_g_property_bind (channel, property, G_TYPE_UINT, config, DISPLAY_TYPE);
- g_free (property);
+ property = g_strconcat (property_base, "/" DISPLAY_TYPE, NULL);
+ xfconf_g_property_bind (channel, property, G_TYPE_UINT, config, DISPLAY_TYPE);
+ g_free (property);
- property = g_strconcat (property_base, "/" DISPLAY_NAME, NULL);
- xfconf_g_property_bind (channel, property, G_TYPE_UINT, config, DISPLAY_NAME);
- g_free (property);
+ property = g_strconcat (property_base, "/" DISPLAY_NAME, NULL);
+ xfconf_g_property_bind (channel, property, G_TYPE_UINT, config, DISPLAY_NAME);
+ g_free (property);
- property = g_strconcat (property_base, "/" DISPLAY_SCALE, NULL);
- xfconf_g_property_bind (channel, property, G_TYPE_UINT, config, DISPLAY_SCALE);
- g_free (property);
+ property = g_strconcat (property_base, "/" DISPLAY_SCALE, NULL);
+ xfconf_g_property_bind (channel, property, G_TYPE_UINT, config, DISPLAY_SCALE);
+ g_free (property);
- property = g_strconcat (property_base, "/" DISPLAY_TOOLTIP_ICON, NULL);
- xfconf_g_property_bind (channel, property, G_TYPE_BOOLEAN, config, DISPLAY_TOOLTIP_ICON);
- g_free (property);
+ property = g_strconcat (property_base, "/" DISPLAY_TOOLTIP_ICON, NULL);
+ xfconf_g_property_bind (channel, property, G_TYPE_BOOLEAN, config, DISPLAY_TOOLTIP_ICON);
+ g_free (property);
- property = g_strconcat (property_base, "/" GROUP_POLICY, NULL);
- xfconf_g_property_bind (channel, property, G_TYPE_UINT, config, GROUP_POLICY);
- g_free (property);
+ property = g_strconcat (property_base, "/" GROUP_POLICY, NULL);
+ xfconf_g_property_bind (channel, property, G_TYPE_UINT, config, GROUP_POLICY);
+ g_free (property);
}
- return config;
+ return config;
}
diff --git a/panel-plugin/xkb-xfconf.h b/panel-plugin/xkb-xfconf.h
index d609976..7dae172 100644
--- a/panel-plugin/xkb-xfconf.h
+++ b/panel-plugin/xkb-xfconf.h
@@ -5,9 +5,6 @@
* Parts of this program comes from the XfKC tool:
* Copyright (C) 2006 Gauvain Pocentek <gauvainpocentek at gmail.com>
*
- * A part of this file comes from the gnome keyboard capplet (control-center):
- * Copyright (C) 2003 Sergey V. Oudaltsov <svu at 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)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list