Ejemplo n.º 1
0
static gboolean
event_window_button_press_event_cb (GstyleSlidein *self,
                                    GdkEvent      *event,
                                    GstyleSlidein *unused)
{
  GdkEventButton *button_event = (GdkEventButton *)event;
  GtkAllocation child_alloc;
  gboolean is_in_slide;
  GtkWidget *src_widget;
  gint dest_x, dest_y;

  g_assert (GSTYLE_IS_SLIDEIN (self));

  src_widget = gtk_get_event_widget (event);
  gtk_widget_translate_coordinates (src_widget, GTK_WIDGET (self->overlay_child),
                                    button_event->x, button_event->y,
                                    &dest_x, &dest_y);

  gtk_widget_get_allocated_size (self->overlay_child, &child_alloc, NULL);
  is_in_slide = (0 <= dest_x && dest_x <= child_alloc.width && 0 <= dest_y && dest_y <= child_alloc.height);
  if (!is_in_slide)
    {
      gtk_grab_remove (GTK_WIDGET (self));
      gstyle_slidein_reveal_slide (self, FALSE);

      return GDK_EVENT_PROPAGATE;
    }
  else
    return GDK_EVENT_STOP;
}
Ejemplo n.º 2
0
static void
gstyle_eyedropper_calculate_window_position (GstyleEyedropper *self,
                                             GtkWindow        *window,
                                             gint              cursor_root_x,
                                             gint              cursor_root_y,
                                             gint             *x,
                                             gint             *y)
{
  GtkAllocation alloc;
  gint spot_x = ZOOM_AREA_SPOT_X;
  gint spot_y = ZOOM_AREA_SPOT_Y;

  g_assert (GSTYLE_IS_EYEDROPPER (self));
  g_assert (GTK_IS_WINDOW (window));

  gtk_widget_get_allocated_size (GTK_WIDGET (window), &alloc, NULL);

  if ((spot_x < 0 && cursor_root_x > self->screen_width - alloc.width + spot_x * 2) ||
      (spot_x > 0 && cursor_root_x < alloc.width + spot_x * 2))
    spot_x = -spot_x;

  if (spot_x > 0)
    *x = cursor_root_x - alloc.width - spot_x;
  else
    *x = cursor_root_x - spot_x;

  if ((spot_y < 0 && cursor_root_y > self->screen_height - alloc.height + spot_y * 2) ||
      (spot_y > 0 && cursor_root_y < alloc.height + spot_y + 2))
    spot_y = -spot_y;

  if (spot_y > 0)
    *y = cursor_root_y - alloc.height - spot_y;
  else
    *y = cursor_root_y - spot_y;
}
Ejemplo n.º 3
0
static gboolean
gstyle_slidein_draw (GtkWidget *widget,
                     cairo_t   *cr)
{
  GstyleSlidein *self = (GstyleSlidein *)widget;
  GtkStyleContext *context;
  GtkAllocation shade_box;
  GtkWidget *child;
  GdkRGBA rgba;

  g_assert (GSTYLE_IS_SLIDEIN (self));
  g_assert (cr != NULL);

  /* To draw the shade effect in between the regular child and the slides,
   * we bypass gtk_event_box_draw (we use a windowless one so not a problem),
   * and provide your own container draw implementation.
   */

  child = gtk_bin_get_child (GTK_BIN (self));
  if (child == NULL)
    return GDK_EVENT_STOP;

  gtk_container_propagate_draw (GTK_CONTAINER (self), child, cr);

  if (self->offset > 0.0)
    {
      context = gtk_widget_get_style_context (widget);
      gtk_style_context_save (context);
      gtk_style_context_add_class (context, "shade");
      gtk_style_context_get_color (context, gtk_style_context_get_state (context), &rgba);
      gtk_style_context_restore (context);
      rgba.alpha = rgba.alpha * self->offset;

      /* We shade the whole surface in case of slide tranparency */
      gtk_widget_get_allocated_size (widget, &shade_box, NULL);
      cairo_rectangle (cr, shade_box.x, shade_box.y, shade_box.width, shade_box.height);
      gdk_cairo_set_source_rgba (cr, &rgba);
      cairo_fill (cr);
    }

  if (self->overlay_child != NULL)
   gtk_container_propagate_draw (GTK_CONTAINER (self), self->overlay_child, cr);

  return GDK_EVENT_STOP;
}