Logo Search packages:      
Sourcecode: gnome-compiz-manager version File versions

gcp-mouse-shortcut.c

/* Generated by GOB (v2.0.14)   (do not edit directly) */

/* End world hunger, donate to the World Food Programme, http://www.wfp.org */

#define GOB_VERSION_MAJOR 2
#define GOB_VERSION_MINOR 0
#define GOB_VERSION_PATCHLEVEL 14

#define selfp (self->_priv)

#include <string.h> /* memset() */

#include "gcp-mouse-shortcut.h"

#ifdef G_LIKELY
#define ___GOB_LIKELY(expr) G_LIKELY(expr)
#define ___GOB_UNLIKELY(expr) G_UNLIKELY(expr)
#else /* ! G_LIKELY */
#define ___GOB_LIKELY(expr) (expr)
#define ___GOB_UNLIKELY(expr) (expr)
#endif /* G_LIKELY */

#line 31 "gcp-mouse-shortcut.gob"

#include <gdk/gdkkeysyms.h>
#include <librsvg/rsvg.h>
#include <librsvg/rsvg-cairo.h>

/*
 * Standard gettext macros.
 */
#ifdef ENABLE_NLS
#  include <libintl.h>
#  undef _
#  define _(String) dgettext (PACKAGE, String)
#  ifdef gettext_noop
#    define N_(String) gettext_noop (String)
#  else
#    define N_(String) (String)
#  endif
#else
#  define textdomain(String) (String)
#  define gettext(String) (String)
#  define dgettext(Domain,Message) (Message)
#  define dcgettext(Domain,Message,Type) (Message)
#  define bindtextdomain(Domain,Directory) (Domain)
#  define _(String) (String)
#  define N_(String) (String)
#endif

static void
cairo_rectangle_round (cairo_t *cr,
                       double x0,    double y0,
                       double width, double height,
                       double radius);

static gchar *GCPMouseButtonsSvg[6] = {
    NULL,
    PACKAGE_DATA_DIR"/gnome-compiz-manager/left-button.svg",
    PACKAGE_DATA_DIR"/gnome-compiz-manager/middle-button.svg",
    PACKAGE_DATA_DIR"/gnome-compiz-manager/right-button.svg",
    PACKAGE_DATA_DIR"/gnome-compiz-manager/up-button.svg",
    PACKAGE_DATA_DIR"/gnome-compiz-manager/down-button.svg"
};

#line 67 "gcp-mouse-shortcut.c"
static const GEnumValue _gcp_mouse_shortcut_size_values[] = {
      { GCP_MOUSE_SHORTCUT_WIDTH, (char *)"GCP_MOUSE_SHORTCUT_WIDTH", (char *)"width" },
      { GCP_MOUSE_SHORTCUT_HEIGHT, (char *)"GCP_MOUSE_SHORTCUT_HEIGHT", (char *)"height" },
      { 0, NULL, NULL }
};

GType
gcp_mouse_shortcut_size_get_type (void)
{
      static GType type = 0;
      if ___GOB_UNLIKELY(type == 0)
            type = g_enum_register_static ("GCPMouseShortcutSize", _gcp_mouse_shortcut_size_values);
      return type;
}

/* self casting macros */
#define SELF(x) GCP_MOUSE_SHORTCUT(x)
#define SELF_CONST(x) GCP_MOUSE_SHORTCUT_CONST(x)
#define IS_SELF(x) GCP_IS_MOUSE_SHORTCUT(x)
#define TYPE_SELF GCP_TYPE_MOUSE_SHORTCUT
#define SELF_CLASS(x) GCP_MOUSE_SHORTCUT_CLASS(x)

#define SELF_GET_CLASS(x) GCP_MOUSE_SHORTCUT_GET_CLASS(x)

/* self typedefs */
typedef GCPMouseShortcut Self;
typedef GCPMouseShortcutClass SelfClass;

