Exemple #1
0
static int gtkDialogSetBackgroundAttrib(Ihandle* ih, const char* value)
{
  if (iupdrvBaseSetBgColorAttrib(ih, value))
  {
    GtkStyle *style = gtk_widget_get_style(ih->handle);
    if (style->bg_pixmap[GTK_STATE_NORMAL])
    {
      style = gtk_style_copy(style);
      style->bg_pixmap[GTK_STATE_NORMAL] = NULL;
      gtk_widget_set_style(ih->handle, style);
    }
    return 1;
  }
  else
  {
    GdkPixbuf* pixbuf = iupImageGetImage(value, ih, 0);
    if (pixbuf)
    {
      GdkPixmap* pixmap;
      GtkStyle *style;

      gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap, NULL, 255);

      style = gtk_style_copy(gtk_widget_get_style(ih->handle));
      style->bg_pixmap[GTK_STATE_NORMAL] = pixmap;
      gtk_widget_set_style(ih->handle, style);

      return 1;
    }
  }

  return 0;
}
Exemple #2
0
/* AW: I pulled this code off the interwebs. It makes background 
 * transparency actually work */
void change_bg(PanelApplet *applet, PanelAppletBackgroundType type,
               GdkColor *color, GdkPixmap *pixmap)
{
  GtkRcStyle *rc_style;
  GtkStyle *style;

  /* reset style */
  gtk_widget_set_style(GTK_WIDGET(applet), NULL);
  rc_style = gtk_rc_style_new();
  gtk_widget_modify_style(GTK_WIDGET(applet), rc_style);
  gtk_rc_style_unref(rc_style);

  switch(type) {
    case PANEL_NO_BACKGROUND:
      break;
    case PANEL_COLOR_BACKGROUND:
      gtk_widget_modify_bg(GTK_WIDGET(applet), GTK_STATE_NORMAL, color);
      break;
    case PANEL_PIXMAP_BACKGROUND:
      style = gtk_style_copy(GTK_WIDGET(applet)->style);

      if(style->bg_pixmap[GTK_STATE_NORMAL])
        g_object_unref(style->bg_pixmap[GTK_STATE_NORMAL]);

      style->bg_pixmap[GTK_STATE_NORMAL] = g_object_ref(pixmap);
      gtk_widget_set_style(GTK_WIDGET(applet), style);
      g_object_unref(style);
      break;
  }
}
void applet_back_change (MyPanelApplet *a, MyPanelAppletBackgroundType type, GdkColor *color, GdkPixmap *pixmap, streamer_applet *applet) {
	// taken from the TrashApplet
	GtkRcStyle *rc_style;
	GtkStyle *style;

	// reset style
	gtk_widget_set_style (GTK_WIDGET(applet->applet), NULL);
	gtk_widget_set_style (GTK_WIDGET(applet->event_box), NULL);
	rc_style = gtk_rc_style_new ();
	gtk_widget_modify_style (GTK_WIDGET(applet->applet), rc_style);
	gtk_widget_modify_style (GTK_WIDGET(applet->event_box), rc_style);
	g_object_unref (rc_style);

	switch (type) {
		case PANEL_COLOR_BACKGROUND:
			gtk_widget_modify_bg (GTK_WIDGET(applet->applet), GTK_STATE_NORMAL, color);
			gtk_widget_modify_bg (GTK_WIDGET(applet->event_box), GTK_STATE_NORMAL, color);
			break;

		case PANEL_PIXMAP_BACKGROUND:
			style = gtk_style_copy (gtk_widget_get_style (GTK_WIDGET(applet->applet)));
			if (style->bg_pixmap[GTK_STATE_NORMAL])
				g_object_unref (style->bg_pixmap[GTK_STATE_NORMAL]);
			style->bg_pixmap[GTK_STATE_NORMAL] = g_object_ref(pixmap);
			gtk_widget_set_style (GTK_WIDGET(applet->applet), style);
			gtk_widget_set_style (GTK_WIDGET(applet->event_box), style);
			g_object_unref (style);
			break;

		case PANEL_NO_BACKGROUND:
		default:
			break;
	}
}
Exemple #4
0
int
clip_GTK_BUTTONSETSTYLE(ClipMachine * ClipMachineMemory)
{
    C_widget *cbtn = _fetch_cw_arg(ClipMachineMemory);

    ClipVar  *mstyle = _clip_spar(ClipMachineMemory, 2);

    GtkStyle *style;

    GtkWidget *wid;

    CHECKCWID(cbtn, GTK_IS_BUTTON);
    CHECKARG(2, MAP_type_of_ClipVarType);
    /*alena - I'm think it is bad idea: wid = GTK_BIN(&(GTK_BUTTON(cbtn->widget)->bin))->child; */
    /* alena - style for button now setting! */
    wid = cbtn->widget;
    style = gtk_style_copy(wid->style);
    //gtk_style_unref(wid->style);
    _map_to_style(ClipMachineMemory, mstyle, style);
    gtk_widget_set_style(wid, style);

    wid = GTK_BIN(&(GTK_BUTTON(cbtn->widget)->bin))->child;
    gtk_widget_set_style(wid, style);
    return 0;
err:
    return 1;
}
Exemple #5
0
void
update_widget_bg(GtkWidget *widget, gchar *img_file)
{       
    GtkStyle *style;     
    GdkPixbuf *pixbuf;       
    GdkPixmap *pixmap;     
    gint width, height;    

    pixbuf = gdk_pixbuf_new_from_file(img_file, NULL);    
    width = gdk_pixbuf_get_width(pixbuf);   
    height = gdk_pixbuf_get_height(pixbuf);    
    pixmap = gdk_pixmap_new(NULL, width, height, 24);   
    gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap, NULL, 0);
    style = gtk_style_copy(GTK_WIDGET (widget)->style);    

    if (style->bg_pixmap[GTK_STATE_NORMAL])        
    g_object_unref(style->bg_pixmap[GTK_STATE_NORMAL]);    

    style->bg_pixmap[GTK_STATE_NORMAL] = g_object_ref(pixmap);    
    style->bg_pixmap[GTK_STATE_ACTIVE] = g_object_ref(pixmap);
    style->bg_pixmap[GTK_STATE_PRELIGHT] = g_object_ref(pixmap);
    style->bg_pixmap[GTK_STATE_SELECTED] = g_object_ref(pixmap);
    style->bg_pixmap[GTK_STATE_INSENSITIVE] = g_object_ref(pixmap);
    gtk_widget_set_style(GTK_WIDGET (widget), style);
    g_object_unref(style);
}
Exemple #6
0
void update_widget_bg(GtkWidget *widget, gchar *img_file)
{
	GtkStyle *style;
	GdkPixbuf *pixbuf;/*缓存文件*/
	GdkPixmap *pixmap;/*表明显示区域*/

	gint width, height;

	pixbuf = gdk_pixbuf_new_from_file(img_file, NULL);/*把文件读到缓存中*/

	width = gdk_pixbuf_get_width(pixbuf);
	height = gdk_pixbuf_get_height(pixbuf);

	pixmap = gdk_pixmap_new(NULL, width, height, 24);/*建立一个显示的区域,以告诉在哪里显示图*/


	gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap, NULL, 0);/*将缓存和显示区域联系*/

	/*设置显示图片构件的相应参数风格*/
	style = gtk_style_copy(GTK_WIDGET (widget)->style);
	if (style->bg_pixmap[GTK_STATE_NORMAL])
		g_object_unref(style->bg_pixmap[GTK_STATE_NORMAL]);

	style->bg_pixmap[GTK_STATE_NORMAL] = g_object_ref(pixmap);
	style->bg_pixmap[GTK_STATE_ACTIVE] = g_object_ref(pixmap);
	style->bg_pixmap[GTK_STATE_PRELIGHT] = g_object_ref(pixmap);
	style->bg_pixmap[GTK_STATE_SELECTED] = g_object_ref(pixmap);
	style->bg_pixmap[GTK_STATE_INSENSITIVE] = g_object_ref(pixmap);

	gtk_widget_set_style(GTK_WIDGET (widget), style);//替代了
	//gtk_widget_modify_style(GTK_WIDGET (widget), style);//直接改,但是style类型不同了
	g_object_unref(style);
}
Exemple #7
0
/*
 * CreateColorfulStyle 
 *
 * Create a style using the colors passed in.  
 * Set the foreground color, the text color and the
 * background color.  Note that this makes all the 
 * states be the same color. 
 *
 * fg - foreground color
 * text - text color
 * bg - background color
 */
