Example #1
0
gboolean
alarm_dialog_run (GtkWidget *parent,
                  ECalClient *cal_client,
                  ECalComponentAlarm *alarm)
{
	Dialog dialog;
	GtkWidget *container;
	gint response_id;

	g_return_val_if_fail (alarm != NULL, FALSE);

	dialog.alarm = alarm;
	dialog.cal_client = cal_client;

	dialog.builder = gtk_builder_new ();
	e_load_ui_builder_definition (dialog.builder, "alarm-dialog.ui");

	if (!get_widgets (&dialog)) {
		g_object_unref (dialog.builder);
		return FALSE;
	}

	if (!setup_select_names (&dialog)) {
		g_object_unref (dialog.builder);
		return FALSE;
	}

	init_widgets (&dialog);

	alarm_to_dialog (&dialog);

	gtk_widget_ensure_style (dialog.toplevel);

	container = gtk_dialog_get_action_area (GTK_DIALOG (dialog.toplevel));
	gtk_container_set_border_width (GTK_CONTAINER (container), 12);

	container = gtk_dialog_get_content_area (GTK_DIALOG (dialog.toplevel));
	gtk_container_set_border_width (GTK_CONTAINER (container), 0);

	gtk_window_set_icon_name (
		GTK_WINDOW (dialog.toplevel), "x-office-calendar");

	gtk_window_set_transient_for (
		GTK_WINDOW (dialog.toplevel),
		GTK_WINDOW (parent));

	response_id = gtk_dialog_run (GTK_DIALOG (dialog.toplevel));

	if (response_id == GTK_RESPONSE_OK)
		dialog_to_alarm (&dialog);

	if (dialog.name_selector) {
		e_name_selector_cancel_loading (dialog.name_selector);
		g_object_unref (dialog.name_selector);
	}
	gtk_widget_destroy (dialog.toplevel);
	g_object_unref (dialog.builder);

	return response_id == GTK_RESPONSE_OK ? TRUE : FALSE;
}
Example #2
0
gboolean
alarm_dialog_run (GtkWidget *parent, ECal *ecal, ECalComponentAlarm *alarm)
{
    Dialog dialog;
    int response_id;
    GList *icon_list;
    char *gladefile;

    g_return_val_if_fail (alarm != NULL, FALSE);

    dialog.alarm = alarm;
    dialog.ecal = ecal;

    gladefile = g_build_filename (EVOLUTION_GLADEDIR,
                                  "alarm-dialog.glade",
                                  NULL);
    dialog.xml = glade_xml_new (gladefile, NULL, NULL);
    g_free (gladefile);
    if (!dialog.xml) {
        g_message (G_STRLOC ": Could not load the Glade XML file!");
        return FALSE;
    }

    if (!get_widgets (&dialog)) {
        g_object_unref(dialog.xml);
        return FALSE;
    }

    if (!setup_select_names (&dialog)) {
        g_object_unref (dialog.xml);
        return FALSE;
    }

    init_widgets (&dialog);

    alarm_to_dialog (&dialog);

    gtk_widget_ensure_style (dialog.toplevel);
    gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog.toplevel)->vbox), 0);
    gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog.toplevel)->action_area), 12);

    icon_list = e_icon_factory_get_icon_list ("stock_calendar");
    if (icon_list) {
        gtk_window_set_icon_list (GTK_WINDOW (dialog.toplevel), icon_list);
        g_list_foreach (icon_list, (GFunc) g_object_unref, NULL);
        g_list_free (icon_list);
    }

    gtk_window_set_transient_for (GTK_WINDOW (dialog.toplevel),
                                  GTK_WINDOW (parent));

    response_id = gtk_dialog_run (GTK_DIALOG (dialog.toplevel));

    if (response_id == GTK_RESPONSE_OK)
        dialog_to_alarm (&dialog);

    gtk_widget_destroy (dialog.toplevel);
    g_object_unref (dialog.xml);

    return response_id == GTK_RESPONSE_OK ? TRUE : FALSE;
}