~ubuntu-branches/ubuntu/saucy/mutter/saucy

« back to all changes in this revision

Viewing changes to src/ui/themewidget.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-10-01 11:39:17 UTC
  • mfrom: (1.2.1 upstream) (10.1.20 maverick)
  • Revision ID: james.westby@ubuntu.com-20101001113917-d1c9zswwaehyn07e
Tags: 2.31.5-0ubuntu9
* debian/patches/20_unity_no_3D_detection.patch:
  - add an extra string in fallback mode to guide user in live session
    (LP: #651085)

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include "themewidget.h"
25
25
#include <math.h>
26
26
 
27
 
static void meta_area_class_init   (MetaAreaClass  *klass);
28
 
static void meta_area_init         (MetaArea       *area);
 
27
#include "gtk-compat.h"
 
28
 
29
29
static void meta_area_size_request (GtkWidget      *widget,
30
30
                                    GtkRequisition *req);
31
31
static gint meta_area_expose       (GtkWidget      *widget,
33
33
static void meta_area_finalize     (GObject        *object);
34
34
 
35
35
 
36
 
static GtkMiscClass *parent_class;
37
 
 
38
 
GType
39
 
meta_area_get_type (void)
40
 
{
41
 
  static GType area_type = 0;
42
 
 
43
 
  if (!area_type)
44
 
    {
45
 
      static const GtkTypeInfo area_info =
46
 
      {
47
 
        "MetaArea",
48
 
        sizeof (MetaArea),
49
 
        sizeof (MetaAreaClass),
50
 
        (GtkClassInitFunc) meta_area_class_init,
51
 
        (GtkObjectInitFunc) meta_area_init,
52
 
        /* reserved_1 */ NULL,
53
 
        /* reserved_2 */ NULL,
54
 
        (GtkClassInitFunc) NULL,
55
 
      };
56
 
 
57
 
      area_type = gtk_type_unique (GTK_TYPE_MISC, &area_info);
58
 
    }
59
 
 
60
 
  return area_type;
61
 
}
 
36
G_DEFINE_TYPE (MetaArea, meta_area, GTK_TYPE_MISC);
62
37
 
63
38
static void
64
39
meta_area_class_init (MetaAreaClass *class)
69
44
 
70
45
  object_class = (GtkObjectClass*) class;
71
46
  widget_class = (GtkWidgetClass*) class;
72
 
  parent_class = gtk_type_class (gtk_misc_get_type ());
73
47
 
74
48
  gobject_class->finalize = meta_area_finalize;
75
49
 
80
54
static void
81
55
meta_area_init (MetaArea *area)
82
56
{
83
 
  GTK_WIDGET_SET_FLAGS (area, GTK_NO_WINDOW);
 
57
  gtk_widget_set_has_window (GTK_WIDGET (area), FALSE);
84
58
}
85
59
 
86
60
GtkWidget*
88
62
{
89
63
  MetaArea *area;
90
64
  
91
 
  area = gtk_type_new (META_TYPE_AREA);
 
65
  area = g_object_new (META_TYPE_AREA, NULL);
92
66
  
93
67
  return GTK_WIDGET (area);
94
68
}
103
77
  if (area->dnotify)
104
78
    (* area->dnotify) (area->user_data);
105
79
  
106
 
  G_OBJECT_CLASS (parent_class)->finalize (object);
 
80
  G_OBJECT_CLASS (meta_area_parent_class)->finalize (object);
107
81
}
108
82
 
109
83
static gint
111
85
                  GdkEventExpose *event)
112
86
{
113
87
  MetaArea *area;
 
88
  GtkAllocation allocation;
114
89
  GtkMisc *misc;
 
90
  GtkRequisition requisition;
 
91
  gfloat xalign, yalign;
115
92
  gint x, y;
116
 
  gfloat xalign;
 
93
  gint xpad, ypad;
117
94
 
118
95
  g_return_val_if_fail (META_IS_AREA (widget), FALSE);
119
96
  g_return_val_if_fail (event != NULL, FALSE);
120
97
 
121
 
  if (GTK_WIDGET_DRAWABLE (widget))
 
98
  if (gtk_widget_is_drawable (widget))
122
99
    {
123
100
      area = META_AREA (widget);
124
101
      misc = GTK_MISC (widget);
125
102
 
126
 
      if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
127
 
        xalign = misc->xalign;
128
 
      else
129
 
        xalign = 1.0 - misc->xalign;
 
103
      gtk_widget_get_allocation (widget, &allocation);
 
104
      gtk_widget_get_requisition (widget, &requisition);
 
105
      gtk_misc_get_alignment (misc, &xalign, &yalign);
 
106
      gtk_misc_get_padding (misc, &xpad, &ypad);
 
107
 
 
108
      if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
 
109
        xalign = 1.0 - xalign;
130
110
  
131
 
      x = floor (widget->allocation.x + misc->xpad
132
 
                 + ((widget->allocation.width - widget->requisition.width) * xalign)
 
111
      x = floor (allocation.x + xpad
 
112
                 + ((allocation.width - requisition.width) * xalign)
133
113
                 + 0.5);
134
 
      y = floor (widget->allocation.y + misc->ypad 
135
 
                 + ((widget->allocation.height - widget->requisition.height) * misc->yalign)
 
114
      y = floor (allocation.y + ypad
 
115
                 + ((allocation.height - requisition.height) * yalign)
136
116
                 + 0.5);
137
117
      
138
118
      if (area->expose_func)