static void
update_fonts (UmEditableButton *button)
{
        PangoAttrList *attrs;
        PangoAttribute *attr;
        GtkWidget *label;

        UmEditableButtonPrivate *priv = button->priv;

        attrs = pango_attr_list_new ();
        if (priv->scale_set) {
                attr = pango_attr_scale_new (priv->scale);
                pango_attr_list_insert (attrs, attr);
        }
        if (priv->weight_set) {
                attr = pango_attr_weight_new (priv->weight);
                pango_attr_list_insert (attrs, attr);
        }

        gtk_label_set_attributes (priv->label, attrs);

        label = gtk_bin_get_child (GTK_BIN (priv->button));
        gtk_label_set_attributes (GTK_LABEL (label), attrs);

        pango_attr_list_unref (attrs);
}
Exemplo n.º 2
0
static void
thunar_chooser_button_file_changed (ThunarChooserButton *chooser_button,
                                    ThunarFile          *file)
{
  ThunarVfsMimeApplication *application;
  ThunarVfsMimeInfo        *info;
  ThunarIconFactory        *icon_factory;
  GtkIconTheme             *icon_theme;
  const gchar              *icon_name;
  GdkPixbuf                *icon = NULL;
  gint                      icon_size;

  _thunar_return_if_fail (THUNAR_IS_CHOOSER_BUTTON (chooser_button));
  _thunar_return_if_fail (chooser_button->file == file);
  _thunar_return_if_fail (THUNAR_IS_FILE (file));

  /* determine the mime info for the file */
  info = thunar_file_get_mime_info (file);

  /* determine the default application for that mime info */
  application = thunar_vfs_mime_database_get_default_application (chooser_button->database, info);
  if (G_LIKELY (application != NULL))
    {
      /* determine the icon size for menus */
      gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &icon_size, &icon_size);

      /* setup the image for the application */
      icon_factory = thunar_icon_factory_get_default ();
      icon_theme = thunar_icon_factory_get_icon_theme (icon_factory);
      icon_name = thunar_vfs_mime_handler_lookup_icon_name (THUNAR_VFS_MIME_HANDLER (application), icon_theme);
      if (G_LIKELY (icon_name != NULL))
        icon = thunar_icon_factory_load_icon (icon_factory, icon_name, icon_size, NULL, FALSE);
      gtk_image_set_from_pixbuf (GTK_IMAGE (chooser_button->image), icon);
      g_object_unref (G_OBJECT (icon_factory));
      if (G_LIKELY (icon != NULL))
        g_object_unref (G_OBJECT (icon));

      /* setup the label for the application */
      gtk_label_set_attributes (GTK_LABEL (chooser_button->label), NULL);
      gtk_label_set_text (GTK_LABEL (chooser_button->label), thunar_vfs_mime_handler_get_name (THUNAR_VFS_MIME_HANDLER (application)));

      /* cleanup */
      g_object_unref (G_OBJECT (application));
    }
  else
    {
      /* no default application specified */
      gtk_label_set_attributes (GTK_LABEL (chooser_button->label), thunar_pango_attr_list_italic ());
      gtk_label_set_text (GTK_LABEL (chooser_button->label), _("No application selected"));
      gtk_image_set_from_pixbuf (GTK_IMAGE (chooser_button->image), NULL);
    }

  /* setup a useful tooltip for the button */
  thunar_gtk_widget_set_tooltip (chooser_button->button,
                                 _("The selected application is used to open "
                                   "this and other files of type \"%s\"."),
                                 thunar_vfs_mime_info_get_comment (info));
}
Exemplo n.º 3
0
bool wxStaticText::SetFont( const wxFont &font )
{
    const bool wasUnderlined = GetFont().GetUnderlined();
    const bool wasStrickenThrough = GetFont().GetStrikethrough();

    bool ret = wxControl::SetFont(font);

    const bool isUnderlined = GetFont().GetUnderlined();
    const bool isStrickenThrough = GetFont().GetStrikethrough();

    if ( (isUnderlined != wasUnderlined) ||
            (isStrickenThrough != wasStrickenThrough) )
    {
        // We need to update the Pango attributes used for the text.
        if ( isUnderlined || isStrickenThrough )
        {
            PangoAttrList* const attrs = pango_attr_list_new();
            if ( isUnderlined )
            {
                PangoAttribute *a = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
                a->start_index = 0;
                a->end_index = (guint)-1;
                pango_attr_list_insert(attrs, a);
            }

            if ( isStrickenThrough )
            {
                PangoAttribute *a = pango_attr_strikethrough_new( TRUE );
                a->start_index = 0;
                a->end_index = (guint) -1;
                pango_attr_list_insert(attrs, a);
            }

            gtk_label_set_attributes(GTK_LABEL(m_widget), attrs);
            pango_attr_list_unref(attrs);
        }
        else // No special attributes any more.
        {
            // Just remove any attributes we had set.
            gtk_label_set_attributes(GTK_LABEL(m_widget), NULL);
        }

        // The underlines for mnemonics are incompatible with using attributes
        // so turn them off when setting underlined font.
        gtk_label_set_use_underline(GTK_LABEL(m_widget), !isUnderlined);
    }

    // adjust the label size to the new label unless disabled
    if (!HasFlag(wxST_NO_AUTORESIZE))
    {
        SetSize( GetBestSize() );
    }
    return ret;
}
Exemplo n.º 4
0
static void
match_label_color (GstyleColorWidget *self,
                   GstyleColor       *color)
{
  PangoLayout *layout;
  PangoAttrList *attr_list;
  PangoAttribute *attr;
  GdkRGBA rgba;
  GdkRGBA dst_rgba;

  g_assert (GSTYLE_IS_COLOR_WIDGET (self));
  g_assert (GSTYLE_IS_COLOR (color));

  layout = gtk_label_get_layout (self->label);
  attr_list = pango_layout_get_attributes (layout);
  if (attr_list == NULL)
    {
      attr_list = pango_attr_list_new ();
      gtk_label_set_attributes (self->label, attr_list);
      pango_attr_list_unref (attr_list);
    }

  gstyle_color_fill_rgba (color, &rgba);
  gstyle_utils_get_contrasted_rgba (rgba, &dst_rgba);
  attr = pango_attr_foreground_new (dst_rgba.red * 0xffff, dst_rgba.green * 0xffff, dst_rgba.blue * 0xffff);
  pango_attr_list_change (attr_list, attr);
  attr = pango_attr_background_new (rgba.red * 0xffff, rgba.green * 0xffff, rgba.blue * 0xffff);
  pango_attr_list_change (attr_list, attr);
}
Exemplo n.º 5
0
void
CoordWinSetFont(const char *font)
{
#if GTK_CHECK_VERSION(3, 16, 0)
  if (NgraphApp.CoordWin.data.text && font) {
    set_widget_font(NgraphApp.CoordWin.data.text, font);
  }
#else  /* GTK_CHECK_VERSION(3, 16, 0) */
  const char *ptr;
  PangoAttrList *pattr;
  PangoFontDescription *desc;
  GtkLabel *label;

  label = GTK_LABEL(NgraphApp.CoordWin.data.text);

  if (label == NULL)
    return;

  pattr = gtk_label_get_attributes(label);
  if (pattr == NULL) {
    pattr = pango_attr_list_new();
    gtk_label_set_attributes(GTK_LABEL(label), pattr);
  }

  ptr = (font) ? font : "Monospace";

  desc = pango_font_description_from_string(ptr);
  pango_attr_list_change(pattr, pango_attr_font_desc_new(desc));
  pango_font_description_free(desc);
#endif
}
Exemplo n.º 6
0
/* Set the colour of the "valid from" and "valid until" elements on the
 * Certificate page to red if they are incorrectly in the future or
 * past. */