struct _GCPMouseShortcutPrivate {
#line 82 "gcp-mouse-shortcut.gob"
      RsvgHandle * mouse_svg;
#line 84 "gcp-mouse-shortcut.gob"
      RsvgHandle * buttons_svg[5];
#line 92 "gcp-mouse-shortcut.gob"
      gboolean grab;
#line 93 "gcp-mouse-shortcut.gob"
      gint button;
#line 94 "gcp-mouse-shortcut.gob"
      gchar * edge;
#line 107 "gcp-mouse-shortcut.c"
};
/* here are local prototypes */
static void ___object_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
static void ___object_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
static void gcp_mouse_shortcut_init (GCPMouseShortcut * o) G_GNUC_UNUSED;
static void gcp_mouse_shortcut_class_init (GCPMouseShortcutClass * c) G_GNUC_UNUSED;
gboolean    gcp_mouse_shortcut_delete_event     (GCPMouseShortcut * self, GdkEvent * event, gpointer data);
static void gcp_mouse_shortcut_set_colormap (GCPMouseShortcut * self) G_GNUC_UNUSED;
static gboolean ___7_gcp_mouse_shortcut_expose_event (GtkWidget * widget, GdkEventExpose * event) G_GNUC_UNUSED;
static gboolean ___8_gcp_mouse_shortcut_key_press_event (GtkWidget * widget, GdkEventKey * key) G_GNUC_UNUSED;
static gboolean ___9_gcp_mouse_shortcut_button_press_event (GtkWidget * widget, GdkEventButton * button) G_GNUC_UNUSED;
static gboolean ___a_gcp_mouse_shortcut_button_release_event (GtkWidget * widget, GdkEventButton * button) G_GNUC_UNUSED;
static void gcp_mouse_shortcut_draw (GCPMouseShortcut * self, cairo_t * ctx) G_GNUC_UNUSED;
static void gcp_mouse_shortcut_draw_mouse (GCPMouseShortcut * self, cairo_t * ctx, gdouble x, gdouble y, gdouble width, gdouble height) G_GNUC_UNUSED;
static void gcp_mouse_shortcut_draw_text (GCPMouseShortcut * self, cairo_t * ctx, gdouble x, gdouble y, gdouble width, gdouble height) G_GNUC_UNUSED;
static void gcp_mouse_shortcut_draw_rectangle (GCPMouseShortcut * self, cairo_t * ctx, gdouble x, gdouble y, gdouble width, gdouble height) G_GNUC_UNUSED;

/*
 * Signal connection wrapper macro shortcuts
 */
#define self_connect__button_changed(object,func,data)      gcp_mouse_shortcut_connect__button_changed((object),(func),(data))
#define self_connect_after__button_changed(object,func,data)      gcp_mouse_shortcut_connect_after__button_changed((object),(func),(data))
#define self_connect_data__button_changed(object,func,data,destroy_data,flags)      gcp_mouse_shortcut_connect_data__button_changed((object),(func),(data),(destroy_data),(flags))

typedef void  (*___Sig1) (GCPMouseShortcut *, gint , gchar *, gpointer);

static void
___marshal_Sig1 (GClosure *closure,
      GValue *return_value G_GNUC_UNUSED,
      guint n_param_values,
      const GValue *param_values,
      gpointer invocation_hint G_GNUC_UNUSED,
      gpointer marshal_data)
{
      register ___Sig1 callback;
      register GCClosure *cc = (GCClosure*) closure;
      register gpointer data1, data2;

      g_return_if_fail (n_param_values == 3);

      if (G_CCLOSURE_SWAP_DATA (closure)) {
            data1 = closure->data;
            data2 = g_value_peek_pointer (param_values + 0);
      } else {
            data1 = g_value_peek_pointer (param_values + 0);
            data2 = closure->data;
      }

      callback = (___Sig1) (marshal_data != NULL ? marshal_data : cc->callback);

      callback ((GCPMouseShortcut *)data1,
            (gint ) g_value_get_int (param_values + 1),
            (gchar *) g_value_get_string (param_values + 2),
            data2);
}


enum {
      BUTTON_CHANGED_SIGNAL,
      LAST_SIGNAL
};

enum {
      PROP_0,
      PROP_EDGE
};

static guint object_signals[LAST_SIGNAL] = {0};

/* pointer to the class of our parent */
static GtkWindowClass *parent_class = NULL;

/* Short form macros */
#define self_get_edge gcp_mouse_shortcut_get_edge
#define self_set_edge gcp_mouse_shortcut_set_edge
#define self_button_changed gcp_mouse_shortcut_button_changed
#define self_new gcp_mouse_shortcut_new
#define self_delete_event gcp_mouse_shortcut_delete_event
#define self_set_colormap gcp_mouse_shortcut_set_colormap
#define self_draw gcp_mouse_shortcut_draw
#define self_draw_mouse gcp_mouse_shortcut_draw_mouse
#define self_draw_text gcp_mouse_shortcut_draw_text
#define self_draw_rectangle gcp_mouse_shortcut_draw_rectangle
GType
gcp_mouse_shortcut_get_type (void)
{
      static GType type = 0;

      if ___GOB_UNLIKELY(type == 0) {
            static const GTypeInfo info = {
                  sizeof (GCPMouseShortcutClass),
                  (GBaseInitFunc) NULL,
                  (GBaseFinalizeFunc) NULL,
                  (GClassInitFunc) gcp_mouse_shortcut_class_init,
                  (GClassFinalizeFunc) NULL,
                  NULL /* class_data */,
                  sizeof (GCPMouseShortcut),
                  0 /* n_preallocs */,
                  (GInstanceInitFunc) gcp_mouse_shortcut_init,
                  NULL
            };

            type = g_type_register_static (GTK_TYPE_WINDOW, "GCPMouseShortcut", &info, (GTypeFlags)0);
      }

      return type;
}

