Exemplo n.º 1
0
/**
 * gimp_enum_icon_box_set_child_padding:
 * @icon_box: an icon box widget
 * @xpad:     horizontal padding
 * @ypad:     vertical padding
 *
 * Sets the padding of all buttons in a box created by
 * gimp_enum_icon_box_new().
 *
 * Since: GIMP 2.10
 **/
void
gimp_enum_icon_box_set_child_padding (GtkWidget *icon_box,
                                      gint       xpad,
                                      gint       ypad)
{
  GList *children;
  GList *list;

  g_return_if_fail (GTK_IS_CONTAINER (icon_box));

  children = gtk_container_get_children (GTK_CONTAINER (icon_box));

  for (list = children; list; list = g_list_next (list))
    {
      GtkWidget *child = gtk_bin_get_child (GTK_BIN (list->data));

      if (GTK_IS_MISC (child))
        {
          GtkMisc *misc = GTK_MISC (child);
          gint     misc_xpad;
          gint     misc_ypad;

          gtk_misc_get_padding (misc, &misc_xpad, &misc_ypad);

          gtk_misc_set_padding (misc,
                                xpad < 0 ? misc_xpad : xpad,
                                ypad < 0 ? misc_ypad : ypad);
        }
    }

  g_list_free (children);
}
Exemplo n.º 2
0
static gint
calculate_arrow_rect(GtkWidget* arrow, GdkRectangle* rect,
                     GdkRectangle* arrow_rect, GtkTextDirection direction)
{
    /* defined in gtkarrow.c */
    gfloat arrow_scaling = 0.7;
    gfloat xalign, xpad;
    gint extent;
    GtkMisc* misc = GTK_MISC(arrow);
    gfloat misc_xalign, misc_yalign;
    gint misc_xpad, misc_ypad;

    if (have_arrow_scaling)
        gtk_widget_style_get(arrow, "arrow_scaling", &arrow_scaling, NULL);

    gtk_misc_get_padding(misc, &misc_xpad, &misc_ypad);
    gtk_misc_get_alignment(misc, &misc_xalign, &misc_yalign);

    extent = MIN((rect->width - misc_xpad * 2),
                 (rect->height - misc_ypad * 2)) * arrow_scaling;

    xalign = direction == GTK_TEXT_DIR_LTR ? misc_xalign : 1.0 - misc_xalign;
    xpad = misc_xpad + (rect->width - extent) * xalign;

    arrow_rect->x = direction == GTK_TEXT_DIR_LTR ?
                        floor(rect->x + xpad) : ceil(rect->x + xpad);
    arrow_rect->y = floor(rect->y + misc_ypad +
                          ((rect->height - extent) * misc_yalign));

    arrow_rect->width = arrow_rect->height = extent;

    return MOZ_GTK_SUCCESS;
}
static void
awn_image_size_request (GtkWidget *widget, GtkRequisition *req)
{
  gint xpad, ypad, offset;
  GtkPositionType pos;
  GTK_WIDGET_CLASS (awn_image_parent_class)->size_request (widget, req);

  AwnImagePrivate *priv = AWN_IMAGE_GET_PRIVATE (widget);

  gtk_misc_get_padding (GTK_MISC (widget), &xpad, &ypad);
  awn_effects_set_icon_size (priv->effects,
                             req->width - xpad * 2,
                             req->height - ypad * 2,
                             FALSE);

  g_object_get (priv->effects, "position", &pos, NULL);
  if (pos == GTK_POS_TOP || pos == GTK_POS_BOTTOM)
  {
    offset = ypad;
  }
  else
  {
    offset = xpad;
  }
  g_object_set (priv->effects, "icon-offset", offset, NULL);
}
static void
style_set_handler (GtkWidget *widget, GtkStyle *previous_style)
{
	PangoLayout *layout;
	int width, width2;
	int xpad;

	layout = gtk_label_get_layout (GTK_LABEL(widget));

	layout = pango_layout_copy (layout);

	pango_layout_set_text (layout, LOCATION_LABEL, -1);
	pango_layout_get_pixel_size (layout, &width, NULL);
	
	pango_layout_set_text (layout, GO_TO_LABEL, -1);
	pango_layout_get_pixel_size (layout, &width2, NULL);
	width = MAX (width, width2);

	gtk_misc_get_padding (GTK_MISC (widget),
			      &xpad, NULL);

	width += 2 * xpad;

	gtk_widget_set_size_request (widget, width, -1);

	g_object_unref (layout);
}
Exemplo n.º 5
0
static VALUE
misc_get_padding(VALUE self)
{
    gint xpad, ypad;
    gtk_misc_get_padding(_SELF(self), &xpad, &ypad);

    return rb_ary_new3(2, INT2NUM(xpad), INT2NUM(ypad));
}
Exemplo n.º 6
0
static gint
luaH_label_get_padding(lua_State *L)
{
    widget_t *w = luaH_checkwidget(L, 1);
    gint xpad, ypad;
    gtk_misc_get_padding(GTK_MISC(w->widget), &xpad, &ypad);
    lua_pushnumber(L, xpad);
    lua_pushnumber(L, ypad);
    return 2;
}
Exemplo n.º 7
0
static gint
luaH_label_get_padding(lua_State *L, widget_t *w)
{
    gint xpad, ypad;
    gtk_misc_get_padding(GTK_MISC(w->widget), &xpad, &ypad);
    lua_createtable(L, 0, 2);
    /* set padding.x */
    lua_pushliteral(L, "x");
    lua_pushnumber(L, xpad);
    lua_rawset(L, -3);
    /* set padding.y */
    lua_pushliteral(L, "y");
    lua_pushnumber(L, ypad);
    lua_rawset(L, -3);
    return 1;
}
Exemplo n.º 8
0
static gint
luaH_label_set_padding(lua_State *L, widget_t *w)
{
    luaH_checktable(L, 3);
    /* get old padding values */
    gint xpad = 0, ypad = 0;
    gtk_misc_get_padding(GTK_MISC(w->widget), &xpad, &ypad);
    /* get padding.x */
    if (luaH_rawfield(L, 3, "x")) {
        xpad = (gint) lua_tonumber(L, -1);
        lua_pop(L, 1);
    }
    /* get padding.y */
    if (luaH_rawfield(L, 3, "y")) {
        ypad = (gint) lua_tonumber(L, -1);
        lua_pop(L, 1);
    }
    gtk_misc_set_padding(GTK_MISC(w->widget), xpad, ypad);
    return 0;
}
Exemplo n.º 9
0
/**
 * gimp_pixmap_set:
 * @pixmap: The pixmap widget you want to set the new xpm_data for.
 * @xpm_data: A pointer to a XPM data structure as found in XPM files.
 *
 * Sets a new image for an existing #GimpPixmap widget.
 **/
