/* Widget changed, so add it to the highlighing list */ static void ghack_highlight_widget( GtkWidget* widget, GtkStyle* oldStyle, GtkStyle* newStyle) { Highlight *highlt; GList *item; /* Check if this widget is already in the queue. If so then * remove it, so we will only have the new entry in the queue */ for (item = g_list_first( s_HighLightList) ; item ; ) { highlt = (Highlight*) item->data; if (highlt) { if ( highlt->widget == widget) { s_HighLightList = g_list_remove_link(s_HighLightList, item); g_free( highlt); g_list_free_1( item); break; } } if (item) item=item->next; else break; } /* Ok, now highlight this widget and add it into the fade * highlighting queue */ highlt = g_new( Highlight, 1); highlt->nTurnsLeft=NUM_TURNS_HIGHLIGHTED; highlt->oldStyle=oldStyle; highlt->widget=widget; s_HighLightList = g_list_prepend (s_HighLightList, highlt); gtk_widget_set_style( GTK_WIDGET( widget), newStyle); }
static void _gradient_slider_realize(GtkWidget *widget) { GdkWindowAttr attributes; guint attributes_mask; g_return_if_fail(widget != NULL); g_return_if_fail(DTGTK_IS_GRADIENT_SLIDER(widget)); gtk_widget_set_realized(widget, TRUE); GtkAllocation allocation; gtk_widget_get_allocation(widget, &allocation); attributes.window_type = GDK_WINDOW_CHILD; attributes.x = allocation.x; attributes.y = allocation.y; attributes.width = 100; attributes.height = 17; attributes.wclass = GDK_INPUT_OUTPUT; attributes.event_mask = gtk_widget_get_events(widget) | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_POINTER_MOTION_MASK; attributes_mask = GDK_WA_X | GDK_WA_Y; gtk_widget_set_window(widget, gdk_window_new( gtk_widget_get_parent_window (widget), & attributes, attributes_mask )); gdk_window_set_user_data(gtk_widget_get_window(widget), widget); gtk_widget_set_style(widget, gtk_style_attach(gtk_widget_get_style(widget), gtk_widget_get_window(widget))); gtk_style_set_background(gtk_widget_get_style(widget), gtk_widget_get_window(widget), GTK_STATE_NORMAL); }
static void _slider_realize(GtkWidget *widget) { g_return_if_fail(widget != NULL); g_return_if_fail(DTGTK_IS_SLIDER(widget)); GdkWindowAttr attributes; guint attributes_mask; GtkWidgetClass *klass = GTK_WIDGET_CLASS(_slider_parent_class); if(klass->realize) klass->realize(widget); gtk_widget_set_realized(widget, TRUE); GtkAllocation allocation; gtk_widget_get_allocation(widget, &allocation); attributes.window_type = GDK_WINDOW_CHILD; attributes.x = allocation.x; attributes.y = allocation.y; attributes.width = DT_PIXEL_APPLY_DPI(100); attributes.height = DTGTK_SLIDER_CONTROL_MIN_HEIGHT; attributes.wclass = GDK_INPUT_OUTPUT; attributes.event_mask = gtk_widget_get_events(widget) | GDK_EXPOSURE_MASK; attributes_mask = GDK_WA_X | GDK_WA_Y; gtk_widget_set_window(widget, gdk_window_new(gtk_widget_get_parent_window(gtk_widget_get_parent(widget)), &attributes, attributes_mask)); gdk_window_set_user_data(gtk_widget_get_window(widget), widget); gtk_widget_set_style(widget, gtk_style_attach(gtk_widget_get_style(widget), gtk_widget_get_window(widget))); gtk_style_set_background(gtk_widget_get_style(widget), gtk_widget_get_window(widget), GTK_STATE_NORMAL); }
/* 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 }
int setupwindow() { GdkPixmap *background; GdkPixbuf *pixbuf; GdkPixbuf *scaled; GdkScreen *screen; GdkColormap *colormap; GError *error=NULL; GtkStyle *style; window=gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(G_OBJECT(window), "expose_event", G_CALLBACK(expose_window),NULL); gtk_window_set_title(GTK_WINDOW(window), "clock"); gtk_window_stick(GTK_WINDOW(window)); gtk_window_set_resizable(GTK_WINDOW(window),TRUE); gtk_window_set_skip_taskbar_hint(GTK_WINDOW(window),TRUE); gtk_window_set_keep_above(GTK_WINDOW(window),TRUE); gtk_container_set_border_width(GTK_CONTAINER(window), 3); gtk_window_set_decorated(GTK_WINDOW(window),TRUE); gtk_window_set_default_size(GTK_WINDOW(window),100,100); gtk_widget_set_app_paintable(window,TRUE); /* Get the screen to get the colormap */ screen=gtk_widget_get_screen(window); colormap = gdk_screen_get_rgba_colormap(screen); if(colormap != NULL){ alpha_channel_support=TRUE; } else { alpha_channel_support=FALSE; colormap=gdk_screen_get_rgb_colormap(screen); g_print("Sorry, no alpha!\n"); } /* Tell the window to use the colormap */ gtk_widget_set_colormap(window,colormap); /* Get a pixbuf from the image file */ pixbuf=gdk_pixbuf_new_from_file("clockface.png",&error); if(pixbuf==NULL){ g_print("Failed to open background image: %s\n", error->message); g_error_free(error); error=NULL; return 0; } /* Make it the same size as the window */ scaled=gdk_pixbuf_scale_simple(pixbuf,100,100, GDK_INTERP_BILINEAR); /* Render it using the colormap of the window */ gdk_pixbuf_render_pixmap_and_mask_for_colormap(scaled,colormap,&background,NULL,0); /* Make a new style, stick the background in it, tell window to use it. */ style = gtk_style_new(); style->bg_pixmap[0] = background; gtk_widget_set_style(GTK_WIDGET(window),GTK_STYLE(style)); /*gtk_window_set_opacity(GTK_WINDOW(window),0.3);*/ gtk_window_move(GTK_WINDOW(window), 0, 0); gtk_widget_show_all(window); return 1; }
static void ViewOvBoxRealize(GtkWidget *widget) // IN { ViewOvBox *that; ViewOvBoxPrivate *priv; GdkWindowAttr attributes; gint mask; GtkAllocation allocation; GdkWindow *window; gtk_widget_set_realized (widget, TRUE); that = VIEW_OV_BOX(widget); priv = that->priv; attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual(widget); attributes.event_mask = gtk_widget_get_events(widget) | GDK_EXPOSURE_MASK; mask = GDK_WA_VISUAL | GDK_WA_X | GDK_WA_Y; gtk_widget_get_allocation(widget, &allocation); attributes.x = allocation.x; attributes.y = allocation.y; attributes.width = allocation.width; attributes.height = allocation.height; window = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, mask); gtk_widget_set_window(widget, window); gdk_window_set_user_data(window, that); #if !GTK_CHECK_VERSION(3, 0, 0) gtk_widget_set_style(widget, gtk_style_attach(gtk_widget_get_style(widget), window)); #endif /* * The order in which we create the children X window matters: the child * created last is stacked on top. --hpreg */ ViewOvBoxGetUnderGeometry(that, &attributes.x, &attributes.y, &attributes.width, &attributes.height); priv->underWin = gdk_window_new(window, &attributes, mask); gdk_window_set_user_data(priv->underWin, that); if (priv->under) { gtk_widget_set_parent_window(priv->under, priv->underWin); } gdk_window_show(priv->underWin); ViewOvBoxGetOverGeometry(that, &attributes.x, &attributes.y, &attributes.width, &attributes.height); priv->overWin = gdk_window_new(window, &attributes, mask); gdk_window_set_user_data(priv->overWin, that); if (priv->over) { gtk_widget_set_parent_window(priv->over, priv->overWin); } gdk_window_show(priv->overWin); ViewOvBoxSetBackground(that); }
void ascii_open (void) { int do_unref = TRUE; int i, j, val; unsigned char name[2], num[4]; GtkWidget *wid, *but, *hbox, *vbox, *win; GtkStyle *style; style = gtk_style_new (); gdk_font_unref (style->font); if (menu_sess && menu_sess->type == SESS_DIALOG) { style->font = dialog_font_normal; gdk_font_ref (dialog_font_normal); } else { style->font = font_normal; gdk_font_ref (font_normal); } win = maingui_window ("asciichart", _("Ascii Chart"), TRUE, TRUE, NULL, NULL, 0, 0, NULL); vbox = wins_get_vbox (win); name[1] = 0; for (i = 0; i < 16; i++) { hbox = gtk_hbox_new (0, 0); sprintf (num, "%03d", i * 16); wid = gtk_label_new (num); gtk_widget_set_usize (wid, 36, 20); gtk_container_add (GTK_CONTAINER (hbox), wid); gtk_widget_show (wid); for (j = 0; j < 16; j++) { val = j + (i * 16); name[0] = val; but = gtk_button_new_with_label (name); gtk_widget_set_style (GTK_BIN (but)->child, style); if (do_unref) { do_unref = FALSE; gtk_style_unref (style); } gtk_signal_connect (GTK_OBJECT (but), "clicked", GTK_SIGNAL_FUNC (ascii_click), GINT_TO_POINTER (val)); gtk_widget_set_usize (but, 24, 20); gtk_container_add (GTK_CONTAINER (hbox), but); gtk_widget_show (but); } gtk_container_add (GTK_CONTAINER (vbox), hbox); gtk_widget_show (hbox); } gtk_widget_show (win); }
/* 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; }
/* 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); }
/** * 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); }
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 }
static void he_check_button_init (HeCheckButton *self) { HeCheckButtonPrivate *priv = HE_CHECK_BUTTON_GET_PRIVATE (self); /* Store private part */ self->priv = priv; priv->title = GTK_LABEL (gtk_label_new (NULL)); priv->value = GTK_LABEL (gtk_label_new (NULL)); priv->alignment = gtk_alignment_new (0.5, 0.5, 0, 0); priv->toggle_renderer = GTK_CELL_RENDERER_TOGGLE (gtk_cell_renderer_toggle_new ()); priv->cell_view = gtk_cell_view_new (); priv->hbox = NULL; priv->label_box = NULL; priv->style = HE_CHECK_BUTTON_STYLE_NORMAL; priv->setting_style = FALSE; /* Setup the cell renderer */ /* We need to set the correct style from the gtkrc file. Otherwise the check box * does not look like a check box on a HildonCheckButton. */ GtkStyle *style = gtk_rc_get_style_by_paths(gtk_widget_get_settings(GTK_WIDGET(self)), NULL, "*.HildonCheckButton.GtkAlignment.GtkHBox.GtkCellView", G_TYPE_NONE); gtk_widget_set_style(priv->cell_view, style); /* Make sure that the check box is always shown, no matter the value of gtk-button-images */ g_signal_connect (priv->cell_view, "notify::visible", G_CALLBACK (gtk_widget_show), NULL); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (priv->cell_view), GTK_CELL_RENDERER (priv->toggle_renderer), TRUE); /* Get checkbox-size style property of HildonCheckButton from theme */ style = gtk_rc_get_style_by_paths (gtk_widget_get_settings (GTK_WIDGET(self)), NULL, "*.HildonCheckButton", HILDON_TYPE_CHECK_BUTTON); glong checkbox_size = get_style_property_long (style, HILDON_TYPE_CHECK_BUTTON, "checkbox-size"); /* Set the indicator to the right size (the size of the pixmap) */ g_object_set (priv->toggle_renderer, "indicator-size", checkbox_size, NULL); /* Setup the labels */ gtk_widget_set_name (GTK_WIDGET (priv->title), "hildon-button-title"); gtk_widget_set_name (GTK_WIDGET (priv->value), "hildon-button-value"); he_check_button_set_style (self, HE_CHECK_BUTTON_STYLE_NORMAL); gtk_misc_set_alignment (GTK_MISC (priv->title), 0, 0.5); gtk_misc_set_alignment (GTK_MISC (priv->value), 0, 0.5); g_object_ref_sink (priv->alignment); /* The labels are not shown automatically, see he_check_button_set_(title|value) */ gtk_widget_set_no_show_all (GTK_WIDGET (priv->title), TRUE); gtk_widget_set_no_show_all (GTK_WIDGET (priv->value), TRUE); gtk_button_set_focus_on_click (GTK_BUTTON (self), FALSE); }
static void ppg_util_header_item_on_style_set (GtkWidget *widget, GtkStyle *old_style, GtkWidget *child) { GtkStyle *style; style = gtk_widget_get_style(widget); gtk_widget_set_style(child, style); }
static void applet_back_change (MatePanelApplet *a, MatePanelAppletBackgroundType type, GdkColor *color, GdkPixmap *pixmap, EyesApplet *eyes_applet) { /* taken from the TrashApplet */ GtkRcStyle *rc_style; GtkStyle *style; /* reset style */ gtk_widget_set_style (GTK_WIDGET (eyes_applet->applet), NULL); rc_style = gtk_rc_style_new (); gtk_widget_modify_style (GTK_WIDGET (eyes_applet->applet), rc_style); g_object_unref (rc_style); switch (type) { case PANEL_COLOR_BACKGROUND: gtk_widget_modify_bg (GTK_WIDGET (eyes_applet->applet), GTK_STATE_NORMAL, color); break; case PANEL_PIXMAP_BACKGROUND: style = gtk_style_copy (gtk_widget_get_style (GTK_WIDGET ( eyes_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 (eyes_applet->applet), style); g_object_unref (style); break; case PANEL_NO_BACKGROUND: default: break; } }
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); }
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; }
/* called from ui_open_canvas_window */ void ui_init_checkbox_style(void) { ui_style_red = gtk_style_new(); ui_style_red->fg[GTK_STATE_NORMAL] = drive_led_on_red_pixel; ui_style_red->fg[GTK_STATE_ACTIVE] = drive_led_on_red_pixel; ui_style_red->fg[GTK_STATE_SELECTED] = drive_led_on_red_pixel; ui_style_red->fg[GTK_STATE_PRELIGHT] = drive_led_on_red_pixel; gtk_widget_set_style(video_ctrl_checkbox_label, ui_style_red); if (machine_class != VICE_MACHINE_VSID) { gtk_widget_set_style(event_rec_checkbox_label, ui_style_red); ui_style_green = gtk_style_new(); ui_style_green->fg[GTK_STATE_NORMAL] = drive_led_on_green_pixel; ui_style_green->fg[GTK_STATE_ACTIVE] = drive_led_on_green_pixel; ui_style_green->fg[GTK_STATE_SELECTED] = drive_led_on_green_pixel; ui_style_green->fg[GTK_STATE_PRELIGHT] = drive_led_on_green_pixel; gtk_widget_set_style(event_playback_checkbox_label, ui_style_green); } }
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); }
void setWindow(GtkWidget *widget,gpointer data ) { GdkPixbuf *LoadImage = NULL; GtkStyle *StyleNew = NULL; GdkPixmap *LoadPixmap = NULL; LoadImage = load_pixbuf_from_file ((gchar*)data); gdk_pixbuf_render_pixmap_and_mask (LoadImage, &LoadPixmap, NULL, 0); StyleNew = gtk_style_new (); StyleNew->bg_pixmap [0] = LoadPixmap; gtk_widget_set_style (GTK_WIDGET(window), GTK_STYLE (StyleNew)); }
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); }
void matenu_menu_bar_set_background (MatenuMenuBar* self, MatenuBackground* value) { MatenuBackgroundType old_type; GdkColor old_color; GdkPixmap* _tmp0_; g_return_if_fail (self != NULL); old_type = self->priv->_background->type; old_color = self->priv->_background->color; self->priv->_background->type = value->type; self->priv->_background->pixmap = (_tmp0_ = _g_object_ref0 (value->pixmap), _g_object_unref0 (self->priv->_background->pixmap), _tmp0_); self->priv->_background->color = value->color; self->priv->_background->offset_x = value->offset_x; self->priv->_background->offset_y = value->offset_y; switch (self->priv->_background->type) { case MATENU_BACKGROUND_TYPE_NONE: { if (old_type != self->priv->_background->type) { GtkRcStyle* rc_style; gtk_widget_set_style ((GtkWidget*) self, NULL); rc_style = gtk_rc_style_new (); gtk_widget_modify_style ((GtkWidget*) self, rc_style); _g_object_unref0 (rc_style); } break; } case MATENU_BACKGROUND_TYPE_COLOR: { gboolean _tmp1_ = FALSE; if (old_type != self->priv->_background->type) { _tmp1_ = TRUE; } else { gboolean _tmp2_ = FALSE; if (old_type == self->priv->_background->type) { _tmp2_ = !gdk_color_equal (&old_color, &self->priv->_background->color); } else { _tmp2_ = FALSE; } _tmp1_ = _tmp2_; } if (_tmp1_) { gtk_widget_modify_bg ((GtkWidget*) self, GTK_STATE_NORMAL, &self->priv->_background->color); } break; } case MATENU_BACKGROUND_TYPE_PIXMAP: { matenu_menu_bar_reset_bg_pixmap (self); break; } } g_object_notify ((GObject *) self, "background"); }
static void accessx_status_applet_background(MatePanelApplet* a, MatePanelAppletBackgroundType type, GdkColor* color, GdkPixmap* pixmap, gpointer user_data) { AccessxStatusApplet* sapplet = user_data; GtkRcStyle* rc_style; GtkStyle* style; /* reset style */ gtk_widget_set_style(GTK_WIDGET(sapplet->applet), NULL); rc_style = gtk_rc_style_new(); gtk_widget_modify_style(GTK_WIDGET(sapplet->applet), rc_style); g_object_unref(rc_style); switch (type) { case PANEL_COLOR_BACKGROUND: gtk_widget_modify_bg(GTK_WIDGET(sapplet->applet), GTK_STATE_NORMAL, color); break; case PANEL_PIXMAP_BACKGROUND: style = gtk_style_copy(gtk_widget_get_style(GTK_WIDGET(sapplet->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(sapplet->applet), style); g_object_unref(style); break; case PANEL_NO_BACKGROUND: default: break; } }
void fe_print_text (struct session *sess, char *text) { int indent; if (sess->type == SESS_DIALOG) indent = prefs.dialog_indent_nicks; else indent = prefs.indent_nicks; PrintTextRaw (sess->gui->textgad, text, indent); if (prefs.limitedtabhighlight && !sess->highlight_tab) return; sess->highlight_tab = FALSE; if (!sess->new_data && !sess->nick_said && sess != current_tab) { #ifdef USE_PANEL if (sess->gui->panel_button) gtk_widget_set_style (GTK_BIN (sess->gui->panel_button)->child, redtab_style); #endif if (prefs.treeview) tree_red_style (sess); } if (!sess->new_data && sess != current_tab && sess->is_tab && !sess->nick_said) { sess->new_data = TRUE; gtk_widget_set_style (sess->gui->changad, redtab_style); } }
/* * SetStyleRecursively * * Set the widget's style to the style (data) and make sure * that all the children (if it's a container) are also set * to that particular style. */ void SetStyleRecursively (GtkWidget *widget, gpointer data) { GtkStyle *style; /* --- Get the style --- */ style = (GtkStyle *) data; /* --- Set the style of the widget --- */ gtk_widget_set_style (widget, style); /* --- If it may have children widgets --- */ if (GTK_IS_CONTAINER (widget)) { /* --- Set all the children's styles too. --- */ gtk_container_foreach (GTK_CONTAINER (widget), SetStyleRecursively, style); } }
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; }
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); }
/* 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; }
/** * gtk_font_button_set_use_font: * @font_button: a #GtkFontButton * @use_font: If %TRUE, font name will be written using font chosen. * * If @use_font is %TRUE, the font name will be written using the selected font. * * Since: 2.4 */ void gtk_font_button_set_use_font (GtkFontButton *font_button, gboolean use_font) { g_return_if_fail (GTK_IS_FONT_BUTTON (font_button)); use_font = (use_font != FALSE); if (font_button->priv->use_font != use_font) { font_button->priv->use_font = use_font; if (use_font) gtk_font_button_label_use_font (font_button); else gtk_widget_set_style (font_button->priv->font_label, NULL); g_object_notify (G_OBJECT (font_button), "use-font"); } }
void ami_desktop_set_background(AmiDesktop *desktop) { GdkPixmap *pixmap; GdkPixbuf *pixbuf; GtkStyle *style; pixbuf = gdk_pixbuf_new_from_file(amiconfig->wallpaper, NULL); gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap, NULL, 0); style = gtk_style_copy(gtk_widget_get_style(GTK_WIDGET(desktop->window))); 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(desktop->window), style); g_object_unref (pixbuf); g_object_unref (pixmap); g_object_unref (style); }
void calendar_font_selection_ok( GtkWidget *button, CalendarData *calendar ) { GtkStyle *style; GdkFont *font; calendar->font = gtk_font_selection_dialog_get_font_name( GTK_FONT_SELECTION_DIALOG (calendar->font_dialog)); if (calendar->window) { font = gtk_font_selection_dialog_get_font(GTK_FONT_SELECTION_DIALOG(calendar->font_dialog)); if (font) { style = gtk_style_copy (gtk_widget_get_style (calendar->window)); gdk_font_unref (style->font); style->font = font; gdk_font_ref (style->font); gtk_widget_set_style (calendar->window, style); } } }