void colour_changed(GtkWidget *w, gpointer data)
{
	rgba_t *col = (rgba_t*)data;
	GdkColor gdk_col;

	gtk_color_button_get_color(GTK_COLOR_BUTTON(w), &gdk_col);

	int alpha = (gtk_color_button_get_alpha(GTK_COLOR_BUTTON(w)) / 255);
	if (alpha > 255)
		alpha = 255;

	int red = (gdk_col.red / 255);
	if (red > 255)
		red = 255;

	int green = (gdk_col.green / 255);
	if (green > 255)
		green = 255;

	int blue = (gdk_col.blue / 255);
	if (blue > 255)
		blue = 255;

	//col->set((BYTE)red, (BYTE)green, (BYTE)blue, (BYTE)alpha);
	col->r = (BYTE)red;
	col->g = (BYTE)green;
	col->b = (BYTE)blue;
	col->a = (BYTE)alpha;

	force_map_redraw(true, true);
}
static void
gtk_color_button_get_property (GObject    *object,
			       guint       param_id,
			       GValue     *value,
			       GParamSpec *pspec)
{
  GtkColorButton *color_button = GTK_COLOR_BUTTON (object);
  GdkColor color;

  switch (param_id) 
    {
    case PROP_USE_ALPHA:
      g_value_set_boolean (value, gtk_color_button_get_use_alpha (color_button));
      break;
    case PROP_TITLE:
      g_value_set_string (value, gtk_color_button_get_title (color_button));
      break;
    case PROP_COLOR:
      gtk_color_button_get_color (color_button, &color);
      g_value_set_boxed (value, &color);
      break;
    case PROP_ALPHA:
      g_value_set_uint (value, gtk_color_button_get_alpha (color_button));
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
      break;
    }
}
void
global_config_save(FILE *fp)
{
    GdkColor c;

    fprintf(fp, "# fbpanel <profile> config file\n");
    fprintf(fp, "# see http://fbpanel.sf.net/docs.html for complete configuration guide\n");
    fprintf(fp, "\n\n");
    fprintf(fp, "Global {\n");
    fprintf(fp, "    edge = %s\n",
            num2str(edge_pair, gtk_combo_box_get_active(GTK_COMBO_BOX(edge_opt)) + 1, "none"));
    fprintf(fp, "    allign = %s\n",
            num2str(allign_pair, gtk_combo_box_get_active(GTK_COMBO_BOX(allign_opt)) + 1, "none"));
    fprintf(fp, "    margin = %d\n", (int) margin_adj->value);
    fprintf(fp, "    widthtype = %s\n",
            num2str(width_pair, gtk_combo_box_get_active(GTK_COMBO_BOX(width_opt)) + 1, "none"));
    fprintf(fp, "    width = %d\n", (int) width_adj->value);
    fprintf(fp, "    height = %d\n", (int) height_adj->value);
    fprintf(fp, "    transparent = %s\n",
            num2str(bool_pair, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(tr_checkb)), "false"));
    gtk_color_button_get_color(GTK_COLOR_BUTTON(tr_colorb), &c);
    fprintf(fp, "    tintcolor = #%06x\n", gcolor2rgb24(&c));
    fprintf(fp, "    alpha = %d\n", gtk_color_button_get_alpha(GTK_COLOR_BUTTON(tr_colorb)) * 0xff / 0xffff);
    fprintf(fp, "    setdocktype = %s\n",
            num2str(bool_pair, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(prop_dt_checkb)), "true"));
    fprintf(fp, "    setpartialstrut = %s\n",
            num2str(bool_pair, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(prop_st_checkb)), "true"));

    fprintf(fp, "}\n\n");
}
Example #4
0
PRIVATE void propgen(Component *c, Generator *g) {
  Data *data = g->data;

    GtkWidget *dialog, *vbox2, *color1; //, *color2; //*type;

    dialog = gtk_dialog_new_with_buttons( "GL Cube Properties",  gui_get_mesh_window(), GTK_DIALOG_DESTROY_WITH_PARENT,
	    "Oki", GTK_RESPONSE_OK, "Not Now", GTK_RESPONSE_CANCEL, NULL );

    vbox2 = gtk_vbox_new( FALSE, 10 );
    color1 = g_object_new( GTK_TYPE_COLOR_BUTTON, "color", &(data->cube_color), "title", "cube_color", "use-alpha", TRUE, "alpha", data->cube_alpha, NULL );


    gtk_container_add( GTK_CONTAINER( vbox2 ), color1 );
    
    gtk_container_add( GTK_CONTAINER( GTK_DIALOG( dialog )->vbox ), vbox2 );
    gtk_widget_show_all( dialog );

    gint response = gtk_dialog_run( GTK_DIALOG(dialog) );
    if( response != GTK_RESPONSE_CANCEL ) {
	gtk_color_button_get_color( GTK_COLOR_BUTTON(color1), &(data->cube_color) );
	data->cube_alpha = gtk_color_button_get_alpha( GTK_COLOR_BUTTON(color1) );
    }

    
    gtk_widget_destroy( dialog );

}
Example #5
0
/**
 * Print the color currently selected by a color button.
 * @param color_button color button to print information about
 */
