Commit 4dda3ade authored by Javier Jardón's avatar Javier Jardón
Browse files

Use accessor functions instead direct access. Second patch

GTK+ 2.19.0 is now the required version
I've used all the GTK+ 2.19.1 api available, still missing:
GTK_WIDGET_UNSET_FLAGS (widget, GTK_TOPLEVEL);
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
GTK_WIDGET_REALIZED ()
GTK_WIDGET_MAPPED ()

https://bugzilla.gnome.org/show_bug.cgi?id=594957
parent 2d7e9abe
2009-12-04 Javier Jardón <jjardon@gnome.org>
Use accessor functions instead direct access. Second patch
GTK+ 2.19.0 is now the required version
I've used all the GTK+ 2.19.1 api available, still missing:
GTK_WIDGET_UNSET_FLAGS (widget, GTK_TOPLEVEL);
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
GTK_WIDGET_REALIZED ()
GTK_WIDGET_MAPPED ()
https://bugzilla.gnome.org/show_bug.cgi?id=594957
2009-12-04 Javier Jardón <jjardon@gnome.org>
Use accessor functions instead direct access.
......
......@@ -121,7 +121,7 @@ GTK_DOC_CHECK(1.9)
dnl ================================================================
dnl Check for gtk+
dnl ================================================================
PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.17.10 gthread-2.0 libxml-2.0 >= 2.4.0])
PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.19.0 gthread-2.0 libxml-2.0 >= 2.4.0])
AC_SUBST(GTK_LIBS)
AC_SUBST(GTK_CFLAGS)
......
......@@ -260,7 +260,7 @@ glade_util_ui_message (GtkWidget *parent,
gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);
if (widget)
gtk_box_pack_end (GTK_BOX (GTK_DIALOG (dialog)->vbox),
gtk_box_pack_end (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
widget, TRUE, TRUE, 2);
response = gtk_dialog_run (GTK_DIALOG (dialog));
......@@ -424,7 +424,7 @@ glade_util_gtk_combo_func (gpointer data)
ltext = (gchar *) g_object_get_data (G_OBJECT (listitem),
gtk_combo_string_key);
if (!ltext) {
label = GTK_BIN (listitem)->child;
label = gtk_bin_get_child (GTK_BIN (listitem));
if (!label || !GTK_IS_LABEL (label))
return NULL;
ltext = (gchar*) gtk_label_get_text (GTK_LABEL (label));
......@@ -556,7 +556,7 @@ add_format_options (GtkDialog *dialog,
gtk_widget_show_all (frame);
gtk_box_pack_end (GTK_BOX (dialog->vbox), frame, FALSE, TRUE, 2);
gtk_box_pack_end (GTK_BOX (gtk_dialog_get_content_area (dialog)), frame, FALSE, TRUE, 2);
}
......@@ -712,7 +712,7 @@ glade_util_get_window_positioned_in (GtkWidget *widget)
{
GtkWidget *parent;
parent = widget->parent;
parent = gtk_widget_get_parent (widget);
#ifdef USE_GNOME
/* BonoboDockItem widgets use a different window when floating.
......@@ -730,9 +730,9 @@ glade_util_get_window_positioned_in (GtkWidget *widget)
#endif
if (parent)
return parent->window;
return gtk_widget_get_window (parent);
return widget->window;
return gtk_widget_get_window (widget);
}
static void
......@@ -801,10 +801,10 @@ glade_util_can_draw_nodes (GtkWidget *sel_widget, GdkWindow *sel_win,
GdkWindow *viewport_win = NULL;
/* Check if the selected widget is inside a viewport. */
for (widget = sel_widget->parent; widget; widget = widget->parent) {
for (widget = gtk_widget_get_parent (sel_widget); widget; widget = gtk_widget_get_parent (widget)) {
if (GTK_IS_VIEWPORT (widget)) {
viewport = widget;
viewport_win = GTK_VIEWPORT (widget)->bin_window;
viewport_win = gtk_viewport_get_bin_window (GTK_VIEWPORT (widget));
break;
}
}
......@@ -854,7 +854,7 @@ glade_util_draw_selection_nodes (GdkWindow *expose_win)
/* Find the corresponding GtkWidget */
gdk_window_get_user_data (expose_win, (gpointer)&expose_widget);
gc = expose_widget->style->black_gc;
gc = gtk_widget_get_style (expose_widget)->black_gc;
/* Calculate the offset of the expose window within its toplevel. */
glade_util_calculate_window_offset (expose_win,
......@@ -887,10 +887,13 @@ glade_util_draw_selection_nodes (GdkWindow *expose_win)
if (expose_toplevel == sel_toplevel
&& glade_util_can_draw_nodes (sel_widget, sel_win,
expose_win)) {
x = sel_x + sel_widget->allocation.x - expose_win_x;
y = sel_y + sel_widget->allocation.y - expose_win_y;
w = sel_widget->allocation.width;
h = sel_widget->allocation.height;
GtkAllocation allocation;
gtk_widget_get_allocation (sel_widget, &allocation);
x = sel_x + allocation.x - expose_win_x;
y = sel_y + allocation.y - expose_win_y;
w = allocation.width;
h = allocation.height;
/* Draw the selection nodes if they intersect the
expose window bounds. */
......@@ -930,6 +933,8 @@ glade_util_add_selection (GtkWidget *widget)
void
glade_util_remove_selection (GtkWidget *widget)
{
GtkWidget *parent;
g_return_if_fail (GTK_IS_WIDGET (widget));
if (!glade_util_has_selection (widget))
return;
......@@ -939,8 +944,8 @@ glade_util_remove_selection (GtkWidget *widget)
/* We redraw the parent, since the selection rectangle may not be
cleared if we just redraw the widget itself. */
gtk_widget_queue_draw (widget->parent ?
widget->parent : widget);
parent = gtk_widget_get_parent (widget);
gtk_widget_queue_draw (parent ? parent : widget);
}
/**
......@@ -952,6 +957,7 @@ void
glade_util_clear_selection (void)
{
GtkWidget *widget;
GtkWidget *parent;
GList *list;
for (list = glade_util_selection;
......@@ -959,8 +965,8 @@ glade_util_clear_selection (void)
list = list->next)
{
widget = list->data;
gtk_widget_queue_draw (widget->parent ?
widget->parent : widget);
parent = gtk_widget_get_parent (widget);
gtk_widget_queue_draw (parent ? parent : widget);
}
glade_util_selection =
(g_list_free (glade_util_selection), NULL);
......@@ -1678,6 +1684,7 @@ glade_util_get_placeholder_from_pointer (GtkContainer *container)
{
GtkWidget *toplevel;
GtkWidget *retval = NULL, *child;
GtkAllocation allocation;
GList *c, *l;
gint x, y, x2, y2;
......@@ -1699,10 +1706,10 @@ glade_util_get_placeholder_from_pointer (GtkContainer *container)
gtk_widget_translate_coordinates (toplevel, child,
x, y, &x2, &y2);
gtk_widget_get_allocation (child, &allocation);
if (x2 >= 0 && y2 >= 0 &&
x2 <= child->allocation.width &&
y2 <= child->allocation.height)
x2 <= allocation.width &&
y2 <= allocation.height)
{
retval = child;
break;
......@@ -2289,7 +2296,10 @@ glade_utils_hijack_key_press (GtkWindow *win,
GdkEventKey *event,
gpointer user_data)
{
if (win->focus_widget &&
GtkWidget *focus_widget;
focus_widget = gtk_window_get_focus (win);
if (focus_widget &&
(event->keyval == GDK_Delete || /* Filter Delete from accelerator keys */
((event->state & GDK_CONTROL_MASK) && /* CNTL keys... */
((event->keyval == GDK_c || event->keyval == GDK_C) || /* CNTL-C (copy) */
......@@ -2297,7 +2307,7 @@ glade_utils_hijack_key_press (GtkWindow *win,
(event->keyval == GDK_v || event->keyval == GDK_V) || /* CNTL-V (paste) */
(event->keyval == GDK_n || event->keyval == GDK_N))))) /* CNTL-N (new project) */
{
return gtk_widget_event (win->focus_widget,
return gtk_widget_event (focus_widget,
(GdkEvent *)event);
}
return FALSE;
......
......@@ -188,7 +188,9 @@ glade_cell_renderer_button_focus_out_event (GtkWidget *entry,
priv = GLADE_CELL_RENDERER_BUTTON_GET_PRIVATE (cell_text);
GTK_ENTRY (entry)->editing_canceled = TRUE;
g_object_set (entry,
"editing-canceled", TRUE,
NULL);
gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (entry));
gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (entry));
......@@ -220,6 +222,7 @@ static void
glade_cell_renderer_button_activate (GtkCellEditable *entry,
GtkCellRendererText *cell_text)
{
gboolean canceled;
const gchar *path;
const gchar *new_text;
GladeCellRendererButtonPrivate *priv;
......@@ -228,10 +231,12 @@ glade_cell_renderer_button_activate (GtkCellEditable *entry,
g_signal_handlers_disconnect_by_func (entry, glade_cell_renderer_button_focus_out_event, cell_text);
gtk_cell_renderer_stop_editing (GTK_CELL_RENDERER (cell_text),
GTK_ENTRY (entry)->editing_canceled);
g_object_get (entry,
"editing-canceled", &canceled,
NULL);
gtk_cell_renderer_stop_editing (GTK_CELL_RENDERER (cell_text), canceled);
if (GTK_ENTRY (entry)->editing_canceled)
if (canceled)
return;
path = g_object_get_data (G_OBJECT (entry), GLADE_CELL_RENDERER_BUTTON_PATH);
......@@ -244,6 +249,7 @@ static void
glade_cell_renderer_button_editing_done (GtkCellEditable *entry,
GtkCellRendererText *cell_text)
{
gboolean canceled;
const gchar *path;
const gchar *new_text;
GladeCellRendererButtonPrivate *priv;
......@@ -252,10 +258,12 @@ glade_cell_renderer_button_editing_done (GtkCellEditable *entry,
g_signal_handlers_disconnect_by_func (entry, glade_cell_renderer_button_focus_out_event, cell_text);
gtk_cell_renderer_stop_editing (GTK_CELL_RENDERER (cell_text),
GTK_ENTRY (entry)->editing_canceled);
g_object_get (entry,
"editing-canceled", &canceled,
NULL);
gtk_cell_renderer_stop_editing (GTK_CELL_RENDERER (cell_text), canceled);
if (GTK_ENTRY (entry)->editing_canceled)
if (canceled)
return;
path = g_object_get_data (G_OBJECT (entry), GLADE_CELL_RENDERER_BUTTON_PATH);
......@@ -277,20 +285,33 @@ glade_cell_renderer_button_start_editing (GtkCellRenderer *cell,
GladeCellRendererButtonPrivate *priv;
GtkCellRendererText *cell_text;
GladeTextButton *text_button;
gboolean editable;
gchar *text;
gfloat xalign;
cell_text = GTK_CELL_RENDERER_TEXT (cell);
priv = GLADE_CELL_RENDERER_BUTTON_GET_PRIVATE (cell);
if (cell_text->editable == FALSE)
g_object_get (cell_text,
"editable", &editable,
"text", &text,
NULL);
if (editable == FALSE)
return NULL;
priv->button = text_button = (GladeTextButton *)glade_text_button_new ();
gtk_entry_set_text (GTK_ENTRY (text_button->entry), cell_text->text ? cell_text->text : "");
gtk_entry_set_text (GTK_ENTRY (text_button->entry), text ? text : "");
g_free (text);
gtk_editable_set_editable (GTK_EDITABLE (text_button->entry), priv->entry_editable);
g_object_get (cell,
"xalign", &xalign,
NULL);
g_object_set (text_button->entry,
"has-frame", FALSE,
"xalign", cell->xalign,
"xalign", xalign,
NULL);
g_object_set_data_full (G_OBJECT (text_button->entry), GLADE_CELL_RENDERER_BUTTON_PATH,
......
......@@ -106,7 +106,9 @@ glade_text_button_key_press_event (GtkEntry *entry,
{
if (key_event->keyval == GDK_Escape)
{
entry->editing_canceled = TRUE;
g_object_get (entry,
"editing-canceled", TRUE,
NULL);
gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (button));
gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (button));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment