[gucharmap] Simplify GSEAL work
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gucharmap] Simplify GSEAL work
- Date: Sun, 18 Apr 2010 09:43:13 +0000 (UTC)
commit 458295be438aba4869899023d3b12bccbaa6643f
Author: Christian Persch <chpe gnome org>
Date: Sun Apr 18 11:40:19 2010 +0200
Simplify GSEAL work
Unify some code, and fix some style issues with the last commit.
gucharmap/gucharmap-chartable-accessible.c | 54 +++++-----
gucharmap/gucharmap-chartable.c | 175 ++++++++++++++--------------
gucharmap/gucharmap-mini-fontsel.c | 14 ++-
gucharmap/gucharmap-search-dialog.c | 12 +-
gucharmap/gucharmap-window.c | 17 ++--
5 files changed, 138 insertions(+), 134 deletions(-)
---
diff --git a/gucharmap/gucharmap-chartable-accessible.c b/gucharmap/gucharmap-chartable-accessible.c
index 4a9c166..5dca040 100644
--- a/gucharmap/gucharmap-chartable-accessible.c
+++ b/gucharmap/gucharmap-chartable-accessible.c
@@ -105,8 +105,8 @@ gucharmap_chartable_accessible_ref_child (AtkObject *obj,
GPtrArray *cells;
guint n_cells, n;
-#if GTK_CHECK_VERSION(2,21,0)
- widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
+#if GTK_CHECK_VERSION (2, 21, 0)
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
#else
widget = GTK_ACCESSIBLE (obj)->widget;
#endif
@@ -163,8 +163,8 @@ gucharmap_chartable_accessible_ref_at (AtkTable *table,
AtkObject *child;
gint index;
-#if GTK_CHECK_VERSION(2,21,0)
- widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
+#if GTK_CHECK_VERSION (2, 21, 0)
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
#else
widget = GTK_ACCESSIBLE (table)->widget;
#endif
@@ -194,8 +194,8 @@ gucharmap_chartable_accessible_ref_accessible_at_point (AtkComponent *component,
gint x_pos, y_pos;
gint row, col;
-#if GTK_CHECK_VERSION(2,21,0)
- widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (component));
+#if GTK_CHECK_VERSION (2, 21, 0)
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (component));
#else
widget = GTK_ACCESSIBLE (component)->widget;
#endif
@@ -256,8 +256,8 @@ gucharmap_chartable_accessible_ref_state_set (AtkObject *obj)
GtkWidget *widget;
state_set = ATK_OBJECT_CLASS (gucharmap_chartable_accessible_parent_class)->ref_state_set (obj);
-#if GTK_CHECK_VERSION(2,21,0)
- widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
+#if GTK_CHECK_VERSION (2, 21, 0)
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
#else
widget = GTK_ACCESSIBLE (obj)->widget;
#endif
@@ -275,8 +275,8 @@ gucharmap_chartable_accessible_get_n_children (AtkObject *obj)
{
GtkWidget *widget;
-#if GTK_CHECK_VERSION(2,21,0)
- widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
+#if GTK_CHECK_VERSION (2, 21, 0)
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
#else
widget = GTK_ACCESSIBLE (obj)->widget;
#endif
@@ -333,8 +333,8 @@ gucharmap_chartable_accessible_update_all_cells (AtkObject *obj)
GPtrArray *cells;
guint n_cells, n;
-#if GTK_CHECK_VERSION(2,21,0)
- widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
+#if GTK_CHECK_VERSION (2, 21, 0)
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
#else
widget = GTK_ACCESSIBLE (obj)->widget;
#endif
@@ -522,7 +522,7 @@ gucharmap_chartable_accessible_destroyed (GtkWidget *widget,
static void
gucharmap_chartable_accessible_connect_widget_destroyed (GtkAccessible *accessible)
{
-#if GTK_CHECK_VERSION(2,21,0)
+#if GTK_CHECK_VERSION (2, 21, 0)
if (gtk_accessible_get_widget (accessible))
{
g_signal_connect_after (gtk_accessible_get_widget (accessible),
@@ -567,8 +567,8 @@ gucharmap_chartable_accessible_get_n_columns (AtkTable *table)
GucharmapChartable *chartable;
GucharmapChartablePrivate *chartable_priv;
-#if GTK_CHECK_VERSION(2,21,0)
- widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
+#if GTK_CHECK_VERSION (2, 21, 0)
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
#else
widget = GTK_ACCESSIBLE (table)->widget;
#endif
@@ -590,8 +590,8 @@ gucharmap_chartable_accessible_get_column_extent_at (AtkTable *table,
{
GtkWidget *widget;
-#if GTK_CHECK_VERSION(2,21,0)
- widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
+#if GTK_CHECK_VERSION (2, 21, 0)
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
#else
widget = GTK_ACCESSIBLE (table)->widget;
#endif
@@ -611,8 +611,8 @@ gucharmap_chartable_accessible_get_n_rows (AtkTable *table)
GucharmapChartablePrivate *chartable_priv;
gint n_rows;
-#if GTK_CHECK_VERSION(2,21,0)
- widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
+#if GTK_CHECK_VERSION (2, 21, 0)
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
#else
widget = GTK_ACCESSIBLE (table)->widget;
#endif
@@ -636,8 +636,8 @@ gucharmap_chartable_accessible_get_row_extent_at (AtkTable *table,
{
GtkWidget *widget;
-#if GTK_CHECK_VERSION(2,21,0)
- widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
+#if GTK_CHECK_VERSION (2, 21, 0)
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
#else
widget = GTK_ACCESSIBLE (table)->widget;
#endif
@@ -658,8 +658,8 @@ gucharmap_chartable_accessible_get_index_at (AtkTable *table,
GucharmapChartable *chartable;
GucharmapChartablePrivate *chartable_priv;
-#if GTK_CHECK_VERSION(2,21,0)
- widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
+#if GTK_CHECK_VERSION (2, 21, 0)
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
#else
widget = GTK_ACCESSIBLE (table)->widget;
#endif
@@ -682,8 +682,8 @@ gucharmap_chartable_accessible_get_column_at_index (AtkTable *table,
GucharmapChartable *chartable;
GucharmapChartablePrivate *chartable_priv;
-#if GTK_CHECK_VERSION(2,21,0)
- widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
+#if GTK_CHECK_VERSION (2, 21, 0)
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
#else
widget = GTK_ACCESSIBLE (table)->widget;
#endif
@@ -706,8 +706,8 @@ gucharmap_chartable_accessible_get_row_at_index (AtkTable *table,
GucharmapChartable *chartable;
GucharmapChartablePrivate *chartable_priv;
-#if GTK_CHECK_VERSION(2,21,0)
- widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
+#if GTK_CHECK_VERSION (2, 21, 0)
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
#else
widget = GTK_ACCESSIBLE (table)->widget;
#endif
diff --git a/gucharmap/gucharmap-chartable.c b/gucharmap/gucharmap-chartable.c
index 6994da3..cc2061c 100644
--- a/gucharmap/gucharmap-chartable.c
+++ b/gucharmap/gucharmap-chartable.c
@@ -833,59 +833,45 @@ draw_borders (GucharmapChartable *chartable)
{
GucharmapChartablePrivate *priv = chartable->priv;
GtkWidget *widget = GTK_WIDGET (chartable);
-#if GTK_CHECK_VERSION (2,18,0)
- GtkAllocation allocation;
-#endif
+ GtkAllocation *allocation;
GtkStyle *style;
gint x, y, col, row;
+#if GTK_CHECK_VERSION (2, 18, 0)
+ GtkAllocation widget_allocation;
+
+ gtk_widget_get_allocation (widget, &widget_allocation);
+ allocation = &widget_allocation;
+#else
+ allocation = &widget->allocation;
+#endif
/* dark_gc[GTK_STATE_NORMAL] seems to be what is used to draw the borders
* around widgets, so we use it for the lines */
style = gtk_widget_get_style (widget);
-#if GTK_CHECK_VERSION (2,18,0)
- gtk_widget_get_allocation (widget, &allocation);
-#endif
-
/* vertical lines */
gdk_draw_line (priv->pixmap,
style->dark_gc[GTK_STATE_NORMAL],
-#if GTK_CHECK_VERSION (2,18,0)
- 0, 0, 0, allocation.height - 1);
-#else
- 0, 0, 0, widget->allocation.height - 1);
-#endif
+ 0, 0, 0, allocation->height - 1);
for (col = 0, x = 0; col < priv->cols; col++)
{
x += _gucharmap_chartable_column_width (chartable, col);
gdk_draw_line (priv->pixmap,
style->dark_gc[GTK_STATE_NORMAL],
-#if GTK_CHECK_VERSION (2,18,0)
- x, 0, x, allocation.height - 1);
-#else
- x, 0, x, widget->allocation.height - 1);
-#endif
+ x, 0, x, allocation->height - 1);
}
/* horizontal lines */
gdk_draw_line (priv->pixmap,
style->dark_gc[GTK_STATE_NORMAL],
-#if GTK_CHECK_VERSION (2,18,0)
- 0, 0, allocation.width - 1, 0);
-#else
- 0, 0, widget->allocation.width - 1, 0);
-#endif
+ 0, 0, allocation->width - 1, 0);
for (row = 0, y = 0; row < priv->rows; row++)
{
y += _gucharmap_chartable_row_height (chartable, row);
gdk_draw_line (priv->pixmap,
style->dark_gc[GTK_STATE_NORMAL],
-#if GTK_CHECK_VERSION (2,18,0)
- 0, y, allocation.width - 1, y);
-#else
- 0, y, widget->allocation.width - 1, y);
-#endif
+ 0, y, allocation->width - 1, y);
}
}
@@ -955,7 +941,7 @@ draw_character (GucharmapChartable *chartable,
style = gtk_widget_get_style (widget);
-#if GTK_CHECK_VERSION (2,18,0)
+#if GTK_CHECK_VERSION (2, 18, 0)
if (gtk_widget_has_focus (widget) && (gint)cell == priv->active_cell)
#else
if (GTK_WIDGET_HAS_FOCUS (widget) && (gint)cell == priv->active_cell)
@@ -1003,7 +989,7 @@ draw_square_bg (GucharmapChartable *chartable, gint row, gint col)
style = gtk_widget_get_style (widget);
-#if GTK_CHECK_VERSION (2,18,0)
+#if GTK_CHECK_VERSION (2, 18, 0)
if (gtk_widget_has_focus (widget) && (gint)cell == priv->active_cell)
#else
if (GTK_WIDGET_HAS_FOCUS (widget) && (gint)cell == priv->active_cell)
@@ -1074,34 +1060,31 @@ draw_chartable_from_scratch (GucharmapChartable *chartable)
{
GucharmapChartablePrivate *priv = chartable->priv;
GtkWidget *widget = GTK_WIDGET (chartable);
-#if GTK_CHECK_VERSION (2,18,0)
- GtkAllocation allocation;
-#endif
gint row, col;
+ GtkAllocation *allocation;
+#if GTK_CHECK_VERSION (2, 18, 0)
+ GtkAllocation widget_allocation;
+
+ gtk_widget_get_allocation (widget, &widget_allocation);
+ allocation = &widget_allocation;
+#else
+ allocation = &widget->allocation;
+#endif
/* drawing area may not be exposed yet when restoring last char setting
*/
-#if GTK_CHECK_VERSION (2,20,0)
+#if GTK_CHECK_VERSION (2, 20, 0)
if (!gtk_widget_get_realized (GTK_WIDGET (chartable)))
#else
if (!GTK_WIDGET_REALIZED (chartable))
#endif
return;
-#if GTK_CHECK_VERSION (2,18,0)
- gtk_widget_get_allocation (widget, &allocation);
-#endif
-
if (priv->pixmap == NULL)
priv->pixmap = gdk_pixmap_new (
gtk_widget_get_window (widget),
-#if GTK_CHECK_VERSION (2,18,0)
- allocation.width,
- allocation.height, -1);
-#else
- widget->allocation.width,
- widget->allocation.height, -1);
-#endif
+ allocation->width,
+ allocation->height, -1);
draw_borders (chartable);
@@ -1119,16 +1102,21 @@ copy_rows (GucharmapChartable *chartable, gint row_offset)
{
GucharmapChartablePrivate *priv = chartable->priv;
GtkWidget *widget = GTK_WIDGET (chartable);
-#if GTK_CHECK_VERSION (2,18,0)
- GtkAllocation allocation;
-#endif
gint num_padded_rows = priv->n_padded_rows;
gint from_row, to_row;
+ GtkStyle *style;
+ GtkAllocation *allocation;
+#if GTK_CHECK_VERSION (2, 18, 0)
+ GtkAllocation widget_allocation;
-#if GTK_CHECK_VERSION (2,18,0)
- gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_get_allocation (widget, &widget_allocation);
+ allocation = &widget_allocation;
+#else
+ allocation = &widget->allocation;
#endif
+ style = gtk_widget_get_style (widget);
+
if (ABS (row_offset) < priv->rows - num_padded_rows)
{
gint num_rows, height;
@@ -1151,15 +1139,11 @@ copy_rows (GucharmapChartable *chartable, gint row_offset)
gdk_draw_drawable (
priv->pixmap,
- (gtk_widget_get_style (widget))->base_gc[GTK_STATE_NORMAL],
+ style->base_gc[GTK_STATE_NORMAL],
priv->pixmap,
0, _gucharmap_chartable_y_offset (chartable, from_row),
0, _gucharmap_chartable_y_offset (chartable, to_row),
-#if GTK_CHECK_VERSION (2,18,0)
- allocation.width, height);
-#else
- widget->allocation.width, height);
-#endif
+ allocation->width, height);
}
if (ABS (row_offset) < num_padded_rows)
@@ -1179,17 +1163,12 @@ copy_rows (GucharmapChartable *chartable, gint row_offset)
/* it's ok to go off the end (so use allocation.height) */
gdk_draw_drawable (
priv->pixmap,
- (gtk_widget_get_style (widget))->base_gc[GTK_STATE_NORMAL],
+ style->base_gc[GTK_STATE_NORMAL],
priv->pixmap,
0, _gucharmap_chartable_y_offset (chartable, from_row),
0, _gucharmap_chartable_y_offset (chartable, to_row),
-#if GTK_CHECK_VERSION (2,18,0)
- allocation.width,
- allocation.height);
-#else
- widget->allocation.width,
- widget->allocation.height);
-#endif
+ allocation->width,
+ allocation->height);
}
}
@@ -1304,16 +1283,31 @@ update_scrollbar_adjustment (GucharmapChartable *chartable)
{
GucharmapChartablePrivate *priv = chartable->priv;
GtkAdjustment *vadjustment = priv->vadjustment;
+#if 0
+ GObject *vadjustment_object = G_OBJECT (vadjustment);
+#endif
if (!vadjustment)
return;
+ vadjustment->value = 1.0 * priv->page_first_cell / priv->cols;
+ vadjustment->lower = 0.0;
+ vadjustment->upper = 1.0 * ( priv->last_cell / priv->cols + 1 );
+ vadjustment->step_increment = 3.0;
+ vadjustment->page_increment = 1.0 * priv->rows;
+ vadjustment->page_size = priv->rows; /* FIXMEchpe + 1 maybe? so scroll-wheel up/down scroll exactly half a page? */
+
+#if 0
+ g_object_freeze_notify (vadjustment_object);
gtk_adjustment_set_value (vadjustment, 1.0 * priv->page_first_cell / priv->cols);
gtk_adjustment_set_lower (vadjustment, 0.0);
gtk_adjustment_set_upper (vadjustment, 1.0 * ( priv->last_cell / priv->cols + 1 ));
gtk_adjustment_set_step_increment (vadjustment, 3.0);
gtk_adjustment_set_page_increment (vadjustment, 1.0 * priv->rows);
+ /* FIXMEchpe: shouldn't set page size at all! */
gtk_adjustment_set_page_size (vadjustment, priv->rows); /* FIXMEchpe + 1 maybe? so scroll-wheel up/down scroll exactly half a page? */
+ g_object_thaw_notify (vadjustment_object);
+#endif
gtk_adjustment_changed (vadjustment);
}
@@ -1457,7 +1451,8 @@ gucharmap_chartable_drag_data_received (GtkWidget *widget,
gchar *text;
gunichar wc;
- if (gtk_selection_data_get_length (selection_data) <= 0 || gtk_selection_data_get_data (selection_data) == NULL)
+ if (gtk_selection_data_get_length (selection_data) <= 0 ||
+ gtk_selection_data_get_data (selection_data) == NULL)
return;
text = (gchar *) gtk_selection_data_get_text (selection_data);
@@ -1492,6 +1487,8 @@ gucharmap_chartable_expose_event (GtkWidget *widget,
GdkRectangle *rects;
int i, n_rects;
GdkGC *gc;
+ GtkStyle *style;
+ GdkWindow *window;
/* Don't draw anything if we haven't set a codepoint list yet */
if (priv->codepoint_list == NULL)
@@ -1520,9 +1517,12 @@ gucharmap_chartable_expose_event (GtkWidget *widget,
}
#endif
- gc = (gtk_widget_get_style (widget))->fg_gc[GTK_STATE_NORMAL];
+ style = gtk_widget_get_style (widget);
+ window = gtk_widget_get_window (widget);
+
+ gc = style->fg_gc[GTK_STATE_NORMAL];
for (i = 0; i < n_rects; ++i) {
- gdk_draw_drawable (gtk_widget_get_window (widget),
+ gdk_draw_drawable (window,
gc,
priv->pixmap,
rects[i].x, rects[i].y,
@@ -1678,17 +1678,24 @@ gucharmap_chartable_size_allocate (GtkWidget *widget,
{
GucharmapChartable *chartable = GUCHARMAP_CHARTABLE (widget);
GucharmapChartablePrivate *priv = chartable->priv;
-#if GTK_CHECK_VERSION (2,18,0)
- GtkAllocation widget_allocation;
-#endif
int old_rows, old_cols;
int total_extra_pixels;
int new_first_cell;
int bare_minimal_column_width, bare_minimal_row_height;
int font_size_px;
+#if GTK_CHECK_VERSION (2, 18, 0)
+ GtkAllocation widget_allocation;
+#endif
GTK_WIDGET_CLASS (gucharmap_chartable_parent_class)->size_allocate (widget, allocation);
+#if GTK_CHECK_VERSION (2, 18, 0)
+ gtk_widget_get_allocation (widget, &widget_allocation);
+ allocation = &widget_allocation;
+#else
+ allocation = &widget->allocation;
+#endif
+
old_rows = priv->rows;
old_cols = priv->cols;
@@ -1713,27 +1720,13 @@ gucharmap_chartable_size_allocate (GtkWidget *widget,
priv->page_size = priv->rows * priv->cols;
-#if GTK_CHECK_VERSION (2,18,0)
- gtk_widget_get_allocation (widget, &widget_allocation);
-#endif
-
-#if GTK_CHECK_VERSION (2,18,0)
- total_extra_pixels = widget_allocation.width - (priv->cols * bare_minimal_column_width + 1);
+ total_extra_pixels = allocation->width - (priv->cols * bare_minimal_column_width + 1);
priv->minimal_column_width = bare_minimal_column_width + total_extra_pixels / priv->cols;
- priv->n_padded_columns = widget_allocation.width - (priv->minimal_column_width * priv->cols + 1);
+ priv->n_padded_columns = allocation->width - (priv->minimal_column_width * priv->cols + 1);
- total_extra_pixels = widget_allocation.height - (priv->rows * bare_minimal_row_height + 1);
+ total_extra_pixels = allocation->height - (priv->rows * bare_minimal_row_height + 1);
priv->minimal_row_height = bare_minimal_row_height + total_extra_pixels / priv->rows;
- priv->n_padded_rows = widget_allocation.height - (priv->minimal_row_height * priv->rows + 1);
-#else
- total_extra_pixels = widget->allocation.width - (priv->cols * bare_minimal_column_width + 1);
- priv->minimal_column_width = bare_minimal_column_width + total_extra_pixels / priv->cols;
- priv->n_padded_columns = widget->allocation.width - (priv->minimal_column_width * priv->cols + 1);
-
- total_extra_pixels = widget->allocation.height - (priv->rows * bare_minimal_row_height + 1);
- priv->minimal_row_height = bare_minimal_row_height + total_extra_pixels / priv->rows;
- priv->n_padded_rows = widget->allocation.height - (priv->minimal_row_height * priv->rows + 1);
-#endif
+ priv->n_padded_rows = allocation->height - (priv->minimal_row_height * priv->rows + 1);
/* force pixmap to be redrawn on next expose event */
if (priv->pixmap != NULL)
@@ -1789,9 +1782,11 @@ gucharmap_chartable_style_set (GtkWidget *widget,
priv->pango_layout = NULL;
if (priv->font_desc == NULL) {
+ GtkStyle *style;
PangoFontDescription *font_desc;
- font_desc = pango_font_description_copy ((gtk_widget_get_style (widget))->font_desc);
+ style = gtk_widget_get_style (widget);
+ font_desc = pango_font_description_copy (style->font_desc);
/* Use twice the size of the style's font */
if (pango_font_description_get_size_is_absolute (font_desc))
@@ -2065,7 +2060,7 @@ gucharmap_chartable_paste_clipboard (GucharmapChartable *chartable)
GtkClipboard *clipboard;
gpointer *data;
-#if GTK_CHECK_VERSION (2,20,0)
+#if GTK_CHECK_VERSION (2, 20, 0)
if (!gtk_widget_get_realized (GTK_WIDGET (chartable)))
#else
if (!GTK_WIDGET_REALIZED (chartable))
@@ -2118,7 +2113,7 @@ gucharmap_chartable_init (GucharmapChartable *chartable)
gtk_drag_dest_add_text_targets (widget);
/* this is required to get key_press events */
-#if GTK_CHECK_VERSION (2,18,0)
+#if GTK_CHECK_VERSION (2, 18, 0)
gtk_widget_set_can_focus (widget, TRUE);
#else
GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
diff --git a/gucharmap/gucharmap-mini-fontsel.c b/gucharmap/gucharmap-mini-fontsel.c
index c2dfc56..5a22e92 100644
--- a/gucharmap/gucharmap-mini-fontsel.c
+++ b/gucharmap/gucharmap-mini-fontsel.c
@@ -267,10 +267,12 @@ static void
gucharmap_mini_font_selection_init (GucharmapMiniFontSelection *fontsel)
{
GtkCellRenderer *renderer;
+ GtkStyle *style;
AtkObject *accessib;
gtk_widget_ensure_style (GTK_WIDGET (fontsel));
- fontsel->font_desc = pango_font_description_copy ((gtk_widget_get_style (GTK_WIDGET (fontsel)))->font_desc);
+ style = gtk_widget_get_style (GTK_WIDGET (fontsel));
+ fontsel->font_desc = pango_font_description_copy (style->font_desc);
fontsel->default_size = -1;
fontsel->size_adj = gtk_adjustment_new (MIN_FONT_SIZE,
@@ -415,8 +417,12 @@ gucharmap_mini_font_selection_change_font_size (GucharmapMiniFontSelection *font
void
gucharmap_mini_font_selection_reset_font_size (GucharmapMiniFontSelection *fontsel)
{
- if (fontsel->default_size > 0)
+ if (fontsel->default_size > 0) {
set_font_size (fontsel, fontsel->default_size);
- else
- set_font_size (fontsel, pango_font_description_get_size ((gtk_widget_get_style (GTK_WIDGET (fontsel)))->font_desc) * 2.0f / PANGO_SCALE);
+ } else {
+ GtkStyle *style;
+
+ style = gtk_widget_get_style (GTK_WIDGET (fontsel));
+ set_font_size (fontsel, pango_font_description_get_size (style->font_desc) * 2.0f / PANGO_SCALE);
+ }
}
diff --git a/gucharmap/gucharmap-search-dialog.c b/gucharmap/gucharmap-search-dialog.c
index e37f743..c0701bb 100644
--- a/gucharmap/gucharmap-search-dialog.c
+++ b/gucharmap/gucharmap-search-dialog.c
@@ -727,14 +727,16 @@ static void
gucharmap_search_dialog_init (GucharmapSearchDialog *search_dialog)
{
GucharmapSearchDialogPrivate *priv = GUCHARMAP_SEARCH_DIALOG_GET_PRIVATE (search_dialog);
- GtkWidget *hbox, *label;
+ GtkWidget *hbox, *label, *content_area;
+
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (search_dialog));
/* follow hig guidelines */
gtk_window_set_title (GTK_WINDOW (search_dialog), _("Find"));
gtk_container_set_border_width (GTK_CONTAINER (search_dialog), 6);
gtk_dialog_set_has_separator (GTK_DIALOG (search_dialog), FALSE);
gtk_window_set_destroy_with_parent (GTK_WINDOW (search_dialog), TRUE);
- gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (search_dialog))), 12);
+ gtk_box_set_spacing (GTK_BOX (content_area), 12);
gtk_window_set_resizable (GTK_WINDOW (search_dialog), FALSE);
g_signal_connect (search_dialog, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);
@@ -772,7 +774,7 @@ gucharmap_search_dialog_init (GucharmapSearchDialog *search_dialog)
hbox = gtk_hbox_new (FALSE, 12);
gtk_widget_show (hbox);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (search_dialog))), hbox, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (content_area), hbox, FALSE, FALSE, 0);
label = gtk_label_new_with_mnemonic (_("_Search:"));
gtk_widget_show (label);
@@ -786,12 +788,12 @@ gucharmap_search_dialog_init (GucharmapSearchDialog *search_dialog)
priv->whole_word_option = gtk_check_button_new_with_mnemonic (_("Match _whole word"));
gtk_widget_show (priv->whole_word_option);
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (search_dialog))), priv->whole_word_option, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (content_area), priv->whole_word_option, FALSE, FALSE, 0);
g_signal_connect (priv->whole_word_option, "toggled", G_CALLBACK (entry_changed), search_dialog);
priv->annotations_option = gtk_check_button_new_with_mnemonic (_("Search in character _details"));
gtk_widget_show (priv->annotations_option);
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (search_dialog))), priv->annotations_option, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (content_area), priv->annotations_option, FALSE, FALSE, 0);
g_signal_connect (priv->annotations_option, "toggled", G_CALLBACK (entry_changed), search_dialog);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), priv->entry);
diff --git a/gucharmap/gucharmap-window.c b/gucharmap/gucharmap-window.c
index 4a80f4e..74ad1aa 100644
--- a/gucharmap/gucharmap-window.c
+++ b/gucharmap/gucharmap-window.c
@@ -757,18 +757,19 @@ static void
status_realize (GtkWidget *status,
GucharmapWindow *guw)
{
-#if GTK_CHECK_VERSION (2,18,0)
- GtkAllocation allocation;
+ GtkAllocation *allocation;
+#if GTK_CHECK_VERSION (2, 18, 0)
+ GtkAllocation widget_allocation;
- gtk_widget_get_allocation (guw->status, &allocation);
+ gtk_widget_get_allocation (guw->status, &widget_allocation);
+ allocation = &widget_allocation;
+#else
+ allocation = &guw->status->allocation;
#endif
+
/* FIXMEchpe ewww... */
/* increase the height a bit so it doesn't resize itself */
-#if GTK_CHECK_VERSION (2,18,0)
- gtk_widget_set_size_request (guw->status, -1, allocation.height + 9);
-#else
- gtk_widget_set_size_request (guw->status, -1, guw->status->allocation.height + 9);
-#endif
+ gtk_widget_set_size_request (guw->status, -1, allocation->height + 9);
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]