Skip to content
This repository has been archived by the owner on Aug 13, 2019. It is now read-only.

Commit

Permalink
Add some Label methods requiring pango consts.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrick committed Apr 20, 2014
1 parent 8c0ac93 commit 39fcaea
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
17 changes: 17 additions & 0 deletions gtk/gtk.go
Expand Up @@ -54,6 +54,7 @@ import (
"github.com/conformal/gotk3/cairo"
"github.com/conformal/gotk3/gdk"
"github.com/conformal/gotk3/glib"
"github.com/conformal/gotk3/pango"
"runtime"
"unsafe"
)
Expand Down Expand Up @@ -4174,6 +4175,11 @@ func (v *Label) SetJustify(jtype Justification) {
C.gtk_label_set_justify(v.native(), C.GtkJustification(jtype))
}

// SetEllipsize is a wrapper around gtk_label_set_ellipsize().
func (v *Label) SetEllipsize(mode pango.EllipsizeMode) {
C.gtk_label_set_ellipsize(v.native(), C.PangoEllipsizeMode(mode))
}

// GetWidthChars is a wrapper around gtk_label_get_width_chars().
func (v *Label) GetWidthChars() int {
c := C.gtk_label_get_width_chars(v.native())
Expand Down Expand Up @@ -4207,6 +4213,11 @@ func (v *Label) SetLineWrap(wrap bool) {
C.gtk_label_set_line_wrap(v.native(), gbool(wrap))
}

// SetLineWrapMode is a wrapper around gtk_label_set_line_wrap_mode().
func (v *Label) SetLineWrapMode(wrapMode pango.WrapMode) {
C.gtk_label_set_line_wrap_mode(v.native(), C.PangoWrapMode(wrapMode))
}

// GetSelectable is a wrapper around gtk_label_get_selectable().
func (v *Label) GetSelectable() bool {
c := C.gtk_label_get_selectable(v.native())
Expand All @@ -4228,6 +4239,12 @@ func (v *Label) GetJustify() Justification {
return Justification(c)
}

// GetEllipsize is a wrapper around gtk_label_get_ellipsize().
func (v *Label) GetEllipsize() pango.EllipsizeMode {
c := C.gtk_label_get_ellipsize(v.native())
return pango.EllipsizeMode(c)
}

// GetCurrentUri is a wrapper around gtk_label_get_current_uri().
func (v *Label) GetCurrentUri() string {
c := C.gtk_label_get_current_uri(v.native())
Expand Down
68 changes: 68 additions & 0 deletions pango/pango.go
@@ -0,0 +1,68 @@
// Copyright (c) 2013-2014 Conformal Systems <info@conformal.com>
//
// This file originated from: http://opensource.conformal.com/
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

// Go bindings for Pango.
package pango

// #cgo pkg-config: pango
// #include <pango/pango.h>
import "C"
import (
"github.com/conformal/gotk3/glib"
"unsafe"
)

func init() {
tm := []glib.TypeMarshaler{
// Enums
{glib.Type(C.pango_ellipsize_mode_get_type()), marshalEllipsizeMode},
{glib.Type(C.pango_wrap_mode_get_type()), marshalWrapMode},
}
glib.RegisterGValueMarshalers(tm)
}

/*
* Constants
*/

// EllipsizeMode is a representation of Pango's PangoEllipsizeMode.
type EllipsizeMode int

const (
ELLIPSIZE_NONE EllipsizeMode = C.PANGO_ELLIPSIZE_NONE
ELLIPSIZE_START EllipsizeMode = C.PANGO_ELLIPSIZE_START
ELLIPSIZE_MIDDLE EllipsizeMode = C.PANGO_ELLIPSIZE_MIDDLE
ELLIPSIZE_END EllipsizeMode = C.PANGO_ELLIPSIZE_END
)

func marshalEllipsizeMode(p uintptr) (interface{}, error) {
c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p)))
return EllipsizeMode(c), nil
}

// WrapMode is a representation of Pango's PangoWrapMode.
type WrapMode int

const (
WRAP_WORD WrapMode = C.PANGO_WRAP_WORD
WRAP_CHAR WrapMode = C.PANGO_WRAP_CHAR
WRAP_WORD_CHAR WrapMode = C.PANGO_WRAP_WORD_CHAR
)

func marshalWrapMode(p uintptr) (interface{}, error) {
c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p)))
return WrapMode(c), nil
}

0 comments on commit 39fcaea

Please sign in to comment.