void mk_print_GtkColorButton_info(GtkColorButton* color_button)
{
    GdkColor color;
    gtk_color_button_get_color(color_button, &color);
    guint16 alpha = gtk_color_button_get_alpha(color_button);

    g_printf("\t%d,%d,%d,%d",
             color.red, color.green, color.blue, alpha);
}
Example #6
0
/* Handler for "color-set" signal on Background Color color button. */
static void preferences_dialog_background_color_set_event(GtkColorButton * widget, Setting * setting)
{
    gtk_color_button_get_color(widget, &setting->background_color);
    setting->background_alpha = gtk_color_button_get_alpha(widget);

    if (setting->background_alpha == 0)
    {
        setting->background_alpha = 1;
    }
}
Example #7
0
void widget_colorbutton_save(variable *var)
{
	FILE             *outfile;
	GdkColor          color;
	GList            *element;
	gchar            *act;
	gchar            *filename = NULL;

#ifdef DEBUG_TRANSITS
	fprintf(stderr, "%s(): Entering.\n", __func__);
#endif

	/* We'll use the output file filename if available */
	act = attributeset_get_first(&element, var->Attributes, ATTR_OUTPUT);
	while (act) {
		if (strncasecmp(act, "file:", 5) == 0 && strlen(act) > 5) {
			filename = act + 5;
			break;
		}
		act = attributeset_get_next(&element, var->Attributes, ATTR_OUTPUT);
	}

	/* If we have a valid filename then open it and dump the
	 * widget's data to it */
	if (filename) {
		if ((outfile = fopen(filename, "w"))) {
			gtk_color_button_get_color(GTK_COLOR_BUTTON(var->Widget), &color);
			if (gtk_color_button_get_use_alpha(GTK_COLOR_BUTTON(var->Widget))) {
				fprintf(outfile, "#%02x%02x%02x|%u",
					(color.red + 257 / 2) / 257,
					(color.green + 257 / 2) / 257,
					(color.blue + 257 / 2) / 257,
					gtk_color_button_get_alpha(GTK_COLOR_BUTTON(var->Widget)));

			} else {
				fprintf(outfile, "#%02x%02x%02x",
					(color.red + 257 / 2) / 257,
					(color.green + 257 / 2) / 257,
					(color.blue + 257 / 2) / 257);
			}
			/* Close the file */
			fclose(outfile);
		} else {
			fprintf(stderr, "%s(): Couldn't open '%s' for writing.\n",
				__func__, filename);
		}
	} else {
		fprintf(stderr, "%s(): No <output file> directive found.\n", __func__);
	}

#ifdef DEBUG_TRANSITS
	fprintf(stderr, "%s(): Exiting.\n", __func__);
#endif
}
Example #8
0
int
clip_GTK_COLORBUTTONGETALPHA(ClipMachine * cm)
{
	C_widget *cbtn = _fetch_cw_arg(cm);

	CHECKCWID(cbtn,GTK_IS_COLOR_BUTTON);

	_clip_retni(cm, gtk_color_button_get_alpha(GTK_COLOR_BUTTON(cbtn->widget)));

	return 0;
err:
	return 1;
}
Example #9
0
File: gconf.c Project: g7/fbpanel
/*********************************************************
 * Edit color
 *********************************************************/
