Exemplo n.º 1
0
static void
gimp_thumb_box_style_set (GtkWidget *widget,
                          GtkStyle  *prev_style)
{
  GimpThumbBox *box   = GIMP_THUMB_BOX (widget);
  GtkStyle     *style = gtk_widget_get_style (widget);
  GtkWidget    *ebox;

  GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);

  gtk_widget_modify_bg (box->preview, GTK_STATE_NORMAL,
                        &style->base[GTK_STATE_NORMAL]);
  gtk_widget_modify_bg (box->preview, GTK_STATE_INSENSITIVE,
                        &style->base[GTK_STATE_NORMAL]);

  ebox = gtk_bin_get_child (GTK_BIN (widget));

  gtk_widget_modify_bg (ebox, GTK_STATE_NORMAL,
                        &style->base[GTK_STATE_NORMAL]);
  gtk_widget_modify_bg (ebox, GTK_STATE_INSENSITIVE,
                        &style->base[GTK_STATE_NORMAL]);
}
static void
mucharmap_charmap_update_text_tags (MucharmapCharmap *charmap)
{
  MucharmapCharmapPrivate *priv = charmap->priv;
  GtkStyle *style;
  int default_font_size;

  style = gtk_widget_get_style (GTK_WIDGET (priv->details_view));
  default_font_size = pango_font_description_get_size (style->font_desc);

  if (priv->font_desc)
	g_object_set (priv->text_tag_gimongous, "font-desc", priv->font_desc, NULL);

  /* FIXME: do we need to consider whether the font size is absolute or not? */
  g_object_set (priv->text_tag_gimongous,
	            "size", 8 * default_font_size,
	            "left-margin", PANGO_PIXELS (5 * default_font_size),
	            NULL);
  g_object_set (priv->text_tag_big,
	            "size", default_font_size * 5 / 4,
	            NULL);
}
Exemplo n.º 3
0
static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBackgroundType type, GdkColor* color, GdkPixmap* pixmap, PagerData* pager)
#endif
{
        /* 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);

#if GTK_CHECK_VERSION (3, 0, 0)
	wnck_pager_set_shadow_type (WNCK_PAGER (pager->pager),
		type == PANEL_NO_BACKGROUND ? GTK_SHADOW_NONE : GTK_SHADOW_IN);
#else
	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 sample_expose(GtkWidget* darea, GdkEventExpose* expose)
#endif
{
	GtkAllocation allocation;
	GdkPixbuf* pixbuf = g_object_get_data(G_OBJECT(darea), "sample-pixbuf");
	GdkWindow* window = gtk_widget_get_window(darea);
	GtkStyle* style = gtk_widget_get_style(darea);
	int width = gdk_pixbuf_get_width(pixbuf);
	int height = gdk_pixbuf_get_height(pixbuf);

	gtk_widget_get_allocation (darea, &allocation);

	int x = (allocation.width - width) / 2;
	int y = (allocation.height - height) / 2;

#if GTK_CHECK_VERSION (3, 0, 0)
	cairo_set_line_width(cr, 1);

	cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
	cairo_rectangle(cr, 0, 0, allocation.width, allocation.height);
	cairo_stroke_preserve(cr);
	cairo_fill(cr);

	cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
	cairo_rectangle(cr, 0, 0, allocation.width - 1, allocation.height - 1);
	cairo_stroke_preserve(cr);
	cairo_fill(cr);

	gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0);
	cairo_paint(cr);
	cairo_fill (cr);
#else
	gdk_draw_rectangle(window, style->white_gc, TRUE, 0, 0, allocation.width, allocation.height);
	gdk_draw_rectangle(window, style->black_gc, FALSE, 0, 0, allocation.width - 1, allocation.height - 1);

	gdk_draw_pixbuf(window, NULL, pixbuf, 0, 0, x, y, width, height, GDK_RGB_DITHER_NORMAL, 0, 0);
#endif
}
Exemplo n.º 5
0
void widget_set_color(GtkWidget* entry,GdkColor* color,int component)

{
   GtkStyle* newstyle;
   gtk_widget_ensure_style(entry);

   {

      int i;
      newstyle = gtk_style_copy(gtk_widget_get_style(entry));


      for( i=0;i<5;++i) 
      {
         if (component & FGCOLOR)
	 {
            newstyle->fg[i] = *color;
	 }
         if (component &  BGCOLOR)
	 {
            newstyle->bg[i] = *color;
         }
         if (component &  TEXTCOLOR)
	 {
            newstyle->text[i] = *color;
	 }    
         if (component & BASECOLOR)
	 {
            newstyle->base[i] = *color;
	 }    

     }

   }

    gtk_widget_set_style(entry,newstyle);

}
Exemplo n.º 6
0
static gboolean
eel_background_ensure_realized (EelBackground *self)
{
    GtkStyle *style;
    int width, height;
    GdkWindow *window;

    /* Set the default color */
    style = gtk_widget_get_style (self->details->widget);
    if (self->details->use_base) {
       self->details->default_color = style->base[GTK_STATE_NORMAL];
    } else {
        self->details->default_color = style->bg[GTK_STATE_NORMAL];
    }

    /* If the window size is the same as last time, don't update */
    drawable_get_adjusted_size (self, &width, &height);
    if (width == self->details->bg_entire_width &&
        height == self->details->bg_entire_height)
    {
        return FALSE;
    }

    free_background_surface (self);

    set_image_properties (self);

    window = gtk_widget_get_window (self->details->widget);
    self->details->bg_surface = mate_bg_create_surface (self->details->bg,
        						window, width, height,
        						self->details->is_desktop);
    self->details->unset_root_surface = self->details->is_desktop;

    self->details->bg_entire_width = width;
    self->details->bg_entire_height = height;

    return TRUE;
}
Exemplo n.º 7
0
static void matenu_menu_bar_setup_overflown_arrow (MatenuMenuBar* self) {
	GError * _inner_error_;
	MatenuShell* shell;
	g_return_if_fail (self != NULL);
	_inner_error_ = NULL;
	gtk_widget_set_parent ((GtkWidget*) self->priv->_overflown_arrow, (GtkWidget*) self);
	gtk_widget_set_style ((GtkWidget*) self->priv->_overflown_arrow, gtk_widget_get_style ((GtkWidget*) self));
	matenu_item_set_has_sub_shell ((MatenuItem*) self->priv->_overflown_arrow, TRUE);
	gtk_widget_set_visible ((GtkWidget*) self->priv->_overflown_arrow, TRUE);
	matenu_item_set_item_id ((MatenuItem*) self->priv->_overflown_arrow, "_arrow_");
	matenu_item_set_item_type ((MatenuItem*) self->priv->_overflown_arrow, MATENU_ITEM_TYPE_ARROW);
	shell = _g_object_ref0 (matenu_item_get_sub_shell ((MatenuItem*) self->priv->_overflown_arrow));
	{
		matenu_parser_parse (shell, MATENU_MENU_BAR_EMPTY_OVERFLOWN_MENU, &_inner_error_);
		if (_inner_error_ != NULL) {
			goto __catch1_g_error;
		}
	}
	goto __finally1;
	__catch1_g_error:
	{
		GError * e;
		e = _inner_error_;
		_inner_error_ = NULL;
		{
			g_warning ("menubar.vala:244: %s", e->message);
			_g_error_free0 (e);
		}
	}
	__finally1:
	if (_inner_error_ != NULL) {
		_g_object_unref0 (shell);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	_g_object_unref0 (shell);
}
Exemplo n.º 8
0
static void
gimp_ruler_draw_pos (GimpRuler *ruler, cairo_t *cr)
{
  GtkWidget        *widget = GTK_WIDGET (ruler);
  GtkStyle         *style  = gtk_widget_get_style (widget);
  GimpRulerPrivate *priv   = GIMP_RULER_GET_PRIVATE (ruler);
  GtkStateType      state  = gtk_widget_get_state (widget);
  GdkRectangle      pos_rect;

  if (! gtk_widget_is_drawable (widget))
    return;

  pos_rect = gimp_ruler_get_pos_rect (ruler, gimp_ruler_get_position (ruler));

  if ((pos_rect.width > 0) && (pos_rect.height > 0))
    {
      gdk_cairo_set_source_color (cr, &style->fg[state]);

      cairo_move_to (cr, pos_rect.x, pos_rect.y);

      if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
        {
          cairo_line_to (cr, pos_rect.x + pos_rect.width / 2.0,
                             pos_rect.y + pos_rect.height);
          cairo_line_to (cr, pos_rect.x + pos_rect.width,
                             pos_rect.y);
        }
      else
        {
          cairo_line_to (cr, pos_rect.x + pos_rect.width,
                             pos_rect.y + pos_rect.height / 2.0);
          cairo_line_to (cr, pos_rect.x,
                             pos_rect.y + pos_rect.height);
        }

      cairo_fill (cr);
    }
}
static void
popup_button_expose (GtkWidget      *widget,
                     GdkEventExpose *event,
                     UmPhotoDialog  *um)
{
        GtkAllocation allocation;

        if (gtk_widget_get_state (widget) != GTK_STATE_PRELIGHT &&
            !gtk_widget_is_focus (gtk_widget_get_parent (widget))) {
                return;
        }

        gtk_widget_get_allocation (widget, &allocation);
        gtk_paint_expander (gtk_widget_get_style (widget),
                            gtk_widget_get_window (widget),
                            gtk_widget_get_state (widget),
                            NULL,
                            widget,
                            NULL,
                            allocation.x + allocation.width,
                            allocation.y + allocation.height,
                            GTK_EXPANDER_EXPANDED);
}
Exemplo n.º 10
0
static gboolean gtkCanvasBorderExposeEvent(GtkWidget *widget, GdkEventExpose *evt, void* user)
#endif
{
#if GTK_CHECK_VERSION(3, 0, 0)
  GtkStyleContext* context = gtk_widget_get_style_context (widget);
  GtkAllocation allocation;
  gtk_widget_get_allocation(widget, &allocation);  
  gtk_style_context_save (context);
  gtk_style_context_add_class(context, GTK_STYLE_CLASS_FRAME);
  gtk_render_frame (context, cr, 0, 0, allocation.width, allocation.height);
  gtk_style_context_restore (context);
#else
  GdkWindow* window = iupgtkGetWindow(widget);
  GtkStyle *style = gtk_widget_get_style(widget);
  GtkAllocation allocation;
  gtk_widget_get_allocation(widget, &allocation);  
  gtk_paint_shadow(style, window, GTK_STATE_NORMAL, GTK_SHADOW_IN,
	                  &evt->area, widget, "scrolled_window",
	                  allocation.x, allocation.y, allocation.width, allocation.height);
#endif
  (void)user;
  return FALSE;
}
Exemplo n.º 11
0
Arquivo: led.c Projeto: pwithnall/mcus
static void
mcus_led_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{
	MCUSLEDPrivate *priv;
	GtkStyle *style;

	g_return_if_fail (allocation != NULL);
	g_return_if_fail (MCUS_IS_LED (widget));

	GTK_WIDGET_CLASS (mcus_led_parent_class)->size_allocate (widget, allocation);

	priv = MCUS_LED (widget)->priv;

	/* Sort out sizes, ratios, etc. */
	if (allocation->height < allocation->width)
		priv->render_size = allocation->height;
	else
		priv->render_size = allocation->width;

	/* Ensure the borders aren't clipped */
	style = gtk_widget_get_style (widget);
	priv->render_size -= style->xthickness * 2.0;
}
Exemplo n.º 12
0
void
rcm_set_satur (GtkWidget *entry,
               RcmGray   *circle)
{
  GtkStyle *style = gtk_widget_get_style (circle->preview);

  if (circle->action_flag != VIRGIN)
    return;

  circle->satur = gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry));

  gtk_widget_queue_draw (circle->preview);

  color_rotate_draw_little_circle (circle->preview->window,
                                   style->black_gc,
                                   circle->hue, circle->satur);

  color_rotate_draw_large_circle (circle->preview->window,
                                  style->black_gc,
                                  circle->gray_sat);

  rcm_render_preview (Current.Bna->after);
}
Exemplo n.º 13
0
static gboolean
gimp_combo_tag_entry_expose (GtkWidget      *widget,
                             GdkEventExpose *event)
{
  GimpComboTagEntry *entry = GIMP_COMBO_TAG_ENTRY (widget);

  if (! entry->arrow_pixbuf)
    {
      GtkStyle  *style = gtk_widget_get_style (widget);
      GdkPixmap *pixmap;
      cairo_t   *cr;

      pixmap = gdk_pixmap_new (gtk_widget_get_window (widget), 8, 8, -1);

      cr = gdk_cairo_create (pixmap);
      gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_NORMAL]);
      cairo_paint (cr);
      cairo_destroy (cr);

      gtk_paint_arrow (style, pixmap,
                       GTK_STATE_NORMAL,
                       GTK_SHADOW_NONE, NULL, widget, NULL,
                       GTK_ARROW_DOWN, TRUE,
                       0, 0, 8, 8);

      entry->arrow_pixbuf = gdk_pixbuf_get_from_drawable (NULL, pixmap, NULL,
                                                          0, 0, 0, 0, 8, 8);

      g_object_unref (pixmap);

      gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry),
                                      GTK_ENTRY_ICON_SECONDARY,
                                      entry->arrow_pixbuf);
    }

  return GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
}
/*! \brief Calculates the window area the renderer will use */
static void
ghid_cell_renderer_visibility_get_size (GtkCellRenderer *cell,
                                        GtkWidget       *widget,
                                        GdkRectangle    *cell_area,
                                        gint            *x_offset,
                                        gint            *y_offset,
                                        gint            *width,
                                        gint            *height)
{
  GtkStyle *style = gtk_widget_get_style (widget);
  gint w, h;
  gint xpad, ypad;
  gfloat xalign, yalign;

  gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
  gtk_cell_renderer_get_alignment (cell, &xalign, &yalign);

  w = VISIBILITY_TOGGLE_SIZE + 2 * (xpad + style->xthickness);
  h = VISIBILITY_TOGGLE_SIZE + 2 * (ypad + style->ythickness);

  if (width)
    *width = w;
  if (height)
    *height = h;

  if (cell_area)
    {
      if (x_offset)
        {
          if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
            xalign = 1. - xalign;
          *x_offset = MAX (0, xalign * (cell_area->width - w));
        }
      if (y_offset)
        *y_offset = MAX(0, yalign * (cell_area->height - h));
    }
}
Exemplo n.º 15
0
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;
	}
}
Exemplo n.º 16
0
static gboolean
pgd_render_drawing_area_expose (GtkWidget      *area,
				GdkEventExpose *event,
				PgdRenderDemo  *demo)
{
	if (demo->mode == PGD_RENDER_CAIRO && !demo->surface)
		return FALSE;

	if (demo->mode == PGD_RENDER_PIXBUF && !demo->pixbuf)
		return FALSE;

	gdk_window_clear (gtk_widget_get_window (area));

	if (demo->mode == PGD_RENDER_CAIRO) {
		cairo_t *cr;

		cr = gdk_cairo_create (gtk_widget_get_window (area));
		cairo_set_source_surface (cr, demo->surface, 0, 0);
		cairo_paint (cr);
		cairo_destroy (cr);
	} else if (demo->mode == PGD_RENDER_PIXBUF) {
		gdk_draw_pixbuf (gtk_widget_get_window (area),
				 gtk_widget_get_style(area)->fg_gc[GTK_STATE_NORMAL],
				 demo->pixbuf,
				 0, 0,
				 0, 0,
				 gdk_pixbuf_get_width (demo->pixbuf),
				 gdk_pixbuf_get_height (demo->pixbuf),
				 GDK_RGB_DITHER_NORMAL,
				 0, 0);
	} else {
		g_assert_not_reached ();
	}

	return TRUE;
}
Exemplo n.º 17
0
/* based on Gossip function */
static void
gnomegadu_contact_list_name_cell_data_func (GtkTreeViewColumn * column,
					    GtkCellRenderer * cell,
					    GtkTreeModel * model, GtkTreeIter * iter, GtkTreeView * list)
{
	gboolean is_group;

	gtk_tree_model_get (model, iter, UI_CONTACTS_COLUMN_IS_GROUP, &is_group, -1);

	if (is_group) {
		GdkColor color;
		GtkStyle *style;

		style = gtk_widget_get_style (GTK_WIDGET (list));
		color = style->text_aa[GTK_STATE_INSENSITIVE];
		color.red = (color.red + (style->white).red) / 2;
		color.green = (color.green + (style->white).green) / 2;
		color.blue = (color.blue + (style->white).blue) / 2;

		g_object_set (cell, "cell-background-gdk", &color, NULL);
	} else {
		g_object_set (cell, "cell-background-gdk", NULL, NULL);
	}
}
Exemplo n.º 18
0
image_expose_event(GtkWidget* widget, GdkEventExpose*, wxToolBarTool* tool)
#endif
{
    const wxBitmap& bitmap = tool->GetDisabledBitmap();
    if (tool->IsEnabled() || !bitmap.IsOk())
        return false;

    // draw disabled bitmap ourselves, GtkImage has no way to specify it
    GtkAllocation alloc;
    gtk_widget_get_allocation(widget, &alloc);
    GtkRequisition req;
    gtk_widget_get_requisition(widget, &req);
    const int x = alloc.x + (alloc.width - req.width) / 2;
    const int y = alloc.y + (alloc.height - req.height) / 2;
#ifdef __WXGTK3__
    bitmap.Draw(cr, x, y);
#else
    gdk_draw_pixbuf(
        gtk_widget_get_window(widget), gtk_widget_get_style(widget)->black_gc, bitmap.GetPixbuf(),
        0, 0, x, y,
        -1, -1, GDK_RGB_DITHER_NORMAL, 0, 0);
#endif
    return true;
}
Exemplo n.º 19
0
Arquivo: tree.c Projeto: jimiszm/peos
GtkWidget *setpixmap (char *str, xmlNode *info)
{
  GtkWidget *hbox;
  GtkWidget *pixmap_wid;
  GtkWidget *label;
  GdkPixmap *pixmap;
  GdkBitmap *mask;
  GtkStyle  *style;
/***************************************************/
  hbox = gtk_hbox_new (FALSE, 2);
  gtk_widget_show (hbox);
  style = gtk_widget_get_style (Peos);
  pixmap = gdk_pixmap_create_from_xpm_d (Peos->window, &mask, &style->bg[GTK_STATE_NORMAL], setpix(info));
  pixmap_wid = gtk_pixmap_new (pixmap, mask);
  gtk_widget_show (pixmap_wid);
  gtk_misc_set_alignment (GTK_MISC (pixmap_wid), 0.0, 0.5);
  gtk_box_pack_start (GTK_BOX(hbox), pixmap_wid, FALSE, FALSE, 0);
  label = gtk_label_new (str);
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  gtk_widget_show (label);
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
/****************************************************/
  return hbox;
}
Exemplo n.º 20
0
void vik_viewport_pan_sync ( VikViewport *vvp, gint x_off, gint y_off )
{
  gint x, y, wid, hei;

  g_return_if_fail ( vvp != NULL );
  gdk_draw_drawable(gtk_widget_get_window(GTK_WIDGET(vvp)), gtk_widget_get_style(GTK_WIDGET(vvp))->bg_gc[0], GDK_DRAWABLE(vvp->scr_buffer), 0, 0, x_off, y_off, vvp->width, vvp->height);

  if (x_off >= 0) {
    x = 0;
    wid = x_off;
  } else {
    x = vvp->width+x_off; 
    wid = -x_off;
  }
  if (y_off >= 0) {
    y = 0;
    hei = y_off;
  } else {
    y = vvp->height+y_off; 
    hei = -y_off;
  }
  gtk_widget_queue_draw_area(GTK_WIDGET(vvp), x, 0, wid, vvp->height);
  gtk_widget_queue_draw_area(GTK_WIDGET(vvp), 0, y, vvp->width, hei);
}
Exemplo n.º 21
0
static void cb_begin_print(GtkPrintOperation *op,
		GtkPrintContext *ctx, gpointer data)
{
	gint layout_height;
	gchar *text;
	GtkTextIter start, end;
	GtkTextBuffer *buffer = gtk_text_view_get_buffer(data);
	PangoTabArray *tabs;
	
	gtk_text_buffer_get_bounds(buffer, &start, &end);
	text = g_strchomp(gtk_text_buffer_get_text(buffer, &start, &end, FALSE));
	
	page_width = gtk_print_context_get_width(ctx);
	page_height = gtk_print_context_get_height(ctx);
	font_desc = gtk_widget_get_style(data)->font_desc;
	layout = gtk_print_context_create_pango_layout(ctx);
	pango_layout_set_width(layout, page_width * PANGO_SCALE);
	pango_layout_set_font_description(layout, font_desc);
	pango_layout_set_text(layout, text, -1);
	
	get_tab_array(&tabs, ctx, data);
	if (tabs) {
		pango_layout_set_tabs(layout, tabs);
		pango_tab_array_free(tabs);
	}
	pango_layout_get_size(layout, NULL, &layout_height);
	
	line_count = pango_layout_get_line_count(layout);
	text_height = pango_font_description_get_size(font_desc) / PANGO_SCALE;
	lines_per_page = page_height / text_height;
	
	n_pages = (line_count - 1) / lines_per_page + 1;
	gtk_print_operation_set_n_pages(op, n_pages);
	
	g_free(text);
}
Exemplo n.º 22
0
static void
rb_vis_widget_realize (GtkWidget *widget)
{
	GtkAllocation  allocation;
	GtkStyle      *style;
	GdkWindowAttr  attributes;
	GdkWindow     *window;
	gint           attributes_mask;

	rb_debug ("realizing container window");
	gtk_widget_get_allocation (widget, &allocation);

	attributes.window_type = GDK_WINDOW_CHILD;
	attributes.x = allocation.x;
	attributes.y = allocation.y;
	attributes.width = allocation.width;
	attributes.height = allocation.height;
	attributes.wclass = GDK_INPUT_OUTPUT;
	attributes.visual = gtk_widget_get_visual (widget);
	attributes.colormap = gtk_widget_get_colormap (widget);
	attributes.event_mask = gtk_widget_get_events (widget);
	attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK;
	attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;

	window = gdk_window_new (gtk_widget_get_parent_window (widget),
				 &attributes, attributes_mask);
	gtk_widget_set_window (widget, window);
	gdk_window_set_user_data (window, widget);
	gdk_window_show (window);

	style = gtk_style_attach (gtk_widget_get_style (widget), window);
	gtk_widget_set_style (widget, style);
	gtk_style_set_background (style, window, GTK_STATE_NORMAL);

	gtk_widget_set_realized (widget, TRUE);
}
Exemplo n.º 23
0
static void
create_gui(MathDisplay *display)
{
    GtkWidget *info_view, *info_box, *main_box;
    PangoFontDescription *font_desc;
    int i;
    GtkStyle *style;

    main_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
    gtk_container_add(GTK_CONTAINER(display), main_box);

    g_signal_connect(display, "key-press-event", G_CALLBACK(key_press_cb), display);

    display->priv->text_view = gtk_text_view_new_with_buffer(GTK_TEXT_BUFFER(display->priv->equation));
    gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(display->priv->text_view), GTK_WRAP_WORD);
    gtk_text_view_set_accepts_tab(GTK_TEXT_VIEW(display->priv->text_view), FALSE);
    gtk_text_view_set_pixels_above_lines(GTK_TEXT_VIEW(display->priv->text_view), 8);
    gtk_text_view_set_pixels_below_lines(GTK_TEXT_VIEW(display->priv->text_view), 2);
    /* TEMP: Disabled for now as GTK+ doesn't properly render a right aligned right margin, see bug #482688 */
    /*gtk_text_view_set_right_margin(GTK_TEXT_VIEW(display->priv->text_view), 6);*/
    gtk_text_view_set_justification(GTK_TEXT_VIEW(display->priv->text_view), GTK_JUSTIFY_RIGHT);
    gtk_widget_ensure_style(display->priv->text_view);
    font_desc = pango_font_description_copy(gtk_widget_get_style(display->priv->text_view)->font_desc);
    pango_font_description_set_size(font_desc, 16 * PANGO_SCALE);
    gtk_widget_modify_font(display->priv->text_view, font_desc);
    pango_font_description_free(font_desc);
    gtk_widget_set_name(display->priv->text_view, "displayitem");
    atk_object_set_role(gtk_widget_get_accessible(display->priv->text_view), ATK_ROLE_EDITBAR);
  //FIXME:<property name="AtkObject::accessible-description" translatable="yes" comments="Accessible description for the area in which results are displayed">Result Region</property>
    g_signal_connect(display->priv->text_view, "key-press-event", G_CALLBACK(display_key_press_cb), display);
    gtk_box_pack_start(GTK_BOX(main_box), display->priv->text_view, TRUE, TRUE, 0);

    info_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
    gtk_box_pack_start(GTK_BOX(main_box), info_box, FALSE, TRUE, 0);

    info_view = gtk_text_view_new();
    gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(info_view), GTK_WRAP_WORD);
    gtk_widget_set_can_focus(info_view, TRUE); // FIXME: This should be FALSE but it locks the cursor inside the main view for some reason
    gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(info_view), FALSE); // FIXME: Just here so when incorrectly gets focus doesn't look editable
    gtk_text_view_set_editable(GTK_TEXT_VIEW(info_view), FALSE);
    gtk_text_view_set_justification(GTK_TEXT_VIEW(info_view), GTK_JUSTIFY_RIGHT);
    /* TEMP: Disabled for now as GTK+ doesn't properly render a right aligned right margin, see bug #482688 */
    /*gtk_text_view_set_right_margin(GTK_TEXT_VIEW(info_view), 6);*/
    gtk_box_pack_start(GTK_BOX(info_box), info_view, TRUE, TRUE, 0);
    display->priv->info_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(info_view));

    display->priv->spinner = gtk_spinner_new();
    gtk_box_pack_end(GTK_BOX(info_box), display->priv->spinner, FALSE, FALSE, 0);
    style = gtk_widget_get_style(info_view);
    for (i = 0; i < 5; i++) {
        gtk_widget_modify_bg(GTK_WIDGET(display), i, &style->base[i]);
    }

    gtk_widget_show(info_box);
    gtk_widget_show(info_view);
    gtk_widget_show(display->priv->text_view);
    gtk_widget_show(main_box);

    g_signal_connect(display->priv->equation, "notify::status", G_CALLBACK(status_changed_cb), display);
    status_changed_cb(display->priv->equation, NULL, display);
}
Exemplo n.º 24
0
static const GtkStyle* ToolTipStyle()
{
    return gtk_widget_get_style(ToolTipWidget());
}
Exemplo n.º 25
0
static void text_entry_populate_popup(GtkEntry *entry, GtkMenu *menu, gpointer data)
{
        GtkWidget *item;
        GtkWidget *submenu;

        item = gtk_menu_item_new_with_mnemonic(_("I_nsert Color Code"));
        gtk_widget_show(item);

        submenu = gtk_menu_new();
        gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
        gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);

        item = gtk_image_menu_item_new_with_label(_("Black"));
        gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
                                      get_color_icon(1, gtk_widget_get_style(item)));
        g_signal_connect(G_OBJECT(item),
                         "activate",
                         G_CALLBACK(color_code_activate),
                         GINT_TO_POINTER(1));
        gtk_menu_shell_append(GTK_MENU_SHELL(submenu), item);
        item = gtk_image_menu_item_new_with_label(_("Dark Blue"));
        gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
                                      get_color_icon(2, gtk_widget_get_style(item)));
        g_signal_connect(G_OBJECT(item),
                         "activate",
                         G_CALLBACK(color_code_activate),
                         GINT_TO_POINTER(2));
        gtk_menu_shell_append(GTK_MENU_SHELL(submenu), item);
        item = gtk_image_menu_item_new_with_label(_("Dark Green"));
        gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
                                      get_color_icon(3, gtk_widget_get_style(item)));
        g_signal_connect(G_OBJECT(item),
                         "activate",
                         G_CALLBACK(color_code_activate),
                         GINT_TO_POINTER(3));
        gtk_menu_shell_append(GTK_MENU_SHELL(submenu), item);
        item = gtk_image_menu_item_new_with_label(_("Red"));
        gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
                                      get_color_icon(4, gtk_widget_get_style(item)));
        g_signal_connect(G_OBJECT(item),
                         "activate",
                         G_CALLBACK(color_code_activate),
                         GINT_TO_POINTER(4));
        gtk_menu_shell_append(GTK_MENU_SHELL(submenu), item);
        item = gtk_image_menu_item_new_with_label(_("Brown"));
        gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
                                      get_color_icon(5, gtk_widget_get_style(item)));
        g_signal_connect(G_OBJECT(item),
                         "activate",
                         G_CALLBACK(color_code_activate),
                         GINT_TO_POINTER(5));
        gtk_menu_shell_append(GTK_MENU_SHELL(submenu), item);
        item = gtk_image_menu_item_new_with_label(_("Purple"));
        gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
                                      get_color_icon(6, gtk_widget_get_style(item)));
        g_signal_connect(G_OBJECT(item),
                         "activate",
                         G_CALLBACK(color_code_activate),
                         GINT_TO_POINTER(6));
        gtk_menu_shell_append(GTK_MENU_SHELL(submenu), item);
        item = gtk_image_menu_item_new_with_label(_("Orange"));
        gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
                                      get_color_icon(7, gtk_widget_get_style(item)));
        g_signal_connect(G_OBJECT(item),
                         "activate",
                         G_CALLBACK(color_code_activate),
                         GINT_TO_POINTER(7));
        gtk_menu_shell_append(GTK_MENU_SHELL(submenu), item);
        item = gtk_image_menu_item_new_with_label(_("Yellow"));
        gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
                                      get_color_icon(8, gtk_widget_get_style(item)));
        g_signal_connect(G_OBJECT(item),
                         "activate",
                         G_CALLBACK(color_code_activate),
                         GINT_TO_POINTER(8));
        gtk_menu_shell_append(GTK_MENU_SHELL(submenu), item);
        item = gtk_image_menu_item_new_with_label(_("Light Green"));
        gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
                                      get_color_icon(9, gtk_widget_get_style(item)));
        g_signal_connect(G_OBJECT(item),
                         "activate",
                         G_CALLBACK(color_code_activate),
                         GINT_TO_POINTER(9));
        gtk_menu_shell_append(GTK_MENU_SHELL(submenu), item);
        item = gtk_image_menu_item_new_with_label(_("Aqua"));
        gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
                                      get_color_icon(10, gtk_widget_get_style(item)));
        g_signal_connect(G_OBJECT(item),
                         "activate",
                         G_CALLBACK(color_code_activate),
                         GINT_TO_POINTER(10));
        gtk_menu_shell_append(GTK_MENU_SHELL(submenu), item);
        item = gtk_image_menu_item_new_with_label(_("Light Blue"));
        gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
                                      get_color_icon(11, gtk_widget_get_style(item)));
        g_signal_connect(G_OBJECT(item),
                         "activate",
                         G_CALLBACK(color_code_activate),
                         GINT_TO_POINTER(11));
        gtk_menu_shell_append(GTK_MENU_SHELL(submenu), item);
        item = gtk_image_menu_item_new_with_label(_("Blue"));
        gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
                                      get_color_icon(12, gtk_widget_get_style(item)));
        g_signal_connect(G_OBJECT(item),
                         "activate",
                         G_CALLBACK(color_code_activate),
                         GINT_TO_POINTER(12));
        gtk_menu_shell_append(GTK_MENU_SHELL(submenu), item);
        item = gtk_image_menu_item_new_with_label(_("Violet"));
        gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
                                      get_color_icon(13, gtk_widget_get_style(item)));
        g_signal_connect(G_OBJECT(item),
                         "activate",
                         G_CALLBACK(color_code_activate),
                         GINT_TO_POINTER(13));
        gtk_menu_shell_append(GTK_MENU_SHELL(submenu), item);
        item = gtk_image_menu_item_new_with_label(_("Grey"));
        gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
                                      get_color_icon(14, gtk_widget_get_style(item)));
        g_signal_connect(G_OBJECT(item),
                         "activate",
                         G_CALLBACK(color_code_activate),
                         GINT_TO_POINTER(14));
        gtk_menu_shell_append(GTK_MENU_SHELL(submenu), item);
        item = gtk_image_menu_item_new_with_label(_("Light Grey"));
        gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
                                      get_color_icon(15, gtk_widget_get_style(item)));
        g_signal_connect(G_OBJECT(item),
                         "activate",
                         G_CALLBACK(color_code_activate),
                         GINT_TO_POINTER(15));
        gtk_menu_shell_append(GTK_MENU_SHELL(submenu), item);
        item = gtk_image_menu_item_new_with_label(_("White"));
        gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
                                      get_color_icon(0, gtk_widget_get_style(item)));
        g_signal_connect(G_OBJECT(item),
                         "activate",
                         G_CALLBACK(color_code_activate),
                         GINT_TO_POINTER(0));
        gtk_menu_shell_append(GTK_MENU_SHELL(submenu), item);

        gtk_widget_show_all(submenu);
}
Exemplo n.º 26
0
static const GtkStyle* MenuBarStyle()
{
    return gtk_widget_get_style(MenuBarWidget());
}
Exemplo n.º 27
0
static const GtkStyle* MenuItemStyle()
{
    return gtk_widget_get_style(MenuItemWidget());
}
Exemplo n.º 28
0
static const GtkStyle* TextCtrlStyle()
{
    return gtk_widget_get_style(TextCtrlWidget());
}
Exemplo n.º 29
0
static const GtkStyle* ListStyle()
{
    return gtk_widget_get_style(ListWidget());
}
Exemplo n.º 30
0
static const GtkStyle* ButtonStyle()
{
    return gtk_widget_get_style(ButtonWidget());
}