[tasks] Use accessor functions instead direct access



commit c32950623dfa7679654a20510065c735030bf08e
Author: Javier Jardón <jjardon gnome org>
Date:   Sat Nov 14 12:38:51 2009 +0100

    Use accessor functions instead direct access

 libkoto/koto-cell-renderer-pixbuf.c |    4 +++-
 libkoto/koto-date-combo.c           |   26 ++++++++++++++++----------
 libkoto/koto-field-editor-factory.c |    4 ++--
 libkoto/koto-hint-entry.c           |    2 +-
 libkoto/koto-task-editor-dialog.c   |    2 +-
 libkoto/koto-task-view.c            |   26 ++++++++++++++------------
 libkoto/koto-undo-action.c          |    2 +-
 src/gtk/main.c                      |    2 +-
 8 files changed, 39 insertions(+), 29 deletions(-)
---
diff --git a/libkoto/koto-cell-renderer-pixbuf.c b/libkoto/koto-cell-renderer-pixbuf.c
index b4ab170..b0b84fd 100644
--- a/libkoto/koto-cell-renderer-pixbuf.c
+++ b/libkoto/koto-cell-renderer-pixbuf.c
@@ -83,7 +83,9 @@ koto_cell_renderer_pixbuf_class_init (KotoCellRendererPixbufClass *class)
 static void
 koto_cell_renderer_pixbuf_init (KotoCellRendererPixbuf *cellpixbuf)
 {
-  GTK_CELL_RENDERER (cellpixbuf)->mode = GTK_CELL_RENDERER_MODE_ACTIVATABLE;
+  g_object_set (cellpixbuf,
+                "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE,
+                NULL);
 }
 
 /*
diff --git a/libkoto/koto-date-combo.c b/libkoto/koto-date-combo.c
index 1d7472f..8d5df3a 100644
--- a/libkoto/koto-date-combo.c
+++ b/libkoto/koto-date-combo.c
@@ -122,20 +122,23 @@ clamp_window (GtkWindow *window, int *x, int *y)
   GdkScreen *screen;
   int monitor_num;
   GdkRectangle monitor;
+  GtkAllocation allocation;
 
   screen = gtk_widget_get_screen (widget);
-  monitor_num = gdk_screen_get_monitor_at_window (screen, widget->window);
+  monitor_num = gdk_screen_get_monitor_at_window (screen, gtk_widget_get_window (widget));
   gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
 
+  gtk_widget_get_allocation (widget, &allocation);
+
   if (*x < monitor.x)
     *x = monitor.x;
-  else if (*x + widget->allocation.width > monitor.x + monitor.width)
-    *x = monitor.x + monitor.width - widget->allocation.width;
+  else if (*x + allocation.width > monitor.x + monitor.width)
+    *x = monitor.x + monitor.width - allocation.width;
 
   if (*y < monitor.y)
     *y = monitor.y;
-  else if (*y + widget->allocation.height > monitor.y + monitor.height)
-    *y = monitor.y + monitor.height - widget->allocation.height;
+  else if (*y + allocation.height > monitor.y + monitor.height)
+    *y = monitor.y + monitor.height - allocation.height;
 }
 
 /*
@@ -148,10 +151,13 @@ koto_date_combo_toggled (GtkToggleButton *button)
   GtkWidget *widget = GTK_WIDGET (button);
 
   if (gtk_toggle_button_get_active (button)) {
+    GtkAllocation allocation;
     int x = 0, y = 0;
-    gdk_window_get_origin (widget->window, &x, &y);
-    x += widget->allocation.x;
-    y += widget->allocation.y + widget->allocation.height;
+
+    gdk_window_get_origin (gtk_widget_get_window (widget), &x, &y);
+    gtk_widget_get_allocation (widget, &allocation);
+    x += allocation.x;
+    y += allocation.y + allocation.height;
 
     gtk_widget_show (priv->popup);
 
@@ -171,7 +177,7 @@ koto_date_combo_toggled (GtkToggleButton *button)
 
     gtk_widget_grab_focus (priv->calendar);
     /* TODO: do I need this? */
