Removed almost all direct GTK struct member accesses.
authorAndrej Kacian <ticho@claws-mail.org>
Tue, 6 Feb 2018 10:19:21 +0000 (11:19 +0100)
committerAndrej Kacian <ticho@claws-mail.org>
Tue, 6 Feb 2018 10:19:21 +0000 (11:19 +0100)
Use accessor functions instead.

The few remaining offenders are in spell_entry.c, which
will require some rework.

12 files changed:
src/browseldap.c
src/gtk/spell_entry.c
src/plugins/archive/archiver_gtk.c
src/plugins/dillo/dillo_viewer.c
src/plugins/notification/notification_banner.c
src/plugins/notification/notification_core.c
src/plugins/rssyl/rssyl_feed_props.c
src/plugins/vcalendar/common-views.c
src/plugins/vcalendar/day-view.c
src/plugins/vcalendar/month-view.c
src/plugins/vcalendar/vcal_meeting_gtk.c
src/plugins/vcalendar/vcalendar.c

index 117d77e..519cc80 100644 (file)
@@ -209,6 +209,7 @@ static void browse_create( void ) {
        GtkWidget *tree_win;
        GtkWidget *hbbox;
        GtkWidget *close_btn;
+       GtkWidget *content_area;
        gint top;
 
        debug_print("creating browse widget\n");
@@ -223,7 +224,8 @@ static void browse_create( void ) {
                         G_CALLBACK(browse_key_pressed), NULL);
 
        vbox = gtk_vbox_new(FALSE, 8);
-       gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), vbox, TRUE, TRUE, 0);
+       content_area = gtk_dialog_get_content_area(GTK_DIALOG(window));
+       gtk_box_pack_start(GTK_BOX(content_area), vbox, TRUE, TRUE, 0);
        gtk_container_set_border_width( GTK_CONTAINER(vbox), 8 );
 
        table = gtk_table_new(2, 2, FALSE);
index f49b259..4f38b78 100644 (file)
@@ -176,14 +176,15 @@ static gint gtk_entry_find_position (GtkEntry *entry, gint x)
        const gchar *text;
        gint cursor_index;
        gint index;
-       gint pos;
+       gint pos, current_pos;
        gboolean trailing;
 
        x = x + entry->scroll_offset;
 
        layout = gtk_entry_get_layout(entry);
        text = pango_layout_get_text(layout);
-       cursor_index = g_utf8_offset_to_pointer(text, entry->current_pos) - text;
+       g_object_get(entry, "cursor-position", &current_pos, NULL);
+       cursor_index = g_utf8_offset_to_pointer(text, current_pos) - text;
 
        line = pango_layout_get_lines(layout)->data;
        pango_layout_line_x_to_index(line, x * PANGO_SCALE, &index, &trailing);
@@ -426,6 +427,7 @@ static gboolean check_word(ClawsSpellEntry *entry, int start, int end)
 
 void claws_spell_entry_recheck_all(ClawsSpellEntry *entry)
 {
+       GtkAllocation allocation;
        GdkRectangle rect;
        PangoLayout *layout;
        int length, i;
@@ -453,9 +455,11 @@ void claws_spell_entry_recheck_all(ClawsSpellEntry *entry)
 
        if (gtk_widget_get_realized(GTK_WIDGET(entry))) {
                rect.x = 0; rect.y = 0;
-               rect.width  = GTK_WIDGET(entry)->allocation.width;
-               rect.height = GTK_WIDGET(entry)->allocation.height;
-               gdk_window_invalidate_rect(GTK_WIDGET(entry)->window, &rect, TRUE);
+               gtk_widget_get_allocation(GTK_WIDGET(entry), &allocation);
+               rect.width  = allocation.width;
+               rect.height = allocation.height;
+               gdk_window_invalidate_rect(gtk_widget_get_window(GTK_WIDGET(entry)),
+                               &rect, TRUE);
        }
 }
 
