/** * uber_label_block_button_press_event: * @widget: A #GtkWidget. * @event: A #GdkEventButton. * @label: An #UberLabel. * * Callback to handle a button press event within the colored block. * * Returns: %FALSE always to allow further signal emission. * Side effects: None. */ static gboolean uber_label_block_button_press_event (GtkWidget *widget, /* IN */ GdkEventButton *event, /* IN */ UberLabel *label) /* IN */ { UberLabelPrivate *priv; GtkWidget *dialog; GtkWidget *selection; g_return_val_if_fail(UBER_IS_LABEL(label), FALSE); priv = label->priv; dialog = gtk_color_selection_dialog_new(""); selection = gtk_color_selection_dialog_get_color_selection( GTK_COLOR_SELECTION_DIALOG(dialog)); gtk_color_selection_set_current_color( GTK_COLOR_SELECTION(selection), &priv->color); if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { gtk_color_selection_get_current_color( GTK_COLOR_SELECTION(selection), &priv->color); gtk_widget_queue_draw(widget); g_signal_emit(label, signals[COLOR_CHANGED], 0, &priv->color); } gtk_widget_destroy(dialog); return FALSE; }
/** * uber_label_set_text: * @label: A #UberLabel. * @text: The label text. * * Sets the text for the label. * * Returns: None. * Side effects: None. */ void uber_label_set_text (UberLabel *label, /* IN */ const gchar *text) /* IN */ { UberLabelPrivate *priv; g_return_if_fail(UBER_IS_LABEL(label)); priv = label->priv; gtk_label_set_text(GTK_LABEL(priv->label), text); }
/** * uber_label_set_color: * @label: A #UberLabel. * @color: A #GdkColor. * * Sets the color of the label. * * Returns: None. * Side effects: None. */ void uber_label_set_color (UberLabel *label, /* IN */ const GdkColor *color) /* IN */ { UberLabelPrivate *priv; g_return_if_fail(UBER_IS_LABEL(label)); priv = label->priv; priv->color = *color; }
static void uber_label_block_expose_event (GtkWidget *block, /* IN */ GdkEventExpose *event, /* IN */ UberLabel *label) /* IN */ { UberLabelPrivate *priv; GtkAllocation alloc; cairo_t *cr; g_return_if_fail(UBER_IS_LABEL(label)); priv = label->priv; gtk_widget_get_allocation(block, &alloc); cr = gdk_cairo_create(event->window); /* * Clip drawing region. */ gdk_cairo_rectangle(cr, &event->area); cairo_clip(cr); /* * Draw background. */ gdk_cairo_set_source_color(cr, &priv->color); cairo_rectangle(cr, .5, .5, alloc.width - 1., alloc.height - 1.); cairo_fill_preserve(cr); /* * Add highlight if mouse is in the block. */ if (priv->in_block) { cairo_set_source_rgba(cr, 1., 1., 1., .3); cairo_fill_preserve(cr); } /* * Stroke the edge of the block. */ cairo_set_line_width(cr, 1.0); cairo_set_source_rgba(cr, 0., 0., 0., .5); cairo_stroke(cr); /* * Stroke the highlight of the block. */ cairo_rectangle(cr, 1.5, 1.5, alloc.width - 3., alloc.height - 3.); cairo_set_source_rgba(cr, 1., 1., 1., .5); cairo_stroke(cr); }
void uber_line_graph_bind_label (UberLineGraph *graph, /* IN */ guint line, /* IN */ UberLabel *label) /* IN */ { UberLineGraphPrivate *priv; LineInfo *info; g_return_if_fail(UBER_IS_LINE_GRAPH(graph)); g_return_if_fail(UBER_IS_LABEL(label)); g_return_if_fail(line > 0); g_return_if_fail(line <= graph->priv->lines->len); priv = graph->priv; info = &g_array_index(priv->lines, LineInfo, line - 1); if (info->label_id) { g_signal_handler_disconnect(info->label, info->label_id); } info->label = label; info->label_id = g_signal_connect(label, "color-changed", G_CALLBACK(uber_line_graph_color_changed), graph); }