-    popup_grab_on_window (priv->popup->window, GDK_CURRENT_TIME, TRUE);
+    popup_grab_on_window (gtk_widget_get_window (priv->popup), GDK_CURRENT_TIME, TRUE);
     gtk_grab_add (priv->popup);
   } else {
     gtk_grab_remove (priv->popup);
@@ -329,7 +335,7 @@ koto_date_combo_map (GtkWidget *widget)
   /* This is used to limit the scope of the grab */
 
   toplevel = gtk_widget_get_toplevel (GTK_WIDGET (widget));
-  if (GTK_WIDGET_TOPLEVEL (toplevel)) {
+  if (gtk_widget_is_toplevel (toplevel)) {
     gtk_window_set_transient_for (GTK_WINDOW (priv->popup),
                                   GTK_WINDOW (toplevel));
   }
diff --git a/libkoto/koto-field-editor-factory.c b/libkoto/koto-field-editor-factory.c
index 4a35ac2..5d1c1ed 100644
--- a/libkoto/koto-field-editor-factory.c
+++ b/libkoto/koto-field-editor-factory.c
@@ -408,7 +408,7 @@ run_new_category_dialog (GtkWidget *widget)
 
   /* Magically get the top-level window */
   parent = gtk_widget_get_toplevel (widget);
-  parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL;
+  parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
 
   dialog = gtk_dialog_new_with_buttons (_("New Category"), GTK_WINDOW (parent),
                                         GTK_DIALOG_NO_SEPARATOR,
@@ -418,7 +418,7 @@ run_new_category_dialog (GtkWidget *widget)
   gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
   gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
 
-  box = GTK_DIALOG (dialog)->vbox;
+  box = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
   gtk_box_set_spacing (GTK_BOX (box), 8);
 
   label = gtk_label_new (_("Enter the name of the new category:"));
diff --git a/libkoto/koto-hint-entry.c b/libkoto/koto-hint-entry.c
index 1825d5f..73426cf 100644
--- a/libkoto/koto-hint-entry.c
+++ b/libkoto/koto-hint-entry.c
@@ -54,7 +54,7 @@ update (KotoHintEntry *entry)
 
   text = gtk_entry_get_text (GTK_ENTRY (entry));
 
-  if (GTK_WIDGET_HAS_FOCUS (entry)) {
+  if (gtk_widget_has_focus (entry)) {
     if (priv->state == STATE_HINTING) {
       priv->state = STATE_ENTRY;
       gtk_widget_modify_text (widget, GTK_STATE_NORMAL, NULL);
diff --git a/libkoto/koto-task-editor-dialog.c b/libkoto/koto-task-editor-dialog.c
index a915c53..0d1f513 100644
--- a/libkoto/koto-task-editor-dialog.c
+++ b/libkoto/koto-task-editor-dialog.c
@@ -264,7 +264,7 @@ koto_task_editor_dialog_init (KotoTaskEditorDialog *self)
 
   notebook = gtk_notebook_new ();
   gtk_widget_show (notebook);
-  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (self)->vbox), notebook);
+  gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (self))), notebook);
 
   priv->editor = koto_task_editor_new ();
   koto_task_editor_add_fields (KOTO_TASK_EDITOR (priv->editor),
diff --git a/libkoto/koto-task-view.c b/libkoto/koto-task-view.c
index 8bf4a91..41202ef 100644
--- a/libkoto/koto-task-view.c
+++ b/libkoto/koto-task-view.c
@@ -308,29 +308,31 @@ static void
 koto_task_view_style_set (GtkWidget *widget, GtkStyle *previous)
 {
   KotoTaskViewPrivate *priv;
+  GtkStyle *style;
 
   g_assert (KOTO_IS_TASK_VIEW (widget));
 
   priv = GET_PRIVATE (widget);
 
+  style = gtk_widget_get_style (widget);
 #if HAVE_DECL_GTK_STYLE_LOOKUP_COLOR
-  if (!gtk_style_lookup_color (widget->style, "priority-low", &priv->colour_low)) {
-    priv->colour_low = widget->style->text[GTK_STATE_INSENSITIVE];
+  if (!gtk_style_lookup_color (style, "priority-low", &priv->colour_low)) {
+    priv->colour_low = style->text[GTK_STATE_INSENSITIVE];
   }
-  if (!gtk_style_lookup_color (widget->style, "priority-normal", &priv->colour_normal)) {
-    priv->colour_normal = widget->style->text[GTK_STATE_NORMAL];
+  if (!gtk_style_lookup_color (style, "priority-normal", &priv->colour_normal)) {
+    priv->colour_normal = style->text[GTK_STATE_NORMAL];
   }
-  if (!gtk_style_lookup_color (widget->style, "priority-high", &priv->colour_high)) {
-    priv->colour_high = widget->style->text[GTK_STATE_NORMAL];
+  if (!gtk_style_lookup_color (style, "priority-high", &priv->colour_high)) {
+    priv->colour_high = style->text[GTK_STATE_NORMAL];
   }
-  if (!gtk_style_lookup_color (widget->style, "priority-done", &priv->colour_done)) {
-    priv->colour_done = widget->style->text[GTK_STATE_INSENSITIVE];
+  if (!gtk_style_lookup_color (style, "priority-done", &priv->colour_done)) {
+    priv->colour_done = style->text[GTK_STATE_INSENSITIVE];
   }
 #else
-  priv->colour_low = widget->style->text[GTK_STATE_INSENSITIVE];
-  priv->colour_normal = widget->style->text[GTK_STATE_NORMAL];
-  priv->colour_high = widget->style->text[GTK_STATE_NORMAL];
-  priv->colour_done = widget->style->text[GTK_STATE_INSENSITIVE];
+  priv->colour_low = style->text[GTK_STATE_INSENSITIVE];
+  priv->colour_normal = style->text[GTK_STATE_NORMAL];
+  priv->colour_high = style->text[GTK_STATE_NORMAL];
+  priv->colour_done = style->text[GTK_STATE_INSENSITIVE];
 #endif
 
   GTK_WIDGET_CLASS (koto_task_view_parent_class)->style_set (widget, previous);
diff --git a/libkoto/koto-undo-action.c b/libkoto/koto-undo-action.c
index 8513992..6bc611d 100644
--- a/libkoto/koto-undo-action.c
+++ b/libkoto/koto-undo-action.c
@@ -105,7 +105,7 @@ koto_undo_action_connect_proxy (GtkAction *action, GtkWidget *proxy)
 
   GTK_ACTION_CLASS (koto_undo_action_parent_class)->connect_proxy (action, proxy);
 
-  label = (GtkLabel*)(GTK_BIN (proxy)->child);
+  label = GTK_LABEL (gtk_bin_get_child (GTK_BIN (proxy)));
   if (GTK_IS_LABEL (label)) {
     gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END);
     /* Vile. */
diff --git a/src/gtk/main.c b/src/gtk/main.c
index c4294d5..3fe60c9 100644
--- a/src/gtk/main.c
+++ b/src/gtk/main.c
@@ -767,7 +767,7 @@ main (int argc, char **argv)
 
   new_button = gtk_button_new_from_stock (GTK_STOCK_ADD);
   gtk_widget_set_sensitive (new_button, FALSE);
-  GTK_WIDGET_SET_FLAGS (new_button, GTK_CAN_DEFAULT);
+  gtk_widget_set_can_default (new_button, TRUE);
   gtk_window_set_default (GTK_WINDOW (window), new_button);
   g_signal_connect (new_button, "clicked", G_CALLBACK (on_new_clicked), NULL);
   g_signal_connect (new_entry, "changed", G_CALLBACK (on_new_entry_changed), new_button);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]