コード例 #1
0
GtkWidget *
data_delete_dialog_new (GimpDataFactory *factory,
                        GimpData        *data,
                        GimpContext     *context,
                        GtkWidget       *parent)
{
  DataDeleteDialog *delete_data;
  GtkWidget        *dialog;

  g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), NULL);
  g_return_val_if_fail (GIMP_IS_DATA (data), NULL);
  g_return_val_if_fail (context == NULL || GIMP_IS_CONTEXT (context), NULL);
  g_return_val_if_fail (GTK_IS_WIDGET (parent), NULL);

  delete_data = g_slice_new0 (DataDeleteDialog);

  delete_data->factory = factory;
  delete_data->data    = data;
  delete_data->context = context;
  delete_data->parent  = parent;

  dialog = gimp_message_dialog_new (_("Delete Object"), GTK_STOCK_DELETE,
                                    gtk_widget_get_toplevel (parent), 0,
                                    gimp_standard_help_func, NULL,

                                    GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                    GTK_STOCK_DELETE, GTK_RESPONSE_OK,

                                    NULL);

  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
                                           GTK_RESPONSE_OK,
                                           GTK_RESPONSE_CANCEL,
                                           -1);

  g_signal_connect_object (data, "disconnect",
                           G_CALLBACK (gtk_widget_destroy),
                           dialog, G_CONNECT_SWAPPED);

  g_signal_connect (dialog, "response",
                    G_CALLBACK (data_delete_dialog_response),
                    delete_data);

  gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
                                     _("Delete '%s'?"),
                                     gimp_object_get_name (data));
  gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box,
                             _("Are you sure you want to remove '%s' "
                               "from the list and delete it on disk?"),
                             gimp_object_get_name (data));

  return dialog;
}
コード例 #2
0
void
gimp_data_editor_set_data (GimpDataEditor *editor,
                           GimpData       *data)
{
  g_return_if_fail (GIMP_IS_DATA_EDITOR (editor));
  g_return_if_fail (data == NULL || GIMP_IS_DATA (data));
  g_return_if_fail (data == NULL ||
                    g_type_is_a (G_TYPE_FROM_INSTANCE (data),
                                 gimp_data_factory_get_data_type (editor->data_factory)));

  if (editor->data != data)
    {
      GIMP_DATA_EDITOR_GET_CLASS (editor)->set_data (editor, data);

      g_object_notify (G_OBJECT (editor), "data");

      if (gimp_editor_get_ui_manager (GIMP_EDITOR (editor)))
        gimp_ui_manager_update (gimp_editor_get_ui_manager (GIMP_EDITOR (editor)),
                                gimp_editor_get_popup_data (GIMP_EDITOR (editor)));
    }
}