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

gcm-tray-menu.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-tray-menu.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 34 "gcm-tray-menu.gob"

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif
      
#include <gnome.h>
#include <libgnome/gnome-desktop-item.h>

#include "gcm-application.h"
#include "gcm-classic-desktop.h"
#include "gcm-config.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 59 "gcm-tray-menu.c"
/* self casting macros */
#define SELF(x) GCM_TRAY_MENU(x)
#define SELF_CONST(x) GCM_TRAY_MENU_CONST(x)
#define IS_SELF(x) GCM_IS_TRAY_MENU(x)
#define TYPE_SELF GCM_TYPE_TRAY_MENU
#define SELF_CLASS(x) GCM_TRAY_MENU_CLASS(x)

#define SELF_GET_CLASS(x) GCM_TRAY_MENU_GET_CLASS(x)

/* self typedefs */
typedef GCMTrayMenu Self;
typedef GCMTrayMenuClass SelfClass;

struct _GCMTrayMenuPrivate {
#line 71 "gcm-tray-menu.gob"
      GCMGLDesktop * gl_desktop;
#line 73 "gcm-tray-menu.gob"
      GCMClassicDesktop * classic_desktop;
#line 75 "gcm-tray-menu.gob"
      GCMApplication * config_app;
#line 77 "gcm-tray-menu.gob"
      GtkWidget * compiz_menu;
#line 79 "gcm-tray-menu.gob"
      GtkWidget * config_menu;
#line 81 "gcm-tray-menu.gob"
      GtkWidget * about_menu;
#line 86 "gcm-tray-menu.c"
};
/* here are local prototypes */
static void gcm_tray_menu_init (GCMTrayMenu * o) G_GNUC_UNUSED;
static void gcm_tray_menu_class_init (GCMTrayMenuClass * klass) G_GNUC_UNUSED;
static void gcm_tray_menu_compiz_menu_activate (GCMTrayMenu * self, GtkWidget * compiz_menu) G_GNUC_UNUSED;
static void gcm_tray_menu_config_menu_activate (GCMTrayMenu * self, GtkWidget * config_menu) G_GNUC_UNUSED;
static void gcm_tray_menu_about_menu_activate (GCMTrayMenu * self, GtkWidget * themes_menu) G_GNUC_UNUSED;
static void gcm_tray_menu_enable_gl_desktop_changed (GConfClient * client, guint cnxn_id, GConfEntry * entry, GCMTrayMenu * self) G_GNUC_UNUSED;
static void gcm_tray_menu_switch_to_gl_desktop (GCMTrayMenu * self) G_GNUC_UNUSED;
static void gcm_tray_menu_switch_to_classic_desktop (GCMTrayMenu * self) G_GNUC_UNUSED;
static void gcm_tray_menu_gl_desktop_autostart (GCMTrayMenu * self, gboolean enable) G_GNUC_UNUSED;

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

/* Short form macros */
#define self_new gcm_tray_menu_new
#define self_compiz_menu_activate gcm_tray_menu_compiz_menu_activate
#define self_config_menu_activate gcm_tray_menu_config_menu_activate
#define self_about_menu_activate gcm_tray_menu_about_menu_activate
#define self_enable_gl_desktop_changed gcm_tray_menu_enable_gl_desktop_changed
#define self_switch_to_gl_desktop gcm_tray_menu_switch_to_gl_desktop
#define self_switch_to_classic_desktop gcm_tray_menu_switch_to_classic_desktop
#define self_gl_desktop_autostart gcm_tray_menu_gl_desktop_autostart
GType
gcm_tray_menu_get_type (void)
{
      static GType type = 0;

      if ___GOB_UNLIKELY(type == 0) {
            static const GTypeInfo info = {
                  sizeof (GCMTrayMenuClass),
                  (GBaseInitFunc) NULL,
                  (GBaseFinalizeFunc) NULL,
                  (GClassInitFunc) gcm_tray_menu_class_init,
                  (GClassFinalizeFunc) NULL,
                  NULL /* class_data */,
                  sizeof (GCMTrayMenu),
                  0 /* n_preallocs */,
                  (GInstanceInitFunc) gcm_tray_menu_init,
                  NULL
            };

            type = g_type_register_static (GTK_TYPE_MENU, "GCMTrayMenu", &info, (GTypeFlags)0);
      }

      return type;
}

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

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