static void
gconf_edit_color_cb(GtkColorButton *w, xconf *xc)
{
    GdkColor c;
    xconf *xc_alpha;

    gtk_color_button_get_color(GTK_COLOR_BUTTON(w), &c);
    xconf_set_value(xc, gdk_color_to_RRGGBB(&c));
    if ((xc_alpha = g_object_get_data(G_OBJECT(w), "alpha")))
    {
        guint16 a = gtk_color_button_get_alpha(GTK_COLOR_BUTTON(w));
        a >>= 8;
        xconf_set_int(xc_alpha, (int) a);
    }
Example #10
0
void bimp_resize_save(resize_settings orig_settings) 
{    
    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio_size_percent))) {
        orig_settings->resize_mode = RESIZE_PERCENT;
        orig_settings->new_w_pc = gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin_width));
        orig_settings->new_h_pc = gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin_height));
        orig_settings->new_w_px = last_pixel_w_value;
        orig_settings->new_h_px = last_pixel_h_value;
    }
    else {
        int combo_manualsize_sel = gtk_combo_box_get_active(GTK_COMBO_BOX(combo_manualsize));        
        if (combo_manualsize_sel == 1) orig_settings->resize_mode = RESIZE_PIXEL_WIDTH;
        else if (combo_manualsize_sel == 2) orig_settings->resize_mode = RESIZE_PIXEL_HEIGHT;
        else orig_settings->resize_mode = RESIZE_PIXEL_BOTH;
        
        orig_settings->new_w_pc = last_percent_w_value;
        orig_settings->new_h_pc = last_percent_h_value;
        orig_settings->new_w_px = gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin_width));
        orig_settings->new_h_px = gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin_height));
    }
    
    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio_stretch_aspect))) orig_settings->stretch_mode = STRETCH_ASPECT;
    else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio_stretch_padded))) orig_settings->stretch_mode = STRETCH_PADDED;
    else orig_settings->stretch_mode = STRETCH_ALLOW;
    
    gtk_color_button_get_color(GTK_COLOR_BUTTON(chooser_paddingcolor), &(orig_settings->padding_color));
    orig_settings->padding_color_alpha = gtk_color_button_get_alpha(GTK_COLOR_BUTTON(chooser_paddingcolor));
    
    int interpolation = gtk_combo_box_get_active(GTK_COMBO_BOX(combo_quality));
    if (interpolation == 1) {
        orig_settings->interpolation = GIMP_INTERPOLATION_LINEAR;
    }
    else if (interpolation == 2) {
        orig_settings->interpolation = GIMP_INTERPOLATION_CUBIC;
    }
    else if (interpolation == 3) {
        orig_settings->interpolation = GIMP_INTERPOLATION_LANCZOS;
    }
    else {
        orig_settings->interpolation = GIMP_INTERPOLATION_NONE;
    }
    
    orig_settings->change_res = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_resolution));
    orig_settings->new_res_x = gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin_resX));
    orig_settings->new_res_y = gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin_resY));
}
Example #11
0
static void
gtk_color_button_get_property (GObject    *object,
                               guint       param_id,
                               GValue     *value,
                               GParamSpec *pspec)
{
  GtkColorButton *button = GTK_COLOR_BUTTON (object);

  switch (param_id)
    {
    case PROP_USE_ALPHA:
      g_value_set_boolean (value, gtk_color_button_get_use_alpha (button));
      break;
    case PROP_TITLE:
      g_value_set_string (value, gtk_color_button_get_title (button));
      break;
    case PROP_COLOR:
      {
        GdkColor color;
        GdkRGBA rgba;

        gtk_color_button_get_rgba (button, &rgba);

        color.red = (guint16) (rgba.red * 65535 + 0.5);
        color.green = (guint16) (rgba.green * 65535 + 0.5);
        color.blue = (guint16) (rgba.blue * 65535 + 0.5);

        g_value_set_boxed (value, &color);
      }
      break;
    case PROP_ALPHA:
      g_value_set_uint (value, gtk_color_button_get_alpha (button));
      break;
    case PROP_RGBA:
      {
        GdkRGBA rgba;

        gtk_color_button_get_rgba (button, &rgba);
        g_value_set_boxed (value, &rgba);
      }
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
      break;
    }
}
Example #12
0
gchar *widget_colorbutton_envvar_construct(GtkWidget *widget)
{
	GdkColor          color;
	gchar             envvar[32];
	gchar            *string;

#ifdef DEBUG_TRANSITS
	fprintf(stderr, "%s(): Entering.\n", __func__);
#endif

	gtk_color_button_get_color(GTK_COLOR_BUTTON(widget), &color);

#ifdef DEBUG_CONTENT
	fprintf(stderr, "%s(): color.red  =#%04x  rgb=%02x\n", __func__,
		color.red, (color.red + 257 / 2) / 257);
	fprintf(stderr, "%s(): color.green=#%04x  rgb=%02x\n", __func__,
		color.green, (color.green + 257 / 2) / 257);
	fprintf(stderr, "%s(): color.blue =#%04x  rgb=%02x\n", __func__,
		color.blue, (color.blue + 257 / 2) / 257);
#endif

	if (gtk_color_button_get_use_alpha(GTK_COLOR_BUTTON(widget))) {
		sprintf(envvar, "#%02x%02x%02x|%u",
			(color.red + 257 / 2) / 257,
			(color.green + 257 / 2) / 257,
			(color.blue + 257 / 2) / 257,
			gtk_color_button_get_alpha(GTK_COLOR_BUTTON(widget)));

	} else {
		sprintf(envvar, "#%02x%02x%02x",
			(color.red + 257 / 2) / 257,
			(color.green + 257 / 2) / 257,
			(color.blue + 257 / 2) / 257);
	}

	string = g_strdup(envvar);

#ifdef DEBUG_TRANSITS
	fprintf(stderr, "%s(): Exiting.\n", __func__);
#endif

	return string;
}
void
on_button_config (GtkMenuItem *menuitem, gpointer user_data)
{
    GtkWidget *waveform_properties;
    GtkWidget *config_dialog;
    GtkWidget *vbox01;
    GtkWidget *color_label;
    GtkWidget *color_frame;
    GtkWidget *color_table;
    GtkWidget *color_background_label;
    GtkWidget *background_color;
    GtkWidget *color_waveform_label;
    GtkWidget *foreground_color;
    GtkWidget *color_rms_label;
    GtkWidget *foreground_rms_color;
    GtkWidget *color_progressbar_label;
    GtkWidget *progressbar_color;
    GtkWidget *downmix_to_mono;
    GtkWidget *log_scale;
    GtkWidget *display_rms;
    GtkWidget *display_ruler;
    GtkWidget *style_label;
    GtkWidget *style_frame;
    GtkWidget *vbox02;
    GtkWidget *render_method_spikes;
    GtkWidget *render_method_bars;
    GtkWidget *shade_waveform;
    GtkWidget *fill_waveform;
    GtkWidget *soundcloud_style;
    GtkWidget *dialog_action_area13;
    GtkWidget *applybutton1;
    GtkWidget *cancelbutton1;
    GtkWidget *okbutton1;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
    waveform_properties = gtk_dialog_new ();
    gtk_window_set_transient_for (GTK_WINDOW (waveform_properties), gtk_widget_get_toplevel(menuitem));
    gtk_window_set_title (GTK_WINDOW (waveform_properties), "Waveform Properties");
    gtk_window_set_type_hint (GTK_WINDOW (waveform_properties), GDK_WINDOW_TYPE_HINT_DIALOG);

    config_dialog = gtk_dialog_get_content_area (GTK_DIALOG (waveform_properties));
    gtk_widget_show (config_dialog);

    vbox01 = gtk_vbox_new (FALSE, 8);
    gtk_widget_show (vbox01);
    gtk_box_pack_start (GTK_BOX (config_dialog), vbox01, FALSE, FALSE, 0);
    gtk_container_set_border_width (GTK_CONTAINER (vbox01), 12);

    color_label = gtk_label_new (NULL);
    gtk_label_set_markup (GTK_LABEL (color_label),"<b>Colors</b>");
    gtk_widget_show (color_label);

    color_frame = gtk_frame_new ("Colors");
    gtk_frame_set_label_widget ((GtkFrame *)color_frame, color_label);
    gtk_frame_set_shadow_type ((GtkFrame *)color_frame, GTK_SHADOW_IN);
    gtk_widget_show (color_frame);
    gtk_box_pack_start (GTK_BOX (vbox01), color_frame, TRUE, FALSE, 0);

    color_table = gtk_table_new (2, 4, TRUE);
    gtk_widget_show (color_table);
    gtk_container_add (GTK_CONTAINER (color_frame), color_table);
    gtk_table_set_col_spacings ((GtkTable *) color_table, 8);
    gtk_container_set_border_width (GTK_CONTAINER (color_table), 6);

    color_background_label = gtk_label_new ("Background");
    gtk_widget_show (color_background_label);
    gtk_table_attach_defaults ((GtkTable *) color_table, color_background_label, 0,1,0,1);

    color_waveform_label = gtk_label_new ("Waveform");
    gtk_widget_show (color_waveform_label);
    gtk_table_attach_defaults ((GtkTable *) color_table, color_waveform_label, 1,2,0,1);

    color_rms_label = gtk_label_new ("RMS");
    gtk_widget_show (color_rms_label);
    gtk_table_attach_defaults ((GtkTable *) color_table, color_rms_label, 2,3,0,1);

    color_progressbar_label = gtk_label_new ("Progressbar");
    gtk_widget_show (color_progressbar_label);
    gtk_table_attach_defaults ((GtkTable *) color_table, color_progressbar_label, 3,4,0,1);

    background_color = gtk_color_button_new ();
    gtk_color_button_set_use_alpha ((GtkColorButton *)background_color, TRUE);
    gtk_widget_show (background_color);
    gtk_table_attach_defaults ((GtkTable *) color_table, background_color, 0,1,1,2);

    foreground_color = gtk_color_button_new ();
    gtk_color_button_set_use_alpha ((GtkColorButton *)foreground_color, TRUE);
    gtk_widget_show (foreground_color);
    gtk_table_attach_defaults ((GtkTable *) color_table, foreground_color, 1,2,1,2);

    foreground_rms_color = gtk_color_button_new ();
    gtk_color_button_set_use_alpha ((GtkColorButton *)foreground_rms_color, TRUE);
    gtk_widget_show (foreground_rms_color);
    gtk_table_attach_defaults ((GtkTable *) color_table, foreground_rms_color, 2,3,1,2);

    progressbar_color = gtk_color_button_new ();
    gtk_color_button_set_use_alpha ((GtkColorButton *)progressbar_color, TRUE);
    gtk_widget_show (progressbar_color);
    gtk_table_attach_defaults ((GtkTable *) color_table, progressbar_color, 3,4,1,2);

    style_label = gtk_label_new (NULL);
    gtk_label_set_markup (GTK_LABEL (style_label),"<b>Style</b>");
    gtk_widget_show (style_label);

    style_frame = gtk_frame_new ("Style");
    gtk_frame_set_label_widget ((GtkFrame *)style_frame, style_label);
    gtk_frame_set_shadow_type ((GtkFrame *)style_frame, GTK_SHADOW_IN);
    gtk_widget_show (style_frame);
    gtk_box_pack_start (GTK_BOX (vbox01), style_frame, FALSE, FALSE, 0);

    vbox02 = gtk_vbox_new (FALSE, 6);
    gtk_widget_show (vbox02);
    gtk_container_add (GTK_CONTAINER (style_frame), vbox02);

    render_method_spikes = gtk_radio_button_new_with_label (NULL, "Spikes");
    gtk_widget_show (render_method_spikes);
    gtk_box_pack_start (GTK_BOX (vbox02), render_method_spikes, TRUE, TRUE, 0);

    render_method_bars = gtk_radio_button_new_with_label_from_widget ((GtkRadioButton *)render_method_spikes, "Bars");
    gtk_widget_show (render_method_bars);
    gtk_box_pack_start (GTK_BOX (vbox02), render_method_bars, TRUE, TRUE, 0);

    fill_waveform = gtk_check_button_new_with_label ("Fill waveform");
    gtk_widget_show (fill_waveform);
    gtk_box_pack_start (GTK_BOX (vbox02), fill_waveform, TRUE, TRUE, 0);

    soundcloud_style = gtk_check_button_new_with_label ("Soundcloud style");
    gtk_widget_show (soundcloud_style);
    gtk_box_pack_start (GTK_BOX (vbox02), soundcloud_style, TRUE, TRUE, 0);

    shade_waveform = gtk_check_button_new_with_label ("Shade waveform");
    gtk_widget_show (shade_waveform);
    gtk_box_pack_start (GTK_BOX (vbox02), shade_waveform, TRUE, TRUE, 0);

    downmix_to_mono = gtk_check_button_new_with_label ("Downmix to mono");
    gtk_widget_show (downmix_to_mono);
    gtk_box_pack_start (GTK_BOX (vbox01), downmix_to_mono, FALSE, FALSE, 0);

    log_scale = gtk_check_button_new_with_label ("Logarithmic scale");
    gtk_widget_show (log_scale);
    gtk_box_pack_start (GTK_BOX (vbox01), log_scale, FALSE, FALSE, 0);

    display_rms = gtk_check_button_new_with_label ("Display RMS");
    gtk_widget_show (display_rms);
    gtk_box_pack_start (GTK_BOX (vbox01), display_rms, FALSE, FALSE, 0);

    display_ruler = gtk_check_button_new_with_label ("Display Ruler");
    gtk_widget_show (display_ruler);
    gtk_box_pack_start (GTK_BOX (vbox01), display_ruler, FALSE, FALSE, 0);

    dialog_action_area13 = gtk_dialog_get_action_area (GTK_DIALOG (waveform_properties));
    gtk_widget_show (dialog_action_area13);
    gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area13), GTK_BUTTONBOX_END);

    applybutton1 = gtk_button_new_from_stock ("gtk-apply");
    gtk_widget_show (applybutton1);
    gtk_dialog_add_action_widget (GTK_DIALOG (waveform_properties), applybutton1, GTK_RESPONSE_APPLY);
    gtk_widget_set_can_default (applybutton1, TRUE);

    cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel");
    gtk_widget_show (cancelbutton1);
    gtk_dialog_add_action_widget (GTK_DIALOG (waveform_properties), cancelbutton1, GTK_RESPONSE_CANCEL);
    gtk_widget_set_can_default (cancelbutton1, TRUE);

    okbutton1 = gtk_button_new_from_stock ("gtk-ok");
    gtk_widget_show (okbutton1);
    gtk_dialog_add_action_widget (GTK_DIALOG (waveform_properties), okbutton1, GTK_RESPONSE_OK);
    gtk_widget_set_can_default (okbutton1, TRUE);

    gtk_color_button_set_color (GTK_COLOR_BUTTON (background_color), &CONFIG_BG_COLOR);
    gtk_color_button_set_color (GTK_COLOR_BUTTON (foreground_color), &CONFIG_FG_COLOR);
    gtk_color_button_set_color (GTK_COLOR_BUTTON (progressbar_color), &CONFIG_PB_COLOR);
    gtk_color_button_set_color (GTK_COLOR_BUTTON (foreground_rms_color), &CONFIG_FG_RMS_COLOR);
    gtk_color_button_set_alpha (GTK_COLOR_BUTTON (background_color), CONFIG_BG_ALPHA);
    gtk_color_button_set_alpha (GTK_COLOR_BUTTON (foreground_color), CONFIG_FG_ALPHA);
    gtk_color_button_set_alpha (GTK_COLOR_BUTTON (progressbar_color), CONFIG_PB_ALPHA);
    gtk_color_button_set_alpha (GTK_COLOR_BUTTON (foreground_rms_color), CONFIG_FG_RMS_ALPHA);

    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (downmix_to_mono), CONFIG_MIX_TO_MONO);
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (log_scale), CONFIG_LOG_ENABLED);
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (display_rms), CONFIG_DISPLAY_RMS);
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (display_ruler), CONFIG_DISPLAY_RULER);
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shade_waveform), CONFIG_SHADE_WAVEFORM);
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (soundcloud_style), CONFIG_SOUNDCLOUD_STYLE);
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fill_waveform), CONFIG_FILL_WAVEFORM);

    gtk_widget_set_sensitive (display_rms, !CONFIG_SOUNDCLOUD_STYLE);

    switch (CONFIG_RENDER_METHOD) {
    case SPIKES:
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (render_method_spikes), TRUE);
        break;
    case BARS:
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (render_method_bars), TRUE);
        break;
    }

    for (;;) {
        int response = gtk_dialog_run (GTK_DIALOG (waveform_properties));
        if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY) {
            gtk_color_button_get_color (GTK_COLOR_BUTTON (background_color), &CONFIG_BG_COLOR);
            gtk_color_button_get_color (GTK_COLOR_BUTTON (foreground_color), &CONFIG_FG_COLOR);
            gtk_color_button_get_color (GTK_COLOR_BUTTON (progressbar_color), &CONFIG_PB_COLOR);
            gtk_color_button_get_color (GTK_COLOR_BUTTON (foreground_rms_color), &CONFIG_FG_RMS_COLOR);
            CONFIG_BG_ALPHA = gtk_color_button_get_alpha (GTK_COLOR_BUTTON (background_color));
            CONFIG_FG_ALPHA = gtk_color_button_get_alpha (GTK_COLOR_BUTTON (foreground_color));
            CONFIG_PB_ALPHA = gtk_color_button_get_alpha (GTK_COLOR_BUTTON (progressbar_color));
            CONFIG_FG_RMS_ALPHA = gtk_color_button_get_alpha (GTK_COLOR_BUTTON (foreground_rms_color));
            CONFIG_MIX_TO_MONO = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (downmix_to_mono));
            CONFIG_LOG_ENABLED = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (log_scale));
            CONFIG_DISPLAY_RMS = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (display_rms));
            CONFIG_DISPLAY_RULER = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (display_ruler));
            CONFIG_SHADE_WAVEFORM = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (shade_waveform));
            CONFIG_SOUNDCLOUD_STYLE = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (soundcloud_style));
            CONFIG_FILL_WAVEFORM = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fill_waveform));
            gtk_widget_set_sensitive (display_rms, !CONFIG_SOUNDCLOUD_STYLE);
            if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (render_method_spikes)) == TRUE) {
                CONFIG_RENDER_METHOD = SPIKES;
            }
            else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (render_method_bars)) == TRUE) {
                CONFIG_RENDER_METHOD = BARS;
            }
            save_config ();
            deadbeef->sendmessage (DB_EV_CONFIGCHANGED, 0, 0, 0);
        }
        if (response == GTK_RESPONSE_APPLY) {
            continue;
        }
        break;
    }
    gtk_widget_destroy (waveform_properties);
