M!163 - EConfig: Expect GtkGrid instead of GtkTable

Change E_CONFIG_SECTION_TABLE to E_CONFIG_SECTION_GRID as it now expects a GtkGrid.
Also do the same for E_CONFIG_ITEM_TABLE.

Closes: https://gitlab.gnome.org/GNOME/evolution/-/merge_requests/163
This commit is contained in:
Corentin Noël
2025-01-21 13:59:22 +01:00
parent 8408a4ea1a
commit 099c0acdd6
8 changed files with 53 additions and 89 deletions

View File

@ -1240,7 +1240,7 @@
specific order, each containing a number of titled sections in a specific
order, each containing a number of items. The variations are that
the top-level widget may be a GtkNotebook or a GnomeDruid; and each
section may instrument a GtkBox, or a GtkTable. The definition of
section may instrument a GtkBox, or a GtkGrid. The definition of
the available hooks will define what form they take.
</para>
<para>
@ -1283,7 +1283,7 @@
commit="function spec"?
abort="function spec"?>
<item
type="book | druid | page | page_start | page_finish | section | section_table | item"
type="book | druid | page | page_start | page_finish | section | section_grid | item | item_grid"
path="/absolute/path"
label="name" | factory="function spec"
/> *
@ -1492,7 +1492,7 @@
<para>
In this case the plugin has merely added a new section on the
bottom of the HTML Mail settings page. When the factory is called
the plugin has a parent GtkTable (in this case, it could be a VBox)
the plugin has a parent GtkGrid (in this case, it could be a VBox)
and borderless frame already defined, and it just has to
instantiate its own control widgets, add them to the table, and
return one of the widgets. The returned widget is used later if

View File