static void
___finalize(GObject *obj_self)
{
#define __GOB_FUNCTION__ "GCM:Tray:Menu::finalize"
      GCMTrayMenu *self G_GNUC_UNUSED = GCM_TRAY_MENU (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 72 "gcm-tray-menu.gob"
      if(self->_priv->gl_desktop) { g_object_unref ((gpointer) self->_priv->gl_desktop); self->_priv->gl_desktop = NULL; }
#line 164 "gcm-tray-menu.c"
#line 74 "gcm-tray-menu.gob"
      if(self->_priv->classic_desktop) { g_object_unref ((gpointer) self->_priv->classic_desktop); self->_priv->classic_desktop = NULL; }
#line 167 "gcm-tray-menu.c"
#line 76 "gcm-tray-menu.gob"
      if(self->_priv->config_app) { g_object_unref ((gpointer) self->_priv->config_app); self->_priv->config_app = NULL; }
#line 170 "gcm-tray-menu.c"
#line 78 "gcm-tray-menu.gob"
      if(self->_priv->compiz_menu) { g_object_unref ((gpointer) self->_priv->compiz_menu); self->_priv->compiz_menu = NULL; }
#line 173 "gcm-tray-menu.c"
#line 80 "gcm-tray-menu.gob"
      if(self->_priv->config_menu) { g_object_unref ((gpointer) self->_priv->config_menu); self->_priv->config_menu = NULL; }
#line 176 "gcm-tray-menu.c"
#line 82 "gcm-tray-menu.gob"
      if(self->_priv->about_menu) { g_object_unref ((gpointer) self->_priv->about_menu); self->_priv->about_menu = NULL; }
#line 179 "gcm-tray-menu.c"
}
#undef __GOB_FUNCTION__

static void 
gcm_tray_menu_init (GCMTrayMenu * o G_GNUC_UNUSED)
{
#define __GOB_FUNCTION__ "GCM:Tray:Menu::init"
      o->_priv = G_TYPE_INSTANCE_GET_PRIVATE(o,GCM_TYPE_TRAY_MENU,GCMTrayMenuPrivate);
}
#undef __GOB_FUNCTION__
#line 85 "gcm-tray-menu.gob"
static void 
gcm_tray_menu_class_init (GCMTrayMenuClass * klass G_GNUC_UNUSED)
#line 193 "gcm-tray-menu.c"
{
#define __GOB_FUNCTION__ "GCM:Tray:Menu::class_init"
      GObjectClass *g_object_class G_GNUC_UNUSED = (GObjectClass*) klass;

      g_type_class_add_private(klass,sizeof(GCMTrayMenuPrivate));

      parent_class = g_type_class_ref (GTK_TYPE_MENU);

      g_object_class->finalize = ___finalize;
 {
#line 86 "gcm-tray-menu.gob"

            klass->client = gconf_client_get_default ();
            gconf_client_add_dir (klass->client,
                                            GCP_PREFIX,
                                            GCONF_CLIENT_PRELOAD_NONE,
                                            NULL);
      
#line 212 "gcm-tray-menu.c"
 }
}
#undef __GOB_FUNCTION__



#line 94 "gcm-tray-menu.gob"
GCMTrayMenu * 
gcm_tray_menu_new (GCMGLDesktop * gl_desktop)
#line 222 "gcm-tray-menu.c"
{
#define __GOB_FUNCTION__ "GCM:Tray:Menu::new"
#line 94 "gcm-tray-menu.gob"
      g_return_val_if_fail (gl_desktop != NULL, (GCMTrayMenu * )NULL);
#line 227 "gcm-tray-menu.c"
{
#line 96 "gcm-tray-menu.gob"
      
            GCMTrayMenu * self = GET_NEW;
            GtkWidget * separator;
            gboolean val;
            
            /* Create GL Desktop launcher */
            selfp->gl_desktop = g_object_ref(gl_desktop);
            
            /* Create Classic Desktop Launcher */
            selfp->classic_desktop = gcm_classic_desktop_new();
            
            /* Create configuration application */
            selfp->config_app = gcm_application_new("gnome-compiz-preferences", NULL, NULL);
            
            /* Create enable compiz menu */
            selfp->compiz_menu = gtk_check_menu_item_new_with_label(_("GL Desktop"));
            g_signal_connect_swapped(GTK_WIDGET(selfp->compiz_menu), 
                                                 "activate", 
                                                 (GCallback)self_compiz_menu_activate, 
                                                 self);
            gtk_menu_shell_append(GTK_MENU_SHELL(self), selfp->compiz_menu);
            gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(selfp->compiz_menu),
                                                         gcm_gl_desktop_enabled(selfp->gl_desktop));
            
            /* Create separator */
            separator = gtk_separator_menu_item_new();
            gtk_menu_shell_append(GTK_MENU_SHELL(self), separator);

            /* Create config menu */
            selfp->config_menu = 
                          gtk_image_menu_item_new_from_stock(GTK_STOCK_PREFERENCES,
                                                                                     NULL);
            g_signal_connect_swapped(GTK_WIDGET(selfp->config_menu), 
                                                 "activate", 
                                                 (GCallback)self_config_menu_activate, self);
            gtk_menu_shell_append(GTK_MENU_SHELL(self), selfp->config_menu);
            
            /* Create about menu */
            selfp->about_menu = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT,
                                                                                                NULL);
            g_signal_connect_swapped(GTK_WIDGET(selfp->about_menu), 
                                                 "activate", 
                                                 (GCallback)self_about_menu_activate, 
                                                 self);
            gtk_menu_shell_append(GTK_MENU_SHELL(self), selfp->about_menu);
            
            gtk_widget_show_all(GTK_WIDGET(self));
            
            /* Monitor gconf enable_gl_desktop value */
            gconf_client_notify_add(SELF_GET_CLASS(self)->client, 
                                                GCP_CONFIG_ENABLE_GL_DESKTOP,
                                                (GConfClientNotifyFunc)self_enable_gl_desktop_changed,
                                                self, NULL, NULL);
            
            val = gconf_client_get_bool(SELF_GET_CLASS(self)->client, 
                                                      GCP_CONFIG_ENABLE_GL_DESKTOP, NULL);
          if (val)
                  self_switch_to_gl_desktop(self);
            else
                  self_switch_to_classic_desktop(self);
            gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(selfp->compiz_menu),
                                                         val);
                  
            return self;
      }}
