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

gcm-entry-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 "gcm-entry-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 33 "gcm-entry-shortcut.gob"

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include "eggaccelerators.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

#line 54 "gcm-entry-shortcut.c"
/* self casting macros */
#define SELF(x) GCM_ENTRY_SHORTCUT(x)
#define SELF_CONST(x) GCM_ENTRY_SHORTCUT_CONST(x)
#define IS_SELF(x) GCM_IS_ENTRY_SHORTCUT(x)
#define TYPE_SELF GCM_TYPE_ENTRY_SHORTCUT
#define SELF_CLASS(x) GCM_ENTRY_SHORTCUT_CLASS(x)

#define SELF_GET_CLASS(x) GCM_ENTRY_SHORTCUT_GET_CLASS(x)

/* self typedefs */
typedef GCMEntryShortcut Self;
typedef GCMEntryShortcutClass SelfClass;

struct _GCMEntryShortcutPrivate {
#line 65 "gcm-entry-shortcut.gob"
      gboolean edited;
#line 66 "gcm-entry-shortcut.gob"
      gchar * old_value;
#line 68 "gcm-entry-shortcut.gob"
      gboolean mouse;
#line 69 "gcm-entry-shortcut.gob"
      guint button;
#line 77 "gcm-entry-shortcut.c"
};
/* here are local prototypes */
static void gcm_entry_shortcut_init (GCMEntryShortcut * o) G_GNUC_UNUSED;
static void gcm_entry_shortcut_class_init (GCMEntryShortcutClass * c) G_GNUC_UNUSED;
static gboolean ___3_gcm_entry_shortcut_focus_out_event (GtkWidget * widget, GdkEventFocus * event) G_GNUC_UNUSED;
static gboolean ___4_gcm_entry_shortcut_button_press_event (GtkWidget * widget, GdkEventButton * event) G_GNUC_UNUSED;
static gboolean ___5_gcm_entry_shortcut_scroll_event (GtkWidget * widget, GdkEventScroll * event) G_GNUC_UNUSED;
static gboolean ___6_gcm_entry_shortcut_key_release_event (GtkWidget * widget, GdkEventKey * event) G_GNUC_UNUSED;

/*
 * Signal connection wrapper macro shortcuts
 */
#define self_connect__edited(object,func,data)  gcm_entry_shortcut_connect__edited((object),(func),(data))
#define self_connect_after__edited(object,func,data)  gcm_entry_shortcut_connect_after__edited((object),(func),(data))
#define self_connect_data__edited(object,func,data,destroy_data,flags)  gcm_entry_shortcut_connect_data__edited((object),(func),(data),(destroy_data),(flags))

enum {
      EDITED_SIGNAL,
      LAST_SIGNAL
};

static guint object_signals[LAST_SIGNAL] = {0};

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

/* Short form macros */
#define self_edited gcm_entry_shortcut_edited
#define self_new gcm_entry_shortcut_new
GType
gcm_entry_shortcut_get_type (void)
{
      static GType type = 0;

      if ___GOB_UNLIKELY(type == 0) {
            static const GTypeInfo info = {
                  sizeof (GCMEntryShortcutClass),
                  (GBaseInitFunc) NULL,
                  (GBaseFinalizeFunc) NULL,
                  (GClassInitFunc) gcm_entry_shortcut_class_init,
                  (GClassFinalizeFunc) NULL,
                  NULL /* class_data */,
                  sizeof (GCMEntryShortcut),
                  0 /* n_preallocs */,
                  (GInstanceInitFunc) gcm_entry_shortcut_init,
                  NULL
            };

            type = g_type_register_static (GTK_TYPE_ENTRY, "GCMEntryShortcut", &info, (GTypeFlags)0);
      }

      return type;
}

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

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


static void
___finalize(GObject *obj_self)
{
#define __GOB_FUNCTION__ "GCM:Entry:Shortcut::finalize"
      GCMEntryShortcut *self G_GNUC_UNUSED = GCM_ENTRY_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 67 "gcm-entry-shortcut.gob"
      if(self->_priv->old_value) { g_free ((gpointer) self->_priv->old_value); self->_priv->old_value = NULL; }
#line 160 "gcm-entry-shortcut.c"
}
#undef __GOB_FUNCTION__