/* a macro for creating a new object of our type */
#define GET_NEW ((GCPMouseShortcut *)g_object_new(gcp_mouse_shortcut_get_type(), NULL))

/* a function for creating a new object of our type */
#include <stdarg.h>
static GCPMouseShortcut * GET_NEW_VARG (const char *first, ...) G_GNUC_UNUSED;
static GCPMouseShortcut *
GET_NEW_VARG (const char *first, ...)
{
      GCPMouseShortcut *ret;
      va_list ap;
      va_start (ap, first);
      ret = (GCPMouseShortcut *)g_object_new_valist (gcp_mouse_shortcut_get_type (), first, ap);
      va_end (ap);
      return ret;
}


static void
___finalize(GObject *obj_self)
{
#define __GOB_FUNCTION__ "GCP:Mouse:Shortcut::finalize"
      GCPMouseShortcut *self G_GNUC_UNUSED = GCP_MOUSE_SHORTCUT (obj_self);
      gpointer priv G_GNUC_UNUSED = self->_priv;
      if(G_OBJECT_CLASS(parent_class)->finalize) \
            (* G_OBJECT_CLASS(parent_class)->finalize)(obj_self);
#line 83 "gcp-mouse-shortcut.gob"
      if(self->_priv->mouse_svg) { g_object_unref ((gpointer) self->_priv->mouse_svg); self->_priv->mouse_svg = NULL; }
#line 244 "gcp-mouse-shortcut.c"
#define buttons_svg (self->_priv->buttons_svg)
#define VAR buttons_svg
      {
#line 85 "gcp-mouse-shortcut.gob"
      
            gint cpt;
            
            for (cpt = 1; cpt < 6; cpt++)
                if (buttons_svg[cpt]) 
                    g_object_unref(buttons_svg[cpt]);
        }
#line 256 "gcp-mouse-shortcut.c"
      memset(&buttons_svg, 0, sizeof(buttons_svg));
#undef VAR
#undef buttons_svg
#line 95 "gcp-mouse-shortcut.gob"
      if(self->_priv->edge) { g_free ((gpointer) self->_priv->edge); self->_priv->edge = NULL; }
#line 262 "gcp-mouse-shortcut.c"
}
#undef __GOB_FUNCTION__

