~mhall119/ubuntu/precise/geany/add_keywords

« back to all changes in this revision

Viewing changes to src/geanywraplabel.c

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2011-12-10 07:43:26 UTC
  • mfrom: (3.3.7 sid)
  • Revision ID: package-import@ubuntu.com-20111210074326-s8yqbew5i20h33tf
Tags: 0.21-1ubuntu1
* Merge from Debian Unstable, remaining changes:
  - debian/patches/20_use_evince_viewer.patch:
     + use evince as viewer for pdf and dvi files
  - debian/patches/20_use_x_terminal_emulator.patch:
     + use x-terminal-emulator as terminal
  - debian/control
     + Add breaks on geany-plugins-common << 0.20
* Also fixes bugs:
  - Filter for MATLAB/Octave files filters everythign (LP: 885505)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 *      geanywraplabel.c - this file is part of Geany, a fast and lightweight IDE
3
3
 *
4
 
 *      Copyright 2009-2010 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5
 
 *      Copyright 2009-2010 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
 
4
 *      Copyright 2009-2011 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
 
5
 *      Copyright 2009-2011 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
6
6
 *
7
7
 *      This program is free software; you can redistribute it and/or modify
8
8
 *      it under the terms of the GNU General Public License as published by
18
18
 *      along with this program; if not, write to the Free Software
19
19
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
20
 *
21
 
 *  $Id: geanywraplabel.c 5283 2010-10-06 15:32:40Z ntrel $
 
21
 *  $Id: geanywraplabel.c 5795 2011-05-10 23:51:01Z colombanw $
22
22
 */
23
23
 
24
24
/*
56
56
static void geany_wrap_label_size_request       (GtkWidget *widget, GtkRequisition *req);
57
57
static void geany_wrap_label_size_allocate      (GtkWidget *widget, GtkAllocation *alloc);
58
58
static void geany_wrap_label_set_wrap_width     (GtkWidget *widget, gsize width);
 
59
static void geany_wrap_label_label_notify       (GObject *object, GParamSpec *pspec, gpointer data);
59
60
 
60
61
G_DEFINE_TYPE(GeanyWrapLabel, geany_wrap_label, GTK_TYPE_LABEL)
61
62
 
80
81
 
81
82
        priv = self->priv;
82
83
        priv->wrap_width = 0;
 
84
 
 
85
        g_signal_connect(self, "notify::label", G_CALLBACK(geany_wrap_label_label_notify), NULL);
 
86
        pango_layout_set_wrap(gtk_label_get_layout(GTK_LABEL(self)), PANGO_WRAP_WORD_CHAR);
 
87
        gtk_misc_set_alignment(GTK_MISC(self), 0.0, 0.0);
83
88
}
84
89
 
85
90
 
106
111
}
107
112
 
108
113
 
 
114
/* updates the wrap width when the label text changes */
 
115
static void geany_wrap_label_label_notify(GObject *object, GParamSpec *pspec, gpointer data)
 
116
{
 
117
        GeanyWrapLabelPrivate *priv = GEANY_WRAP_LABEL_GET_PRIVATE(object);
 
118
 
 
119
        geany_wrap_label_set_wrap_width(GTK_WIDGET(object), priv->wrap_width);
 
120
}
 
121
 
 
122
 
109
123
/* Forces the height to be the size necessary for the Pango layout, while allowing the
110
124
 * width to be flexible. */
111
125
static void geany_wrap_label_size_request(GtkWidget *widget, GtkRequisition *req)
128
142
}
129
143
 
130
144
 
131
 
void geany_wrap_label_set_text(GtkLabel *label, const gchar *text)
132
 
{
133
 
        GeanyWrapLabelPrivate *priv = GEANY_WRAP_LABEL_GET_PRIVATE(label);
134
 
 
135
 
        gtk_label_set_text(label, text);
136
 
        geany_wrap_label_set_wrap_width(GTK_WIDGET(label), priv->wrap_width);
137
 
}
138
 
 
139
 
 
140
145
GtkWidget *geany_wrap_label_new(const gchar *text)
141
146
{
142
 
        GtkWidget *l = g_object_new(GEANY_WRAP_LABEL_TYPE, NULL);
143
 
 
144
 
        if (NZV(text))
145
 
                gtk_label_set_text(GTK_LABEL(l), text);
146
 
 
147
 
        pango_layout_set_wrap(gtk_label_get_layout(GTK_LABEL(l)), PANGO_WRAP_WORD_CHAR);
148
 
        gtk_misc_set_alignment(GTK_MISC(l), 0.0, 0.0);
149
 
 
150
 
        return l;
 
147
        return g_object_new(GEANY_WRAP_LABEL_TYPE, "label", text, NULL);
151
148
}