[glabels] Use accessor functions instead direct access
- From: Jim Evins <jimevins src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glabels] Use accessor functions instead direct access
- Date: Sun, 22 Nov 2009 23:55:18 +0000 (UTC)
commit b87405cab3c8fba70b5261280b5ed1e3de0871bd
Author: Jim Evins <evins snaught com>
Date: Sun Nov 22 18:50:38 2009 -0500
Use accessor functions instead direct access
Replaced direct access of widget fields with accessor functions. This round
catches flags and allocations which now have accessor functions in Gtk 2.18.
As a result, the master branch now requires Gtk-2.18/GNOME-2.28.
configure.in | 8 +-
docs/libglabels/libglabels-decl-list.txt | 172 ------------------------------
src/color-combo-button.c | 10 +-
src/color-combo.c | 10 +-
src/color-swatch.c | 24 +++--
src/field-button.c | 10 +-
src/font-combo.c | 10 +-
src/font-sample.c | 19 ++--
src/glabels-batch.c | 3 -
src/merge-text.c | 6 +-
src/mini-label-preview.c | 18 ++--
src/mini-preview.c | 21 +++--
src/object-editor-edit-page.c | 5 +-
src/view.c | 20 ++--
src/wdgt-chain-button.c | 14 ++-
15 files changed, 94 insertions(+), 256 deletions(-)
---
diff --git a/configure.in b/configure.in
index 8631513..663d849 100644
--- a/configure.in
+++ b/configure.in
@@ -58,13 +58,13 @@ dnl ---------------------------------------------------------------------------
dnl - Library dependencies
dnl ---------------------------------------------------------------------------
dnl Required dependencies
-GLIB_REQUIRED=2.20.0
-GTK_REQUIRED=2.16.0
-GCONF_REQUIRED=2.26.0
+GLIB_REQUIRED=2.22.0
+GTK_REQUIRED=2.18.0
+GCONF_REQUIRED=2.28.0
LIBXML_REQUIRED=2.7.0
dnl Optional dependencies
-LIBEBOOK_REQUIRED=2.26.0
+LIBEBOOK_REQUIRED=2.28.0
LIBBARCODE_REQUIRED=0.98
LIBQRENCODE_REQUIRED=3.1.0
LIBIEC16022_REQUIRED=0.2.4
diff --git a/src/color-combo-button.c b/src/color-combo-button.c
index 3593275..80ec08f 100644
--- a/src/color-combo-button.c
+++ b/src/color-combo-button.c
@@ -306,7 +306,7 @@ menu_position_function (GtkMenu *menu,
gint w_screen, h_screen;
GdkWindow *window;
gint x_window, y_window;
- GtkAllocation *allocation;
+ GtkAllocation allocation;
gint x_this, y_this, h_this;
GtkRequisition menu_requisition;
gint h_menu, w_menu;
@@ -327,10 +327,10 @@ menu_position_function (GtkMenu *menu,
/*
* Position and size of "this" inside window
*/
- allocation = >K_WIDGET (this)->allocation;
- x_this = allocation->x;
- y_this = allocation->y;
- h_this = allocation->height;
+ gtk_widget_get_allocation (GTK_WIDGET (this), &allocation);
+ x_this = allocation.x;
+ y_this = allocation.y;
+ h_this = allocation.height;
/*
* Size of menu.
diff --git a/src/color-combo.c b/src/color-combo.c
index 0334efd..c833f19 100644
--- a/src/color-combo.c
+++ b/src/color-combo.c
@@ -248,7 +248,7 @@ menu_position_function (GtkMenu *menu,
gint w_screen, h_screen;
GdkWindow *window;
gint x_window, y_window;
- GtkAllocation *allocation;
+ GtkAllocation allocation;
gint x_this, y_this, h_this;
GtkRequisition menu_requisition;
gint h_menu, w_menu;
@@ -269,10 +269,10 @@ menu_position_function (GtkMenu *menu,
/*
* Position and size of "this" inside window
*/
- allocation = >K_WIDGET (this)->allocation;
- x_this = allocation->x;
- y_this = allocation->y;
- h_this = allocation->height;
+ gtk_widget_get_allocation (GTK_WIDGET (this), &allocation);
+ x_this = allocation.x;
+ y_this = allocation.y;
+ h_this = allocation.height;
/*
* Size of menu.
diff --git a/src/color-swatch.c b/src/color-swatch.c
index d850e52..f43108f 100644
--- a/src/color-swatch.c
+++ b/src/color-swatch.c
@@ -96,7 +96,7 @@ gl_color_swatch_class_init (glColorSwatchClass *class)
static void
gl_color_swatch_init (glColorSwatch *this)
{
- GTK_WIDGET_SET_FLAGS (GTK_WIDGET (this), GTK_NO_WINDOW);
+ gtk_widget_set_has_window (GTK_WIDGET (this), FALSE);
this->priv = g_new0 (glColorSwatchPrivate, 1);
}
@@ -191,8 +191,9 @@ static gboolean
expose_event_cb (GtkWidget *widget,
GdkEventExpose *event)
{
- GdkWindow *window;
- cairo_t *cr;
+ GdkWindow *window;
+ cairo_t *cr;
+ GtkAllocation allocation;
window = gtk_widget_get_window (widget);
@@ -203,7 +204,8 @@ expose_event_cb (GtkWidget *widget,
event->area.width, event->area.height);
cairo_clip (cr);
- cairo_translate (cr, widget->allocation.x, widget->allocation.y);
+ gtk_widget_get_allocation (widget, &allocation);
+ cairo_translate (cr, allocation.x, allocation.y);
draw_swatch (GL_COLOR_SWATCH (widget), cr);
@@ -220,20 +222,22 @@ static void
draw_swatch (glColorSwatch *this,
cairo_t *cr)
{
- GtkStyle *style;
- gdouble w, h;
- guint fill_color, line_color;
+ GtkAllocation allocation;
+ GtkStyle *style;
+ gdouble w, h;
+ guint fill_color, line_color;
cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
- w = GTK_WIDGET (this)->allocation.width;
- h = GTK_WIDGET (this)->allocation.height;
+ gtk_widget_get_allocation (GTK_WIDGET (this), &allocation);
+ w = allocation.width;
+ h = allocation.height;
style = gtk_widget_get_style (GTK_WIDGET (this));
- if ( GTK_WIDGET_IS_SENSITIVE (GTK_WIDGET (this)) )
+ if ( gtk_widget_is_sensitive (GTK_WIDGET (this)) )
{
fill_color = this->priv->color;
line_color = gl_color_from_gdk_color (&style->fg[GTK_STATE_NORMAL]);
diff --git a/src/field-button.c b/src/field-button.c
index 4000d41..a0061a8 100644
--- a/src/field-button.c
+++ b/src/field-button.c
@@ -202,7 +202,7 @@ menu_position_function (GtkMenu *menu,
gint w_screen, h_screen;
GdkWindow *window;
gint x_window, y_window;
- GtkAllocation *allocation;
+ GtkAllocation allocation;
gint x_this, y_this, h_this;
GtkRequisition menu_requisition;
gint h_menu, w_menu;
@@ -223,10 +223,10 @@ menu_position_function (GtkMenu *menu,
/*
* Position and size of "this" inside window
*/
- allocation = >K_WIDGET (this)->allocation;
- x_this = allocation->x;
- y_this = allocation->y;
- h_this = allocation->height;
+ gtk_widget_get_allocation (GTK_WIDGET (this), &allocation);
+ x_this = allocation.x;
+ y_this = allocation.y;
+ h_this = allocation.height;
/*
* Size of menu.
diff --git a/src/font-combo.c b/src/font-combo.c
index 49b0d7e..993089f 100644
--- a/src/font-combo.c
+++ b/src/font-combo.c
@@ -229,7 +229,7 @@ menu_position_function (GtkMenu *menu,
gint w_screen, h_screen;
GdkWindow *window;
gint x_window, y_window;
- GtkAllocation *allocation;
+ GtkAllocation allocation;
gint x_this, y_this, h_this;
GtkRequisition menu_requisition;
gint h_menu, w_menu;
@@ -250,10 +250,10 @@ menu_position_function (GtkMenu *menu,
/*
* Position and size of "this" inside window
*/
- allocation = >K_WIDGET (this)->allocation;
- x_this = allocation->x;
- y_this = allocation->y;
- h_this = allocation->height;
+ gtk_widget_get_allocation (GTK_WIDGET (this), &allocation);
+ x_this = allocation.x;
+ y_this = allocation.y;
+ h_this = allocation.height;
/*
* Size of menu.
diff --git a/src/font-sample.c b/src/font-sample.c
index ff04ac8..4302064 100644
--- a/src/font-sample.c
+++ b/src/font-sample.c
@@ -99,7 +99,7 @@ gl_font_sample_class_init (glFontSampleClass *class)
static void
gl_font_sample_init (glFontSample *this)
{
- GTK_WIDGET_SET_FLAGS (GTK_WIDGET (this), GTK_NO_WINDOW);
+ gtk_widget_set_has_window (GTK_WIDGET (this), FALSE);
this->priv = g_new0 (glFontSamplePrivate, 1);
}
@@ -185,8 +185,9 @@ static gboolean
expose_event_cb (GtkWidget *widget,
GdkEventExpose *event)
{
- GdkWindow *window;
- cairo_t *cr;
+ GdkWindow *window;
+ cairo_t *cr;
+ GtkAllocation allocation;
window = gtk_widget_get_window (widget);
@@ -197,7 +198,8 @@ expose_event_cb (GtkWidget *widget,
event->area.width, event->area.height);
cairo_clip (cr);
- cairo_translate (cr, widget->allocation.x, widget->allocation.y);
+ gtk_widget_get_allocation (widget, &allocation);
+ cairo_translate (cr, allocation.x, allocation.y);
draw_sample (GL_FONT_SAMPLE (widget), cr);
@@ -214,6 +216,7 @@ static void
draw_sample (glFontSample *this,
cairo_t *cr)
{
+ GtkAllocation allocation;
GtkStyle *style;
gdouble w, h;
guint fill_color, line_color;
@@ -223,13 +226,13 @@ draw_sample (glFontSample *this,
gdouble layout_x, layout_y, layout_width, layout_height;
-
- w = GTK_WIDGET (this)->allocation.width;
- h = GTK_WIDGET (this)->allocation.height;
+ gtk_widget_get_allocation (GTK_WIDGET (this), &allocation);
+ w = allocation.width;
+ h = allocation.height;
style = gtk_widget_get_style (GTK_WIDGET (this));
- if ( GTK_WIDGET_IS_SENSITIVE (GTK_WIDGET (this)) )
+ if ( gtk_widget_is_sensitive (GTK_WIDGET (this)) )
{
fill_color = gl_color_from_gdk_color (&style->light[GTK_STATE_NORMAL]);
line_color = gl_color_from_gdk_color (&style->fg[GTK_STATE_NORMAL]);
diff --git a/src/glabels-batch.c b/src/glabels-batch.c
index b05673b..ac57432 100644
--- a/src/glabels-batch.c
+++ b/src/glabels-batch.c
@@ -31,7 +31,6 @@
#include "print-op.h"
#include "file-util.h"
#include "prefs.h"
-#include "font-history.h"
#include "debug.h"
/*============================================*/
@@ -128,8 +127,6 @@ main (int argc, char **argv)
gl_merge_init ();
lgl_db_init ();
gl_prefs_init ();
- gl_template_history_init ();
- gl_font_history_init ();
/* now print the files */
for (p = file_list; p; p = p->next) {
diff --git a/src/merge-text.c b/src/merge-text.c
index b502a87..e23803e 100644
--- a/src/merge-text.c
+++ b/src/merge-text.c
@@ -158,7 +158,6 @@ static void
gl_merge_text_finalize (GObject *object)
{
glMergeText *merge_text = GL_MERGE_TEXT (object);
- gint i;
gl_debug (DEBUG_MERGE, "START");
@@ -284,10 +283,7 @@ static GList *
gl_merge_text_get_key_list (glMerge *merge)
{
glMergeText *merge_text;
- GList *record_list, *p_rec;
- glMergeRecord *record;
- GList *p_field;
- gint i_field, n_fields_line, n_fields;
+ gint i_field, n_fields;
GList *key_list;
gl_debug (DEBUG_MERGE, "BEGIN");
diff --git a/src/mini-label-preview.c b/src/mini-label-preview.c
index e5f2181..ec78aad 100644
--- a/src/mini-label-preview.c
+++ b/src/mini-label-preview.c
@@ -100,7 +100,7 @@ gl_mini_label_preview_class_init (glMiniLabelPreviewClass *class)
static void
gl_mini_label_preview_init (glMiniLabelPreview *this)
{
- GTK_WIDGET_SET_FLAGS (GTK_WIDGET (this), GTK_NO_WINDOW);
+ gtk_widget_set_has_window (GTK_WIDGET (this), FALSE);
this->priv = g_new0 (glMiniLabelPreviewPrivate, 1);
}
@@ -203,8 +203,9 @@ static gboolean
expose_event_cb (GtkWidget *widget,
GdkEventExpose *event)
{
- GdkWindow *window;
- cairo_t *cr;
+ GdkWindow *window;
+ cairo_t *cr;
+ GtkAllocation allocation;
window = gtk_widget_get_window (widget);
@@ -215,7 +216,8 @@ expose_event_cb (GtkWidget *widget,
event->area.width, event->area.height);
cairo_clip (cr);
- cairo_translate (cr, widget->allocation.x, widget->allocation.y);
+ gtk_widget_get_allocation (widget, &allocation);
+ cairo_translate (cr, allocation.x, allocation.y);
draw_preview (GL_MINI_LABEL_PREVIEW (widget), cr);
@@ -232,6 +234,7 @@ static void
draw_preview (glMiniLabelPreview *this,
cairo_t *cr)
{
+ GtkAllocation allocation;
GtkStyle *style;
gdouble w, h;
guint fill_color, line_color, shadow_color;
@@ -240,12 +243,13 @@ draw_preview (glMiniLabelPreview *this,
gdouble scale;
- w = GTK_WIDGET (this)->allocation.width;
- h = GTK_WIDGET (this)->allocation.height;
+ gtk_widget_get_allocation (GTK_WIDGET (this), &allocation);
+ w = allocation.width;
+ h = allocation.height;
style = gtk_widget_get_style (GTK_WIDGET (this));
- if ( GTK_WIDGET_IS_SENSITIVE (GTK_WIDGET (this)) )
+ if ( gtk_widget_is_sensitive (GTK_WIDGET (this)) )
{
fill_color = gl_color_from_gdk_color (&style->light[GTK_STATE_NORMAL]);
line_color = gl_color_from_gdk_color (&style->fg[GTK_STATE_NORMAL]);
diff --git a/src/mini-preview.c b/src/mini-preview.c
index 2d5882a..6ba6dde 100644
--- a/src/mini-preview.c
+++ b/src/mini-preview.c
@@ -224,7 +224,7 @@ gl_mini_preview_init (glMiniPreview *this)
gtk_event_box_set_visible_window (GTK_EVENT_BOX (this), FALSE);
this->priv->canvas = gtk_drawing_area_new ();
- GTK_WIDGET_SET_FLAGS (this->priv->canvas, GTK_NO_WINDOW);
+ gtk_widget_set_has_window(this->priv->canvas, FALSE);
gtk_container_add (GTK_CONTAINER (this), this->priv->canvas);
g_signal_connect (G_OBJECT (this->priv->canvas), "expose-event",
@@ -555,14 +555,16 @@ static gdouble
set_transform_and_get_scale (glMiniPreview *this,
cairo_t *cr)
{
- lglTemplate *template = this->priv->template;
- gdouble w, h;
- gdouble scale;
- gdouble offset_x, offset_y;
+ lglTemplate *template = this->priv->template;
+ GtkAllocation allocation;
+ gdouble w, h;
+ gdouble scale;
+ gdouble offset_x, offset_y;
/* Establish scale and origin. */
- w = GTK_WIDGET (this)->allocation.width;
- h = GTK_WIDGET (this)->allocation.height;
+ gtk_widget_get_allocation (GTK_WIDGET (this), &allocation);
+ w = allocation.width;
+ h = allocation.height;
/* establish scale. */
scale = MIN( (w - 2*MARGIN - 2*SHADOW_OFFSET)/template->page_width,
@@ -752,6 +754,7 @@ expose_event_cb (GtkWidget *widget,
{
GdkWindow *window;
cairo_t *cr;
+ GtkAllocation allocation;
gl_debug (DEBUG_MINI_PREVIEW, "START");
@@ -765,7 +768,9 @@ expose_event_cb (GtkWidget *widget,
event->area.x, event->area.y,
event->area.width, event->area.height);
cairo_clip (cr);
- cairo_translate (cr, widget->allocation.x, widget->allocation.y);
+
+ gtk_widget_get_allocation (widget, &allocation);
+ cairo_translate (cr, allocation.x, allocation.y);
draw (this, cr);
diff --git a/src/object-editor-edit-page.c b/src/object-editor-edit-page.c
index c85ff5b..704b8ef 100644
--- a/src/object-editor-edit-page.c
+++ b/src/object-editor-edit-page.c
@@ -76,8 +76,9 @@ gl_object_editor_prepare_edit_page (glObjectEditor *editor)
editor->priv->edit_insert_field_button = gl_field_button_new (_("Insert merge field"));
gtk_box_pack_start (GTK_BOX (editor->priv->edit_insert_field_vbox),
editor->priv->edit_insert_field_button, FALSE, FALSE, 0);
- GTK_WIDGET_UNSET_FLAGS (editor->priv->edit_insert_field_button,
- GTK_CAN_FOCUS | GTK_CAN_DEFAULT);
+
+ gtk_widget_set_can_focus (editor->priv->edit_insert_field_button, FALSE);
+ gtk_widget_set_can_default (editor->priv->edit_insert_field_button, FALSE);
/* Un-hide */
gtk_widget_show_all (editor->priv->edit_page_vbox);
diff --git a/src/view.c b/src/view.c
index ca91734..c814cd1 100644
--- a/src/view.c
+++ b/src/view.c
@@ -328,7 +328,7 @@ gl_view_init (glView *view)
gtk_widget_modify_bg (GTK_WIDGET (view->canvas), GTK_STATE_NORMAL, bg_color);
g_free (bg_color);
- GTK_WIDGET_SET_FLAGS (GTK_WIDGET (view->canvas), GTK_CAN_FOCUS);
+ gtk_widget_set_can_focus (GTK_WIDGET (view->canvas), TRUE);
gtk_widget_add_events (GTK_WIDGET (view->canvas),
(GDK_FOCUS_CHANGE_MASK |
@@ -2675,19 +2675,21 @@ gl_view_zoom_out (glView *view)
void
gl_view_zoom_to_fit (glView *view)
{
- gint w_view, h_view;
- gdouble w_label, h_label;
- gdouble x_scale, y_scale, scale;
+ GtkAllocation allocation;
+ gint w_view, h_view;
+ gdouble w_label, h_label;
+ gdouble x_scale, y_scale, scale;
gl_debug (DEBUG_VIEW, "");
- if ( ! GTK_WIDGET_VISIBLE(view)) {
+ if ( ! gtk_widget_get_window (GTK_WIDGET (view)) ) {
set_zoom_real (view, 1.0, TRUE);
return;
}
- w_view = GTK_WIDGET(view)->allocation.width;
- h_view = GTK_WIDGET(view)->allocation.height;
+ gtk_widget_get_allocation (GTK_WIDGET (view), &allocation);
+ w_view = allocation.width;
+ h_view = allocation.height;
gl_label_get_size (GL_LABEL(view->label), &w_label, &h_label);
@@ -3237,8 +3239,6 @@ static gboolean
focus_in_event_cb (glView *view,
GdkEventFocus *event)
{
- GTK_WIDGET_SET_FLAGS (GTK_WIDGET (view->canvas), GTK_HAS_FOCUS);
-
return FALSE;
}
@@ -3250,8 +3250,6 @@ static gboolean
focus_out_event_cb (glView *view,
GdkEventFocus *event)
{
- GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET (view->canvas), GTK_HAS_FOCUS);
-
return FALSE;
}
diff --git a/src/wdgt-chain-button.c b/src/wdgt-chain-button.c
index be6ab62..5963fea 100644
--- a/src/wdgt-chain-button.c
+++ b/src/wdgt-chain-button.c
@@ -229,6 +229,7 @@ gl_wdgt_chain_button_draw_lines (GtkWidget *widget,
GdkEventExpose *eevent,
glWdgtChainButton *button)
{
+ GtkAllocation allocation;
GdkPoint points[3];
GdkPoint buf;
GtkShadowType shadow;
@@ -241,8 +242,9 @@ gl_wdgt_chain_button_draw_lines (GtkWidget *widget,
g_return_val_if_fail (GL_WDGT_IS_CHAIN_BUTTON (button), FALSE);
- points[0].x = widget->allocation.width / 2;
- points[0].y = widget->allocation.height / 2;
+ gtk_widget_get_allocation (widget, &allocation);
+ points[0].x = allocation.width / 2;
+ points[0].y = allocation.height / 2;
which_line = (widget == button->line1) ? 1 : -1;
@@ -268,7 +270,7 @@ gl_wdgt_chain_button_draw_lines (GtkWidget *widget,
points[1].x = points[0].x - SHORT_LINE;
points[1].y = points[0].y;
points[2].x = points[1].x;
- points[2].y = (which_line == 1) ? widget->allocation.height - 1 : 0;
+ points[2].y = (which_line == 1) ? allocation.height - 1 : 0;
shadow = GTK_SHADOW_ETCHED_IN;
break;
case GL_WDGT_CHAIN_RIGHT:
@@ -276,14 +278,14 @@ gl_wdgt_chain_button_draw_lines (GtkWidget *widget,
points[1].x = points[0].x + SHORT_LINE;
points[1].y = points[0].y;
points[2].x = points[1].x;
- points[2].y = (which_line == 1) ? widget->allocation.height - 1 : 0;
+ points[2].y = (which_line == 1) ? allocation.height - 1 : 0;
shadow = GTK_SHADOW_ETCHED_OUT;
break;
case GL_WDGT_CHAIN_TOP:
points[0].y += SHORT_LINE;
points[1].x = points[0].x;
points[1].y = points[0].y - SHORT_LINE;
- points[2].x = (which_line == 1) ? widget->allocation.width - 1 : 0;
+ points[2].x = (which_line == 1) ? allocation.width - 1 : 0;
points[2].y = points[1].y;
shadow = GTK_SHADOW_ETCHED_OUT;
break;
@@ -291,7 +293,7 @@ gl_wdgt_chain_button_draw_lines (GtkWidget *widget,
points[0].y -= SHORT_LINE;
points[1].x = points[0].x;
points[1].y = points[0].y + SHORT_LINE;
- points[2].x = (which_line == 1) ? widget->allocation.width - 1 : 0;
+ points[2].x = (which_line == 1) ? allocation.width - 1 : 0;
points[2].y = points[1].y;
shadow = GTK_SHADOW_ETCHED_IN;
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]