gui/event-editor: Rework calendars menu
Use a GtkListBox and bind from the model. Create rows from the model items, and bind properties as needed. The action target is set only when the calendar is writable because setting an invalid action+target pair makes the row insensitive. Remove the ancient menu icon hack.
This commit is contained in:
@@ -659,75 +659,6 @@ e_utf8_strftime_fix_am_pm (gchar *str,
|
||||
return sz;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* fix_popover_menu_icons:
|
||||
* @window: a #GtkPopover
|
||||
*
|
||||
* Hackish code that inspects the popover's children,
|
||||
* retrieve the hidden GtkImage buried under lots of
|
||||
* widgets, and make it visible again.
|
||||
*
|
||||
* Hopefully, we'll find a better way to do this in
|
||||
* the long run.
|
||||
*
|
||||
*/
|
||||
void
|
||||
fix_popover_menu_icons (GtkPopover *popover)
|
||||
{
|
||||
GtkWidget *popover_stack;
|
||||
GtkWidget *menu_section;
|
||||
GtkWidget *menu_section_box;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *child;
|
||||
|
||||
/* GtkScrolledWindow */
|
||||
widget = gtk_popover_get_child (GTK_POPOVER (popover));
|
||||
|
||||
/* GtkViewport */
|
||||
widget = gtk_scrolled_window_get_child (GTK_SCROLLED_WINDOW (widget));
|
||||
|
||||
/* GtkStack */
|
||||
popover_stack = gtk_viewport_get_child (GTK_VIEWPORT (widget));
|
||||
|
||||
menu_section = gtk_widget_get_first_child (popover_stack);
|
||||
|
||||
/**
|
||||
* Get the unique box's children.
|
||||
*/
|
||||
menu_section_box = gtk_widget_get_first_child (menu_section);
|
||||
|
||||
gtk_widget_add_css_class (menu_section_box, "calendars-list");
|
||||
|
||||
/**
|
||||
* Iterate through the GtkModelButtons inside the menu section box.
|
||||
*/
|
||||
for (child = gtk_widget_get_first_child (menu_section_box);
|
||||
child;
|
||||
child = gtk_widget_get_next_sibling (child))
|
||||
{
|
||||
GtkWidget *child2;
|
||||
|
||||
/**
|
||||
* Since there is no guarantee that the first child is
|
||||
* the GtkImage we're looking for, we have to iterate
|
||||
* through the children and check if the types match.
|
||||
*/
|
||||
for (child2 = gtk_widget_get_first_child (child);
|
||||
child2;
|
||||
child2 = gtk_widget_get_next_sibling (child2))
|
||||
{
|
||||
if (GTK_IS_IMAGE (child2))
|
||||
{
|
||||
gtk_widget_add_css_class (child2, "calendar-color-image");
|
||||
gtk_widget_set_margin_end (child2, 12);
|
||||
gtk_widget_set_visible (child2, TRUE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get_source_parent_name_color:
|
||||
* @manager: a #GcalManager
|
||||
|
||||
@@ -94,9 +94,6 @@ gsize e_utf8_strftime_fix_am_pm (gchar
|
||||
const gchar *fmt,
|
||||
const struct tm *tm);
|
||||
|
||||
void fix_popover_menu_icons (GtkPopover *popover);
|
||||
|
||||
|
||||
void get_source_parent_name_color (GcalManager *manager,
|
||||
ESource *source,
|
||||
gchar **name,
|
||||
|
||||
Reference in New Issue
Block a user