From 0b238a22d6a19f34672bc8a7efb66e171398acad Mon Sep 17 00:00:00 2001 From: wwp Date: Tue, 10 Jan 2017 09:31:34 +0100 Subject: [PATCH] Don't behave as if avail_d was not hardcoded, it is hardcoded to 7, and do it properly. Saves us a warning and solves Coverity #1372366. --- src/plugins/vcalendar/month-view.c | 31 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/plugins/vcalendar/month-view.c b/src/plugins/vcalendar/month-view.c index b859252cc..430f6e775 100644 --- a/src/plugins/vcalendar/month-view.c +++ b/src/plugins/vcalendar/month-view.c @@ -815,32 +815,31 @@ static void build_month_view_table(month_win *mw) GtkWidget *vp; time_t t = time(NULL); GtkWidget *arrow; - int avail_w = 0, avail_d = 0; + int avail_w = 0, avail_d = 7; int avail_h = 0; int weekoffset = -1; GDate *date; - int first_week=0; + int first_week = 0; if (mainwindow_get_mainwindow()) { - GtkAllocation allocation; - SummaryView *summaryview = mainwindow_get_mainwindow()->summaryview; - GTK_EVENTS_FLUSH(); - allocation = summaryview->mainwidget_book->allocation; - - avail_w = allocation.width - 25 - 2*(mw->hour_req.width); - avail_h = allocation.height - 20; - if (avail_h < 250) - avail_h = 250; - avail_d = avail_w / mw->StartDate_button_req.width; - } - avail_d = 7; + GtkAllocation allocation; + SummaryView *summaryview = mainwindow_get_mainwindow()->summaryview; + GTK_EVENTS_FLUSH(); + allocation = summaryview->mainwidget_book->allocation; + + avail_w = allocation.width - 25 - 2*(mw->hour_req.width); + avail_h = allocation.height - 20; + if (avail_h < 250) + avail_h = 250; + /* avail_d = avail_w / mw->StartDate_button_req.width; */ + } + gtk_widget_set_size_request(mw->StartDate_button, avail_w / avail_d, (avail_h)/6); gtk_widget_size_request(mw->StartDate_button, &mw->StartDate_button_req); /* initial values */ - if (avail_d) - gtk_spin_button_set_value(GTK_SPIN_BUTTON(mw->day_spin), avail_d); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(mw->day_spin), avail_d); #ifdef G_OS_WIN32 if (t < 0) -- 2.25.1