File: gtkzoom.c

package info (click to toggle)
screen-message 0.29-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 464 kB
  • sloc: ansic: 494; python: 95; makefile: 45
file content (127 lines) | stat: -rw-r--r-- 3,034 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include "gtkzoom.h"

struct _GtkZoomPrivate
{
	int dummy;
//  GtkWidget *child;
};

static gboolean
gtk_zoom_draw      (GtkWidget      *widget,
                                     cairo_t        *cr);
static void
gtk_zoom_size_allocate (GtkWidget     *widget, GtkAllocation *allocation);
static void
gtk_zoom_get_preferred_width (GtkWidget *widget,
                                 gint      *minimum,
                                 gint      *natural);
static void
gtk_zoom_get_preferred_height (GtkWidget *widget,
                                 gint      *minimum,
                                 gint      *natural);

G_DEFINE_TYPE (GtkZoom, gtk_zoom, GTK_TYPE_BIN)

static void
gtk_zoom_class_init (GtkZoomClass *class)
{
  GtkWidgetClass *widget_class = (GtkWidgetClass*) class;

  widget_class->draw          = gtk_zoom_draw;
  widget_class->size_allocate = gtk_zoom_size_allocate;
  widget_class->get_preferred_width = gtk_zoom_get_preferred_width;
  widget_class->get_preferred_height = gtk_zoom_get_preferred_height;


  g_type_class_add_private (class, sizeof (GtkZoomPrivate));
}

static void
gtk_zoom_init (GtkZoom *zoom)
{
  GtkZoomPrivate *priv;

  zoom->priv = G_TYPE_INSTANCE_GET_PRIVATE (zoom,
                                           GTK_TYPE_ZOOM,
                                           GtkZoomPrivate);
  priv = zoom->priv;
}

GtkWidget*
gtk_zoom_new (void)
{
  return g_object_new (GTK_TYPE_ZOOM, NULL);
}


static void
gtk_zoom_size_allocate (GtkWidget     *widget, GtkAllocation *allocation)
{
  GtkWidget *main_widget;

  GTK_WIDGET_CLASS (gtk_zoom_parent_class)->size_allocate (widget, allocation);

  main_widget = gtk_bin_get_child (GTK_BIN (widget));
  if (!main_widget || !gtk_widget_get_visible (main_widget))
    return;

  gtk_widget_size_allocate (main_widget, allocation);
}

static void
gtk_zoom_get_preferred_width (GtkWidget *widget,
                                 gint      *minimum,
                                 gint      *natural)
{
  GtkBin *bin = GTK_BIN (widget);
  GtkWidget *child;

  if (minimum)
    *minimum = 0;

  if (natural)
    *natural = 0;

  child = gtk_bin_get_child (bin);
  if (child && gtk_widget_get_visible (child))
    gtk_widget_get_preferred_width (child, minimum, natural);
}

static void
gtk_zoom_get_preferred_height (GtkWidget *widget,
                                  gint      *minimum,
                                  gint      *natural)
{
  GtkBin *bin = GTK_BIN (widget);
  GtkWidget *child;

  if (minimum)
    *minimum = 0;

  if (natural)
    *natural = 0;

  child = gtk_bin_get_child (bin);
  if (child && gtk_widget_get_visible (child))
    gtk_widget_get_preferred_height (child, minimum, natural);
}



static gboolean
gtk_zoom_draw (GtkWidget *widget, cairo_t   *cr)
{
	GtkWidget *child;
	child = gtk_bin_get_child (GTK_BIN(widget));
	if (child) {
		cairo_save(cr);
		cairo_scale(cr, 2, 2);
		gtk_widget_draw(child, cr);
		cairo_restore(cr);
	}

	//GTK_WIDGET_CLASS (gtk_zoom_parent_class)->draw (widget, cr);

	return FALSE;
}