GtkStyle *CreateColorfulStyle (GdkColor fg, 
                               GdkColor text, 
                               GdkColor bg)
{
    GtkStyle *defstyle;
    GtkStyle *style;
    int i;

    /* --- Get the default style --- */
    defstyle = gtk_widget_get_default_style ();

    /* --- Make a copy of it. --- */
    style = gtk_style_copy (defstyle);

    /* --- Set the colors for each state --- */
    for (i = 0; i < 5; i++) {

        /* --- Set the colors for the style --- */
        style->fg[i] = fg;
        style->text[i] = text;
        style->bg[i] = bg;
    }

    /* --- All done, here's new style --- */
    return (style);
}
Exemple #8
0
/*
 * CreateFlashyButton
 *
 */
void CreateFlashyButton (GtkWidget *vbox, char *label)
{
    GtkStyle *defstyle;
    GtkStyle *style;

    defstyle = gtk_widget_get_default_style ();
    style = gtk_style_copy (defstyle);

    style->fg[GTK_STATE_NORMAL] = purple;
    style->text[GTK_STATE_NORMAL] = purple;
    style->bg[GTK_STATE_NORMAL] = cyan;

    style->fg[GTK_STATE_PRELIGHT] = green;
    style->text[GTK_STATE_PRELIGHT] = green;
    style->bg[GTK_STATE_PRELIGHT] = blue;

    style->fg[GTK_STATE_ACTIVE] = orange;
    style->text[GTK_STATE_ACTIVE] = orange;
    style->bg[GTK_STATE_ACTIVE] = yellow;

    gtk_widget_push_style (style);

    /* --- Create a new button --- */
    button = gtk_button_new_with_label (label);

    /* --- The main windows contains the button. --- */
    gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

    /* --- Make the button visible --- */
    gtk_widget_show (button);

    /* --- Remove the style so it's not the default style --- */
    gtk_widget_pop_style ();
}
static void override_style(GtkWidget* widget, GtkStyle* previous_style)
{
	GtkStateType state;
	GtkStyle* style;
	GdkColor fg;
	GdkColor bg;

	style = gtk_style_copy(widget->style);

	if (previous_style == NULL || (previous_style != NULL && (previous_style->bg[GTK_STATE_NORMAL].red != style->bg[GTK_STATE_NORMAL].red || previous_style->bg[GTK_STATE_NORMAL].green != style->bg[GTK_STATE_NORMAL].green || previous_style->bg[GTK_STATE_NORMAL].blue != style->bg[GTK_STATE_NORMAL].blue)))
	{
		state = (GtkStateType) 0;

		while (state < (GtkStateType) G_N_ELEMENTS(widget->style->bg))
		{
			color_reverse(&style->bg[state], &bg);
			gtk_widget_modify_bg(widget, state, &bg);
			state++;
		}
	}

	if (previous_style == NULL || (previous_style != NULL && (previous_style->fg[GTK_STATE_NORMAL].red != style->fg[GTK_STATE_NORMAL].red || previous_style->fg[GTK_STATE_NORMAL].green != style->fg[GTK_STATE_NORMAL].green || previous_style->fg[GTK_STATE_NORMAL].blue != style->fg[GTK_STATE_NORMAL].blue)))
	{
		state = (GtkStateType) 0;

		while (state < (GtkStateType) G_N_ELEMENTS(widget->style->fg))
		{
			color_reverse(&style->fg[state], &fg);
			gtk_widget_modify_fg(widget, state, &fg);
			state++;
		}
	}

	g_object_unref(style);
}
Exemple #10
0
/********************************************************************\
 * gnc_set_label_color                                              *
 *   sets the color of the label given the value                    *
 *                                                                  *
 * Args: label - gtk label widget                                   *
 *       value - value to use to set color                          *
 * Returns: none                                                    *
 \*******************************************************************/