#pragma GCC diagnostic pop
    return;
}
Example #14
0
static void termomix_color_dialog (GtkWidget *widget, void *data) {
    GtkWidget *color_dialog;
    GtkWidget *label1, *label2;
    GtkWidget *buttonfore, *buttonback;
    GtkWidget *hbox_fore, *hbox_back;
    gint response;
    guint16 backalpha;

    color_dialog=gtk_dialog_new_with_buttons(gettext("Select color"),
            GTK_WINDOW(termomix.main_window), GTK_DIALOG_MODAL, GTK_STOCK_CANCEL,
            GTK_RESPONSE_REJECT, GTK_STOCK_APPLY, GTK_RESPONSE_ACCEPT, NULL);

    gtk_dialog_set_default_response(GTK_DIALOG(color_dialog), GTK_RESPONSE_ACCEPT);
    gtk_window_set_modal(GTK_WINDOW(color_dialog), TRUE);
    /* Set style */
    gchar *css = g_strdup_printf (HIG_DIALOG_CSS);
    gtk_css_provider_load_from_data(termomix.provider, css, -1, NULL);
    GtkStyleContext *context = gtk_widget_get_style_context (color_dialog);
    gtk_style_context_add_provider (context, 
            GTK_STYLE_PROVIDER(termomix.provider),
            GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
    g_free(css);

    hbox_fore=gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
    hbox_back=gtk_box_new(FALSE, 12);
    label1=gtk_label_new(gettext("Select foreground color:"));
    label2=gtk_label_new(gettext("Select background color:"));
    buttonfore=gtk_color_button_new_with_color(&termomix.forecolor);
    buttonback=gtk_color_button_new_with_color(&termomix.backcolor);
    /* When the times comes (gtk-3.4) */
    // buttonfore=gtk_color_button_new_with_rgba(&termomix.forecolor);
    // buttonback=gtk_color_button_new_with_rgba(&termomix.backcolor);*/

    /* This rounding sucks...*/
    backalpha = roundf((termomix.opacity_level*65535)/99);
    if (termomix.has_rgba) {
        gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(buttonback), TRUE);
        gtk_color_button_set_alpha(GTK_COLOR_BUTTON(buttonback), backalpha);
    }

    gtk_box_pack_start(GTK_BOX(hbox_fore), label1, FALSE, FALSE, 12);
    gtk_box_pack_end(GTK_BOX(hbox_fore), buttonfore, FALSE, FALSE, 12);
    gtk_box_pack_start(GTK_BOX(hbox_back), label2, FALSE, FALSE, 12);
    gtk_box_pack_end(GTK_BOX(hbox_back), buttonback, FALSE, FALSE, 12);
    gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(color_dialog))), hbox_fore, FALSE, FALSE, 6);
    gtk_box_pack_end(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(color_dialog))), hbox_back, FALSE, FALSE, 6);

    gtk_widget_show_all(gtk_dialog_get_content_area(GTK_DIALOG(color_dialog)));

    response=gtk_dialog_run(GTK_DIALOG(color_dialog));

    if (response==GTK_RESPONSE_ACCEPT) {
        /* TODO: Remove deprecated get_color */
        //gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(color_dialog), &termomix.forecolor);
        //gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(color_dialog), &termomix.backcolor);
        gtk_color_button_get_color(GTK_COLOR_BUTTON(buttonfore), &termomix.forecolor);
        gtk_color_button_get_color(GTK_COLOR_BUTTON(buttonback), &termomix.backcolor);

        if (termomix.has_rgba) {
            backalpha = gtk_color_button_get_alpha(GTK_COLOR_BUTTON(buttonback));
        }

        if (termomix.has_rgba) {
            vte_terminal_set_opacity(VTE_TERMINAL (termomix.term->vte), backalpha);
        }
        vte_terminal_set_colors(VTE_TERMINAL(termomix.term->vte), &termomix.forecolor,
                &termomix.backcolor, termomix.palette, PALETTE_SIZE);

        gchar *cfgtmp;
        cfgtmp = g_strdup_printf("#%02x%02x%02x", termomix.forecolor.red >>8,
                                 termomix.forecolor.green>>8, termomix.forecolor.blue>>8);
        termomix_set_config_string("forecolor", cfgtmp);
        g_free(cfgtmp);

        cfgtmp = g_strdup_printf("#%02x%02x%02x", termomix.backcolor.red >>8,
                                 termomix.backcolor.green>>8, termomix.backcolor.blue>>8);
        termomix_set_config_string("backcolor", cfgtmp);
        g_free(cfgtmp);

        termomix.opacity_level= roundf((backalpha*99)/65535);     /* Opacity value is between 0 and 99 */
        termomix_set_config_integer("opacity_level", termomix.opacity_level);  

    }