void
gimp_pixmap_set (GimpPixmap  *pixmap,
                 gchar      **xpm_data)
{
  g_return_if_fail (GIMP_IS_PIXMAP (pixmap));

  pixmap->xpm_data = xpm_data;

  GTK_WIDGET (pixmap)->requisition.width  = 0;
  GTK_WIDGET (pixmap)->requisition.height = 0;

  if (! gtk_widget_get_realized (GTK_WIDGET (pixmap)))
    {
      if (xpm_data)
        {
          gint width, height;

          if (sscanf (xpm_data[0], "%d %d", &width, &height) != 2)
            {
              g_warning ("%s: passed pointer is no XPM data", G_STRFUNC);
            }
          else
            {
              gint xpad, ypad;

              gtk_misc_get_padding (GTK_MISC (pixmap), &xpad, &ypad);

              GTK_WIDGET (pixmap)->requisition.width  = width + xpad * 2;
              GTK_WIDGET (pixmap)->requisition.height = height + ypad * 2;
            }
        }
    }
  else
    {
      gimp_pixmap_create_from_xpm_d (pixmap);
    }
}
Exemplo n.º 10
0
static void
egg_status_icon_update_image (EggStatusIcon *status_icon)
{
  if (status_icon->priv->blink_off)
    {
      gtk_image_set_from_pixbuf (GTK_IMAGE (status_icon->priv->image),
				 egg_status_icon_blank_icon (status_icon));
      return;
    }

  switch (status_icon->priv->image_type)
    {
    case GTK_IMAGE_PIXBUF:
      {
	GdkPixbuf *pixbuf;

	pixbuf = status_icon->priv->image_data.pixbuf;

	if (pixbuf)
	  {
	    GdkPixbuf *scaled;
	    gint size;
	    gint width;
	    gint height;

	    size = status_icon->priv->size;

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

	    if (width > size || height > size)
	      {
                scaled = gdk_pixbuf_scale_simple (pixbuf,
                                                        MIN (size, width),
                                                        MIN (size, height),
                                                        GDK_INTERP_BILINEAR);
	      }
	    else
              {
                scaled = g_object_ref (pixbuf);
              }

	    gtk_image_set_from_pixbuf (GTK_IMAGE (status_icon->priv->image), scaled);

            /* Sets the icon's transparency mask as the window's shape mask.
               Note: This doesn't handle translucency (partial transparency). */
            gint image_offset_x, image_offset_y;
            /* No way to know the image's real offset but by calculating ourselves. */
            {
              GtkOrientation orientation;
              gfloat xalign, yalign;
              gint xpad, ypad;
              GtkWidget* image = status_icon->priv->image;
              gtk_misc_get_padding(GTK_MISC(image), &xpad, &ypad);
              gtk_misc_get_alignment(GTK_MISC(image), &xalign, &yalign);
              /* We're aligning either horizontally or vertically, depending
                 on the orientation. According to this, we'll assume either
                 width or height to be preallocated up to the panel's size. */
              orientation = egg_tray_icon_get_orientation (EGG_TRAY_ICON (status_icon->priv->tray_icon));
              /* We base on the code found in gtk_image_expose */
              image_offset_x = floor(image->allocation.x + xpad + ((status_icon->priv->alloc_width - image->requisition.width) * xalign) + 0.5);
              image_offset_y = floor(image->allocation.y + ypad + ((status_icon->priv->alloc_height - image->requisition.height) * yalign) + 0.5);
            }
            GdkBitmap* scaled_mask = NULL;
            gdk_pixbuf_render_pixmap_and_mask(scaled, NULL, &scaled_mask, 0);
            if (scaled_mask)
            {
               /* It's only possible to set shape masks on real windows, so we have to set an offseted shape mask. */
               gtk_widget_shape_combine_mask(GTK_WIDGET(status_icon->priv->tray_icon), scaled_mask, image_offset_x, image_offset_y);
               g_object_unref(scaled_mask);
            }
	    
	    g_object_unref (scaled);
	  }
	else
	  {
	    gtk_image_set_from_pixbuf (GTK_IMAGE (status_icon->priv->image), NULL);
	  }
      }
      break;
    case GTK_IMAGE_STOCK:
    case GTK_IMAGE_ANIMATION:
    case GTK_IMAGE_EMPTY:
      gtk_image_set_from_pixbuf (GTK_IMAGE (status_icon->priv->image), NULL);
      break;
    default:
      g_assert_not_reached ();
      break;
    }
    
}
Exemplo n.º 11
0
static GtkWidget *
auto_key_locate_frame (SettingsDlg *dialog)
{
  const char *tooltip;
  GtkWidget *frame;
  GtkWidget *label;
  GtkWidget *frame_vbox;
  GtkWidget *combo;
  GtkWidget *entry;
  GtkWidget *hbox;
  int xpad, ypad;
  int idx;

  /* Build UI.  */
  frame = gtk_frame_new (NULL);
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
  label = gtk_label_new_with_mnemonic (_("<b>Auto key _locate</b>"));
  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
  gtk_frame_set_label_widget (GTK_FRAME (frame), label);

  frame_vbox = gtk_vbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (frame), frame_vbox);

  /* The method selection.  */
  hbox = gtk_hbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (frame_vbox), hbox);
  tooltip = _("The list of methods to locate keys via an email address.\n"
              "All given methods are used in turn until a matching "
              "key is found.  The supported methods are:\n"
              " Local\n"
              "   - Use the local keyring.\n"
#ifdef ENABLE_KEYSERVER_SUPPORT
              " Keyserver\n"
              "   - Use the default keyserver.\n"
#endif /*ENABLE_KEYSERVER_SUPPORT*/
              " PKA\n"
              "   - Use the Public Key Association.\n"
              " kDNS\n"
              "   - Use kDNS with the nameserver below.\n"
              " Custom\n"
              "   - Configured in the backend dialog.\n");
  gpa_add_tooltip (hbox, tooltip);

  label = gtk_label_new (_("Method:"));
  gtk_misc_get_padding (GTK_MISC (label), &xpad, &ypad);
  xpad += 5;
  gtk_misc_set_padding (GTK_MISC (label), xpad, ypad);
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);

  combo = gtk_combo_box_new_text ();
  gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);

  idx=0;
  do
    gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _(akl_table[idx].text));
  while (akl_table[idx++].list);

  /* The kDNS server.  */
  hbox = gtk_hbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (frame_vbox), hbox);
  tooltip = _("The IP address of the nameserver used for the kDNS method.");
  gpa_add_tooltip (hbox, tooltip);
  label = gtk_label_new (_("kDNS Server:"));
  gtk_misc_get_padding (GTK_MISC (label), &xpad, &ypad);
  xpad += 5;
  gtk_misc_set_padding (GTK_MISC (label), xpad, ypad);
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);

  entry = gtk_entry_new ();
  gtk_entry_set_max_length (GTK_ENTRY(entry), 3+1+3+1+3+1+3);
  gtk_entry_set_width_chars (GTK_ENTRY(entry), 3+1+3+1+3+1+3);
  gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);

  dialog->akl.addr_hbox = hbox;
  dialog->akl.addr_entry = GTK_ENTRY (entry);
  dialog->akl.methods = GTK_COMBO_BOX (combo);

  g_signal_connect_swapped (G_OBJECT (combo),
                            "changed",
                            G_CALLBACK (akl_method_changed_cb), dialog);
  g_signal_connect_swapped (G_OBJECT (entry),
                            "changed",
                            G_CALLBACK (akl_addr_changed_cb), dialog);

  dialog->akl.frame = frame;

  return frame;
}