void
gnc_set_label_color(GtkWidget *label, gnc_numeric value)
{
    gboolean deficit;
    GdkColormap *cm;
    GtkStyle *style;

    if (!gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED))
        return;

    cm = gtk_widget_get_colormap(GTK_WIDGET(label));
    gtk_widget_ensure_style(GTK_WIDGET(label));
    style = gtk_widget_get_style(GTK_WIDGET(label));

    style = gtk_style_copy(style);

    deficit = gnc_numeric_negative_p (value);

    if (deficit)
    {
        gnc_get_deficit_color(&style->fg[GTK_STATE_NORMAL]);
        gdk_colormap_alloc_color(cm, &style->fg[GTK_STATE_NORMAL], FALSE, TRUE);
    }
    else
        style->fg[GTK_STATE_NORMAL] = style->black;

    gtk_widget_set_style(label, style);

    g_object_unref(style);
}
Exemple #11
0
/* Init function. Here we setup all the gtk stuff */
static GtkWidget *init_fftscope_window()
{
	GtkWidget *fftscope_win;
	GtkStyle *style;
	GdkColor color;
	guint32 colors[129];
	int i;

	pthread_mutex_init(&fftscope_mutex, NULL);

	style = gtk_style_new();
	fftscope_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(fftscope_win), "FFTscope");
	gtk_widget_set_usize(fftscope_win, 256, SCOPE_HEIGHT);
	gtk_window_set_wmclass(GTK_WINDOW(fftscope_win), "FFTscope",
			       "AlsaPlayer");
	gtk_window_set_policy(GTK_WINDOW(fftscope_win), FALSE, FALSE,
			      FALSE);
	style =
	    gtk_style_copy(gtk_widget_get_style(GTK_WIDGET(fftscope_win)));

	color.red = SCOPE_BG_RED << 8;
	color.blue = SCOPE_BG_BLUE << 8;
	color.green = SCOPE_BG_GREEN << 8;
	gdk_color_alloc(gdk_colormap_get_system(), &color);
	gtk_widget_set_style(GTK_WIDGET(fftscope_win), style);

	for (i = 0; i < 32; i++) {
		colors[i * 2] = colors[i * 2 + 1] =
		    ((i * 8) << 16) + (255 << 8);
		colors[i * 2 + 64] = colors[i * 2 + 65] =
		    (255 << 16) + (((31 - i) * 8) << 8);
	}
	colors[128] = 0;
	color_map = gdk_rgb_cmap_new(colors, 129);
	area = gtk_drawing_area_new();
	gtk_container_add(GTK_CONTAINER(fftscope_win), area);
	gtk_widget_realize(area);
	gdk_window_set_background(area->window, &color);

	gtk_widget_show(area);
	gtk_widget_show(fftscope_win);

	/* Signals */

	gtk_signal_connect(GTK_OBJECT(fftscope_win), "delete_event",
			   GTK_SIGNAL_FUNC(close_fftscope_window),
			   fftscope_win);


	/* Clear and show the window */
	gdk_window_clear(fftscope_win->window);
	gdk_flush();

	ready_state = 1;

	return fftscope_win;
}
Exemple #12
0
/*-----------------------------------------------------------------------------------------------------------------------*/
void Start(GtkWidget *W,gpointer Data)
{
gint i;
GtkWidget *Win,*VBox,*HBox,*Label,*But,*Entry;
static GdkColor Black   = {0,0x0000,0x0000,0x0000};
static GdkColor Magenta = {0,0xFFFF,0x0000,0xFFFF};
static GdkColor Gray   = {0,0x8888,0x8888,0x8888};
static GdkColor Blue  =   {0,0x7777,0x7777,0xFFFF};
GtkStyle *Style1,*Style2,*Style3;
 
if (AcqOn) { Attention(100,"Counting is already started"); return; }

Style1=gtk_style_copy(gtk_widget_get_default_style());                                  //Copy default style to this style
for (i=0;i<5;i++) { Style1->fg[i]=Style1->text[i]=Magenta; Style1->bg[i]=Black; }             //Set colours for all states
Style2=gtk_style_copy(gtk_widget_get_default_style());                             //Copy default style to this style
for (i=0;i<5;i++) { Style2->fg[i]=Style2->text[i]=Black; Style2->bg[i]=Blue; }           //Set colours
Style3=gtk_style_copy(gtk_widget_get_default_style());                                             //Copy default style
for (i=0;i<5;i++) { Style3->fg[i]=Style3->text[i]=Black; Style3->bg[i]=Gray; }                   //Set colours

Win=gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_grab_add(Win);                                    //Define a new modal window
gtk_window_set_title(GTK_WINDOW(Win),"Start Counting"); gtk_widget_set_uposition(GTK_WIDGET(Win),300,300);
gtk_widget_set_usize(GTK_WIDGET(Win),245,90); gtk_container_set_border_width(GTK_CONTAINER(Win),10);
VBox=gtk_vbox_new(FALSE,0); gtk_container_add(GTK_CONTAINER(Win),VBox);                       //VBox for the entire window

HBox=gtk_hbox_new(FALSE,10); gtk_box_pack_start(GTK_BOX(VBox),HBox,FALSE,FALSE,5);
Label=gtk_label_new("Run Name:"); gtk_box_pack_start(GTK_BOX(HBox),Label,FALSE,FALSE,5);
Entry=gtk_entry_new_with_max_length(35); gtk_box_pack_start(GTK_BOX(HBox),Entry,FALSE,FALSE,0);
SetStyleRecursively(Entry,Style1);
strcpy(RunName,"mydata"); gtk_entry_set_text(GTK_ENTRY(Entry),RunName);
gtk_widget_set_usize(GTK_WIDGET(Entry),130,25);
gtk_signal_connect(GTK_OBJECT(Entry),"changed",GTK_SIGNAL_FUNC(RunNameCallBack),NULL);

HBox=gtk_hbox_new(FALSE,10); gtk_box_pack_start(GTK_BOX(VBox),HBox,FALSE,FALSE,5);
But=gtk_button_new_with_label("Start"); SetStyleRecursively(But,Style2);
gtk_widget_set_usize(GTK_WIDGET(But),100,25);
gtk_box_pack_start(GTK_BOX(HBox),But,TRUE,FALSE,5);
gtk_signal_connect(GTK_OBJECT(But),"clicked",GTK_SIGNAL_FUNC(StartCallBack),GTK_OBJECT(Win));
But=gtk_button_new_with_label("Cancel"); SetStyleRecursively(But,Style3);
gtk_widget_set_usize(GTK_WIDGET(But),100,25);
gtk_box_pack_start(GTK_BOX(HBox),But,TRUE,FALSE,5);
gtk_signal_connect(GTK_OBJECT(But),"clicked",GTK_SIGNAL_FUNC(CancelCallBack),GTK_OBJECT(Win));
 
gtk_widget_show_all(Win);
gtk_style_unref(Style1); gtk_style_unref(Style2); gtk_style_unref(Style3);
}
Exemple #13
0
/*----------------------------------------------------------------------------------------------------------------------*/
void InitializeFileColours(void)                             //The styles for the file widget open.c are set permanently
{
static GdkColor Red       = {0,0xDDDD,0x0000,0x0000};
static GdkColor Yellow    = {0,0xFFFF,0xFFFF,0xBBBB};
static GdkColor GrYellow  = {0,0xDDDD,0xDDDD,0x7777};
static GdkColor White     = {0,0xFFFF,0xFFFF,0xFFFF};
static GdkColor Black     = {0,0x0000,0x0000,0x0000};
static GdkColor Gray      = {0,0xDDDD,0xDDDD,0xDDDD};

FolderStyle=gtk_style_copy(gtk_widget_get_default_style());
FolderStyle->fg[0]=FolderStyle->text[0]=Black; FolderStyle->bg[0]=White;                                  //Normal
FolderStyle->fg[1]=FolderStyle->text[1]=Black; FolderStyle->bg[1]=Gray;                             //Button press
FolderStyle->fg[2]=FolderStyle->text[2]=Black; FolderStyle->bg[2]=Gray;                                    //Focus
FileStyle=gtk_style_copy(gtk_widget_get_default_style());
FileStyle->fg[0]=FileStyle->text[0]=Red; FileStyle->bg[0]=Yellow;                                          //Normal
FileStyle->fg[1]=FileStyle->text[1]=Red; FileStyle->bg[1]=GrYellow;                                  //Button press
FileStyle->fg[2]=FileStyle->text[2]=Red; FileStyle->bg[2]=GrYellow;                                         //Focus
}
Exemple #14
0
/**
 * Callback to initialize SPSVGSPViewWidget object.
 */