Example #15
0
File: main.c Project: hannenz/zebra
static void on_gesture_end(ClutterGestureAction *action, ClutterActor *stage, gpointer data) {
	ClutterActor *new_actor, *texture, *actor;
	gfloat x, y, w, h;
	GError *error = NULL;
	GdkColor color;
	guint16 alpha;
	gint iw = 125;
	gint ih = 126;
	gboolean repeat_x = FALSE;
	gboolean repeat_y = TRUE;
	guint bgr;


	new_actor = tmpRect;

	gtk_color_button_get_color(GTK_COLOR_BUTTON(app.colorpicker), &color);
	alpha = gtk_color_button_get_alpha(GTK_COLOR_BUTTON(app.colorpicker));
	ClutterColor col =  {
		CLAMP(((color.red / 65535.0) * 255), 0, 255),
		CLAMP(((color.green / 65535.0) * 255), 0, 255),
		CLAMP(((color.blue / 65535.0) * 255), 0, 255),
		CLAMP(((alpha / 65535.0) * 255), 0, 255),

	};

	clutter_rectangle_set_color(CLUTTER_RECTANGLE(new_actor), &col);
	clutter_rectangle_set_border_width(CLUTTER_RECTANGLE(new_actor), 0);
	tmpRect = NULL;


	clutter_actor_get_position(new_actor, &x, &y);
	clutter_actor_get_size(new_actor, &w, &h);

	if (background_image_file != NULL){

		texture = clutter_texture_new_from_file(background_image_file, &error);
		if (error != NULL){
			g_print("Loading image failed\n");
			g_error_free(error);
		}
		clutter_actor_set_position(texture, x, y);
		clutter_actor_set_size(texture, w, h);
		clutter_actor_add_child(stage, texture);
		clutter_actor_show(texture);

		bgr = gtk_combo_box_get_active(GTK_COMBO_BOX(app.background_repeat_select));
		switch (bgr){
			case 0:
				repeat_x = repeat_y = FALSE;
				break;
			case 1:
				repeat_x = TRUE; repeat_y = FALSE;
				break;
			case 2:
				repeat_x = FALSE; repeat_y = TRUE;
				break;
			case 3:
				repeat_x = repeat_y = TRUE;
				break;
		}
		clutter_texture_get_base_size(CLUTTER_TEXTURE(texture), &iw, &ih);
		clutter_actor_set_clip(texture, 0, 0, repeat_x ? w : iw, repeat_y ? h : ih);
		clutter_texture_set_sync_size(CLUTTER_TEXTURE(texture), TRUE);
		clutter_texture_set_repeat(CLUTTER_TEXTURE(texture), TRUE, TRUE);
		clutter_texture_set_keep_aspect_ratio(CLUTTER_TEXTURE(texture), TRUE);
		actor = texture;
		clutter_actor_destroy(new_actor);
	}
	else {
		actor = new_actor;
	}
	tool = TOOL_SELECT;
	clutter_actor_add_action(actor, clutter_drag_action_new());
	clutter_actor_set_reactive(actor, TRUE);
	actors = g_list_append(actors, actor);
	GdkWindow *gdk_window;
	gdk_window = gtk_widget_get_window(app.stage);
	gdk_window_set_cursor(gdk_window, NULL);
}
/* Handler for "color-set" signal on Background Color color button. */
static void preferences_dialog_background_color_set_event(GtkColorButton * widget, LXTerminal * terminal)
{
    gtk_color_button_get_color(widget, &terminal->setting->background_color);
    terminal->setting->background_alpha = gtk_color_button_get_alpha(widget);
    terminal_settings_apply_to_all(terminal);
}