@@ -579,7 +583,7 @@ static void set_menu_pos(GtkMenu *menu, gint *x, gint *y,
        gtk_widget_get_child_requisition(GTK_WIDGET(entry), &subject_rq);
        
        /* screen -> compose window coords */
-       gdk_window_get_origin(GTK_WIDGET(gtkaspell->parent_window)->window,
+       gdk_window_get_origin(gtk_widget_get_window(GTK_WIDGET(gtkaspell->parent_window)),
                                &scr_x, &scr_y);
 
        /* compose window -> subject entry coords */
index ca74c3b..aa9e1b3 100644 (file)
@@ -106,6 +106,7 @@ static void progress_dialog_cb(GtkWidget* widget, gint action, gpointer data) {
 static void create_progress_dialog(struct ArchivePage* page) {
        gchar* title = g_strdup_printf("%s %s", _("Archiving"), page->path);
        MainWindow* mainwin = mainwindow_get_mainwindow();
+       GtkWidget *content_area;
 
        progress->position = 0;
        progress->progress_dialog = gtk_dialog_new_with_buttons (
@@ -126,8 +127,8 @@ static void create_progress_dialog(struct ArchivePage* page) {
        gtk_frame_set_shadow_type(GTK_FRAME(progress->frame),
                                        GTK_SHADOW_ETCHED_OUT);
        gtk_container_set_border_width(GTK_CONTAINER(progress->frame), 4);
-       gtk_container_add(GTK_CONTAINER(
-                               GTK_DIALOG(progress->progress_dialog)->vbox), progress->frame);
+       content_area = gtk_dialog_get_content_area(GTK_DIALOG(progress->progress_dialog));
+       gtk_container_add(GTK_CONTAINER(content_area), progress->frame);
 
        progress->vbox1 = gtk_vbox_new (FALSE, 4);
        gtk_container_set_border_width (GTK_CONTAINER (progress->vbox1), 4);
@@ -668,6 +669,7 @@ static void show_result(struct ArchivePage* page) {
        GtkTreeViewColumn* header;
        GtkCellRenderer* renderer;
        GtkWidget* dialog;
+       GtkWidget* content_area;
        gchar* msg = NULL;
        gchar* method = NULL;
        gchar* format = NULL;
@@ -773,8 +775,9 @@ static void show_result(struct ArchivePage* page) {
                                _("Values"), renderer, "text", STRING2, NULL);
        gtk_tree_view_append_column(view, header);
 
+       content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
        gtk_container_add(
-                               GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), GTK_WIDGET(view));
+                               GTK_CONTAINER(content_area), GTK_WIDGET(view));
 
        gtk_list_store_append(list, &iter);
        gtk_list_store_set(
@@ -1026,6 +1029,7 @@ void archiver_gtk_show() {
        GtkWidget* pax_radio_btn;
        GtkWidget* cpio_radio_btn;
        GtkWidget* tar_radio_btn;
+       GtkWidget* content_area;
        struct ArchivePage* page;
        MainWindow* mainwin = mainwindow_get_mainwindow();
 
@@ -1053,7 +1057,8 @@ void archiver_gtk_show() {
        frame = gtk_frame_new(_("Enter Archiver arguments"));
        gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_OUT);
        gtk_container_set_border_width(GTK_CONTAINER(frame), 4);
-       gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), frame);
+       content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
+       gtk_container_add(GTK_CONTAINER(content_area), frame);
 
        vbox1 = gtk_vbox_new (FALSE, 4);
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), 4);
index 6c820f0..d5eae61 100644 (file)
@@ -121,6 +121,7 @@ static void dillo_show_mimepart(MimeViewer *_viewer,
                                MimeInfo *partinfo)
 {
        DilloViewer *viewer = (DilloViewer *) _viewer;
+       GdkWindow *gdkwin;
 
        debug_print("dillo_show_mimepart\n");
 
@@ -145,10 +146,11 @@ static void dillo_show_mimepart(MimeViewer *_viewer,
                g_signal_connect(G_OBJECT(viewer->socket), "destroy", 
                                 G_CALLBACK(socket_destroy_cb), viewer);
 
+               gdkwin = gtk_widget_get_window(viewer->socket);
                cmd = g_strdup_printf("dillo %s%s-x %d \"%s\"",
                                      (!load_images(viewer) ? "-l " : ""),
                                      (dillo_prefs.full ? "-f " : ""),
-                                     (gint) GDK_WINDOW_XWINDOW(viewer->socket->window),
+                                     (gint) GDK_WINDOW_XWINDOW(gdkwin),
                                      viewer->filename);
 
                execute_command_line(cmd, TRUE, NULL);
index d566ba5..f2b4ee9 100644 (file)
@@ -272,8 +272,9 @@ static gboolean scroller(gpointer data)
                gtk_main_iteration();
   G_LOCK(sdata);
   if(sdata.adj && GTK_IS_ADJUSTMENT(sdata.adj)) {
-    if(sdata.adj->value != sdata.banner_width)
-      gtk_adjustment_set_value(sdata.adj, sdata.adj->value + 1);
+    if(gtk_adjustment_get_value(sdata.adj) != sdata.banner_width)
+      gtk_adjustment_set_value(sdata.adj,
+                                       gtk_adjustment_get_value(sdata.adj) + 1);
     else
       gtk_adjustment_set_value(sdata.adj, 0);
                gtk_adjustment_value_changed(sdata.adj);
index 1736523..967f67f 100644 (file)
@@ -81,11 +81,14 @@ void notification_core_global_includes_changed(void)
 void notification_toggle_hide_show_window(void)
 {
   MainWindow *mainwin;
+       GdkWindow *gdkwin;
+
   if((mainwin = mainwindow_get_mainwindow()) == NULL)
     return;
 
+       gdkwin = gtk_widget_get_window(GTK_WIDGET(mainwin->window));
   if(gtk_widget_get_visible(GTK_WIDGET(mainwin->window))) {
-    if((gdk_window_get_state(GTK_WIDGET(mainwin->window)->window)&GDK_WINDOW_STATE_ICONIFIED)
+    if((gdk_window_get_state(gdkwin) & GDK_WINDOW_STATE_ICONIFIED)
        || mainwindow_is_obscured()) {
       notification_show_mainwindow(mainwin);
     }
index d2936c0..a425433 100644 (file)
@@ -512,7 +512,7 @@ void rssyl_gtk_prop(RFolderItem *ritem)
        /* OK button */
        ok_button = gtk_button_new();
        gtk_container_add(GTK_CONTAINER(bbox), ok_button);
-       GTK_WIDGET_SET_FLAGS(ok_button, GTK_CAN_DEFAULT );
+       gtk_widget_set_can_default(ok_button, TRUE);
 
        ok_align = gtk_alignment_new(0.5, 0.5, 0, 0);
        gtk_container_add(GTK_CONTAINER(ok_button), ok_align);
index 32717a4..3acb48e 100644 (file)
@@ -85,7 +85,7 @@ GtkWidget *build_line(gint start_x, gint start_y
      
     pic1_cmap = gdk_colormap_get_system();
     pic1_vis = gdk_colormap_get_visual(pic1_cmap);
-    depth = pic1_vis->depth;
+    depth = gdk_visual_get_depth(pic1_vis);
     if (hour_line == NULL) {
         pic1 = gdk_pixmap_new(NULL, width, height, depth);
         gdk_drawable_set_colormap(pic1, pic1_cmap);
index 061da42..826b233 100644 (file)
@@ -122,7 +122,8 @@ static void set_scroll_position(day_win *dw)
         gtk_adjustment_set_value(v_adj, dw->scroll_pos);
     else if (dw->scroll_pos < 0)
         /* default: let's try to start roughly from line 8 = 8 o'clock */
-        gtk_adjustment_set_value(v_adj, v_adj->upper/3);
+        gtk_adjustment_set_value(v_adj,
+                                               gtk_adjustment_get_upper(v_adj) / 3);
     gtk_adjustment_changed(v_adj);
 }
 
@@ -240,7 +241,7 @@ static void dw_summary_selected(GtkCMCTree *ctree, GtkCMCTreeNode *row,
                                localtime_r(&t_start, &tm_start);
                                if (tm_start.tm_hour > 2)
                                        gtk_adjustment_set_value(v_adj, 
-                                               ((v_adj->upper-v_adj->page_size)/((gdouble)24/(gdouble)(tm_start.tm_hour-2))));
+                                               ((gtk_adjustment_get_upper(v_adj) - gtk_adjustment_get_page_size(v_adj))/((gdouble)24/(gdouble)(tm_start.tm_hour-2))));
                                else
                                        gtk_adjustment_set_value(v_adj, 0);
                                gtk_adjustment_changed(v_adj);
@@ -628,7 +629,8 @@ static void build_day_view_header(day_win *dw, char *start_date)
     if (mainwindow_get_mainwindow()) {
         GtkAllocation allocation;
        summaryview = mainwindow_get_mainwindow()->summaryview;
-       allocation = summaryview->mainwidget_book->allocation;
+       gtk_widget_get_allocation(summaryview->mainwidget_book,
+                       &allocation);
        
        avail_w = allocation.width - 20 - 2*(dw->hour_req.width);
        avail_d = avail_w / dw->StartDate_button_req.width;
@@ -647,7 +649,7 @@ static void build_day_view_header(day_win *dw, char *start_date)
 
 static void build_day_view_colours(day_win *dw)
 {
-    GtkStyle *def_style;
+    GtkStyle *def_style, *cur_style;
     GdkColormap *pic1_cmap;
     GtkWidget *ctree = NULL;
     def_style = gtk_widget_get_default_style();
@@ -657,8 +659,9 @@ static void build_day_view_colours(day_win *dw)
         ctree = mainwindow_get_mainwindow()->summaryview->ctree;
     }
     if (ctree) {
-        dw->bg1 = ctree->style->bg[GTK_STATE_NORMAL];
-        dw->bg2 = ctree->style->bg[GTK_STATE_NORMAL];
+        cur_style = gtk_widget_get_style(ctree);
+        dw->bg1 = cur_style->bg[GTK_STATE_NORMAL];
+        dw->bg2 = cur_style->bg[GTK_STATE_NORMAL];
     } else {
         dw->bg1 = def_style->bg[GTK_STATE_NORMAL];
         dw->bg2 = def_style->bg[GTK_STATE_NORMAL];
@@ -695,12 +698,13 @@ static void build_day_view_colours(day_win *dw)
     }
 
     if (ctree) {
-        dw->fg_sunday.red = (dw->fg_sunday.red + ctree->style->fg[GTK_STATE_SELECTED].red)/2;
-        dw->fg_sunday.green = (dw->fg_sunday.green + ctree->style->fg[GTK_STATE_SELECTED].red)/2;
-        dw->fg_sunday.blue = (3*dw->fg_sunday.blue + ctree->style->fg[GTK_STATE_SELECTED].red)/4;
-        dw->bg_today.red = (3*dw->bg_today.red + ctree->style->bg[GTK_STATE_NORMAL].red)/4;
-        dw->bg_today.green = (3*dw->bg_today.green + ctree->style->bg[GTK_STATE_NORMAL].red)/4;
-        dw->bg_today.blue = (3*dw->bg_today.blue + ctree->style->bg[GTK_STATE_NORMAL].red)/4;
+        cur_style = gtk_widget_get_style(ctree);
+        dw->fg_sunday.red = (dw->fg_sunday.red + cur_style->fg[GTK_STATE_SELECTED].red)/2;
+        dw->fg_sunday.green = (dw->fg_sunday.green + cur_style->fg[GTK_STATE_SELECTED].red)/2;
+        dw->fg_sunday.blue = (3*dw->fg_sunday.blue + cur_style->fg[GTK_STATE_SELECTED].red)/4;
+        dw->bg_today.red = (3*dw->bg_today.red + cur_style->bg[GTK_STATE_NORMAL].red)/4;
+        dw->bg_today.green = (3*dw->bg_today.green + cur_style->bg[GTK_STATE_NORMAL].red)/4;
+        dw->bg_today.blue = (3*dw->bg_today.blue + cur_style->bg[GTK_STATE_NORMAL].red)/4;
     }
 
     gdk_colormap_alloc_color(pic1_cmap, &dw->line_color, FALSE, TRUE);
index 430f6e7..e2afed3 100644 (file)
@@ -725,7 +725,7 @@ static void build_month_view_header(month_win *mw, char *start_date)
 
 static void build_month_view_colours(month_win *mw)
 {
-    GtkStyle *def_style;
+    GtkStyle *def_style, *cur_style;
     GdkColormap *pic1_cmap;
     GtkWidget *ctree = NULL;
     def_style = gtk_widget_get_default_style();
@@ -735,8 +735,9 @@ static void build_month_view_colours(month_win *mw)
         ctree = mainwindow_get_mainwindow()->summaryview->ctree;
     }
     if (ctree) {
-        mw->bg1 = ctree->style->bg[GTK_STATE_NORMAL];
-        mw->bg2 = ctree->style->bg[GTK_STATE_NORMAL];
+        cur_style = gtk_widget_get_style(ctree);
+        mw->bg1 = cur_style->bg[GTK_STATE_NORMAL];
+        mw->bg2 = cur_style->bg[GTK_STATE_NORMAL];
     } else {
         mw->bg1 = def_style->bg[GTK_STATE_NORMAL];
         mw->bg2 = def_style->bg[GTK_STATE_NORMAL];
@@ -774,12 +775,13 @@ static void build_month_view_colours(month_win *mw)
     }
 
     if (ctree) {
-        mw->fg_sunday.red = (mw->fg_sunday.red + ctree->style->fg[GTK_STATE_SELECTED].red)/2;
-        mw->fg_sunday.green = (mw->fg_sunday.green + ctree->style->fg[GTK_STATE_SELECTED].red)/2;
-        mw->fg_sunday.blue = (3*mw->fg_sunday.blue + ctree->style->fg[GTK_STATE_SELECTED].red)/4;
-        mw->bg_today.red = (3*mw->bg_today.red + ctree->style->bg[GTK_STATE_NORMAL].red)/4;
-        mw->bg_today.green = (3*mw->bg_today.green + ctree->style->bg[GTK_STATE_NORMAL].red)/4;
-        mw->bg_today.blue = (3*mw->bg_today.blue + ctree->style->bg[GTK_STATE_NORMAL].red)/4;
+        cur_style = gtk_widget_get_style(ctree);
+        mw->fg_sunday.red = (mw->fg_sunday.red + cur_style->fg[GTK_STATE_SELECTED].red)/2;
+        mw->fg_sunday.green = (mw->fg_sunday.green + cur_style->fg[GTK_STATE_SELECTED].red)/2;
+        mw->fg_sunday.blue = (3*mw->fg_sunday.blue + cur_style->fg[GTK_STATE_SELECTED].red)/4;
+        mw->bg_today.red = (3*mw->bg_today.red + cur_style->bg[GTK_STATE_NORMAL].red)/4;
+        mw->bg_today.green = (3*mw->bg_today.green + cur_style->bg[GTK_STATE_NORMAL].red)/4;
+        mw->bg_today.blue = (3*mw->bg_today.blue + cur_style->bg[GTK_STATE_NORMAL].red)/4;
     }
     gdk_colormap_alloc_color(pic1_cmap, &mw->line_color, FALSE, TRUE);
     gdk_colormap_alloc_color(pic1_cmap, &mw->fg_sunday, FALSE, TRUE);
@@ -825,7 +827,8 @@ static void build_month_view_table(month_win *mw)
                GtkAllocation allocation;
                SummaryView *summaryview = mainwindow_get_mainwindow()->summaryview;
                GTK_EVENTS_FLUSH();
-               allocation = summaryview->mainwidget_book->allocation;
+               gtk_widget_get_allocation(summaryview->mainwidget_book,
+                               &allocation);
 
                avail_w = allocation.width - 25 - 2*(mw->hour_req.width);
                avail_h = allocation.height - 20;
index 976d7da..b5871e7 100644 (file)
@@ -1003,6 +1003,7 @@ static gboolean check_attendees_availability(VCalMeeting *meet, gboolean tell_if
                                "internal.ifb", NULL);
        gboolean local_only = FALSE;
        GSList *attlist;
+       GdkWindow *gdkwin;
 
        if (vcalprefs.freebusy_get_url == NULL
        ||  *vcalprefs.freebusy_get_url == '\0') {
@@ -1057,8 +1058,9 @@ static gboolean check_attendees_availability(VCalMeeting *meet, gboolean tell_if
        gtk_widget_set_sensitive(meet->save_btn, FALSE);
        gtk_widget_set_sensitive(meet->avail_btn, FALSE);
 
-       if (meet->window->window)
-               gdk_window_set_cursor(meet->window->window, watch_cursor);
+       gdkwin = gtk_widget_get_window(meet->window);
+       if (gdkwin != NULL)
+               gdk_window_set_cursor(gdkwin, watch_cursor);
 
        for (cur = attlist; cur && cur->data; cur = cur->next) {
                VCalAttendee *attendee = (VCalAttendee *)cur->data;
@@ -1183,8 +1185,9 @@ static gboolean check_attendees_availability(VCalMeeting *meet, gboolean tell_if
        }
        gtk_widget_set_sensitive(meet->save_btn, TRUE);
        gtk_widget_set_sensitive(meet->avail_btn, avail_btn_can_be_sensitive());
-       if (meet->window->window)
-               gdk_window_set_cursor(meet->window->window, NULL);
+
+       if (gdkwin != NULL)
+               gdk_window_set_cursor(gdkwin, NULL);
 
        if (!local_only)
                meet->attendees = g_slist_remove(meet->attendees, dummy_org);
@@ -1227,6 +1230,7 @@ static gboolean send_meeting_cb(GtkButton *widget, gpointer data)
        gboolean found_att = FALSE;
        Folder *folder = folder_find_from_name (PLUGIN_NAME, vcal_folder_get_class());
        gboolean redisp = FALSE;
+       GdkWindow *gdkwin;
 
        if (meet->uid == NULL && meet->visible && 
            !check_attendees_availability(meet, FALSE, TRUE)) {
@@ -1242,8 +1246,10 @@ static gboolean send_meeting_cb(GtkButton *widget, gpointer data)
        }
        gtk_widget_set_sensitive(meet->save_btn, FALSE);
        gtk_widget_set_sensitive(meet->avail_btn, FALSE);
-       if (meet->window->window)
-               gdk_window_set_cursor(meet->window->window, watch_cursor);
+
+       gdkwin = gtk_widget_get_window(meet->window);
+       if (gdkwin != NULL)
+               gdk_window_set_cursor(gdkwin, watch_cursor);
 
        organizer       = get_organizer(meet);
        account         = account_find_from_address(organizer, FALSE);
@@ -1331,8 +1337,8 @@ static gboolean send_meeting_cb(GtkButton *widget, gpointer data)
 
        gtk_widget_set_sensitive(meet->save_btn, TRUE);
        gtk_widget_set_sensitive(meet->avail_btn, avail_btn_can_be_sensitive());
-       if (meet->window->window)
-               gdk_window_set_cursor(meet->window->window, NULL);
+       if (gdkwin != NULL)
+               gdk_window_set_cursor(gdkwin, NULL);
 
        if (res) {
                vcal_destroy(meet);
index b4462b3..0b6bf69 100644 (file)
@@ -852,6 +852,8 @@ static VCalViewer *s_vcalviewer = NULL;
 static void vcal_viewer_show_mimepart(MimeViewer *_mimeviewer, const gchar *file, MimeInfo *mimeinfo)
 {
        VCalViewer *vcalviewer = (VCalViewer *) _mimeviewer;
+       GtkAllocation allocation;
+
        START_TIMING("");
 
        s_vcalviewer = vcalviewer;
@@ -871,8 +873,9 @@ static void vcal_viewer_show_mimepart(MimeViewer *_mimeviewer, const gchar *file
        vcalviewer_hide_error(vcalviewer);
        vcalviewer_get_event(vcalviewer, mimeinfo);
        GTK_EVENTS_FLUSH();
+       gtk_widget_get_allocation(vcalviewer->scrolledwin, &allocation);
        gtk_widget_set_size_request(vcalviewer->description, 
-               vcalviewer->scrolledwin->allocation.width - 200, -1);
+               allocation.width - 200, -1);
        gtk_label_set_line_wrap(GTK_LABEL(vcalviewer->location), TRUE);
        gtk_label_set_line_wrap(GTK_LABEL(vcalviewer->summary), TRUE);
        gtk_label_set_line_wrap(GTK_LABEL(vcalviewer->description), TRUE);