Logo Search packages:      
Sourcecode: unity version File versions  Download package

maximus.c

/* maximus.c generated by valac, the Vala compiler
 * generated from maximus.vala, do not modify */

/*
 * Copyright (C) 2009 Canonical Ltd
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 3 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Authored by Jason Smith <jason.smith@canonical.com>
 *
 */

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <mutter-plugins.h>
#include <clutter/clutter.h>


#define UNITY_TYPE_MAXIMUS (unity_maximus_get_type ())
#define UNITY_MAXIMUS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_TYPE_MAXIMUS, UnityMaximus))
#define UNITY_MAXIMUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_TYPE_MAXIMUS, UnityMaximusClass))
#define UNITY_IS_MAXIMUS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_TYPE_MAXIMUS))
#define UNITY_IS_MAXIMUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_TYPE_MAXIMUS))
#define UNITY_MAXIMUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_TYPE_MAXIMUS, UnityMaximusClass))

typedef struct _UnityMaximus UnityMaximus;
typedef struct _UnityMaximusClass UnityMaximusClass;
typedef struct _UnityMaximusPrivate UnityMaximusPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _UnityMaximus {
      GObject parent_instance;
      UnityMaximusPrivate * priv;
};

struct _UnityMaximusClass {
      GObjectClass parent_class;
};


extern char* unity_maximus_user_unmaximize_hint;
char* unity_maximus_user_unmaximize_hint = NULL;
static char** unity_maximus_default_exclude_classes;
static gint unity_maximus_default_exclude_classes_length1;
static char** unity_maximus_default_exclude_classes = NULL;
static gint unity_maximus_default_exclude_classes_length1 = 0;
static gint _unity_maximus_default_exclude_classes_size_ = 0;
static gpointer unity_maximus_parent_class = NULL;

GType unity_maximus_get_type (void);
enum  {
      UNITY_MAXIMUS_DUMMY_PROPERTY
};
UnityMaximus* unity_maximus_new (void);
UnityMaximus* unity_maximus_construct (GType object_type);
static gboolean unity_maximus_window_is_excluded (UnityMaximus* self, MutterWindow* window);
gboolean unity_maximus_process_window (UnityMaximus* self, MutterWindow* window);
static GObject * unity_maximus_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void unity_maximus_finalize (GObject* obj);



UnityMaximus* unity_maximus_construct (GType object_type) {
      UnityMaximus * self;
      self = g_object_newv (object_type, 0, NULL);
      return self;
}


UnityMaximus* unity_maximus_new (void) {
      return unity_maximus_construct (UNITY_TYPE_MAXIMUS);
}


static gboolean string_contains (const char* self, const char* needle) {
      gboolean result = FALSE;
      g_return_val_if_fail (self != NULL, FALSE);
      g_return_val_if_fail (needle != NULL, FALSE);
      result = strstr (self, needle) != NULL;
      return result;
}


static gpointer _g_object_ref0 (gpointer self) {
      return self ? g_object_ref (self) : NULL;
}


static gboolean unity_maximus_window_is_excluded (UnityMaximus* self, MutterWindow* window) {
      gboolean result = FALSE;
      MetaCompWindowType type;
      MetaWindow* meta;
      gboolean _tmp0_ = FALSE;
      const char* res_class;
      void* hint;
      g_return_val_if_fail (self != NULL, FALSE);
      g_return_val_if_fail (window != NULL, FALSE);
      type = mutter_window_get_window_type (window);
      if (type != META_COMP_WINDOW_NORMAL) {
            result = TRUE;
            return result;
      }
      meta = mutter_window_get_meta_window (window);
      if (meta_window_is_maximized (meta)) {
            _tmp0_ = TRUE;
      } else {
            _tmp0_ = !meta_window_allows_resize (meta);
      }
      if (_tmp0_) {
            result = TRUE;
            return result;
      }
      res_class = meta_window_get_wm_class (meta);
      {
            char** s_collection;
            int s_collection_length1;
            int s_it;
            s_collection = unity_maximus_default_exclude_classes;
            s_collection_length1 = unity_maximus_default_exclude_classes_length1;
            for (s_it = 0; s_it < unity_maximus_default_exclude_classes_length1; s_it = s_it + 1) {
                  char* s;
                  s = g_strdup (s_collection[s_it]);
                  {
                        if (string_contains (res_class, s)) {
                              result = TRUE;
                              _g_free0 (s);
                              return result;
                        }
                        _g_free0 (s);
                  }
            }
      }
      hint = g_object_get_data ((GObject*) window, unity_maximus_user_unmaximize_hint);
      if (hint != NULL) {
            result = TRUE;
            return result;
      }
      {
            ClutterActor* stage;
            gboolean _tmp1_ = FALSE;
            gboolean _tmp2_ = FALSE;
            gboolean _tmp3_ = FALSE;
            stage = _g_object_ref0 (clutter_stage_get_default ());
            if (clutter_actor_get_width ((ClutterActor*) window) < (clutter_actor_get_width (stage) * 0.6)) {
                  _tmp3_ = TRUE;
            } else {
                  _tmp3_ = clutter_actor_get_height ((ClutterActor*) window) < (clutter_actor_get_height (stage) * 0.6);
            }
            if (_tmp3_) {
                  _tmp2_ = TRUE;
            } else {
                  _tmp2_ = (clutter_actor_get_width ((ClutterActor*) window) / clutter_actor_get_height ((ClutterActor*) window)) < 0.6;
            }
            if (_tmp2_) {
                  _tmp1_ = TRUE;
            } else {
                  _tmp1_ = (clutter_actor_get_width ((ClutterActor*) window) / clutter_actor_get_height ((ClutterActor*) window)) > 2.0;
            }
            if (_tmp1_) {
                  result = TRUE;
                  _g_object_unref0 (stage);
                  return result;
            }
            _g_object_unref0 (stage);
      }
      result = FALSE;
      return result;
}