static void 
gcm_entry_shortcut_init (GCMEntryShortcut * o G_GNUC_UNUSED)
{
#define __GOB_FUNCTION__ "GCM:Entry:Shortcut::init"
      o->_priv = G_TYPE_INSTANCE_GET_PRIVATE(o,GCM_TYPE_ENTRY_SHORTCUT,GCMEntryShortcutPrivate);
#line 33 "gcm-entry-shortcut.gob"
      o->_priv->edited = FALSE;
#line 171 "gcm-entry-shortcut.c"
#line 33 "gcm-entry-shortcut.gob"
      o->_priv->mouse = TRUE;
#line 174 "gcm-entry-shortcut.c"
#line 33 "gcm-entry-shortcut.gob"
      o->_priv->button = 0;
#line 177 "gcm-entry-shortcut.c"
}
#undef __GOB_FUNCTION__
static void 
gcm_entry_shortcut_class_init (GCMEntryShortcutClass * c G_GNUC_UNUSED)
{
#define __GOB_FUNCTION__ "GCM:Entry: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(GCMEntryShortcutPrivate));

      parent_class = g_type_class_ref (GTK_TYPE_ENTRY);

      object_signals[EDITED_SIGNAL] =
            g_signal_new ("edited",
                  G_TYPE_FROM_CLASS (g_object_class),
                  (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
                  G_STRUCT_OFFSET (GCMEntryShortcutClass, edited),
                  NULL, NULL,
                  g_cclosure_marshal_VOID__VOID,
                  G_TYPE_NONE, 0);

      c->edited = NULL;
#line 90 "gcm-entry-shortcut.gob"
      gtk_widget_class->focus_out_event = ___3_gcm_entry_shortcut_focus_out_event;
#line 109 "gcm-entry-shortcut.gob"
      gtk_widget_class->button_press_event = ___4_gcm_entry_shortcut_button_press_event;
#line 136 "gcm-entry-shortcut.gob"
      gtk_widget_class->scroll_event = ___5_gcm_entry_shortcut_scroll_event;
#line 154 "gcm-entry-shortcut.gob"
      gtk_widget_class->key_release_event = ___6_gcm_entry_shortcut_key_release_event;
#line 209 "gcm-entry-shortcut.c"
      g_object_class->finalize = ___finalize;
}
#undef __GOB_FUNCTION__



#line 71 "gcm-entry-shortcut.gob"
void 
gcm_entry_shortcut_edited (GCMEntryShortcut * self)
#line 219 "gcm-entry-shortcut.c"
{
      GValue ___param_values[1];
      GValue ___return_val;

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

#line 71 "gcm-entry-shortcut.gob"
      g_return_if_fail (self != NULL);
#line 71 "gcm-entry-shortcut.gob"
      g_return_if_fail (GCM_IS_ENTRY_SHORTCUT (self));
#line 231 "gcm-entry-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);

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

      g_value_unset (&___param_values[0]);
}

#line 74 "gcm-entry-shortcut.gob"
GtkWidget * 
gcm_entry_shortcut_new (gchar * value, gboolean mouse)
#line 248 "gcm-entry-shortcut.c"
{
#define __GOB_FUNCTION__ "GCM:Entry:Shortcut::new"
{
#line 76 "gcm-entry-shortcut.gob"
      
            GCMEntryShortcut * self = GET_NEW;
            
            selfp->old_value = value ? g_strdup(value) : g_strdup(_("Disabled"));
            selfp->mouse = mouse;
            
            gtk_entry_set_editable(GTK_ENTRY(self), FALSE);
            gtk_entry_set_text(GTK_ENTRY(self), selfp->old_value);
            
            gtk_widget_add_events(GTK_WIDGET(self), GDK_BUTTON_PRESS_MASK);
            
            return GTK_WIDGET(self);
      }}
#line 266 "gcm-entry-shortcut.c"
#undef __GOB_FUNCTION__

#line 90 "gcm-entry-shortcut.gob"
static gboolean 
___3_gcm_entry_shortcut_focus_out_event (GtkWidget * widget G_GNUC_UNUSED, GdkEventFocus * event)
#line 272 "gcm-entry-shortcut.c"
#define PARENT_HANDLER(___widget,___event) \
      ((GTK_WIDGET_CLASS(parent_class)->focus_out_event)? \
            (* GTK_WIDGET_CLASS(parent_class)->focus_out_event)(___widget,___event): \
            ((gboolean )0))
{
#define __GOB_FUNCTION__ "GCM:Entry:Shortcut::focus_out_event"
{
#line 92 "gcm-entry-shortcut.gob"
      
            GCMEntryShortcut * self = SELF(widget);
            
            if (selfp->edited)
            {
                  gtk_entry_set_text(GTK_ENTRY(self), selfp->old_value);
                  gdk_keyboard_ungrab(GDK_CURRENT_TIME);
                  gdk_pointer_ungrab(GDK_CURRENT_TIME);
                  selfp->edited = FALSE;
                  selfp->button = 0;
            }
            
            PARENT_HANDLER(widget, event);
            
            return FALSE;
      }}
#line 297 "gcm-entry-shortcut.c"
#undef __GOB_FUNCTION__
#undef PARENT_HANDLER

#line 109 "gcm-entry-shortcut.gob"
static gboolean 
___4_gcm_entry_shortcut_button_press_event (GtkWidget * widget G_GNUC_UNUSED, GdkEventButton * event)
#line 304 "gcm-entry-shortcut.c"
#define PARENT_HANDLER(___widget,___event) \
      ((GTK_WIDGET_CLASS(parent_class)->button_press_event)? \
            (* GTK_WIDGET_CLASS(parent_class)->button_press_event)(___widget,___event): \
            ((gboolean )0))
{
#define __GOB_FUNCTION__ "GCM:Entry:Shortcut::button_press_event"
{
#line 111 "gcm-entry-shortcut.gob"
      
            GCMEntryShortcut * self = SELF(widget);
            
            if (event->type == GDK_BUTTON_PRESS)
            {
                  if (!selfp->edited)
                  {
                        g_free(selfp->old_value);
                        selfp->old_value = g_strdup(gtk_entry_get_text(GTK_ENTRY(self)));
                        gtk_entry_set_text(GTK_ENTRY(self), 
                              selfp->mouse ? _("<Press keys and mouse shortcut...>") : _("<Press keys shortcut...>"));
                        gdk_keyboard_grab(GTK_WIDGET(self)->window,
                                                  TRUE,
                                                  GDK_CURRENT_TIME);
                        gdk_pointer_grab(GTK_WIDGET(self)->window, TRUE, 
                                                 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK, 
                                                 GTK_WIDGET(self)->window, NULL, GDK_CURRENT_TIME);
                        selfp->edited = TRUE;
                  }
            }                 
            PARENT_HANDLER(widget, event);
            
            return FALSE;
      }}
#line 337 "gcm-entry-shortcut.c"
#undef __GOB_FUNCTION__
#undef PARENT_HANDLER

#line 136 "gcm-entry-shortcut.gob"
static gboolean 
___5_gcm_entry_shortcut_scroll_event (GtkWidget * widget G_GNUC_UNUSED, GdkEventScroll * event)
#line 344 "gcm-entry-shortcut.c"
#define PARENT_HANDLER(___widget,___event) \
      ((GTK_WIDGET_CLASS(parent_class)->scroll_event)? \
            (* GTK_WIDGET_CLASS(parent_class)->scroll_event)(___widget,___event): \
            ((gboolean )0))
{
#define __GOB_FUNCTION__ "GCM:Entry:Shortcut::scroll_event"
{
#line 138 "gcm-entry-shortcut.gob"
      
            GCMEntryShortcut * self = SELF(widget);
            
            if (selfp->edited)
            {
                  if (event->direction == GDK_SCROLL_UP)
                        selfp->button = GDK_BUTTON4_MASK;
                  else if (event->direction == GDK_SCROLL_DOWN)
                        selfp->button = GDK_BUTTON5_MASK;
            }
            
            PARENT_HANDLER(widget, event);
            
            return FALSE;
      }}
#line 368 "gcm-entry-shortcut.c"
#undef __GOB_FUNCTION__
#undef PARENT_HANDLER

#line 154 "gcm-entry-shortcut.gob"
static gboolean 
___6_gcm_entry_shortcut_key_release_event (GtkWidget * widget G_GNUC_UNUSED, GdkEventKey * event)
#line 375 "gcm-entry-shortcut.c"
#define PARENT_HANDLER(___widget,___event) \
      ((GTK_WIDGET_CLASS(parent_class)->key_release_event)? \
            (* GTK_WIDGET_CLASS(parent_class)->key_release_event)(___widget,___event): \
            ((gboolean )0))
{
#define __GOB_FUNCTION__ "GCM:Entry:Shortcut::key_release_event"
{
#line 156 "gcm-entry-shortcut.gob"
      
            GCMEntryShortcut * self = SELF(widget);
            
            if (selfp->edited && event->type == GDK_KEY_RELEASE)
            {
                  gchar * value = g_strdup("");
                  gchar * tmp;
                  
                  if (event->keyval == GDK_BackSpace)
                        value = g_strdup(_("Disabled"));
                  else if (event->keyval == GDK_Escape)
                        value = g_strdup(selfp->old_value);
                  else
                  {
                        guint keyval = 0;
                        GdkModifierType mods = 0;
                        GdkModifierType consumed_modifiers;
                        EggVirtualModifierType modifier;
                              
                        consumed_modifiers = 0;
                        keyval = gdk_keyval_to_lower(event->keyval);
                        if (keyval == GDK_ISO_Left_Tab) 
                              keyval = GDK_Tab;
                        gdk_keymap_translate_keyboard_state(gdk_keymap_get_default (),
                                                                              event->hardware_keycode,
                                                                              event->state,
                                                                              event->group,
                                                                              &keyval, NULL, NULL, 
                                                                              &consumed_modifiers);
                        if (event->keyval != keyval &&
                              (consumed_modifiers & GDK_SHIFT_MASK))
                              consumed_modifiers &= ~(GDK_SHIFT_MASK);
                        
                        mods = event->state & GDK_MODIFIER_MASK & ~(consumed_modifiers);
                        egg_keymap_virtualize_modifiers(gdk_keymap_get_default(),
                                                                        mods,
                                                                        &modifier);
                        
                        switch (keyval)
                        {
                              case GDK_Shift_L:
                              case GDK_Shift_R:
                                    modifier |= EGG_VIRTUAL_SHIFT_MASK;
                                    keyval = 0;
                                    break;
                              case GDK_Control_L:
                              case GDK_Control_R:
                                    modifier |= EGG_VIRTUAL_CONTROL_MASK;
                                    keyval = 0;
                                    break;
                              case GDK_Alt_L:
                              case GDK_Alt_R:
                                    modifier |= EGG_VIRTUAL_ALT_MASK;
                                    keyval = 0;
                                    break;
                              case GDK_Super_L:
                              case GDK_Super_R:
                                    modifier |= EGG_VIRTUAL_SUPER_MASK;
                                    keyval = 0;
                                    break;
                              default:
                                    break;
                        }
                        
                        if (event->is_modifier)
                              keyval = 0;
                        
                        modifier &= ~(EGG_VIRTUAL_META_MASK);
                        modifier &= ~(EGG_VIRTUAL_HYPER_MASK);
                        
                        value =  egg_virtual_accelerator_name(keyval, 0, modifier);
                        
                        if (selfp->mouse)
                        {
                              if (event->state & GDK_BUTTON1_MASK)
                              {
                                    tmp = g_strconcat(value, "Button1", NULL);
                                    g_free(value);
                                    value = tmp;
                              }
                              if (event->state & GDK_BUTTON2_MASK)
                              {
                                    tmp = g_strconcat(value, "Button2", NULL);
                                    g_free(value);
                                    value = tmp;
                              }
                              if (event->state & GDK_BUTTON3_MASK)
                              {
                                    tmp = g_strconcat(value, "Button3", NULL);
                                    g_free(value);
                                    value = tmp;
                              }
                              if (selfp->button & GDK_BUTTON4_MASK)
                              {
                                    tmp = g_strconcat(value, "Button4", NULL);
                                    g_free(value);
                                    value = tmp;
                              }
                              if (selfp->button & GDK_BUTTON5_MASK)
                              {
                                    tmp = g_strconcat(value, "Button5", NULL);
                                    g_free(value);
                                    value = tmp;
                              }
                        }
                  }

                  selfp->edited = FALSE;
                  gdk_keyboard_ungrab(GDK_CURRENT_TIME);
                  gdk_pointer_ungrab(GDK_CURRENT_TIME);
                  gtk_entry_set_text(GTK_ENTRY(self), value);
                  g_free(value);
                  self_edited(self);
            }
            
            PARENT_HANDLER(widget, event);
            
            return FALSE;
      }}
#line 503 "gcm-entry-shortcut.c"
#undef __GOB_FUNCTION__
#undef PARENT_HANDLER

Generated by  Doxygen 1.6.0   Back to index