@ -61,7 +61,7 @@ struct _widget_node {
EConfigItem *item;
GtkWidget *widget; /* widget created by the factory, if any */
GtkWidget *frame; /* if created by us */
GtkWidget *real_frame; /* used for sections and section tables, this is the real GtkFrame (whereas "frame" above is the internal vbox/table) */
GtkWidget *real_frame; /* used for sections and section grids, this is the real GtkFrame (whereas "frame" above is the internal vbox/grid) */
guint empty:1; /* set if empty (i.e. hidden) */
};
@ -358,7 +358,7 @@ ec_rebuild (EConfig *config)
&& sectionnode->frame != NULL
&& (item->type == E_CONFIG_PAGE
|| item->type == E_CONFIG_SECTION
|| item->type == E_CONFIG_SECTION_TABLE)) {
|| item->type == E_CONFIG_SECTION_GRID)) {
if ((sectionnode->empty = (itemno == 0 || n_visible_widgets == 0))) {
if (sectionnode->real_frame)
gtk_widget_hide (sectionnode->real_frame);
@ -477,7 +477,7 @@ ec_rebuild (EConfig *config)
G_CALLBACK (ec_widget_destroyed), wn);
break;
case E_CONFIG_SECTION:
case E_CONFIG_SECTION_TABLE:
case E_CONFIG_SECTION_GRID:
/* The section factory is always called with
* the parent vbox object. Even for assistant pages. */
if (page == NULL) {
@ -522,7 +522,7 @@ ec_rebuild (EConfig *config)
if (section
&& ((item->type == E_CONFIG_SECTION && !GTK_IS_BOX (section))
|| (item->type == E_CONFIG_SECTION_TABLE && !GTK_IS_TABLE (section))))
|| (item->type == E_CONFIG_SECTION_GRID && !GTK_IS_GRID (section))))
g_warning ("EConfig section type is wrong");
} else {
GtkWidget *frame;
@ -549,9 +549,9 @@ ec_rebuild (EConfig *config)
if (item->type == E_CONFIG_SECTION)
section = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
else {
section = gtk_table_new (1, 1, FALSE);
gtk_table_set_col_spacings ((GtkTable *) section, 6);
gtk_table_set_row_spacings ((GtkTable *) section, 6);
section = gtk_grid_new ();
gtk_grid_set_column_spacing (GTK_GRID (section), 6);
gtk_grid_set_row_spacing (GTK_GRID (section), 6);
}
gtk_widget_set_margin_top (section, 6);
@ -583,21 +583,21 @@ ec_rebuild (EConfig *config)
sectionnode = wn;
break;
case E_CONFIG_ITEM:
case E_CONFIG_ITEM_TABLE:
case E_CONFIG_ITEM_GRID:
/* generated sections never retain their widgets on a rebuild */
if (sectionnode && sectionnode->item->factory == NULL)
wn->widget = NULL;
/* ITEMs are called with the section parent.
* The type depends on the section type,
* either a GtkTable, or a GtkVBox */
* either a GtkGrid, or a GtkVBox */
w = NULL;
if (section == NULL) {
wn->widget = NULL;
wn->frame = NULL;
g_warning ("EConfig item has no parent section: %s", item->path);
} else if ((item->type == E_CONFIG_ITEM && !GTK_IS_BOX (section))
|| (item->type == E_CONFIG_ITEM_TABLE && !GTK_IS_TABLE (section)))
|| (item->type == E_CONFIG_ITEM_GRID && !GTK_IS_GRID (section)))
g_warning ("EConfig item parent type is incorrect: %s", item->path);
else if (item->factory)
w = item->factory (
@ -986,9 +986,9 @@ static const EPluginHookTargetKey config_hook_item_types[] = {
{ "page", E_CONFIG_PAGE },
{ "section", E_CONFIG_SECTION },
{ "section_table", E_CONFIG_SECTION_TABLE },
{ "section_grid", E_CONFIG_SECTION_GRID },
{ "item", E_CONFIG_ITEM },
{ "item_table", E_CONFIG_ITEM_TABLE },
{ "item_grid", E_CONFIG_ITEM_GRID },
{ NULL },
};
@ -1150,10 +1150,10 @@ config_hook_section_factory (EConfig *config,
widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
break;
case E_CONFIG_SECTION_TABLE:
widget = gtk_table_new (1, 1, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (widget), 6);
gtk_table_set_row_spacings (GTK_TABLE (widget), 6);
case E_CONFIG_SECTION_GRID:
widget = gtk_grid_new ();
gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
break;
default:
@ -1192,7 +1192,7 @@ config_hook_construct_item (EPluginHook *eph,
item->factory = config_hook_widget_factory;
else if (item->type == E_CONFIG_SECTION)
item->factory = (EConfigItemFactoryFunc) config_hook_section_factory;
else if (item->type == E_CONFIG_SECTION_TABLE)
else if (item->type == E_CONFIG_SECTION_GRID)
item->factory = (EConfigItemFactoryFunc) config_hook_section_factory;
d (printf (" path=%s label=%s factory=%s\n", item->path, item->label, (gchar *) item->user_data));

View File

@ -119,12 +119,12 @@ enum _e_config_target_change_t {
* The content of the section will be a GtkBox. If a factory is used
* then it is up to the factory method to create the section and add
* it to the parent page, and return a GtkBox for following sections.
* @E_CONFIG_SECTION_TABLE: A table section. The same as an
* @E_CONFIG_SECTION but the content object is a GtkTable instead.
* @E_CONFIG_SECTION_GRID: A table section. The same as an
* @E_CONFIG_SECTION but the content object is a GtkGrid instead.
* @E_CONFIG_ITEM: A configuration item. It must have a parent
* section defined in the configuration system.
* @E_CONFIG_ITEM_TABLE: A configuration item with a parent
* @E_CONFIG_SECTION_TABLE.
* @E_CONFIG_ITEM_GRID: A configuration item with a parent
* @E_CONFIG_SECTION_GRID.
*
* A configuration item type for each configuration item added to the
* EConfig object. These are merged from all contributors to the
@ -139,9 +139,9 @@ enum _e_config_t {
E_CONFIG_PAGE,
E_CONFIG_SECTION,
E_CONFIG_SECTION_TABLE,
E_CONFIG_SECTION_GRID,
E_CONFIG_ITEM,
E_CONFIG_ITEM_TABLE /* only allowed in table sections */
E_CONFIG_ITEM_GRID /* only allowed in grid sections */
};
/**

View File

@ -587,8 +587,8 @@ show_config (ECalendarPreferences *prefs)
static ECalConfigItem eccp_items[] = {
{ E_CONFIG_BOOK, (gchar *) "", (gchar *) "toplevel-notebook", calendar_preferences_get_config_widget },
{ E_CONFIG_PAGE, (gchar *) "00.general", (gchar *) "general", calendar_preferences_get_config_widget },
{ E_CONFIG_SECTION_TABLE, (gchar *) "00.general/00.time", (gchar *) "time", calendar_preferences_get_config_widget },
{ E_CONFIG_SECTION_TABLE, (gchar *) "00.general/10.workWeek", (gchar *) "workWeek", calendar_preferences_get_config_widget },
{ E_CONFIG_SECTION_GRID, (gchar *) "00.general/00.time", (gchar *) "time", calendar_preferences_get_config_widget },
{ E_CONFIG_SECTION_GRID, (gchar *) "00.general/10.workWeek", (gchar *) "workWeek", calendar_preferences_get_config_widget },
{ E_CONFIG_SECTION, (gchar *) "00.general/20.alerts", (gchar *) "alerts", calendar_preferences_get_config_widget },
{ E_CONFIG_PAGE, (gchar *) "10.display", (gchar *) "display", calendar_preferences_get_config_widget },
{ E_CONFIG_SECTION, (gchar *) "10.display/00.general", (gchar *) "displayGeneral", calendar_preferences_get_config_widget },

View File

@ -161,16 +161,11 @@
</packing>
</child>
<child>
<object class="GtkTable" id="time">
<object class="GtkGrid" id="time">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="n_rows">4</property>
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkLabel" id="label_second_zone">
<property name="visible">True</property>
@ -181,10 +176,8 @@
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
<child>
@ -221,11 +214,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
@ -237,10 +226,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
@ -253,10 +239,8 @@
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
<child>
@ -270,10 +254,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
@ -284,8 +265,8 @@
<property name="xalign">0</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
@ -328,9 +309,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
@ -398,10 +377,8 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="y_options">GTK_FILL</property>
<property name="width">2</property>
</packing>
</child>
</object>
@ -451,11 +428,9 @@
</packing>
</child>
<child>
<object class="GtkTable" id="workWeek">
<object class="GtkGrid" id="workWeek">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="n_rows">3</property>
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<child>
@ -468,8 +443,8 @@
<property name="xalign">0</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
@ -480,10 +455,8 @@
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
<child>
@ -496,10 +469,8 @@
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
<child>
@ -650,11 +621,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
@ -673,9 +640,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
@ -727,10 +692,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
</object>

View File

@ -1239,7 +1239,7 @@ static EMConfigItem emmp_items[] = {
/* no subvbox for section { E_CONFIG_PAGE, "30.headers/00.headers", "vbox199", emmp_widget_glade }, */
{ E_CONFIG_PAGE, (gchar *) "40.junk", (gchar *) "vboxJunk", emmp_widget_glade },
/* no subvbox for section { E_CONFIG_SECTION, "40.junk/00.general", xxx, emmp_widget_glade } */
{ E_CONFIG_SECTION_TABLE, (gchar *) "40.junk/10.options", (gchar *) "junk-general-grid", emmp_widget_glade },
{ E_CONFIG_SECTION_GRID, (gchar *) "40.junk/10.options", (gchar *) "junk-general-grid", emmp_widget_glade },
};
static void

View File

@ -99,6 +99,7 @@ prefer_plain_page_factory (EPlugin *epl,
return data->old;
check = gtk_check_button_new_with_mnemonic (_("Show s_uppressed HTML parts as attachments"));
gtk_widget_set_halign (check, GTK_ALIGN_START);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), epp_show_suppressed);
gtk_widget_show (check);
g_signal_connect (
@ -118,6 +119,7 @@ prefer_plain_page_factory (EPlugin *epl,
gtk_combo_box_set_model (dropdown, (GtkTreeModel *) store);
/*gtk_combo_box_set_active(dropdown, -1);*/
gtk_combo_box_set_active (dropdown, epp_mode);
gtk_widget_set_hexpand (GTK_WIDGET (dropdown), TRUE);
gtk_widget_show ((GtkWidget *) dropdown);
dropdown_label = gtk_label_new_with_mnemonic (_("HTML _Mode"));
@ -137,13 +139,13 @@ prefer_plain_page_factory (EPlugin *epl,
dropdown, "changed",
G_CALLBACK (epp_mode_changed), info);
g_object_get (data->parent, "n-rows", &i, NULL);
gtk_table_attach ((GtkTable *) data->parent, check, 0, 2, i, i + 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
gtk_table_attach ((GtkTable *) data->parent, dropdown_label, 0, 1, i + 1, i + 2, 0, 0, 0, 0);
gtk_table_attach ((GtkTable *) data->parent, (GtkWidget *) dropdown, 1, 2, i + 1, i + 2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
gtk_table_attach ((GtkTable *) data->parent, info, 1, 2, i + 2, i + 3, GTK_FILL | GTK_EXPAND, 0, 0, 0);
gtk_grid_attach_next_to (GTK_GRID (data->parent), check, NULL, GTK_POS_BOTTOM, 2, 1);
gtk_container_child_get (GTK_CONTAINER (data->parent), check, "top-attach", &i, NULL);
gtk_grid_attach (GTK_GRID (data->parent), dropdown_label, 0, i + 1, 1, 1);
gtk_grid_attach (GTK_GRID (data->parent), (GtkWidget *) dropdown, 1, i + 1, 1, 1);
gtk_grid_attach (GTK_GRID (data->parent), info, 1, i + 2, 1, 1);
/* since this isnt dynamic, we don't need to track each item */
/* since this isn't dynamic, we don't need to track each item */
return (GtkWidget *) dropdown;
}

View File

@ -16,10 +16,10 @@
<group target="prefs" id="org.gnome.evolution.mail.prefs">
<!-- we could also just insert our own items from a section factory, -->
<!-- but then we also need to create our own section frame -->
<item type="section_table" path="10.html/80.mode" _label="Plain Text Mode"/>
<item type="item_table" path="10.html/80.mode/00.mode" factory="prefer_plain_page_factory"/>
<item type="section_grid" path="10.html/80.mode" _label="Plain Text Mode"/>
<item type="item_grid" path="10.html/80.mode/00.mode" factory="prefer_plain_page_factory"/>
</group>
</hook>
</e-plugin>
</e-plugin-list>
</e-plugin-list>