gboolean unity_maximus_process_window (UnityMaximus* self, MutterWindow* window) {
      gboolean result = FALSE;
      g_return_val_if_fail (self != NULL, FALSE);
      g_return_val_if_fail (window != NULL, FALSE);
      if (unity_maximus_window_is_excluded (self, window)) {
            result = TRUE;
            return result;
      }
      meta_window_maximize (mutter_window_get_meta_window (window), META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL);
      result = TRUE;
      return result;
}


static GObject * unity_maximus_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
      GObject * obj;
      GObjectClass * parent_class;
      UnityMaximus * self;
      parent_class = G_OBJECT_CLASS (unity_maximus_parent_class);
      obj = parent_class->constructor (type, n_construct_properties, construct_properties);
      self = UNITY_MAXIMUS (obj);
      {
      }
      return obj;
}


static void unity_maximus_class_init (UnityMaximusClass * klass) {
      char** _tmp0_ = NULL;
      unity_maximus_parent_class = g_type_class_peek_parent (klass);
      G_OBJECT_CLASS (klass)->constructor = unity_maximus_constructor;
      G_OBJECT_CLASS (klass)->finalize = unity_maximus_finalize;
      unity_maximus_user_unmaximize_hint = g_strdup ("maximus-user-unmaximize");
      unity_maximus_default_exclude_classes = (_tmp0_ = g_new0 (char*, 18 + 1), _tmp0_[0] = g_strdup ("Apport-gtk"), _tmp0_[1] = g_strdup ("Bluetooth-properties"), _tmp0_[2] = g_strdup ("Bluetooth-wizard"), _tmp0_[3] = g_strdup ("Download"), _tmp0_[4] = g_strdup ("Ekiga"), _tmp0_[5] = g_strdup ("Extension"), _tmp0_[6] = g_strdup ("Gimp"), _tmp0_[7] = g_strdup ("Global"), _tmp0_[8] = g_strdup ("Gnome-nettool"), _tmp0_[9] = g_strdup ("Kiten"), _tmp0_[10] = g_strdup ("Kmplot"), _tmp0_[11] = g_strdup ("Nm-editor"), _tmp0_[12] = g_strdup ("Pidgin"), _tmp0_[13] = g_strdup ("Polkit-gnome-authorization"), _tmp0_[14] = g_strdup ("Update-manager"), _tmp0_[15] = g_strdup ("Skype"), _tmp0_[16] = g_strdup ("Toplevel"), _tmp0_[17] = g_strdup ("Transmission"), _tmp0_);
      unity_maximus_default_exclude_classes_length1 = 18;
}


static void unity_maximus_instance_init (UnityMaximus * self) {
}


static void unity_maximus_finalize (GObject* obj) {
      UnityMaximus * self;
      self = UNITY_MAXIMUS (obj);
      G_OBJECT_CLASS (unity_maximus_parent_class)->finalize (obj);
}


GType unity_maximus_get_type (void) {
      static volatile gsize unity_maximus_type_id__volatile = 0;
      if (g_once_init_enter (&unity_maximus_type_id__volatile)) {
            static const GTypeInfo g_define_type_info = { sizeof (UnityMaximusClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) unity_maximus_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UnityMaximus), 0, (GInstanceInitFunc) unity_maximus_instance_init, NULL };
            GType unity_maximus_type_id;
            unity_maximus_type_id = g_type_register_static (G_TYPE_OBJECT, "UnityMaximus", &g_define_type_info, 0);
            g_once_init_leave (&unity_maximus_type_id__volatile, unity_maximus_type_id);
      }
      return unity_maximus_type_id__volatile;
}





Generated by  Doxygen 1.6.0   Back to index