static void sp_svg_view_widget_init(SPSVGSPViewWidget *vw)
{
	SPCanvasItem *parent;

	/* Settings */
	vw->resize = FALSE;
	vw->maxwidth = 400.0;
	vw->maxheight = 400.0;

	/* ScrolledWindow */
	vw->sw = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(vw->sw), GTK_SHADOW_NONE);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (vw->sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_container_add (GTK_CONTAINER (vw), vw->sw);
	gtk_widget_show (vw->sw);

	/* Canvas */
#if !GTK_CHECK_VERSION(3,0,0)
	GdkColormap *cmap = gdk_colormap_get_system();
	gtk_widget_push_colormap(cmap);
#endif

	vw->canvas = SPCanvas::createAA();

#if GTK_CHECK_VERSION(3,0,0)
        GtkCssProvider  *css_provider  = gtk_css_provider_new();
        GtkStyleContext *style_context = gtk_widget_get_style_context(GTK_WIDGET(vw->canvas));

        gtk_css_provider_load_from_data(css_provider,
                                        "SPCanvas {\n"
                                        " background-color: white;\n"
                                        "}\n",
                                        -1, NULL);

        gtk_style_context_add_provider(style_context,
                                       GTK_STYLE_PROVIDER(css_provider),
                                       GTK_STYLE_PROVIDER_PRIORITY_USER);
#else
	gtk_widget_pop_colormap ();
	GtkStyle *style = gtk_style_copy (gtk_widget_get_style (vw->canvas));
	style->bg[GTK_STATE_NORMAL] = style->white;
	gtk_widget_set_style (vw->canvas, style);
#endif

#if GTK_CHECK_VERSION(3,0,0)
	gtk_container_add (GTK_CONTAINER (vw->sw), vw->canvas);
#else
	gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (vw->sw), vw->canvas);
