[planner: 20/61] default-week-dialog: Port weekday selector to GtkComboBoxText
- From: Mart Raudsepp <mraudsepp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [planner: 20/61] default-week-dialog: Port weekday selector to GtkComboBoxText
- Date: Sat, 12 Jun 2021 17:30:23 +0000 (UTC)
commit ef24879b7766a9edbec8fb80771dcadbd9c2e276
Author: Mart Raudsepp <leio gentoo org>
Date: Sat Mar 7 20:07:14 2020 +0200
default-week-dialog: Port weekday selector to GtkComboBoxText
GtkOptionMenu (used before) has been deprecated for most of gtk2 times
and does not exist in gtk3.
data/ui/default-week-dialog.ui | 3 +--
src/planner-default-week-dialog.c | 56 ++++++++++-----------------------------
2 files changed, 15 insertions(+), 44 deletions(-)
---
diff --git a/data/ui/default-week-dialog.ui b/data/ui/default-week-dialog.ui
index a937d7b7..b7f0fc2e 100644
--- a/data/ui/default-week-dialog.ui
+++ b/data/ui/default-week-dialog.ui
@@ -166,10 +166,9 @@
</packing>
</child>
<child>
- <object class="GtkOptionMenu" id="weekday_optionmenu">
+ <object class="GtkComboBoxText" id="weekday_combobox">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="history">-1</property>
</object>
<packing>
<property name="padding">0</property>
diff --git a/src/planner-default-week-dialog.c b/src/planner-default-week-dialog.c
index 46d5cbe5..1945eaff 100644
--- a/src/planner-default-week-dialog.c
+++ b/src/planner-default-week-dialog.c
@@ -61,7 +61,7 @@ typedef struct {
MrpCalendar *calendar;
GtkWidget *dialog;
- GtkWidget *weekday_option_menu;
+ GtkWidget *weekday_combobox;
GtkWidget *day_option_menu;
GtkWidget *from_label[5];
@@ -93,14 +93,14 @@ static void default_week_dialog_response_cb (GtkWidget
gint response,
DialogData *data);
static void default_week_dialog_update_labels (DialogData *data);
-static void default_week_dialog_weekday_selected_cb (GtkOptionMenu *option_menu,
+static void default_week_dialog_weekday_selected_cb (GtkComboBoxText *combotext,
DialogData *data);
static void default_week_dialog_day_selected_cb (GtkOptionMenu *option_menu,
DialogData *data);
static void default_week_dialog_setup_day_option_menu (GtkOptionMenu *option_menu,
MrpProject *project,
MrpCalendar *calendar);
-static void default_week_dialog_setup_weekday_option_menu (GtkOptionMenu *option_menu);
+static void default_week_dialog_setup_weekday_combobox (GtkComboBoxText *combotext);
static gint default_week_dialog_get_selected_weekday (DialogData *data);
static MrpDay * default_week_dialog_get_selected_day (DialogData *data);
static void default_week_dialog_set_selected_day (DialogData *data,
@@ -198,7 +198,7 @@ planner_default_week_dialog_new (PlannerWindow *window,
w = GTK_WIDGET (gtk_builder_get_object (builder, "name_label"));
gtk_label_set_text (GTK_LABEL (w), mrp_calendar_get_name (calendar));
- data->weekday_option_menu = GTK_WIDGET (gtk_builder_get_object (builder, "weekday_optionmenu"));
+ data->weekday_combobox = GTK_WIDGET (gtk_builder_get_object (builder, "weekday_combobox"));
data->day_option_menu = GTK_WIDGET (gtk_builder_get_object (builder, "day_optionmenu"));
default_week_dialog_setup_day_option_menu (GTK_OPTION_MENU (data->day_option_menu),
@@ -210,12 +210,12 @@ planner_default_week_dialog_new (PlannerWindow *window,
G_CALLBACK (default_week_dialog_day_selected_cb),
data);
- g_signal_connect (data->weekday_option_menu,
+ g_signal_connect (data->weekday_combobox,
"changed",
G_CALLBACK (default_week_dialog_weekday_selected_cb),
data);
- default_week_dialog_setup_weekday_option_menu (GTK_OPTION_MENU (data->weekday_option_menu));
+ default_week_dialog_setup_weekday_combobox (GTK_COMBO_BOX_TEXT (data->weekday_combobox));
g_signal_connect (dialog,
"response",
@@ -303,8 +303,8 @@ default_week_dialog_update_labels (DialogData *data)
}
static void
-default_week_dialog_weekday_selected_cb (GtkOptionMenu *option_menu,
- DialogData *data)
+default_week_dialog_weekday_selected_cb (GtkComboBoxText *combotext,
+ DialogData *data)
{
gint weekday;
MrpDay *day;
@@ -381,46 +381,18 @@ default_week_dialog_setup_day_option_menu (GtkOptionMenu *option_menu,
static gint
default_week_dialog_get_selected_weekday (DialogData *data)
{
- GtkWidget *menu;
- GtkWidget *item;
- gint id;
-
- menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (data->weekday_option_menu));
-
- item = gtk_menu_get_active (GTK_MENU (menu));
-
- id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "data"));
-
- return id;
+ return days[gtk_combo_box_get_active (GTK_COMBO_BOX (data->weekday_combobox))].day;
}
static void
-default_week_dialog_setup_weekday_option_menu (GtkOptionMenu *option_menu)
+default_week_dialog_setup_weekday_combobox (GtkComboBoxText *combotext)
{
- GtkWidget *menu;
- GtkWidget *menu_item;
- gint i;
+ gint i;
- menu = gtk_option_menu_get_menu (option_menu);
- if (menu) {
- gtk_widget_destroy (menu);
+ for (i = 0; i < G_N_ELEMENTS(days); i++) {
+ gtk_combo_box_text_append_text (combotext, _(days[i].name));
}
-
- menu = gtk_menu_new ();
-
- for (i = 0; i < 7; i++) {
- menu_item = gtk_menu_item_new_with_label (_(days[i].name));
-
- gtk_widget_show (menu_item);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
-
- g_object_set_data (G_OBJECT (menu_item),
- "data",
- GINT_TO_POINTER (days[i].day));
- }
-
- gtk_widget_show (menu);
- gtk_option_menu_set_menu (option_menu, menu);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (combotext), 0);
}
static MrpDay *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]