コード例 #1
0
ファイル: node.c プロジェクト: sffej/gnome-inform7
static void
i7_node_init(I7Node *self)
{
	I7_NODE_USE_PRIVATE;
	priv->id = g_strdup_printf("node-%p", self);
	self->gnode = g_node_new(self);
	self->tree_item = NULL;
	self->tree_points = goo_canvas_points_new(4);

	priv->blessed = FALSE;
	priv->match = I7_NODE_CANT_COMPARE;
	priv->transcript_diffs = NULL;
	priv->transcript_pango_string = NULL;
	priv->expected_diffs = NULL;
	priv->expected_pango_string = NULL;

	/* Create the cairo gradients */
	/* Label */
	priv->label_pattern = cairo_pattern_create_linear(0.0, 0.0, 0.0, 1.0);
	cairo_pattern_add_color_stop_rgba(priv->label_pattern, 1.0, 0.0, 0.33, 0.0, 0.3);
	cairo_pattern_add_color_stop_rgba(priv->label_pattern, 0.67, 0.73, 0.84, 0.73, 0.1);
	cairo_pattern_add_color_stop_rgba(priv->label_pattern, 0.0, 0.5, 0.85, 0.5, 0.0);
	/* Node, unplayed, without blessed transcript text: Tango Chameleon 3 */
	priv->node_pattern[NODE_UNPLAYED_UNBLESSED] = create_node_pattern(0.31, 0.60, 0.02);
	/* Node, unplayed, with blessed transcript text: Tango Chameleon 1 */
	priv->node_pattern[NODE_UNPLAYED_BLESSED] = create_node_pattern(0.54, 0.87, 0.2);
	/* Node, played, without blessed transcript text: Tango Butter 3 */
	priv->node_pattern[NODE_PLAYED_UNBLESSED] = create_node_pattern(0.77, 0.63, 0.0);
	/* Node, played, with blessed transcript text: Tango Butter 1 */
	priv->node_pattern[NODE_PLAYED_BLESSED] = create_node_pattern(0.99, 0.91, 0.31);

	/* Create the canvas items, though some of them can't be drawn yet */
	priv->command_shape_item = goo_canvas_path_model_new(GOO_CANVAS_ITEM_MODEL(self), "",
		"stroke-pattern", NULL,
		"fill-pattern", priv->node_pattern[NODE_UNPLAYED_UNBLESSED],
		NULL);
	priv->label_shape_item = goo_canvas_path_model_new(GOO_CANVAS_ITEM_MODEL(self), "",
		"stroke-pattern", NULL,
		"fill-pattern", priv->label_pattern,
		NULL);
	priv->command_item = goo_canvas_text_model_new(GOO_CANVAS_ITEM_MODEL(self), "", 0.0, 0.0, -1, GTK_ANCHOR_CENTER, NULL);
	priv->label_item = goo_canvas_text_model_new(GOO_CANVAS_ITEM_MODEL(self), "", 0.0, 0.0, -1, GTK_ANCHOR_CENTER, NULL);
	priv->badge_item = goo_canvas_path_model_new(GOO_CANVAS_ITEM_MODEL(self), "",
	  "fill-color", "red",
	  "line-width", 0,
	  "visibility", GOO_CANVAS_ITEM_HIDDEN,
	  NULL);
	g_object_set_data(G_OBJECT(priv->badge_item), "path-drawn", NULL);
	g_object_set_data(G_OBJECT(priv->badge_item), "node-part", GINT_TO_POINTER(I7_NODE_PART_DIFFERS_BADGE));
	/* Avoid drawing the differs badges unless they're actually needed, otherwise
	it really slows down the story startup */

	priv->x = 0.0;
	priv->command_width = -1.0;
	priv->command_height = -1.0;
	priv->label_width = -1.0;
	priv->label_height = -1.0;
}
コード例 #2
0
ファイル: node.c プロジェクト: sffej/gnome-inform7
gboolean
on_differs_badge_button_press(GooCanvasItem *item, GooCanvasItem *target_item, GdkEventButton *event, GooCanvasItemModel *model)
{
	I7Node *self = I7_NODE(goo_canvas_item_model_get_parent(GOO_CANVAS_ITEM_MODEL(model)));
	I7Skein *skein = I7_SKEIN(goo_canvas_item_model_get_parent(GOO_CANVAS_ITEM_MODEL(self)));
	if(event->type == GDK_2BUTTON_PRESS && event->button == 1) {
		g_signal_emit_by_name(skein, "differs-badge-activate", self);
		return TRUE;
	}
	return FALSE;
}
コード例 #3
0
/** \brief Delete the ground track for a satellite.
 *  \param satmap The satellite map widget.
 *  \param sat Pointer to the satellite object.
 *  \param qth Pointer to the QTH data.
 *  \param obj the satellite object.
 *  \param clear_ssp Flag indicating whether SSP data should be cleared as well (TRUE=yes);
 *
 */
