RSS/Atom feed Twitter
Site is read-only, email is disabled

plugin development

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

2 of 2 messages available
Toggle history

Please log in to manage your subscriptions.

plugin development p144a@kabsi.at 31 Dec 14:17
  plugin development Michael Natterer 06 Jan 11:33
p144a@kabsi.at
2017-12-31 14:17:02 UTC (over 6 years ago)

plugin development

Hi!

I am developing a Gimp plugin in C and have a question, but if this is not the right place to ask, please tell me so and accept my apology.

The plugin requires the user to select a color, but i can't figure out the correct way to do it. In lack of better knowledge i am using a field of type GimpRGB for the struct that holds the plugin options and the GimpParamDef in the query() function has an entry that looks like this:   {
    GIMP_PDB_COLOR,
    "inside color",
    "Inside color"
  }

In the run() function i set the color field of the option like this:   options.inside_color = param[ PARAM_INSIDE_COLOR ].data.d_color;

Again in lack of better knowledge, my function that builds the dialog for chosing options uses a GtkColorButton for the user to pick a color and i connect the signal "color_set" in the following way to a callback which is defined like this:

  static void color_set( GtkColorButton *button, gpointer data ) {     gtk_color_button_get_color( button, data );   }

and when building the dialog i connect it like this: g_signal_connect( color_button, "color_set", G_CALLBACK( color_set ), &options.inside_color );

The gimptool compiles my plugin and it is registered and runs as expected in the Gimp.

However, when building the dialog, i try to set the color that was stored in he options from a previous run like this:

  gtk_color_button_set_color( ( GtkColorButton * ) color_button, &options.inside_color );

the gimptool gives me a warning:   expected ‘const struct GdkColor *’ but argument is of type ‘struct GimpRGB *’

When googling for help i read that GdkColor is deprecated?? and i want to ask you for the correct and preferred way of doing this.

Sorry, if what i want is not clear, i am not a native english speaker and i will happily answer if you need more information.

Regards and Thanks, Paul

Michael Natterer
2018-01-06 11:33:51 UTC (over 6 years ago)

plugin development

On Sun, 2017-12-31 at 15:17 +0100, p144a@kabsi.at wrote:

Hi!

I am developing a Gimp plugin in C and have a question, but if this is not
the right place to ask, please tell me so and accept my apology.

The plugin requires the user to select a color, but i can't figure out the
correct way to do it. In lack of better knowledge i am using a field of
type GimpRGB for the struct that holds the plugin options and the GimpParamDef in the query() function has an entry that looks like this:
{
GIMP_PDB_COLOR,
"inside color",
"Inside color"
}

In the run() function i set the color field of the option like this: options.inside_color = param[ PARAM_INSIDE_COLOR ].data.d_color;

Again in lack of better knowledge, my function that builds the dialog for
chosing options uses a GtkColorButton for the user to pick a color and i connect the signal "color_set" in the
following way to a callback which is defined like this:

static void color_set( GtkColorButton *button, gpointer data ) { gtk_color_button_get_color( button, data ); }

and when building the dialog i connect it like this: g_signal_connect( color_button, "color_set", G_CALLBACK( color_set ), &options.inside_color );

The gimptool compiles my plugin and it is registered and runs as expected
in the Gimp.

However, when building the dialog, i try to set the color that was stored
in he options from a previous run like this:

gtk_color_button_set_color( ( GtkColorButton * ) color_button, &options.inside_color );

the gimptool gives me a warning: expected ‘const struct GdkColor *’ but argument is of type ‘struct GimpRGB *’

When googling for help i read that GdkColor is deprecated?? and i want to
ask you for the correct and preferred way of doing this.

You would simply use a GimpColorButton and gimp_color_button_new()

Regards, Mitch