Skip to content

Commit

Permalink
Gtk code cleanups: Use accessor functions on GtkWidget instead of dep…
Browse files Browse the repository at this point in the history
…recated direct access
  • Loading branch information
gjanssens committed Sep 22, 2015
1 parent ce3e36a commit 5ffe52a
Show file tree
Hide file tree
Showing 29 changed files with 165 additions and 138 deletions.
4 changes: 2 additions & 2 deletions src/business/business-gnome/dialog-billterms.c
Expand Up @@ -107,8 +107,8 @@ read_widget (GtkBuilder *builder, char *name, gboolean read_only)
GtkAdjustment *adj;
gtk_editable_set_editable (GTK_EDITABLE (widget), FALSE);
adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
adj->step_increment = 0.0;
adj->page_increment = 0.0;
gtk_adjustment_set_step_increment (adj, 0.0);
gtk_adjustment_set_page_increment (adj, 0.0);
gtk_adjustment_changed (adj);
}

Expand Down
2 changes: 1 addition & 1 deletion src/business/business-gnome/dialog-date-close.c
Expand Up @@ -261,7 +261,7 @@ gnc_dialog_dates_acct_question_parented (GtkWidget *parent, const char *message,

if (question_check_message)
{
gtk_label_set_text(GTK_LABEL(GTK_BIN(ddc->question_check)->child), question_check_message);
gtk_label_set_text(GTK_LABEL(gtk_bin_get_child (GTK_BIN(ddc->question_check))), question_check_message);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ddc->question_check), *answer);
}
else
Expand Down
2 changes: 1 addition & 1 deletion src/gnome-search/dialog-search.c
Expand Up @@ -973,7 +973,7 @@ gnc_search_dialog_add_criterion (GNCSearchWindow *sw)
data = g_object_get_data (G_OBJECT (w), "data");
sw->crit_list = g_list_append (sw->crit_list, data);

rows = GTK_TABLE (sw->criteria_table)->nrows;
gtk_table_get_size (GTK_TABLE (sw->criteria_table), &rows, NULL);
gtk_table_resize (GTK_TABLE (sw->criteria_table), rows + 1, 2);
attach_element (w, sw, rows);

Expand Down
6 changes: 3 additions & 3 deletions src/gnome-search/search-account.c
Expand Up @@ -263,9 +263,9 @@ button_clicked (GtkButton *button, GNCSearchAccount *fi)
NULL));

/* Put the dialog together */
gtk_box_pack_start ((GtkBox *)dialog->vbox, label,
gtk_box_pack_start ((GtkBox *) gtk_dialog_get_content_area (dialog), label,
FALSE, FALSE, 3);
gtk_box_pack_start ((GtkBox *)dialog->vbox, accounts_scroller,
gtk_box_pack_start ((GtkBox *) gtk_dialog_get_content_area (dialog), accounts_scroller,
TRUE, TRUE, 3);

gtk_widget_show_all (GTK_WIDGET (dialog));
Expand All @@ -280,7 +280,7 @@ button_clicked (GtkButton *button, GNCSearchAccount *fi)
gnc_tree_view_account_get_selected_accounts (GNC_TREE_VIEW_ACCOUNT (account_tree));

desc = describe_button (fi);
gtk_label_set_text (GTK_LABEL (GTK_BIN (button)->child), desc);
gtk_label_set_text (GTK_LABEL (gtk_bin_get_child (GTK_BIN (button))), desc);
}

gtk_widget_destroy (GTK_WIDGET (dialog));
Expand Down
2 changes: 1 addition & 1 deletion src/gnome-utils/cursors.c
Expand Up @@ -88,7 +88,7 @@ gnc_set_busy_cursor (GtkWidget *w, gboolean update_now)
{
w = node->data;

if (!w || !GTK_IS_WIDGET (w) || !w->window)
if (!w || !GTK_IS_WIDGET (w) || !gtk_widget_get_has_window(w))
continue;

gnc_ui_set_cursor (gtk_widget_get_window(w), GNC_CURSOR_BUSY, update_now);
Expand Down
10 changes: 5 additions & 5 deletions src/gnome-utils/dialog-account.c
Expand Up @@ -666,7 +666,7 @@ verify_children_compatible (AccountWindow *aw)
gint size;
PangoFontDescription *font_desc;

size = pango_font_description_get_size (label->style->font_desc);
size = pango_font_description_get_size (gtk_widget_get_style (label)->font_desc);
font_desc = pango_font_description_new ();
pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
pango_font_description_set_size (font_desc, size * PANGO_SCALE_LARGE);
Expand Down Expand Up @@ -695,16 +695,16 @@ verify_children_compatible (AccountWindow *aw)

gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);

gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox,
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox,
TRUE, TRUE, 0);