static void show_date_state(char* label, void* data, int length) {
	gchar* labelname = g_strndup(label, strstr(label, ":") - label);
	GtkLabel* l = GTK_LABEL(gtk_builder_get_object(builder, labelname));
	PangoAttrList *attrs = pango_attr_list_new();
	PangoAttribute *attr;
	gboolean* is_invalid = (gboolean*)data;

	g_free(labelname);
	if(*is_invalid) {
		attr = pango_attr_foreground_new(G_MAXUINT16, 0, 0);
	} else {
#if HAVE_GTK == 3
		GdkRGBA color;
		GtkStyleContext *style = gtk_widget_get_style_context(GTK_WIDGET(l));

		gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
		attr = pango_attr_foreground_new(color.red * G_MAXUINT16, color.green * G_MAXUINT16, color.blue * G_MAXUINT16);
#else
#if HAVE_GTK == 2
		/* In GTK+ 2, there is no GtkStyleContext yet. It
		 * should, in theory, be possible to figure out what the
		 * default foreground color is by using a GTK+
		 * 2-specific API, but that's too much work and GTK+ 2
		 * is a minority now anyway, so... */
		attr = pango_attr_foreground_new(0, 0, 0);
#else
		/* The configure script only allows GTK+2 or GTK+3. */
#error should not happen
#endif
#endif
	}
	pango_attr_list_insert(attrs, attr);
	gtk_label_set_attributes(l, attrs);
}
Exemplo n.º 7
0
void gnome_main_section_new_with_grid(const gchar *title, GtkWidget **frame, GtkWidget **grid)
{
    PangoAttrList *attrs = pango_attr_list_new();
    PangoAttribute *attr = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
    attr->start_index = 0;
    attr->end_index = -1;
    pango_attr_list_insert(attrs, attr);

    *frame = gtk_frame_new(title);
    gtk_frame_set_shadow_type(GTK_FRAME(*frame), GTK_SHADOW_NONE);
    gtk_container_set_border_width(GTK_CONTAINER(*frame), 2);

    GtkWidget *label = gtk_frame_get_label_widget(GTK_FRAME(*frame));
    gtk_label_set_attributes(GTK_LABEL(label), attrs);
    pango_attr_list_unref(attrs);

    GtkWidget *align = gtk_alignment_new(0.08, 0.2, 0.1, 0.1);
    gtk_container_add(GTK_CONTAINER(*frame), align);

    *grid = gtk_grid_new();
    gtk_grid_set_row_spacing(GTK_GRID(*grid), 2);
    gtk_grid_set_column_spacing(GTK_GRID(*grid), 2);
    gtk_widget_show(*grid);
    gtk_container_add(GTK_CONTAINER(align), *grid);
}
Exemplo n.º 8
0
Arquivo: gui.c Projeto: MufriA/stoken
static GtkWidget *app_window_common(void)
{
	GtkWidget *window;
	PangoAttrList *attr;

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_container_set_border_width(GTK_CONTAINER(window), 10);
	gtk_window_set_title(GTK_WINDOW(window), WINDOW_TITLE);

	g_signal_connect(window, "delete-event", G_CALLBACK(delete_event),
			 NULL);

	tokencode_text = gtk_label_new(NULL);
	attr = pango_attr_list_new();
	pango_attr_list_insert(attr, pango_attr_scale_new(PANGO_SCALE_XX_LARGE));
	pango_attr_list_insert(attr, pango_attr_weight_new(PANGO_WEIGHT_BOLD));
	gtk_label_set_attributes(GTK_LABEL(tokencode_text), attr);
	pango_attr_list_unref(attr);

	/* hack to turn off progress bar animation seen on some themes */
	gtk_rc_parse_string("style \"default\" { engine \"\" { }\n"
		"bg[PRELIGHT] = \"#4b6785\" }\n"
		"widget_class \"*.<GtkProgressBar>\" style \"default\"");

	return window;
}
Exemplo n.º 9
0
static void
ide_omni_bar__build_manager__build_started (IdeOmniBar       *self,
                                            IdeBuildPipeline *build_pipeline,
                                            IdeBuildManager  *build_manager)
{
  g_assert (IDE_IS_OMNI_BAR (self));
  g_assert (IDE_IS_BUILD_PIPELINE (build_pipeline));
  g_assert (IDE_IS_BUILD_MANAGER (build_manager));

  self->did_build = TRUE;
  self->seen_count = 0;

  self->message_handler =
    g_signal_connect_object (build_pipeline,
                             "notify::message",
                             G_CALLBACK (ide_omni_bar_notify_message),
                             self,
                             G_CONNECT_SWAPPED);

  gtk_revealer_set_reveal_child (self->popover_details_revealer, TRUE);

  gtk_label_set_label (self->popover_build_result_label, _("Building"));
  gtk_label_set_attributes (self->popover_build_result_label, NULL);
  dzl_gtk_widget_remove_style_class (GTK_WIDGET (self->popover_build_result_label), "error");
  dzl_gtk_widget_remove_style_class (GTK_WIDGET (self->popover_build_result_label), "success");

  dzl_gtk_widget_add_style_class (GTK_WIDGET (self), "building");
}
Exemplo n.º 10
0
static gboolean
query_unlock_tooltip (GtkWidget  *widget,
                      gint        x,
                      gint        y,
                      gboolean    keyboard_tooltip,
                      GtkTooltip *tooltip,
                      gpointer    user_data)
{
        GtkWidget *label;
        PangoLayout *layout;
        PangoAttrList *attrs;
        IconShapeData *data;

        data = g_object_get_data (G_OBJECT (widget), "icon-shape-data");
        label = g_object_get_data (G_OBJECT (widget), "tooltip-label");
        if (label == NULL) {
                label = gtk_label_new (data->text);
                g_object_ref_sink (label);
                g_object_set_data_full (G_OBJECT (widget),
                                        "tooltip-label", label, g_object_unref);
        }

        layout = gtk_label_get_layout (GTK_LABEL (label));
        pango_cairo_context_set_shape_renderer (pango_layout_get_context (layout),
                                                icon_shape_renderer,
                                                data, NULL);

        attrs = create_shape_attr_list_for_layout (layout, data);
        gtk_label_set_attributes (GTK_LABEL (label), attrs);
        pango_attr_list_unref (attrs);

        gtk_tooltip_set_custom (tooltip, label);

        return TRUE;
}
Exemplo n.º 11
0
static void
append_item (NemoImagePropertiesPage *page,
	     const char                  *name,
	     const char                  *value)
{
	GtkWidget *name_label;
	GtkWidget *label;
	PangoAttrList *attrs;

	name_label = gtk_label_new (name);
	attrs = pango_attr_list_new ();
	pango_attr_list_insert (attrs, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
	gtk_label_set_attributes (GTK_LABEL (name_label), attrs);
	pango_attr_list_unref (attrs);
	gtk_misc_set_alignment (GTK_MISC (name_label), 0, 0);
	gtk_container_add (GTK_CONTAINER (page->details->grid), name_label);
	gtk_widget_show (name_label);

	if (value != NULL) {
		label = gtk_label_new (value);
		gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
		gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
		gtk_grid_attach_next_to (GTK_GRID (page->details->grid), label,
					 name_label, GTK_POS_RIGHT,
					 1, 1);
		gtk_widget_show (label);
	}
}
Exemplo n.º 12
0
bool
OxLabel_SetTextColor(OxLabelObject* ox, int iRed, int iGreen, int iBlue)
{
	PangoAttrList* pAL = pango_attr_list_new();
	pango_attr_list_insert(pAL, pango_attr_foreground_new(iRed, iGreen, iBlue));
	gtk_label_set_attributes(GTK_LABEL(ox->pGtk), pAL);
	return TRUE;
}
static void
scale_label (GtkBin *toggle, PangoAttrList *attrs)
{
  GtkWidget *label;

  label = gtk_bin_get_child (toggle);
  gtk_label_set_attributes (GTK_LABEL (label), attrs);
}
Exemplo n.º 14
0
void clr_tsin_cursor(int index)
{
    GtkWidget *label = chars[index].label;

    if (!label)
        return;
    gtk_label_set_attributes(GTK_LABEL(label), attr_list_blank);
}
Exemplo n.º 15
0
static void set_background(CustomData *data) {
    PangoAttrList *attrs;

    attrs = pango_attr_list_new();
    pango_attr_list_insert (attrs, pango_attr_background_new (65535, 0, 0));
    gtk_label_set_attributes(GTK_LABEL (data->timelabel), attrs);
    pango_attr_list_unref (attrs);
}
Exemplo n.º 16
0
GtkWidget *
do_rotated_text (GtkWidget *do_widget)
{
  static GtkWidget *window = NULL;

  if (!window)
    {
      GtkWidget *box;
      GtkWidget *drawing_area;
      GtkWidget *label;
      PangoLayout *layout;
      PangoAttrList *attrs;

      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
      gtk_window_set_screen (GTK_WINDOW (window),
                             gtk_widget_get_screen (do_widget));
      gtk_window_set_title (GTK_WINDOW (window), "Rotated Text");
      gtk_window_set_default_size (GTK_WINDOW (window), 4 * RADIUS, 2 * RADIUS);
      g_signal_connect (window, "destroy",
                        G_CALLBACK (gtk_widget_destroyed), &window);

      box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
      gtk_box_set_homogeneous (GTK_BOX (box), TRUE);
      gtk_container_add (GTK_CONTAINER (window), box);

      /* Add a drawing area */
      drawing_area = gtk_drawing_area_new ();
      gtk_container_add (GTK_CONTAINER (box), drawing_area);
      gtk_style_context_add_class (gtk_widget_get_style_context (drawing_area),
                                   GTK_STYLE_CLASS_VIEW);

      gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area),
                                      rotated_text_draw,
                                      NULL, NULL);

      /* And a label */
      label = gtk_label_new (text);
      gtk_container_add (GTK_CONTAINER (box), label);

      gtk_label_set_angle (GTK_LABEL (label), 45);

      /* Set up fancy stuff on the label */
      layout = gtk_label_get_layout (GTK_LABEL (label));
      pango_cairo_context_set_shape_renderer (pango_layout_get_context (layout),
                                              fancy_shape_renderer,
                                              NULL, NULL);
      attrs = create_fancy_attr_list_for_layout (layout);
      gtk_label_set_attributes (GTK_LABEL (label), attrs);
      pango_attr_list_unref (attrs);
    }

  if (!gtk_widget_get_visible (window))
    gtk_widget_show_all (window);
  else
    gtk_widget_destroy (window);

  return window;
}
Exemplo n.º 17
0
GtkWidget *
gnome_prefs_subsection_new (GtkWidget *window,
			    GtkWidget *container,
			    const gchar *frame_name,       
			    int rows,
			    int cols)      
{
  GnomePrefsWindow *gpw  = NULL;
  
  GtkWidget *hbox = NULL;
  GtkWidget *frame = NULL;
  GtkWidget *table = NULL;
  GtkWidget *label = NULL;
  
  PangoAttrList *attrs = NULL;
  PangoAttribute *attr = NULL;

  if (window)
    gpw = (GnomePrefsWindow *) g_object_get_data (G_OBJECT (window), "gpw");
  
  hbox = gtk_hbox_new (FALSE, 6);

  frame = gtk_frame_new (frame_name);
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
  
  attrs = pango_attr_list_new ();
  attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
  attr->start_index = 0;
  attr->end_index = -1;
  pango_attr_list_insert (attrs, attr);

  label = gtk_frame_get_label_widget (GTK_FRAME (frame));
  gtk_label_set_attributes (GTK_LABEL (label), attrs);
  pango_attr_list_unref (attrs);

  gtk_box_pack_start (GTK_BOX (container), frame,
                      FALSE, FALSE, 0);
  table = gtk_table_new (rows, cols, FALSE);                                   
                                                                              
  gtk_container_add (GTK_CONTAINER (frame), hbox); 

  gtk_container_set_border_width (GTK_CONTAINER (hbox), 3);
  gtk_container_set_border_width (GTK_CONTAINER (frame), 6);

  label = gtk_label_new ("    ");
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
  gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0);
                                                                               
  gtk_table_set_row_spacings (GTK_TABLE (table), 2);     
  gtk_table_set_col_spacings (GTK_TABLE (table), 6);     

  if (gpw)
    g_object_set_data (G_OBJECT (table), "gpw", gpw);

  gtk_widget_show_all (table);
  
  return table;
}                                                                              
Exemplo n.º 18
0
static gboolean
enter_event_box_cb (GtkWidget *widget, GdkEvent *event, gpointer user_data)
{
    GtkWidget *label;

    label = user_data;
    gtk_label_set_attributes (GTK_LABEL (label), label_prelight ());   
    
    return FALSE;                             
}
Exemplo n.º 19
0
void set_cursor_tsin(int index)
{
  GtkWidget *label = chars[index].label;

  if (!label)
    return;

  if (gcin_edit_display_ap_only())
    return;

  gtk_label_set_attributes(GTK_LABEL(label), attr_list);
}
void
gtk_label_set_attribute_bold(GtkLabel *label)
{
	PangoAttrList *Bold = pango_attr_list_new();
	PangoAttribute *Attribute = NULL;
	Attribute = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
	pango_attr_list_insert(Bold, Attribute);

	gtk_label_set_attributes(label, Bold);

	pango_attr_list_unref(Bold);
}
Exemplo n.º 21
0
static void ygtk_step_update_layout (YGtkSteps *steps, gint step)
{
	if (step < 0) return;
	gboolean bold = steps->current_step == step;
	GList *children = gtk_container_get_children (GTK_CONTAINER (steps));
	GtkWidget *label = (GtkWidget *) g_list_nth_data (children, step);
	if (g_object_get_data (G_OBJECT (label), "is-header"))
		return;
	if (bold) {
		PangoAttrList *attrbs = pango_attr_list_new();
		pango_attr_list_insert (attrbs, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
		gtk_label_set_attributes (GTK_LABEL (label), attrbs);
		pango_attr_list_unref (attrbs);
		atk_object_set_description (gtk_widget_get_accessible (label), _("Current step"));
	}
	else {
		gtk_label_set_attributes (GTK_LABEL (label), NULL);
		atk_object_set_description (gtk_widget_get_accessible (label), "");
	}
	g_list_free (children);
}
static void
label_set_bold (GtkLabel *label,
                gboolean  bold)
{
        PangoAttrList *attrs;
        PangoAttribute *attr;

        attrs = pango_attr_list_new ();
        attr = pango_attr_weight_new (bold ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
        pango_attr_list_insert (attrs, attr);
        gtk_label_set_attributes (label, attrs);
        pango_attr_list_unref (attrs);
}
Exemplo n.º 23
0
static void
scale_label(GtkEventBox *button, double scale)
{
  GtkWidget *label;
  PangoAttrList *attrs = pango_attr_list_new();
  PangoAttribute *attr = pango_attr_scale_new(scale);

  pango_attr_list_insert(attrs, attr);
  label = gtk_bin_get_child(GTK_BIN(button));
  if (GTK_IS_LABEL(label))
    gtk_label_set_attributes(GTK_LABEL(label), attrs);
  pango_attr_list_unref(attrs);
}
Exemplo n.º 24
0
static GtkWidget *getTitleLabel() {
    GtkWidget *label = gtk_label_new (_("Home"));
    gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    PangoAttrList *attr_list = pango_attr_list_new ();
    PangoAttribute *attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
    pango_attr_list_insert (attr_list, attr);
    gtk_label_set_attributes (GTK_LABEL (label), attr_list);
    pango_attr_list_unref (attr_list);
    gtk_widget_set_hexpand (label, TRUE);
    gtk_widget_set_vexpand (label, TRUE);
    gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
    return label;
}
Exemplo n.º 25
0
bool wxStaticText::SetFont( const wxFont &font )
{
    const bool wasUnderlined = GetFont().GetUnderlined();

    bool ret = wxControl::SetFont(font);

    if ( font.GetUnderlined() != wasUnderlined )
    {
        // the underlines for mnemonics are incompatible with using attributes
        // so turn them off when setting underlined font and restore them when
        // unsetting it
        gtk_label_set_use_underline(GTK_LABEL(m_widget), wasUnderlined);

        if ( wasUnderlined )
        {
            // it's not underlined any more, remove the attributes we set
            gtk_label_set_attributes(GTK_LABEL(m_widget), NULL);
        }
        else // the text is underlined now
        {
            PangoAttrList *attrs = pango_attr_list_new();
            PangoAttribute *a = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
            a->start_index = 0;
            a->end_index = (guint)-1;
            pango_attr_list_insert(attrs, a);
            gtk_label_set_attributes(GTK_LABEL(m_widget), attrs);
            pango_attr_list_unref(attrs);
        }
    }

    // adjust the label size to the new label unless disabled
    if (!HasFlag(wxST_NO_AUTORESIZE))
    {
        SetSize( GetBestSize() );
    }
    return ret;
}
Exemplo n.º 26
0
void i_fileinfo_grid_add_entry( gchar * field_text , gchar * value_text ,
                                GtkWidget * grid , guint line , PangoAttrList * attrlist )
{
  GtkWidget *field, *value;
  field = gtk_label_new( field_text );
  gtk_label_set_attributes( GTK_LABEL(field) , attrlist );
  gtk_misc_set_alignment( GTK_MISC(field) , 0 , 0 );
  gtk_label_set_justify( GTK_LABEL(field) , GTK_JUSTIFY_LEFT );
  gtk_grid_attach( GTK_GRID(grid) , field , 0 , line , 1 , 1 );
  value = gtk_label_new( value_text );
  gtk_misc_set_alignment( GTK_MISC(value) , 0 , 0 );
  gtk_label_set_justify( GTK_LABEL(value) , GTK_JUSTIFY_LEFT );
  gtk_grid_attach( GTK_GRID(grid) , value , 1 , line , 1 , 1 );
  return;
}
G_MODULE_EXPORT void
strip_attributes_if_no_animation (GtkWidget *widget)
{
  gboolean enabled;

  g_object_get (gtk_widget_get_settings (widget), "gtk-enable-animations", &enabled, NULL);
  if (enabled)
    return;

  g_message ("Unsetting text attributes because animation is disabled.");

  reftest_inhibit_snapshot ();
  gtk_label_set_attributes (GTK_LABEL (widget), NULL);
  g_timeout_add (500, unblock, NULL);
}
Exemplo n.º 28
0
static void
gimp_frame_label_widget_notify (GtkFrame *frame)
{
  GtkWidget *label_widget = gtk_frame_get_label_widget (frame);

  if (label_widget)
    {
      GtkLabel *label = NULL;

      if (GTK_IS_LABEL (label_widget))
        {
          gfloat xalign, yalign;

          label = GTK_LABEL (label_widget);

          gtk_frame_get_label_align (frame, &xalign, &yalign);
          gtk_misc_set_alignment (GTK_MISC (label), xalign, yalign);
        }
      else if (GTK_IS_BIN (label_widget))
        {
          GtkWidget *child = gtk_bin_get_child (GTK_BIN (label_widget));

          if (GTK_IS_LABEL (child))
            label = GTK_LABEL (child);
        }

      if (label)
        {
          PangoAttrList  *attrs = pango_attr_list_new ();
          PangoAttribute *attr;
          gboolean        bold;

          gtk_widget_style_get (GTK_WIDGET (frame), "label_bold", &bold, NULL);

          attr = pango_attr_weight_new (bold ?
                                        PANGO_WEIGHT_BOLD :
                                        PANGO_WEIGHT_NORMAL);
          attr->start_index = 0;
          attr->end_index   = -1;
          pango_attr_list_insert (attrs, attr);

          gtk_label_set_attributes (label, attrs);

          pango_attr_list_unref (attrs);
        }
    }
}
Exemplo n.º 29
0
static void
nautilus_trash_bar_init (NautilusTrashBar *bar)
{
	GtkWidget *content_area, *action_area, *w;
	GtkWidget *label;
	PangoAttrList *attrs;

	bar->priv = NAUTILUS_TRASH_BAR_GET_PRIVATE (bar);
	content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (bar));
	action_area = gtk_info_bar_get_action_area (GTK_INFO_BAR (bar));

	gtk_orientable_set_orientation (GTK_ORIENTABLE (action_area),
					GTK_ORIENTATION_HORIZONTAL);

	attrs = pango_attr_list_new ();
	pango_attr_list_insert (attrs, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
	label = gtk_label_new (_("Trash"));
	gtk_label_set_attributes (GTK_LABEL (label), attrs);
	pango_attr_list_unref (attrs);

	gtk_widget_show (label);
	gtk_container_add (GTK_CONTAINER (content_area), label);

	w = gtk_info_bar_add_button (GTK_INFO_BAR (bar),
				     _("_Restore"),
				     TRASH_BAR_RESPONSE_RESTORE);
	gtk_widget_set_tooltip_text (w,
				     _("Restore selected items to their original position"));

	w = gtk_info_bar_add_button (GTK_INFO_BAR (bar),
	/* Translators: "Empty" is an action (for the trash) , not a state */
				     _("_Empty"),
				     TRASH_BAR_RESPONSE_EMPTY);
	gtk_widget_set_tooltip_text (w,
				     _("Delete all items in the Trash"));

	g_signal_connect_object (nautilus_trash_monitor_get (),
				 "trash-state-changed",
				 G_CALLBACK (nautilus_trash_bar_trash_state_changed),
				 bar,
				 0);
	nautilus_trash_bar_trash_state_changed (nautilus_trash_monitor_get (),
						FALSE, bar);

	g_signal_connect (bar, "response",
			  G_CALLBACK (trash_bar_response_cb), bar);
}
Exemplo n.º 30
0
void ygtk_steps_append_heading (YGtkSteps *steps, const gchar *heading)
{
	GtkWidget *label = gtk_label_new (heading);
	GdkRGBA black = { 0.0, 0.0, 0.0, 1.0 };
	gtk_widget_override_color (label, GTK_STATE_NORMAL, &black);
	g_object_set_data (G_OBJECT (label), "is-header", GINT_TO_POINTER (1));
	gtk_misc_set_alignment (GTK_MISC (label), 0, 0);

	PangoAttrList *attrbs = pango_attr_list_new();
	pango_attr_list_insert (attrbs, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
	pango_attr_list_insert (attrbs, pango_attr_scale_new (PANGO_SCALE_LARGE));
	gtk_label_set_attributes (GTK_LABEL (label), attrbs);
	pango_attr_list_unref (attrbs);

	gtk_widget_show (label);
	gtk_box_pack_start (GTK_BOX (steps), label, FALSE, TRUE, 6);
}