#endif

	gtk_widget_show (vw->canvas);

	/* View */
	parent = sp_canvas_item_new(SP_CANVAS(vw->canvas)->getRoot(), SP_TYPE_CANVAS_GROUP, NULL);
	Inkscape::UI::View::View *view = Inkscape::GC::release(new SPSVGView (SP_CANVAS_GROUP (parent)));
	sp_view_widget_set_view (SP_VIEW_WIDGET (vw), view);
}
Exemple #15
0
uint32_t
wf_get_gtk_base_color(GtkWidget* widget, GtkStateType state, char alpha)
{
	GtkStyle* style = gtk_style_copy(gtk_widget_get_style(widget));
	GdkColor c = style->base[state];
	g_object_unref(style);

	return (wf_color_gdk_to_rgba(&c) & 0xffffff00) | alpha;
}
Exemple #16
0
uint32_t
wf_get_gtk_text_color(GtkWidget* widget, GtkStateType state)
{
	GtkStyle* style = gtk_style_copy(gtk_widget_get_style(widget));
	GdkColor c = style->text[state];
	g_object_unref(style);

	return wf_color_gdk_to_rgba(&c);
}
Exemple #17
0
static void
gwy_color_axis_realize(GtkWidget *widget)
{
    GwyColorAxis *axis;
    GdkWindowAttr attributes;
    gint attributes_mask;
    GtkStyle *s;

    gwy_debug("");

    g_return_if_fail(widget != NULL);
    g_return_if_fail(GWY_IS_COLOR_AXIS(widget));

    GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
    axis = GWY_COLOR_AXIS(widget);

    attributes.x = widget->allocation.x;
    attributes.y = widget->allocation.y;
    attributes.width = widget->allocation.width;
    attributes.height = widget->allocation.height;
    attributes.wclass = GDK_INPUT_OUTPUT;
    attributes.window_type = GDK_WINDOW_CHILD;
    attributes.event_mask = gtk_widget_get_events(widget)
                            | GDK_EXPOSURE_MASK
                            | GDK_BUTTON_PRESS_MASK
                            | GDK_BUTTON_RELEASE_MASK
                            | GDK_POINTER_MOTION_MASK
                            | GDK_POINTER_MOTION_HINT_MASK;
    attributes.visual = gtk_widget_get_visual(widget);
    attributes.colormap = gtk_widget_get_colormap(widget);

    attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
    widget->window = gdk_window_new(gtk_widget_get_parent_window(widget),
                                    &attributes, attributes_mask);
    gdk_window_set_user_data(widget->window, widget);

    widget->style = gtk_style_attach(widget->style, widget->window);

    /*set backgroun for white forever*/
    s = gtk_style_copy(widget->style);
    s->bg_gc[0] =
    s->bg_gc[1] =
    s->bg_gc[2] =
    s->bg_gc[3] =
    s->bg_gc[4] = widget->style->white_gc;
    s->bg[0] =
    s->bg[1] =
    s->bg[2] =
    s->bg[3] =
    s->bg[4] = widget->style->white;

    gtk_style_set_background(s, widget->window, GTK_STATE_NORMAL);

    /*compute axis*/
    gwy_color_axis_update(axis);
}
Exemple #18
0
static void AddStyle(GtkStyle **ppsComb, GtkStyle *psNew)
{
	if (!*ppsComb)
		*ppsComb = psNew;
	else
	{
		*ppsComb = gtk_style_copy(*ppsComb);
		UpdateStyle(*ppsComb, psNew, psGameList);
	}
}
Exemple #19
0
static void set_axis_button_color(GtkObject *button,gpointer *data)
{
	GtkStyle *style = g_object_get_data(G_OBJECT (button), "Style");
	gdouble  *v = g_object_get_data(G_OBJECT (button), "Color");
	GtkWidget *OldButton  = g_object_get_data(G_OBJECT (button), "Button");
  	style =  gtk_style_copy(style); 
  	style->bg[0].red=(gushort)(v[0]*65535.0);
  	style->bg[0].green=(gushort)(v[1]*65535.0);
  	style->bg[0].blue=(gushort)(v[2]*65535.0);
	gtk_widget_set_style(OldButton, style);
}
Exemple #20
0
GtkWidget *newSample(const gchar *fileName)
{
  Context *context = NEW_ARRAY(Context, 1);
  gchar *title;
  GtkWidget *app;
  GtkWidget *area;
  GtkStyle *style;
  int i;

  context->width  = 600;
  context->height = 400;
  context->paragraph = pf_factory(fileName, font, guiSupport);

  title = prettyTitle(fileName);
  app = gnome_app_new("gnomeLayout", title);

  gtk_object_set_data(GTK_OBJECT(app), "context", context);

  gtk_window_set_default_size(GTK_WINDOW(app), 600 - 24, 400);

  gnome_app_create_menus_with_data(GNOME_APP(app), mainMenu, app);

  gtk_signal_connect(GTK_OBJECT(app), "delete_event",
             GTK_SIGNAL_FUNC(eventDelete), NULL);

  area = gtk_drawing_area_new();
  gtk_object_set_data(GTK_OBJECT(app), "area", area);

  style = gtk_style_copy(gtk_widget_get_style(area));

  for (i = 0; i < 5; i += 1) {
    style->fg[i] = style->white;
  }
    
  gtk_widget_set_style(area, style);

  gnome_app_set_contents(GNOME_APP(app), area);

  gtk_signal_connect(GTK_OBJECT(area),
             "expose_event",
             GTK_SIGNAL_FUNC(eventExpose),
             context);

  gtk_signal_connect(GTK_OBJECT(area),
             "configure_event",
             GTK_SIGNAL_FUNC(eventConfigure),
             context);

  appList = g_slist_prepend(appList, app);

  g_free(title);

  return app;
}
Exemple #21
0
static void
set_font(GtkWidget *w, GdkFont *font)
{
    GtkStyle *style;
    
    style = gtk_style_copy(gtk_widget_get_style(w));
    gdk_font_unref(style->font);
    gdk_font_ref(font);
    style->font = font;
    gtk_widget_set_style(w, style);
    gtk_style_unref(style);
}
Exemple #22
0
Fichier : skin.c Projet : XQF/xqf
void set_bg_color (GtkWidget *widget, int color) {
	GtkStyle *style;

	style = gtk_style_copy (widget->style);
	style->bg [GTK_STATE_NORMAL]   = pcolors [color];
	style->bg [GTK_STATE_ACTIVE]   = pcolors [color];
	style->bg [GTK_STATE_PRELIGHT] = pcolors [color];
	style->bg [GTK_STATE_SELECTED] = pcolors [color];
	style->bg [GTK_STATE_INSENSITIVE] = pcolors [color];

	gtk_widget_set_style (widget, style);
}
/* Applet Callback : Change the applet background. */
void
applet_change_bg_cb (MatePanelApplet *mate_panel_applet,
		     MatePanelAppletBackgroundType type,
		     GdkColor *color,
#if GTK_CHECK_VERSION (3, 0, 0)
		     cairo_pattern_t *pattern,
#else
		     GdkPixmap *pixmap,
#endif
		     StickyNotesApplet *applet)
{
#if !GTK_CHECK_VERSION (3, 0, 0)
	/* Taken from TrashApplet */
	GtkRcStyle *rc_style;
	GtkStyle *style;

	if (!applet) g_print ("arrg, no applet!\n");

	/* reset style */
	gtk_widget_set_style (GTK_WIDGET (applet->w_applet), NULL);
	rc_style = gtk_rc_style_new ();
	gtk_widget_modify_style (GTK_WIDGET (applet->w_applet), rc_style);
	g_object_unref (rc_style);

	switch (type)
	{
		case PANEL_NO_BACKGROUND:
			break;
		case PANEL_COLOR_BACKGROUND:
			gtk_widget_modify_bg (GTK_WIDGET (applet->w_applet),
					GTK_STATE_NORMAL, color);
			break;
		case PANEL_PIXMAP_BACKGROUND:
			style = gtk_style_copy (
					gtk_widget_get_style (GTK_WIDGET (applet->w_applet)));
			if (style->bg_pixmap[GTK_STATE_NORMAL])
				g_object_unref (
					style->bg_pixmap[GTK_STATE_NORMAL]);
			style->bg_pixmap[GTK_STATE_NORMAL] = g_object_ref (
					pixmap);
			gtk_widget_set_style (
					GTK_WIDGET (applet->w_applet), style);
			g_object_unref (style);
			break;
	}
#endif
}
static void
update_row (int               row,
	    XSettingsSetting *setting)
{
  char buffer[256];
  GtkStyle *style;
  const char *type;
  
  if (setting->type != XSETTINGS_TYPE_COLOR)
    gtk_clist_set_cell_style (GTK_CLIST (settings_clist),
			      row, VALUE, NULL);

  switch (setting->type)
    {
    case XSETTINGS_TYPE_INT:
      type = "INT";
      sprintf (buffer, "%d", setting->data.v_int);
      gtk_clist_set_text (GTK_CLIST (settings_clist), row, VALUE, buffer);      
      break;
    case XSETTINGS_TYPE_STRING:
      type = "STRING";
      gtk_clist_set_text (GTK_CLIST (settings_clist), row, VALUE, setting->data.v_string);
      break;
    case XSETTINGS_TYPE_COLOR:
      type = "COLOR";
      gtk_clist_set_text (GTK_CLIST (settings_clist), row, VALUE, "");
      style = gtk_style_copy (settings_clist->style);
      style->base[GTK_STATE_NORMAL].red = setting->data.v_color.red;
      style->base[GTK_STATE_NORMAL].green = setting->data.v_color.green;
      style->base[GTK_STATE_NORMAL].blue = setting->data.v_color.blue;
      style->bg[GTK_STATE_SELECTED].red = setting->data.v_color.red;
      style->bg[GTK_STATE_SELECTED].green = setting->data.v_color.green;
      style->bg[GTK_STATE_SELECTED].blue = setting->data.v_color.blue;
      gtk_clist_set_cell_style (GTK_CLIST (settings_clist),
				row, VALUE, style);
      gtk_style_unref (style);
      break;
    default:
      g_assert_not_reached ();
    }

  gtk_clist_set_text (GTK_CLIST (settings_clist), row, TYPE, type);

  sprintf (buffer, "%ld", setting->last_change_serial);
  gtk_clist_set_text (GTK_CLIST (settings_clist), row, SERIAL, buffer);
}
Exemple #25
0
/* This function is called whenever we need to exchange curr_view and
 * other_view.
 */