/* spacings */
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 14);
gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 14);
gtk_container_set_border_width (
GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 5);
gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 6);
GTK_CONTAINER (gtk_dialog_get_action_area (GTK_DIALOG (dialog))), 5);
gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_action_area (GTK_DIALOG (dialog))), 6);

gtk_widget_show_all (hbox);

Expand Down
4 changes: 2 additions & 2 deletions src/gnome-utils/dialog-transfer.c
Expand Up @@ -2035,12 +2035,12 @@ gnc_xfer_dialog_create(GtkWidget *parent, XferDialog *xferData)

if (use_accounting_labels)
{
gtk_label_set_text(GTK_LABEL(GTK_BIN(xferData->amount_radio)->child),
gtk_label_set_text(GTK_LABEL(gtk_bin_get_child (GTK_BIN(xferData->amount_radio))),
_("Debit Amount:"));
}
else
{
gtk_label_set_text(GTK_LABEL(GTK_BIN(xferData->amount_radio)->child),
gtk_label_set_text(GTK_LABEL(gtk_bin_get_child (GTK_BIN(xferData->amount_radio))),
_("To Amount:"));
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/gnome-utils/dialog-utils.c
Expand Up @@ -217,7 +217,7 @@ gnc_window_adjust_for_screen(GtkWindow * window)
return;

g_return_if_fail(GTK_IS_WINDOW(window));
if (GTK_WIDGET(window)->window == NULL)
if (gtk_widget_get_window (GTK_WIDGET(window)) == NULL)
return;

screen_width = gdk_screen_width();
Expand All @@ -234,7 +234,7 @@ gnc_window_adjust_for_screen(GtkWindow * window)
height = MIN(height, screen_height - 10);
height = MAX(height, 0);

gdk_window_resize(GTK_WIDGET(window)->window, width, height);
gdk_window_resize(gtk_widget_get_window (GTK_WIDGET(window)), width, height);
gtk_widget_queue_resize(GTK_WIDGET(window));
}

Expand Down Expand Up @@ -552,8 +552,8 @@ gnc_dialog_run (GtkDialog *dialog, const gchar *pref_name)
: _("Don't tell me again this _session."));
gtk_widget_show(perm);
gtk_widget_show(temp);
gtk_box_pack_start(GTK_BOX(dialog->vbox), perm, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(dialog->vbox), temp, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (dialog)), perm, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (dialog)), temp, TRUE, TRUE, 0);
g_signal_connect(perm, "clicked", G_CALLBACK(gnc_perm_button_cb), temp);