#line 295 "gcm-tray-menu.c"
#undef __GOB_FUNCTION__

#line 162 "gcm-tray-menu.gob"
static void 
gcm_tray_menu_compiz_menu_activate (GCMTrayMenu * self, GtkWidget * compiz_menu)
#line 301 "gcm-tray-menu.c"
{
#define __GOB_FUNCTION__ "GCM:Tray:Menu::compiz_menu_activate"
#line 162 "gcm-tray-menu.gob"
      g_return_if_fail (self != NULL);
#line 162 "gcm-tray-menu.gob"
      g_return_if_fail (GCM_IS_TRAY_MENU (self));
#line 308 "gcm-tray-menu.c"
{
#line 164 "gcm-tray-menu.gob"
      
            gconf_client_set_bool(SELF_GET_CLASS(self)->client, 
                                            GCP_CONFIG_ENABLE_GL_DESKTOP, 
             gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(selfp->compiz_menu)),
                                            NULL);
      }}
#line 317 "gcm-tray-menu.c"
#undef __GOB_FUNCTION__

#line 171 "gcm-tray-menu.gob"
static void 
gcm_tray_menu_config_menu_activate (GCMTrayMenu * self, GtkWidget * config_menu)
#line 323 "gcm-tray-menu.c"
{
#define __GOB_FUNCTION__ "GCM:Tray:Menu::config_menu_activate"
#line 171 "gcm-tray-menu.gob"
      g_return_if_fail (self != NULL);
#line 171 "gcm-tray-menu.gob"
      g_return_if_fail (GCM_IS_TRAY_MENU (self));
#line 330 "gcm-tray-menu.c"
{
#line 173 "gcm-tray-menu.gob"
      
            gcm_application_start(selfp->config_app);
      }}
#line 336 "gcm-tray-menu.c"
#undef __GOB_FUNCTION__

#line 177 "gcm-tray-menu.gob"
static void 
gcm_tray_menu_about_menu_activate (GCMTrayMenu * self, GtkWidget * themes_menu)
#line 342 "gcm-tray-menu.c"
{
#define __GOB_FUNCTION__ "GCM:Tray:Menu::about_menu_activate"
#line 177 "gcm-tray-menu.gob"
      g_return_if_fail (self != NULL);
#line 177 "gcm-tray-menu.gob"
      g_return_if_fail (GCM_IS_TRAY_MENU (self));
#line 349 "gcm-tray-menu.c"
{
#line 179 "gcm-tray-menu.gob"
      
            GtkWidget * about_dialog;
            GdkPixbuf * logo = gdk_pixbuf_new_from_file(PACKAGE_DATA_DIR"/gnome-compiz-manager/gnome-compiz-manager.png", 
                                                                              NULL);
            
            /* Create About dialog */
            about_dialog = gtk_about_dialog_new();
            gtk_about_dialog_set_name((GtkAboutDialog *)about_dialog, 
                                                      "Compiz Tray Icon");
            gtk_about_dialog_set_version((GtkAboutDialog *)about_dialog, 
                                                            VERSION);
            gtk_about_dialog_set_comments((GtkAboutDialog *)about_dialog, 
                                                            "GL Desktop Tray Launcher");        
            gtk_about_dialog_set_copyright((GtkAboutDialog *)about_dialog, "Copyright (c) Nicolas Bruguier");
            gtk_about_dialog_set_logo((GtkAboutDialog *)about_dialog, logo);
            
            gtk_dialog_run(GTK_DIALOG(about_dialog));
            gtk_widget_destroy(about_dialog);
      }}