void
ground_track_delete (GtkSatMap *satmap, sat_t *sat, qth_t *qth, sat_map_obj_t *obj, gboolean clear_ssp)
{
     guint              i,n;
     gint               j;
     GooCanvasItemModel *line;
     GooCanvasItemModel *root;

    (void) qth; /* avoid unusued parameter compiler warning */

    sat_log_log (SAT_LOG_LEVEL_DEBUG,
                     _("%s: Deleting ground track for %s"),
                 __FUNCTION__, sat->nickname);

     root = goo_canvas_get_root_item_model (GOO_CANVAS (satmap->canvas));

     /* remove plylines */
     if (obj->track_data.lines != NULL) {
          n = g_slist_length (obj->track_data.lines);

          for (i = 0; i < n; i++) {

               /* get line */
               line = GOO_CANVAS_ITEM_MODEL (g_slist_nth_data (obj->track_data.lines, i));

               /* find its ID and remove it */
               j = goo_canvas_item_model_find_child (root, line);
               if (j == -1) {
                    sat_log_log (SAT_LOG_LEVEL_ERROR,
                                    _("%s: Could not find part %d of ground track"),
                                    __FUNCTION__, j);
               }
               else {
                    goo_canvas_item_model_remove_child (root, j);
               }
          }

          g_slist_free (obj->track_data.lines);
          obj->track_data.lines = NULL;
               
     }

     /* clear SSP too? */
     if (clear_ssp == TRUE) {
          if (obj->track_data.latlon != NULL) {

               /* free allocated ssp_t */
               g_slist_foreach (obj->track_data.latlon, free_ssp, NULL);

               /* free the SList itself */
               g_slist_free (obj->track_data.latlon);
               obj->track_data.latlon = NULL;

          }

          obj->track_orbit = 0;
     }
}
コード例 #4
0
ファイル: node.c プロジェクト: sffej/gnome-inform7
gboolean
i7_node_get_label_coordinates(I7Node *self, gint *x, gint *y, GooCanvas *canvas)
{
	g_return_val_if_fail(self || I7_IS_NODE(self), FALSE);
	g_return_val_if_fail(canvas || GOO_IS_CANVAS(canvas), FALSE);

	I7_NODE_USE_PRIVATE;

	return i7_goo_canvas_item_get_onscreen_coordinates(goo_canvas_get_item(canvas, GOO_CANVAS_ITEM_MODEL(priv->label_item)), canvas, x, y);
}
コード例 #5
0
ファイル: node.c プロジェクト: sffej/gnome-inform7
gboolean
on_node_button_press(GooCanvasItem *item, GooCanvasItem *target_item, GdkEventButton *event, I7Node *self)
{
	I7Skein *skein = I7_SKEIN(goo_canvas_item_model_get_parent(GOO_CANVAS_ITEM_MODEL(self)));
	if(event->type == GDK_2BUTTON_PRESS && event->button == 1) {
		g_signal_emit_by_name(skein, "node-activate", self);
		return TRUE;
	} else if(event->type == GDK_BUTTON_PRESS && event->button == 3) {
		GooCanvas *view = goo_canvas_item_get_canvas(target_item);
		g_signal_emit_by_name(view, "node-menu-popup", self);
		return TRUE;
	}
	return FALSE;
}