static void 
gcp_mouse_shortcut_init (GCPMouseShortcut * o G_GNUC_UNUSED)
{
#define __GOB_FUNCTION__ "GCP:Mouse:Shortcut::init"
      o->_priv = G_TYPE_INSTANCE_GET_PRIVATE(o,GCP_TYPE_MOUSE_SHORTCUT,GCPMouseShortcutPrivate);
#line 85 "gcp-mouse-shortcut.gob"
      o->_priv->grab = FALSE;
#line 273 "gcp-mouse-shortcut.c"
#line 85 "gcp-mouse-shortcut.gob"
      o->_priv->button = 0;
#line 276 "gcp-mouse-shortcut.c"
#line 85 "gcp-mouse-shortcut.gob"
      o->_priv->edge = NULL;
#line 279 "gcp-mouse-shortcut.c"
}
#undef __GOB_FUNCTION__
static void 
gcp_mouse_shortcut_class_init (GCPMouseShortcutClass * c G_GNUC_UNUSED)
{
#define __GOB_FUNCTION__ "GCP:Mouse:Shortcut::class_init"
      GObjectClass *g_object_class G_GNUC_UNUSED = (GObjectClass*) c;
      GtkWidgetClass *gtk_widget_class = (GtkWidgetClass *)c;

      g_type_class_add_private(c,sizeof(GCPMouseShortcutPrivate));

      parent_class = g_type_class_ref (GTK_TYPE_WINDOW);

      object_signals[BUTTON_CHANGED_SIGNAL] =
            g_signal_new ("button_changed",
                  G_TYPE_FROM_CLASS (g_object_class),
                  (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
                  G_STRUCT_OFFSET (GCPMouseShortcutClass, button_changed),
                  NULL, NULL,
                  ___marshal_Sig1,
                  G_TYPE_NONE, 2,
                  G_TYPE_INT,
                  G_TYPE_STRING);
      if ___GOB_UNLIKELY(sizeof(gint ) != sizeof(gint ) || sizeof(gchar * ) != sizeof(gchar *) || parent_class == NULL /* avoid warning */) {
            g_error("gcp-mouse-shortcut.gob line 102: Type mismatch of \"button_changed\" signal signature");
      }

      c->button_changed = NULL;
#line 157 "gcp-mouse-shortcut.gob"
      gtk_widget_class->expose_event = ___7_gcp_mouse_shortcut_expose_event;
#line 179 "gcp-mouse-shortcut.gob"
      gtk_widget_class->key_press_event = ___8_gcp_mouse_shortcut_key_press_event;
#line 205 "gcp-mouse-shortcut.gob"
      gtk_widget_class->button_press_event = ___9_gcp_mouse_shortcut_button_press_event;
#line 219 "gcp-mouse-shortcut.gob"
      gtk_widget_class->button_release_event = ___a_gcp_mouse_shortcut_button_release_event;
#line 316 "gcp-mouse-shortcut.c"
      g_object_class->finalize = ___finalize;
      g_object_class->get_property = ___object_get_property;
      g_object_class->set_property = ___object_set_property;
    {
      GParamSpec   *param_spec;

      param_spec = g_param_spec_string
            ("edge" /* name */,
             "Edge" /* nick */,
             "Current edge" /* blurb */,
             NULL /* default_value */,
             (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE));
      g_object_class_install_property (g_object_class,
            PROP_EDGE,
            param_spec);
    }
}
#undef __GOB_FUNCTION__

static void
___object_set_property (GObject *object,
      guint property_id,
      const GValue *VAL G_GNUC_UNUSED,
      GParamSpec *pspec G_GNUC_UNUSED)
#define __GOB_FUNCTION__ "GCP:Mouse:Shortcut::set_property"
{
      GCPMouseShortcut *self G_GNUC_UNUSED;

      self = GCP_MOUSE_SHORTCUT (object);

      switch (property_id) {
      case PROP_EDGE:
            {
#line 96 "gcp-mouse-shortcut.gob"
{ char *old = self->_priv->edge; self->_priv->edge = g_value_dup_string (VAL); g_free (old); }
#line 352 "gcp-mouse-shortcut.c"
            }
            break;
      default:
/* Apparently in g++ this is needed, glib is b0rk */
#ifndef __PRETTY_FUNCTION__
#  undef G_STRLOC
#  define G_STRLOC      __FILE__ ":" G_STRINGIFY (__LINE__)
#endif
            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
            break;
      }
}
#undef __GOB_FUNCTION__

static void
___object_get_property (GObject *object,
      guint property_id,
      GValue *VAL G_GNUC_UNUSED,
      GParamSpec *pspec G_GNUC_UNUSED)
#define __GOB_FUNCTION__ "GCP:Mouse:Shortcut::get_property"
{
      GCPMouseShortcut *self G_GNUC_UNUSED;

      self = GCP_MOUSE_SHORTCUT (object);

      switch (property_id) {
      case PROP_EDGE:
            {
#line 96 "gcp-mouse-shortcut.gob"
g_value_set_string (VAL, self->_priv->edge);
#line 383 "gcp-mouse-shortcut.c"
            }
            break;
      default:
/* Apparently in g++ this is needed, glib is b0rk */
#ifndef __PRETTY_FUNCTION__
#  undef G_STRLOC
#  define G_STRLOC      __FILE__ ":" G_STRINGIFY (__LINE__)
#endif
            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
            break;
      }
}
#undef __GOB_FUNCTION__



#line 96 "gcp-mouse-shortcut.gob"
gchar * 
gcp_mouse_shortcut_get_edge (GCPMouseShortcut * self)
#line 403 "gcp-mouse-shortcut.c"
{
#define __GOB_FUNCTION__ "GCP:Mouse:Shortcut::get_edge"
{
#line 96 "gcp-mouse-shortcut.gob"
            gchar* val; g_object_get (G_OBJECT (self), "edge", &val, NULL); return val;
}}
#line 410 "gcp-mouse-shortcut.c"
#undef __GOB_FUNCTION__

#line 96 "gcp-mouse-shortcut.gob"
void 
gcp_mouse_shortcut_set_edge (GCPMouseShortcut * self, gchar * val)
#line 416 "gcp-mouse-shortcut.c"
{
#define __GOB_FUNCTION__ "GCP:Mouse:Shortcut::set_edge"
{
#line 96 "gcp-mouse-shortcut.gob"
            g_object_set (G_OBJECT (self), "edge", val, NULL);
}}
#line 423 "gcp-mouse-shortcut.c"
#undef __GOB_FUNCTION__

#line 102 "gcp-mouse-shortcut.gob"
void 
gcp_mouse_shortcut_button_changed (GCPMouseShortcut * self, gint button, gchar * edge)
#line 429 "gcp-mouse-shortcut.c"
{
      GValue ___param_values[3];
      GValue ___return_val;

memset (&___return_val, 0, sizeof (___return_val));
memset (&___param_values, 0, sizeof (___param_values));

#line 102 "gcp-mouse-shortcut.gob"
      g_return_if_fail (self != NULL);
#line 102 "gcp-mouse-shortcut.gob"
      g_return_if_fail (GCP_IS_MOUSE_SHORTCUT (self));
#line 441 "gcp-mouse-shortcut.c"

      ___param_values[0].g_type = 0;
      g_value_init (&___param_values[0], G_TYPE_FROM_INSTANCE (self));
      g_value_set_instance (&___param_values[0], (gpointer) self);

      ___param_values[1].g_type = 0;
      g_value_init (&___param_values[1], G_TYPE_INT);
      g_value_set_int (&___param_values[1], (gint ) button);

      ___param_values[2].g_type = 0;
      g_value_init (&___param_values[2], G_TYPE_STRING);
      g_value_set_static_string (&___param_values[2], (gchar *) edge);

      g_signal_emitv (___param_values,
            object_signals[BUTTON_CHANGED_SIGNAL],
            0 /* detail */,
            &___return_val);

      g_value_unset (&___param_values[0]);
      g_value_unset (&___param_values[1]);
      g_value_unset (&___param_values[2]);
}

#line 105 "gcp-mouse-shortcut.gob"
GtkWidget * 
gcp_mouse_shortcut_new (void)
#line 468 "gcp-mouse-shortcut.c"
{
#define __GOB_FUNCTION__ "GCP:Mouse:Shortcut::new"
{
#line 107 "gcp-mouse-shortcut.gob"
      
            GCPMouseShortcut * self = GET_NEW;
            gint cpt;
        
            gtk_window_set_decorated(GTK_WINDOW(self), FALSE);
            gtk_window_set_resizable(GTK_WINDOW(self), TRUE);
            gtk_window_set_position(GTK_WINDOW(self), GTK_WIN_POS_CENTER_ALWAYS);
            gtk_widget_set_app_paintable(GTK_WIDGET(self), TRUE);
            gtk_window_set_title(GTK_WINDOW(self), "Mouse button selector");
            gtk_window_set_default_size(GTK_WINDOW (self), 
                                                      GCP_MOUSE_SHORTCUT_WIDTH, 
                                                      GCP_MOUSE_SHORTCUT_HEIGHT);
            gtk_window_set_modal(GTK_WINDOW(self), TRUE);
            
            g_signal_connect(GTK_WIDGET(self), 
                                    "delete-event", 
                                    G_CALLBACK(self_delete_event), NULL);
            
            self_set_colormap(self);
            
            gtk_widget_add_events(GTK_WIDGET(self), GDK_BUTTON_PRESS_MASK);
            gtk_widget_add_events(GTK_WIDGET(self), GDK_BUTTON_RELEASE_MASK);
            
            selfp->mouse_svg = rsvg_handle_new_from_file (PACKAGE_DATA_DIR"/gnome-compiz-manager/mouse.svg", NULL);
        for (cpt = 1; cpt < 6; cpt++)
            selfp->buttons_svg[cpt] = 
                rsvg_handle_new_from_file(GCPMouseButtonsSvg[cpt], NULL);
            
            return GTK_WIDGET(self);
      }}
#line 503 "gcp-mouse-shortcut.c"
#undef __GOB_FUNCTION__

#line 138 "gcp-mouse-shortcut.gob"
gboolean 
gcp_mouse_shortcut_delete_event (GCPMouseShortcut * self, GdkEvent * event, gpointer data)
#line 509 "gcp-mouse-shortcut.c"
{
#define __GOB_FUNCTION__ "GCP:Mouse:Shortcut::delete_event"
#line 138 "gcp-mouse-shortcut.gob"
      g_return_val_if_fail (self != NULL, (gboolean )0);
#line 138 "gcp-mouse-shortcut.gob"
      g_return_val_if_fail (GCP_IS_MOUSE_SHORTCUT (self), (gboolean )0);
#line 516 "gcp-mouse-shortcut.c"
{
#line 140 "gcp-mouse-shortcut.gob"
      
            gtk_widget_hide(GTK_WIDGET(self));
            return TRUE;
      }}
#line 523 "gcp-mouse-shortcut.c"
#undef __GOB_FUNCTION__

#line 145 "gcp-mouse-shortcut.gob"
static void 
gcp_mouse_shortcut_set_colormap (GCPMouseShortcut * self)
#line 529 "gcp-mouse-shortcut.c"
{
#define __GOB_FUNCTION__ "GCP:Mouse:Shortcut::set_colormap"
#line 145 "gcp-mouse-shortcut.gob"
      g_return_if_fail (self != NULL);
#line 145 "gcp-mouse-shortcut.gob"
      g_return_if_fail (GCP_IS_MOUSE_SHORTCUT (self));
#line 536 "gcp-mouse-shortcut.c"
{
#line 147 "gcp-mouse-shortcut.gob"
      
            GdkScreen * screen = gtk_widget_get_screen(GTK_WIDGET(self));
            GdkColormap * colormap = gdk_screen_get_rgba_colormap(screen);
      
            if (!colormap)
                  colormap = gdk_screen_get_rgb_colormap(screen);
            
            gtk_widget_set_colormap(GTK_WIDGET(self), colormap);
      }}
#line 548 "gcp-mouse-shortcut.c"
#undef __GOB_FUNCTION__

#line 157 "gcp-mouse-shortcut.gob"
static gboolean 
___7_gcp_mouse_shortcut_expose_event (GtkWidget * widget G_GNUC_UNUSED, GdkEventExpose * event)
#line 554 "gcp-mouse-shortcut.c"
#define PARENT_HANDLER(___widget,___event) \
      ((GTK_WIDGET_CLASS(parent_class)->expose_event)? \
            (* GTK_WIDGET_CLASS(parent_class)->expose_event)(___widget,___event): \
            ((gboolean )0))
{
#define __GOB_FUNCTION__ "GCP:Mouse:Shortcut::expose_event"
{
#line 159 "gcp-mouse-shortcut.gob"
      
            GCPMouseShortcut * self = SELF(widget);
            cairo_t * ctx;
                  
            if (!selfp->grab)
            {
                  gdk_pointer_grab(GTK_WIDGET(self)->window, TRUE, 
                                           GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK, 
                                           GTK_WIDGET(self)->window, NULL, GDK_CURRENT_TIME);
                  gdk_keyboard_grab(GTK_WIDGET(self)->window, TRUE, GDK_CURRENT_TIME);
            selfp->grab = TRUE;
            }
                  
            ctx = gdk_cairo_create(GTK_WIDGET(self)->window);
            self_draw(self, ctx);
            cairo_destroy(ctx);
            
            return FALSE;
      }}
#line 582 "gcp-mouse-shortcut.c"
#undef __GOB_FUNCTION__
#undef PARENT_HANDLER

#line 179 "gcp-mouse-shortcut.gob"
static gboolean 
___8_gcp_mouse_shortcut_key_press_event (GtkWidget * widget G_GNUC_UNUSED, GdkEventKey * key)
#line 589 "gcp-mouse-shortcut.c"
#define PARENT_HANDLER(___widget,___key) \
      ((GTK_WIDGET_CLASS(parent_class)->key_press_event)? \
            (* GTK_WIDGET_CLASS(parent_class)->key_press_event)(___widget,___key): \
            ((gboolean )0))
{
#define __GOB_FUNCTION__ "GCP:Mouse:Shortcut::key_press_event"
{
#line 181 "gcp-mouse-shortcut.gob"
      
            GCPMouseShortcut  * self = SELF(widget);
            
            if (key->type == GDK_KEY_PRESS)
            {
                  switch (key->keyval)
                  {
                        case GDK_Return:
                    self_button_changed(self, selfp->button, selfp->edge);
                        case GDK_Escape:
                    selfp->grab = FALSE;
                    gdk_pointer_ungrab(GDK_CURRENT_TIME);
                    gdk_keyboard_ungrab(GDK_CURRENT_TIME);
                    gtk_widget_hide(GTK_WIDGET(self));
                    selfp->button = 0;
                    break;
                        default :
                    break;
                  }
            }

            return FALSE;
      }}
#line 621 "gcp-mouse-shortcut.c"
#undef __GOB_FUNCTION__
#undef PARENT_HANDLER

#line 205 "gcp-mouse-shortcut.gob"
static gboolean 
___9_gcp_mouse_shortcut_button_press_event (GtkWidget * widget G_GNUC_UNUSED, GdkEventButton * button)
#line 628 "gcp-mouse-shortcut.c"
#define PARENT_HANDLER(___widget,___button) \
      ((GTK_WIDGET_CLASS(parent_class)->button_press_event)? \
            (* GTK_WIDGET_CLASS(parent_class)->button_press_event)(___widget,___button): \
            ((gboolean )0))
{
#define __GOB_FUNCTION__ "GCP:Mouse:Shortcut::button_press_event"
{
#line 207 "gcp-mouse-shortcut.gob"
      
            GCPMouseShortcut  * self = SELF(widget);
            
            if (button->type == GDK_BUTTON_PRESS)
            {
            selfp->button = button->button;
                  gtk_widget_queue_draw(GTK_WIDGET(self));
            }
            
            return FALSE;
      }}
#line 648 "gcp-mouse-shortcut.c"
#undef __GOB_FUNCTION__
#undef PARENT_HANDLER

#line 219 "gcp-mouse-shortcut.gob"
static gboolean 
___a_gcp_mouse_shortcut_button_release_event (GtkWidget * widget G_GNUC_UNUSED, GdkEventButton * button)
#line 655 "gcp-mouse-shortcut.c"
#define PARENT_HANDLER(___widget,___button) \
      ((GTK_WIDGET_CLASS(parent_class)->button_release_event)? \
            (* GTK_WIDGET_CLASS(parent_class)->button_release_event)(___widget,___button): \
            ((gboolean )0))
{
#define __GOB_FUNCTION__ "GCP:Mouse:Shortcut::button_release_event"
{
#line 221 "gcp-mouse-shortcut.gob"
      
            GCPMouseShortcut  * self = SELF(widget);
            
            if (button->type == GDK_BUTTON_RELEASE)
            {
                  selfp->button = 0;
                  gtk_widget_queue_draw(GTK_WIDGET(self));
            }

            return FALSE;
      }}
#line 675 "gcp-mouse-shortcut.c"
#undef __GOB_FUNCTION__
#undef PARENT_HANDLER

#line 233 "gcp-mouse-shortcut.gob"
static void 
gcp_mouse_shortcut_draw (GCPMouseShortcut * self, cairo_t * ctx)
#line 682 "gcp-mouse-shortcut.c"
{
#define __GOB_FUNCTION__ "GCP:Mouse:Shortcut::draw"
#line 233 "gcp-mouse-shortcut.gob"
      g_return_if_fail (self != NULL);
#line 233 "gcp-mouse-shortcut.gob"
      g_return_if_fail (GCP_IS_MOUSE_SHORTCUT (self));
#line 233 "gcp-mouse-shortcut.gob"
      g_return_if_fail (ctx != NULL);
#line 691 "gcp-mouse-shortcut.c"
{
#line 235 "gcp-mouse-shortcut.gob"
      
            gint width, height;
            
            gtk_window_get_size(GTK_WINDOW(self), &width, &height);
            
            cairo_set_operator(ctx, CAIRO_OPERATOR_SOURCE);
            cairo_set_source_rgba(ctx, 0.0f, 0.0f, 0.0f, 0.0f);
            cairo_paint(ctx);
            
            cairo_set_operator(ctx, CAIRO_OPERATOR_OVER);
            
            self_draw_rectangle(self, ctx, 
                                          0.0f, 
                                          0.0f, 
                                          width, 200.0f);
            
        self_draw_mouse(self, ctx, 0.0f, 0.0f,
                                    width, 200.0f);
        
        self_draw_rectangle(self, ctx, 
                                          0.0f, 
                                          210.0f, 
                                          width, 90.0f);
            self_draw_text(self, ctx, 
                                          0.0f, 
                                          210.0f, 
                                          width, 90.0f);
      }}
#line 722 "gcp-mouse-shortcut.c"
#undef __GOB_FUNCTION__

#line 264 "gcp-mouse-shortcut.gob"
static void 
gcp_mouse_shortcut_draw_mouse (GCPMouseShortcut * self, cairo_t * ctx, gdouble x, gdouble y, gdouble width, gdouble height)
#line 728 "gcp-mouse-shortcut.c"
{
#define __GOB_FUNCTION__ "GCP:Mouse:Shortcut::draw_mouse"
#line 264 "gcp-mouse-shortcut.gob"
      g_return_if_fail (self != NULL);
#line 264 "gcp-mouse-shortcut.gob"
      g_return_if_fail (GCP_IS_MOUSE_SHORTCUT (self));
#line 264 "gcp-mouse-shortcut.gob"
      g_return_if_fail (ctx != NULL);
#line 737 "gcp-mouse-shortcut.c"
{
#line 267 "gcp-mouse-shortcut.gob"
      
            RsvgDimensionData dimension;
            cairo_matrix_t matrix;
            
            rsvg_handle_get_dimensions(selfp->mouse_svg, &dimension);
            cairo_save(ctx);
            cairo_matrix_init_identity(&matrix);
            cairo_matrix_translate (&matrix,
                                                x, 
                                                y);
            cairo_set_matrix(ctx, &matrix);
            cairo_paint_with_alpha(ctx, 0.0f);
            cairo_scale(ctx, width / dimension.width, height / dimension.height);
            rsvg_handle_render_cairo(selfp->mouse_svg, ctx);
        if (selfp->button)
            rsvg_handle_render_cairo(selfp->buttons_svg[selfp->button], ctx);
            cairo_restore(ctx);
      }}
#line 758 "gcp-mouse-shortcut.c"
#undef __GOB_FUNCTION__

#line 286 "gcp-mouse-shortcut.gob"
static void 
gcp_mouse_shortcut_draw_text (GCPMouseShortcut * self, cairo_t * ctx, gdouble x, gdouble y, gdouble width, gdouble height)
#line 764 "gcp-mouse-shortcut.c"
{
#define __GOB_FUNCTION__ "GCP:Mouse:Shortcut::draw_text"
#line 286 "gcp-mouse-shortcut.gob"
      g_return_if_fail (self != NULL);
#line 286 "gcp-mouse-shortcut.gob"
      g_return_if_fail (GCP_IS_MOUSE_SHORTCUT (self));
#line 286 "gcp-mouse-shortcut.gob"
      g_return_if_fail (ctx != NULL);
#line 773 "gcp-mouse-shortcut.c"
{
#line 289 "gcp-mouse-shortcut.gob"
      
            PangoLayout *layout;
            PangoFontDescription *desc;
            gint fwidth, fheight;
            
            cairo_save(ctx);
            cairo_translate (ctx, x, y);
            layout = pango_cairo_create_layout(ctx);
            pango_layout_set_text (layout, 
                                    "Press mouse button\nand \"Return\" key", -1);
            desc = pango_font_description_from_string("Sans Bold 10");
            pango_layout_set_font_description(layout, desc);
            pango_font_description_free(desc);
            
            cairo_set_source_rgb (ctx, 0.0f, 0.0f, 0.0f);
            pango_cairo_update_layout (ctx, layout);
            
            pango_layout_get_size (layout, &fwidth, &fheight);
            cairo_scale(ctx, (width - 10.0f) / ((double)fwidth/ PANGO_SCALE), 
                              (height - 10.0f) / ((double)fheight/ PANGO_SCALE));
            cairo_move_to(ctx, 5.0f, 2.5f);
            pango_cairo_show_layout (ctx, layout);

            cairo_restore(ctx);
      }}
#line 801 "gcp-mouse-shortcut.c"
#undef __GOB_FUNCTION__

#line 315 "gcp-mouse-shortcut.gob"
static void 
gcp_mouse_shortcut_draw_rectangle (GCPMouseShortcut * self, cairo_t * ctx, gdouble x, gdouble y, gdouble width, gdouble height)
#line 807 "gcp-mouse-shortcut.c"
{
#define __GOB_FUNCTION__ "GCP:Mouse:Shortcut::draw_rectangle"
#line 315 "gcp-mouse-shortcut.gob"
      g_return_if_fail (self != NULL);
#line 315 "gcp-mouse-shortcut.gob"
      g_return_if_fail (GCP_IS_MOUSE_SHORTCUT (self));
#line 315 "gcp-mouse-shortcut.gob"
      g_return_if_fail (ctx != NULL);
#line 816 "gcp-mouse-shortcut.c"
{
#line 319 "gcp-mouse-shortcut.gob"
      
            cairo_set_source_rgba(ctx, 1.0f, 1.0f, 1.0f, 0.6f);
            cairo_rectangle_round(ctx,
                                    x, y,
                                    width, height,
                                    25.0f);
            cairo_fill(ctx);
            cairo_set_source_rgb(ctx, 0.0f, 0.0f, 0.0f);
            cairo_rectangle_round(ctx,
                                    x, y,
                                    width, height,
                                    25.0f);
            cairo_stroke(ctx);
      }}
#line 833 "gcp-mouse-shortcut.c"
#undef __GOB_FUNCTION__

#line 335 "gcp-mouse-shortcut.gob"

static void
cairo_rectangle_round (cairo_t *cr,
                       double x0,    double y0,
                       double width, double height,
                       double radius)
{
  double x1,y1;

  x1=x0+width;
  y1=y0+height;

  if (!width || !height)
    return;
  if (width/2<radius)
    {
      if (height/2<radius)
        {
          cairo_move_to  (cr, x0, (y0 + y1)/2);
          cairo_curve_to (cr, x0 ,y0, x0, y0, (x0 + x1)/2, y0);
          cairo_curve_to (cr, x1, y0, x1, y0, x1, (y0 + y1)/2);
          cairo_curve_to (cr, x1, y1, x1, y1, (x1 + x0)/2, y1);
          cairo_curve_to (cr, x0, y1, x0, y1, x0, (y0 + y1)/2);
        }
      else
        {
          cairo_move_to  (cr, x0, y0 + radius);
          cairo_curve_to (cr, x0 ,y0, x0, y0, (x0 + x1)/2, y0);
          cairo_curve_to (cr, x1, y0, x1, y0, x1, y0 + radius);
          cairo_line_to (cr, x1 , y1 - radius);
          cairo_curve_to (cr, x1, y1, x1, y1, (x1 + x0)/2, y1);
          cairo_curve_to (cr, x0, y1, x0, y1, x0, y1- radius);
        }
    }
  else
    {
      if (height/2<radius)
        {
          cairo_move_to  (cr, x0, (y0 + y1)/2);
          cairo_curve_to (cr, x0 , y0, x0 , y0, x0 + radius, y0);
          cairo_line_to (cr, x1 - radius, y0);
          cairo_curve_to (cr, x1, y0, x1, y0, x1, (y0 + y1)/2);
          cairo_curve_to (cr, x1, y1, x1, y1, x1 - radius, y1);
          cairo_line_to (cr, x0 + radius, y1);
          cairo_curve_to (cr, x0, y1, x0, y1, x0, (y0 + y1)/2);
        }
      else
        {
          cairo_move_to  (cr, x0, y0 + radius);
          cairo_curve_to (cr, x0 , y0, x0 , y0, x0 + radius, y0);
          cairo_line_to (cr, x1 - radius, y0);
          cairo_curve_to (cr, x1, y0, x1, y0, x1, y0 + radius);
          cairo_line_to (cr, x1 , y1 - radius);
          cairo_curve_to (cr, x1, y1, x1, y1, x1 - radius, y1);
          cairo_line_to (cr, x0 + radius, y1);
          cairo_curve_to (cr, x0, y1, x0, y1, x0, y1- radius);
        }
    }

  cairo_close_path (cr);
}

#line 899 "gcp-mouse-shortcut.c"

Generated by  Doxygen 1.6.0   Back to index