edit-dialog: update sources when their readonly state changes
This fixes the annoying all-insensitive-menu bug.
This commit is contained in:
+54
-14
@@ -71,6 +71,19 @@ typedef struct
|
|||||||
|
|
||||||
static void fill_sources_menu (GcalEditDialog *dialog);
|
static void fill_sources_menu (GcalEditDialog *dialog);
|
||||||
|
|
||||||
|
static void on_source_activate (GcalManager *manager,
|
||||||
|
ESource *source,
|
||||||
|
gboolean active,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
static void on_source_added (GcalManager *manager,
|
||||||
|
ESource *source,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
static void on_source_removed (GcalManager *manager,
|
||||||
|
ESource *source,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
static void on_calendar_selected (GtkWidget *menu_item,
|
static void on_calendar_selected (GtkWidget *menu_item,
|
||||||
GVariant *value,
|
GVariant *value,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
@@ -117,12 +130,11 @@ fill_sources_menu (GcalEditDialog *dialog)
|
|||||||
GList *aux;
|
GList *aux;
|
||||||
|
|
||||||
priv = gcal_edit_dialog_get_instance_private (dialog);
|
priv = gcal_edit_dialog_get_instance_private (dialog);
|
||||||
|
|
||||||
if (priv->manager == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
list = gcal_manager_get_sources (priv->manager);
|
list = gcal_manager_get_sources (priv->manager);
|
||||||
priv->sources_menu = g_menu_new ();
|
|
||||||
|
/* clear menu */
|
||||||
|
if (priv->sources_menu)
|
||||||
|
g_menu_remove_all (priv->sources_menu);
|
||||||
|
|
||||||
for (aux = list; aux != NULL; aux = aux->next)
|
for (aux = list; aux != NULL; aux = aux->next)
|
||||||
{
|
{
|
||||||
@@ -137,7 +149,7 @@ fill_sources_menu (GcalEditDialog *dialog)
|
|||||||
/* retrieve color */
|
/* retrieve color */
|
||||||
extension = E_SOURCE_SELECTABLE (e_source_get_extension (source, E_SOURCE_EXTENSION_CALENDAR));
|
extension = E_SOURCE_SELECTABLE (e_source_get_extension (source, E_SOURCE_EXTENSION_CALENDAR));
|
||||||
gdk_rgba_parse (&color, e_source_selectable_get_color (E_SOURCE_SELECTABLE (extension)));
|
gdk_rgba_parse (&color, e_source_selectable_get_color (E_SOURCE_SELECTABLE (extension)));
|
||||||
pix = gcal_get_pixbuf_from_color (&color, 16);;
|
pix = gcal_get_pixbuf_from_color (&color, 16);
|
||||||
|
|
||||||
/* menu item */
|
/* menu item */
|
||||||
item = g_menu_item_new (e_source_get_display_name (source), "edit.select_calendar");
|
item = g_menu_item_new (e_source_get_display_name (source), "edit.select_calendar");
|
||||||
@@ -160,11 +172,34 @@ fill_sources_menu (GcalEditDialog *dialog)
|
|||||||
g_object_unref (item);
|
g_object_unref (item);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (priv->sources_button), G_MENU_MODEL (priv->sources_menu));
|
|
||||||
|
|
||||||
g_list_free (list);
|
g_list_free (list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_source_activate (GcalManager *manager,
|
||||||
|
ESource *source,
|
||||||
|
gboolean active,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
fill_sources_menu (GCAL_EDIT_DIALOG (user_data));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_source_added (GcalManager *manager,
|
||||||
|
ESource *source,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
fill_sources_menu (GCAL_EDIT_DIALOG (user_data));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_source_removed (GcalManager *manager,
|
||||||
|
ESource *source,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
fill_sources_menu (GCAL_EDIT_DIALOG (user_data));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_calendar_selected (GtkWidget *menu_item,
|
on_calendar_selected (GtkWidget *menu_item,
|
||||||
GVariant *value,
|
GVariant *value,
|
||||||
@@ -524,6 +559,10 @@ gcal_edit_dialog_constructed (GObject* object)
|
|||||||
|
|
||||||
g_action_map_add_action (G_ACTION_MAP (priv->action_group), G_ACTION (priv->action));
|
g_action_map_add_action (G_ACTION_MAP (priv->action_group), G_ACTION (priv->action));
|
||||||
|
|
||||||
|
/* sources menu */
|
||||||
|
priv->sources_menu = g_menu_new ();
|
||||||
|
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (priv->sources_button), G_MENU_MODEL (priv->sources_menu));
|
||||||
|
|
||||||
/* bind title & symmary */
|
/* bind title & symmary */
|
||||||
g_object_bind_property (priv->summary_entry,
|
g_object_bind_property (priv->summary_entry,
|
||||||
"text",
|
"text",
|
||||||
@@ -841,12 +880,6 @@ gcal_edit_dialog_set_event_data (GcalEditDialog *dialog,
|
|||||||
/* Clear event data */
|
/* Clear event data */
|
||||||
gcal_edit_dialog_clear_data (dialog);
|
gcal_edit_dialog_clear_data (dialog);
|
||||||
|
|
||||||
/* update sources list */
|
|
||||||
if (priv->sources_menu != NULL)
|
|
||||||
g_menu_remove_all (priv->sources_menu);
|
|
||||||
|
|
||||||
fill_sources_menu (dialog);
|
|
||||||
|
|
||||||
/* Load new event data */
|
/* Load new event data */
|
||||||
/* summary */
|
/* summary */
|
||||||
e_cal_component_get_summary (priv->component, &e_summary);
|
e_cal_component_get_summary (priv->component, &e_summary);
|
||||||
@@ -943,6 +976,13 @@ gcal_edit_dialog_set_manager (GcalEditDialog *dialog,
|
|||||||
priv = gcal_edit_dialog_get_instance_private (dialog);
|
priv = gcal_edit_dialog_get_instance_private (dialog);
|
||||||
|
|
||||||
priv->manager = manager;
|
priv->manager = manager;
|
||||||
|
|
||||||
|
g_signal_connect (manager, "source-activate",
|
||||||
|
G_CALLBACK (on_source_activate), dialog);
|
||||||
|
g_signal_connect (manager, "source-added",
|
||||||
|
G_CALLBACK (on_source_added), dialog);
|
||||||
|
g_signal_connect (manager, "source-removed",
|
||||||
|
G_CALLBACK (on_source_removed), dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
ECalComponent*
|
ECalComponent*
|
||||||
|
|||||||
Reference in New Issue
Block a user