#line 371 "gcm-tray-menu.c"
#undef __GOB_FUNCTION__

#line 199 "gcm-tray-menu.gob"
static void 
gcm_tray_menu_enable_gl_desktop_changed (GConfClient * client, guint cnxn_id, GConfEntry * entry, GCMTrayMenu * self)
#line 377 "gcm-tray-menu.c"
{
#define __GOB_FUNCTION__ "GCM:Tray:Menu::enable_gl_desktop_changed"
{
#line 204 "gcm-tray-menu.gob"
      
            GConfValue * value = gconf_entry_get_value(entry);
            gboolean enable = gconf_value_get_bool(value);
                  
            if (enable)
            {
                  self_switch_to_gl_desktop(self);
#ifndef USE_GNOME_SESSION                 
                  gcm_gl_desktop_activate_on_startup(selfp->gl_desktop);
                  gcm_gl_desktop_window_decorator_autostart(selfp->gl_desktop, TRUE);
#else
                        self_gl_desktop_autostart(self, TRUE);
#endif
            }
            else
            {
                  self_switch_to_classic_desktop(self);
#ifndef USE_GNOME_SESSION                 
                  gcm_gl_desktop_desactivate_on_startup(selfp->gl_desktop);
                  gcm_gl_desktop_window_decorator_autostart(selfp->gl_desktop, FALSE);
#else
                        self_gl_desktop_autostart(self, FALSE);
#endif
            }
            gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(selfp->compiz_menu),
                                                         enable);
      }}
#line 409 "gcm-tray-menu.c"
#undef __GOB_FUNCTION__

#line 232 "gcm-tray-menu.gob"
static void 
gcm_tray_menu_switch_to_gl_desktop (GCMTrayMenu * self)
#line 415 "gcm-tray-menu.c"
{
#define __GOB_FUNCTION__ "GCM:Tray:Menu::switch_to_gl_desktop"
#line 232 "gcm-tray-menu.gob"
      g_return_if_fail (self != NULL);
#line 232 "gcm-tray-menu.gob"
      g_return_if_fail (GCM_IS_TRAY_MENU (self));
#line 422 "gcm-tray-menu.c"
{
#line 234 "gcm-tray-menu.gob"
      
            gcm_classic_desktop_stop(selfp->classic_desktop);
            gcm_gl_desktop_start(selfp->gl_desktop);
      }}
#line 429 "gcm-tray-menu.c"
#undef __GOB_FUNCTION__

#line 239 "gcm-tray-menu.gob"
static void 
gcm_tray_menu_switch_to_classic_desktop (GCMTrayMenu * self)
#line 435 "gcm-tray-menu.c"
{
#define __GOB_FUNCTION__ "GCM:Tray:Menu::switch_to_classic_desktop"
#line 239 "gcm-tray-menu.gob"
      g_return_if_fail (self != NULL);
#line 239 "gcm-tray-menu.gob"
      g_return_if_fail (GCM_IS_TRAY_MENU (self));
#line 442 "gcm-tray-menu.c"
{
#line 241 "gcm-tray-menu.gob"
      
            gcm_gl_desktop_stop(selfp->gl_desktop);
            gcm_classic_desktop_start(selfp->classic_desktop);
      }}
#line 449 "gcm-tray-menu.c"
#undef __GOB_FUNCTION__

#line 246 "gcm-tray-menu.gob"
static void 
gcm_tray_menu_gl_desktop_autostart (GCMTrayMenu * self, gboolean enable)
#line 455 "gcm-tray-menu.c"
{
#define __GOB_FUNCTION__ "GCM:Tray:Menu::gl_desktop_autostart"
#line 246 "gcm-tray-menu.gob"
      g_return_if_fail (self != NULL);
#line 246 "gcm-tray-menu.gob"
      g_return_if_fail (GCM_IS_TRAY_MENU (self));
#line 462 "gcm-tray-menu.c"
{
#line 248 "gcm-tray-menu.gob"
      
            gchar *gl_manager = gcm_gl_desktop_get_gl_manager(selfp->gl_desktop);
            
            gconf_client_set_string(SELF_GET_CLASS(self)->client, 
                                              "/desktop/gnome/applications/window_manager/default",
                                              enable ? gl_manager : "", NULL);
      }}
#line 472 "gcm-tray-menu.c"
#undef __GOB_FUNCTION__

Generated by  Doxygen 1.6.0   Back to index