[gnome-initial-setup] account: Clean up um-utils
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup] account: Clean up um-utils
- Date: Thu, 26 Jul 2012 06:41:12 +0000 (UTC)
commit a749ea78c43369f44415a6a90bd116262770adc3
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Wed Jul 25 08:15:42 2012 -0300
account: Clean up um-utils
Remove a bunch of code that we don't care about.
gnome-initial-setup/pages/account/um-utils.c | 245 --------------------------
gnome-initial-setup/pages/account/um-utils.h | 15 --
2 files changed, 0 insertions(+), 260 deletions(-)
---
diff --git a/gnome-initial-setup/pages/account/um-utils.c b/gnome-initial-setup/pages/account/um-utils.c
index f579cb7..3bfbdbb 100644
--- a/gnome-initial-setup/pages/account/um-utils.c
+++ b/gnome-initial-setup/pages/account/um-utils.c
@@ -32,208 +32,6 @@
#include "um-utils.h"
-typedef struct {
- gchar *text;
- gchar *placeholder_str;
- GIcon *icon;
- gunichar placeholder;
- gulong query_id;
-} IconShapeData;
-
-static IconShapeData *
-icon_shape_data_new (const gchar *text,
- const gchar *placeholder,
- GIcon *icon)
-{
- IconShapeData *data;
-
- data = g_new0 (IconShapeData, 1);
-
- data->text = g_strdup (text);
- data->placeholder_str = g_strdup (placeholder);
- data->placeholder = g_utf8_get_char_validated (placeholder, -1);
- data->icon = g_object_ref (icon);
-
- return data;
-}
-
-static void
-icon_shape_data_free (gpointer user_data)
-{
- IconShapeData *data = user_data;
-
- g_free (data->text);
- g_free (data->placeholder_str);
- g_object_unref (data->icon);
- g_free (data);
-}
-
-static void
-icon_shape_renderer (cairo_t *cr,
- PangoAttrShape *attr,
- gboolean do_path,
- gpointer user_data)
-{
- IconShapeData *data = user_data;
- gdouble x, y;
-
- cairo_get_current_point (cr, &x, &y);
- if (GPOINTER_TO_UINT (attr->data) == data->placeholder) {
- gdouble ascent;
- gdouble height;
- GdkPixbuf *pixbuf;
- GtkIconInfo *info;
-
- ascent = pango_units_to_double (attr->ink_rect.y);
- height = pango_units_to_double (attr->ink_rect.height);
- info = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_default (),
- data->icon,
- (gint)height,
- GTK_ICON_LOOKUP_FORCE_SIZE | GTK_ICON_LOOKUP_USE_BUILTIN);
- pixbuf = gtk_icon_info_load_icon (info, NULL);
- gtk_icon_info_free (info);
-
- cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
- cairo_reset_clip (cr);
- gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y + ascent);
- cairo_paint (cr);
- g_object_unref (pixbuf);
- }
-}
-
-static PangoAttrList *
-create_shape_attr_list_for_layout (PangoLayout *layout,
- IconShapeData *data)
-{
- PangoAttrList *attrs;
- PangoFontMetrics *metrics;
- gint ascent, descent;
- PangoRectangle ink_rect, logical_rect;
- const gchar *p;
- const gchar *text;
- gint placeholder_len;
-
- /* Get font metrics and prepare fancy shape size */
- metrics = pango_context_get_metrics (pango_layout_get_context (layout),
- pango_layout_get_font_description (layout),
- NULL);
- ascent = pango_font_metrics_get_ascent (metrics);
- descent = pango_font_metrics_get_descent (metrics);
- pango_font_metrics_unref (metrics);
-
- logical_rect.x = 0;
- logical_rect.y = - ascent;
- logical_rect.width = ascent + descent;
- logical_rect.height = ascent + descent;
-
- ink_rect = logical_rect;
-
- attrs = pango_attr_list_new ();
- text = pango_layout_get_text (layout);
- placeholder_len = strlen (data->placeholder_str);
- for (p = text; (p = strstr (p, data->placeholder_str)); p += placeholder_len) {
- PangoAttribute *attr;
-
- attr = pango_attr_shape_new_with_data (&ink_rect,
- &logical_rect,
- GUINT_TO_POINTER (g_utf8_get_char (p)),
- NULL, NULL);
-
- attr->start_index = p - text;
- attr->end_index = attr->start_index + placeholder_len;
-
- pango_attr_list_insert (attrs, attr);
- }
-
- return attrs;
-}
-
-static gboolean
-query_unlock_tooltip (GtkWidget *widget,
- gint x,
- gint y,
- gboolean keyboard_tooltip,
- GtkTooltip *tooltip,
- gpointer user_data)
-{
- GtkWidget *label;
- PangoLayout *layout;
- PangoAttrList *attrs;
- IconShapeData *data;
-
- data = g_object_get_data (G_OBJECT (widget), "icon-shape-data");
- label = g_object_get_data (G_OBJECT (widget), "tooltip-label");
- if (label == NULL) {
- label = gtk_label_new (data->text);
- g_object_ref_sink (label);
- g_object_set_data_full (G_OBJECT (widget),
- "tooltip-label", label, g_object_unref);
- }
-
- layout = gtk_label_get_layout (GTK_LABEL (label));
- pango_cairo_context_set_shape_renderer (pango_layout_get_context (layout),
- icon_shape_renderer,
- data, NULL);
-
- attrs = create_shape_attr_list_for_layout (layout, data);
- gtk_label_set_attributes (GTK_LABEL (label), attrs);
- pango_attr_list_unref (attrs);
-
- gtk_tooltip_set_custom (tooltip, label);
-
- return TRUE;
-}
-
-void
-setup_tooltip_with_embedded_icon (GtkWidget *widget,
- const gchar *text,
- const gchar *placeholder,
- GIcon *icon)
-{
- IconShapeData *data;
-
- data = g_object_get_data (G_OBJECT (widget), "icon-shape-data");
- if (data) {
- gtk_widget_set_has_tooltip (widget, FALSE);
- g_signal_handler_disconnect (widget, data->query_id);
- g_object_set_data (G_OBJECT (widget), "icon-shape-data", NULL);
- g_object_set_data (G_OBJECT (widget), "tooltip-label", NULL);
- }
-
- if (!placeholder) {
- gtk_widget_set_tooltip_text (widget, text);
- return;
- }
-
- data = icon_shape_data_new (text, placeholder, icon);
- g_object_set_data_full (G_OBJECT (widget),
- "icon-shape-data",
- data,
- icon_shape_data_free);
-
- gtk_widget_set_has_tooltip (widget, TRUE);
- data->query_id = g_signal_connect (widget, "query-tooltip",
- G_CALLBACK (query_unlock_tooltip), NULL);
-
-}
-
-gboolean
-show_tooltip_now (GtkWidget *widget,
- GdkEvent *event)
-{
- GtkSettings *settings;
- gint timeout;
-
- settings = gtk_widget_get_settings (widget);
-
- g_object_get (settings, "gtk-tooltip-timeout", &timeout, NULL);
- g_object_set (settings, "gtk-tooltip-timeout", 1, NULL);
- gtk_tooltip_trigger_tooltip_query (gtk_widget_get_display (widget));
- g_object_set (settings, "gtk-tooltip-timeout", timeout, NULL);
-
- return FALSE;
-}
-
static gboolean
query_tooltip (GtkWidget *widget,
gint x,
@@ -342,49 +140,6 @@ popup_menu_below_button (GtkMenu *menu,
}
void
-rounded_rectangle (cairo_t *cr,
- gdouble aspect,
- gdouble x,
- gdouble y,
- gdouble corner_radius,
- gdouble width,
- gdouble height)
-{
- gdouble radius;
- gdouble degrees;
-
- radius = corner_radius / aspect;
- degrees = G_PI / 180.0;
-
- cairo_new_sub_path (cr);
- cairo_arc (cr,
- x + width - radius,
- y + radius,
- radius,
- -90 * degrees,
- 0 * degrees);
- cairo_arc (cr,
- x + width - radius,
- y + height - radius,
- radius,
- 0 * degrees,
- 90 * degrees);
- cairo_arc (cr,
- x + radius,
- y + height - radius,
- radius,
- 90 * degrees,
- 180 * degrees);
- cairo_arc (cr,
- x + radius,
- y + radius,
- radius,
- 180 * degrees,
- 270 * degrees);
- cairo_close_path (cr);
-}
-
-void
down_arrow (GtkStyleContext *context,
cairo_t *cr,
gint x,
diff --git a/gnome-initial-setup/pages/account/um-utils.h b/gnome-initial-setup/pages/account/um-utils.h
index 54f57aa..ea30a89 100644
--- a/gnome-initial-setup/pages/account/um-utils.h
+++ b/gnome-initial-setup/pages/account/um-utils.h
@@ -26,13 +26,6 @@
G_BEGIN_DECLS
-void setup_tooltip_with_embedded_icon (GtkWidget *widget,
- const gchar *text,
- const gchar *placeholder,
- GIcon *icon);
-gboolean show_tooltip_now (GtkWidget *widget,
- GdkEvent *event);
-
void set_entry_validation_error (GtkEntry *entry,
const gchar *text);
void clear_entry_validation_error (GtkEntry *entry);
@@ -43,14 +36,6 @@ void popup_menu_below_button (GtkMenu *menu,
gboolean *push_in,
GtkWidget *button);
-void rounded_rectangle (cairo_t *cr,
- gdouble aspect,
- gdouble x,
- gdouble y,
- gdouble corner_radius,
- gdouble width,
- gdouble height);
-
void down_arrow (GtkStyleContext *context,
cairo_t *cr,
gint x,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]