static void
switch_views()
{
  gint i;
  gint num_cols;
  GtkStyle *style;
  FileView *temp;
  GList *tmp;

  temp = other_view;
  other_view = curr_view;
  curr_view = temp;

  gtk_signal_emit_by_name(GTK_OBJECT(other_view->clist), "end-selection");
  if (other_view->old_selection)
    g_list_free(other_view->old_selection);
  other_view->old_selection = g_list_copy(
                                GTK_CLIST(other_view->clist)->selection);
  for (tmp = other_view->old_selection; tmp != NULL; tmp = tmp->next)
    gtk_clist_set_background(GTK_CLIST(other_view->clist), (gint)tmp->data,
                             &SELECT_COLOR);
  for (tmp = curr_view->old_selection; tmp != NULL; tmp = tmp->next)
    gtk_clist_set_background(GTK_CLIST(curr_view->clist), (gint)tmp->data,
                             &CLIST_COLOR);

  gtk_clist_unselect_all(GTK_CLIST(other_view->clist));
  style = gtk_style_copy(gtk_widget_get_style(
                         GTK_CLIST(other_view->clist)->column[0].button));
  style->bg[GTK_STATE_NORMAL] = COL_COLOR;
  num_cols = GTK_CLIST(curr_view->clist)->columns;
  for (i = 0; i < num_cols; i++)
  {
    gtk_widget_set_style(GTK_CLIST(curr_view->clist)->column[i].button,
                         style);
    gtk_widget_set_style(curr_view->sort_arrows[i], style);
  }
  for (i = 0; i < num_cols; i++)
  {
    gtk_widget_restore_default_style(
          GTK_CLIST(other_view->clist)->column[i].button);
    gtk_widget_restore_default_style(other_view->sort_arrows[i]);
  }

  chdir(curr_view->dir);
}
static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBackgroundType type, GdkColor* color, cairo_pattern_t *pattern, PagerData* pager)
{
        GtkStyleContext *new_context;
        gtk_widget_reset_style (GTK_WIDGET (pager->pager));
        new_context = gtk_style_context_new ();
        gtk_style_context_set_path (new_context, gtk_widget_get_path (GTK_WIDGET (pager->pager)));
        g_object_unref (new_context);

        wnck_pager_set_shadow_type (WNCK_PAGER (pager->pager),
                type == PANEL_NO_BACKGROUND ? GTK_SHADOW_NONE : GTK_SHADOW_IN);
#else
static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBackgroundType type, GdkColor* color, GdkPixmap* pixmap, PagerData* pager)
{
        /* taken from the TrashApplet */
        GtkRcStyle *rc_style;
        GtkStyle *style;

        /* reset style */
        gtk_widget_set_style (GTK_WIDGET (pager->pager), NULL);
        rc_style = gtk_rc_style_new ();
        gtk_widget_modify_style (GTK_WIDGET (pager->pager), rc_style);
        g_object_unref (rc_style);

	switch (type)
	{
                case PANEL_COLOR_BACKGROUND:
                        gtk_widget_modify_bg (GTK_WIDGET (pager->pager), GTK_STATE_NORMAL, color);
                        break;

                case PANEL_PIXMAP_BACKGROUND:
                        style = gtk_style_copy (gtk_widget_get_style (GTK_WIDGET (pager->pager)));
                        if (style->bg_pixmap[GTK_STATE_NORMAL])
                                g_object_unref (style->bg_pixmap[GTK_STATE_NORMAL]);
                        style->bg_pixmap[GTK_STATE_NORMAL] = g_object_ref(pixmap);
                        gtk_widget_set_style (GTK_WIDGET (pager->pager), style);
                        g_object_unref (style);
                        break;

                case PANEL_NO_BACKGROUND:
                default:
                        break;
	}
#endif
}
Exemple #27
0
int
clip_GTK_RADIOBUTTONSETSTYLE(ClipMachine * cm)
{
	C_widget   *cbtn = _fetch_cw_arg(cm);
	ClipVar  *mstyle = _clip_spar(cm,2);
	GtkStyle *style;
        GtkButton *button;
        CHECKCWID(cbtn,GTK_IS_TOGGLE_BUTTON);
	CHECKARG(2,MAP_t);

        button = &(GTK_TOGGLE_BUTTON(cbtn->widget)->button);
	style = gtk_style_copy(GTK_BIN(&(button->bin))->child->style);
        //gtk_style_unref(GTK_BIN(&(button->bin))->child->style);
	_map_to_style(cm, mstyle, style);
	gtk_widget_set_style (GTK_BIN(&(button->bin))->child, style);
	return 0;
err:
	return 1;
}
Exemple #28
0
void  
hack_max_combo_width_cb (GtkWidget *widget,
							GtkStyle *previous_style,
                            gpointer user_data)
{
  PangoRectangle logical_rect, ink_rect;
  GtkWidget *tmp_entry;
	
  if (!GTK_IS_ENTRY(widget))
	  return;
  tmp_entry = gtk_entry_new();
  gtk_widget_set_style(tmp_entry, gtk_style_copy(widget->style));
  gtk_entry_set_text(GTK_ENTRY(tmp_entry), "00:00:00.0000.");
  
  pango_layout_get_extents (gtk_entry_get_layout (GTK_ENTRY(tmp_entry)), &ink_rect, &logical_rect);
  gtk_widget_destroy(tmp_entry);
  
  gtk_widget_set_usize(GTK_WIDGET(GTK_ENTRY(widget)),  PANGO_PIXELS (ink_rect.width), -1);
}
Exemple #29
0
void GetStyleFromRCFile(GtkStyle** ppStyle, char* name, GtkStyle* psBase)
{	/* Note gtk 1.3 doesn't seem to have a nice way to do this... */
	BoardData *bd = BOARD(pwBoard)->board_data;
	GtkStyle *psDefault, *psNew;
	GtkWidget *dummy, *temp;
	char styleName[100];
	/* Get default style so only changes to this are applied */
	temp = gtk_button_new();
	gtk_widget_ensure_style(temp);
	psDefault = gtk_widget_get_style( temp );

	/* Get Style from rc file */
	strcpy(styleName, "gnubg-");
	strcat(styleName, name);
	dummy = gtk_label_new("");
	gtk_widget_ensure_style(dummy);
	gtk_widget_set_name(dummy, styleName);
	/* Pack in box to make sure style is loaded */
	gtk_box_pack_start(GTK_BOX(bd->table), dummy, FALSE, FALSE, 0);
	psNew = gtk_widget_get_style(dummy);

	/* Base new style on base style passed in */
	*ppStyle = gtk_style_copy(psBase);
	/* Make changes to fg+bg and copy to selected states */
	if (memcmp(&psNew->fg[GTK_STATE_ACTIVE], &psDefault->fg[GTK_STATE_ACTIVE], sizeof(GdkColor)))
		memcpy(&(*ppStyle)->fg[GTK_STATE_NORMAL], &psNew->fg[GTK_STATE_ACTIVE], sizeof(GdkColor));
	if (memcmp(&psNew->fg[GTK_STATE_NORMAL], &psDefault->fg[GTK_STATE_NORMAL], sizeof(GdkColor)))
		memcpy(&(*ppStyle)->fg[GTK_STATE_NORMAL], &psNew->fg[GTK_STATE_NORMAL], sizeof(GdkColor));
	memcpy(&(*ppStyle)->fg[GTK_STATE_SELECTED], &(*ppStyle)->fg[GTK_STATE_NORMAL], sizeof(GdkColor));

	if (memcmp(&psNew->base[GTK_STATE_NORMAL], &psDefault->base[GTK_STATE_NORMAL], sizeof(GdkColor)))
		memcpy(&(*ppStyle)->base[GTK_STATE_NORMAL], &psNew->base[GTK_STATE_NORMAL], sizeof(GdkColor));
	memcpy(&(*ppStyle)->bg[GTK_STATE_SELECTED], &(*ppStyle)->base[GTK_STATE_NORMAL], sizeof(GdkColor));
	/* Update the font if different */
	if (!gtk_compare_fonts(psNew, psDefault))
		gtk_set_font(*ppStyle, psNew);

	/* Remove useless widgets */
	gtk_widget_destroy(dummy);
	g_object_ref_sink(G_OBJECT(temp));
	g_object_unref(G_OBJECT(temp));
}
Exemple #30
0
/* Set style of a widget */
int
clip_GTK_WIDGETSETSTYLE (ClipMachine *cm)
{
	C_widget *cwid  = _fetch_cw_arg(cm);
	ClipVar *mstyle = _clip_par(cm,2);
	GtkStyle *style;
	int i;

	CHECKARG(2,MAP_t);
	CHECKCWID(cwid,GTK_IS_WIDGET);

	style = gtk_style_copy(cwid->widget->style);
	//style = cwid->widget->style;

	/*alena*/

	style->white_gc = cwid->widget->style->white_gc;
	style->black_gc = cwid->widget->style->black_gc;
	for (i = 0; i < 5; i++)
	{
		style->fg_gc[i] = cwid->widget->style->fg_gc[i];
		style->bg_gc[i] = cwid->widget->style->bg_gc[i];
		style->light_gc[i] = cwid->widget->style->light_gc[i];
		style->dark_gc[i] = cwid->widget->style->dark_gc[i];
		style->mid_gc[i] = cwid->widget->style->mid_gc[i];
		style->text_gc[i] = cwid->widget->style->text_gc[i];
		style->base_gc[i] = cwid->widget->style->base_gc[i];
	}

	/*******/
	//style = cwid->widget->style;
	//gtk_style_unref(cwid->widget->style);
	//gtk_style_ref(style);

	////style = gtk_widget_get_style(cwid->widget);
	_map_to_style(cm, mstyle, style);
	// Apply new style to a widget
	gtk_widget_set_style (cwid->widget, style);
	return 0;
err:
	return 1;
}