/* OK. Present the dialog. */
Expand Down
2 changes: 1 addition & 1 deletion src/gnome-utils/gnc-cell-renderer-popup-entry.c
Expand Up @@ -230,7 +230,7 @@ gpw_key_press_event (GtkWidget *box,
/* Hackish :/ Synthesize a key press event for the entry. */
memcpy (&tmp_event, key_event, sizeof (GdkEventKey));

tmp_event.key.window = widget->entry->window;
tmp_event.key.window = gtk_widget_get_window (widget->entry);
tmp_event.key.send_event = TRUE;

gtk_widget_event (widget->entry, &tmp_event);
Expand Down
25 changes: 14 additions & 11 deletions src/gnome-utils/gnc-cell-renderer-popup.c
Expand Up @@ -255,7 +255,7 @@ gcrp_show_popup (GncCellRendererPopup *cell,
gtk_window_move (GTK_WINDOW (cell->popup_window), -500, -500);
gtk_widget_show (cell->popup_window);

alloc = cell->popup_window->allocation;
gtk_widget_get_allocation (cell->popup_window, &alloc);

x = x2;
y = y2;
Expand Down Expand Up @@ -298,7 +298,7 @@ gcrp_show_popup (GncCellRendererPopup *cell,

gtk_widget_grab_focus (cell->focus_window);

gcrp_grab_on_window (cell->popup_window->window,
gcrp_grab_on_window (gtk_widget_get_window (cell->popup_window),
gtk_get_current_event_time ());
}

Expand Down Expand Up @@ -345,16 +345,16 @@ gcrp_arrow_clicked (GtkCellEditable *entry,
* events generated when the window is mapped, such as enter
* notify events on subwidgets. If the grab fails, bail out.
*/
if (!gcrp_grab_on_window (GTK_WIDGET (entry)->window,
if (!gcrp_grab_on_window (gtk_widget_get_window (GTK_WIDGET (entry)),
gtk_get_current_event_time ())) {
return;
}

gtk_editable_select_region (GTK_EDITABLE (GNC_POPUP_ENTRY (entry)->entry), 0, 0);

gdk_window_get_origin (GTK_WIDGET (entry)->window, &x, &y);
gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (entry)), &x, &y);

alloc = GTK_WIDGET (entry)->allocation;
gtk_widget_get_allocation (GTK_WIDGET (entry), &alloc);

g_signal_emit (cell, signals[SHOW_POPUP], 0,
path,
Expand All @@ -376,17 +376,19 @@ gcrp_start_editing (GtkCellRenderer *cell,
GncCellRendererPopup *popup;
GtkWidget *editable;
gchar *text;
gboolean iseditable;

popup = GNC_CELL_RENDERER_POPUP (cell);

g_object_get (G_OBJECT (popup), "editable", &iseditable, NULL);
/* If the cell isn't editable we return NULL. */
if (GTK_CELL_RENDERER_TEXT (popup)->editable == FALSE) {
if (iseditable == FALSE) {
return NULL;
}

editable = g_object_new (GNC_TYPE_POPUP_ENTRY, NULL);

text = GTK_CELL_RENDERER_TEXT (cell)->text;
g_object_get (G_OBJECT (cell), "text", &text, NULL);
popup->cell_text = text;

gnc_popup_entry_set_text (GNC_POPUP_ENTRY (editable), text ? text : "");
Expand Down Expand Up @@ -506,14 +508,15 @@ gcrp_button_press_event (GtkWidget *widget,
x = event->x_root;
y = event->y_root;

gdk_window_get_root_origin (widget->window,
gdk_window_get_root_origin (gtk_widget_get_window (widget),
&xoffset,
&yoffset);

xoffset += widget->allocation.x;
yoffset += widget->allocation.y;
gtk_widget_get_allocation (widget, &alloc);
xoffset += alloc.x;
yoffset += alloc.y;

alloc = popup->popup_window->allocation;
gtk_widget_get_allocation (popup->popup_window, &alloc);
x1 = alloc.x + xoffset;
y1 = alloc.y + yoffset;
x2 = x1 + alloc.width;
Expand Down
17 changes: 11 additions & 6 deletions src/gnome-utils/gnc-combott.c
Expand Up @@ -469,27 +469,32 @@ gctt_combott_menu_position (GtkMenu *menu,
gint sx, sy;
GtkWidget *child;
GtkRequisition req;
GtkAllocation alloc;

child = GTK_BIN (priv->button)->child;
child = gtk_bin_get_child (GTK_BIN (priv->button));

sx = sy = 0;

if (!gtk_widget_get_has_window (child))
{
sx += child->allocation.x;
sy += child->allocation.y;
gtk_widget_get_allocation (child, &alloc);
sx += alloc.x;
sy += alloc.y;
}

gdk_window_get_root_coords (child->window, sx, sy, &sx, &sy);
gdk_window_get_root_coords (gtk_widget_get_window (child), sx, sy, &sx, &sy);

sx -= GTK_WIDGET (priv->button)->style->xthickness;
sx -= gtk_widget_get_style (GTK_WIDGET (priv->button))->xthickness;

gtk_widget_size_request (GTK_WIDGET (menu), &req);

if (gtk_widget_get_direction (GTK_WIDGET (priv->button)) == GTK_TEXT_DIR_LTR)
*x = sx;
else
*x = sx + child->allocation.width - req.width;
{
gtk_widget_get_allocation (child, &alloc);
*x = sx + alloc.width - req.width;
}

if(priv->active == -1 || priv->active == 0)
*y = sy;
Expand Down
14 changes: 8 additions & 6 deletions src/gnome-utils/gnc-date-edit.c
Expand Up @@ -215,15 +215,17 @@ position_popup (GNCDateEdit *gde)
gint x, y;
gint bwidth, bheight;
GtkRequisition req;
GtkAllocation alloc;

gtk_widget_size_request (gde->cal_popup, &req);

gdk_window_get_origin (gde->date_button->window, &x, &y);
gdk_window_get_origin (gtk_widget_get_window (gde->date_button), &x, &y);

x += gde->date_button->allocation.x;
y += gde->date_button->allocation.y;
bwidth = gde->date_button->allocation.width;
bheight = gde->date_button->allocation.height;
gtk_widget_get_allocation (gde->date_button, &alloc);
x += alloc.x;
y += alloc.y;
bwidth = alloc.width;
bheight = alloc.height;

x += bwidth - req.width;
y += bheight;
Expand Down Expand Up @@ -322,7 +324,7 @@ gnc_date_edit_popup (GNCDateEdit *gde)
if (!gtk_widget_has_focus (gde->calendar))
gtk_widget_grab_focus (gde->calendar);

if (!popup_grab_on_window ((GTK_WIDGET(gde->cal_popup))->window,
if (!popup_grab_on_window (gtk_widget_get_window ((GTK_WIDGET(gde->cal_popup))),
GDK_CURRENT_TIME, TRUE))
{
gtk_widget_hide (gde->cal_popup);
Expand Down

0 comments on commit 5ffe52a

Please sign in to comment.