Ejemplo n.º 1
0
static void
ViewAutoDrawerEnforce(ViewAutoDrawer *that, // IN
                      gboolean animate)     // IN
{
   double fraction;
   GtkAllocation allocation;
   ViewAutoDrawerPrivate *priv = that->priv;

   if (!priv->active) {
      ViewOvBox_SetMin(VIEW_OV_BOX(that), -1);
      ViewOvBox_SetFraction(VIEW_OV_BOX(that), 0);
      return;
   }

   g_assert(priv->over != NULL);
   g_assert(GTK_IS_WIDGET(priv->over));

   ViewOvBox_SetMin(VIEW_OV_BOX(that), priv->noOverlapPixels);

   // The forceClosing flag overrides the opened flag.
   if (priv->opened && !priv->forceClosing) {
      fraction = 1;
   } else {
      gtk_widget_get_allocation (priv->over, &allocation);
      fraction = ((double)priv->overlapPixels / allocation.height);
   }

   if (!animate) {
      ViewOvBox_SetFraction(VIEW_OV_BOX(that), fraction);
   }
   ViewDrawer_SetGoal(VIEW_DRAWER(that), fraction);
}
Ejemplo n.º 2
0
static void
ViewOvBoxSizeAllocate(GtkWidget *widget,         // IN
                      GtkAllocation *allocation) // IN
{
   ViewOvBox *that;
   ViewOvBoxPrivate *priv;
   GtkAllocation under;
   GtkAllocation over;

   gtk_widget_set_allocation (widget, allocation);

   that = VIEW_OV_BOX(widget);
   priv = that->priv;

   ViewOvBoxGetUnderGeometry(that, &under.x, &under.y, &under.width,
                             &under.height);
   ViewOvBoxGetOverGeometry(that, &over.x, &over.y, &over.width, &over.height);

   if (gtk_widget_get_realized(widget)) {
      gdk_window_move_resize(gtk_widget_get_window(widget),
                             allocation->x, allocation->y,
                             allocation->width, allocation->height);
      gdk_window_move_resize(priv->underWin, under.x, under.y, under.width,
                             under.height);
      gdk_window_move_resize(priv->overWin, over.x, over.y, over.width,
                             over.height);
   }

   under.x = 0;
   under.y = 0;
   gtk_widget_size_allocate(priv->under, &under);
   over.x = 0;
   over.y = 0;
   gtk_widget_size_allocate(priv->over, &over);
}
Ejemplo n.º 3
0
static void
ViewOvBoxUnrealize(GtkWidget *widget) // IN
{
   ViewOvBox *that;
   ViewOvBoxPrivate *priv;

   that = VIEW_OV_BOX(widget);
   priv = that->priv;

   /*
    * Unrealize the parent before destroying the windows so that we end up
    * unrealizing all the child widgets before destroying the child windows,
    * giving them a chance to reparent their windows before we clobber them.
    */
   GTK_WIDGET_CLASS(parentClass)->unrealize(widget);


   gdk_window_set_user_data(priv->underWin, NULL);
   gdk_window_destroy(priv->underWin);
   priv->underWin = NULL;

   gdk_window_set_user_data(priv->overWin, NULL);
   gdk_window_destroy(priv->overWin);
   priv->overWin = NULL;

}
Ejemplo n.º 4
0
static void
ViewOvBoxRealize(GtkWidget *widget) // IN
{
   ViewOvBox *that;
   ViewOvBoxPrivate *priv;
   GdkWindowAttr attributes;
   gint mask;
   GtkAllocation allocation;
   GdkWindow *window;

   gtk_widget_set_realized (widget, TRUE);

   that = VIEW_OV_BOX(widget);
   priv = that->priv;

   attributes.window_type = GDK_WINDOW_CHILD;
   attributes.wclass = GDK_INPUT_OUTPUT;
   attributes.visual = gtk_widget_get_visual(widget);
   attributes.event_mask = gtk_widget_get_events(widget) | GDK_EXPOSURE_MASK;
   mask = GDK_WA_VISUAL | GDK_WA_X | GDK_WA_Y;

   gtk_widget_get_allocation(widget, &allocation);
   attributes.x = allocation.x;
   attributes.y = allocation.y;
   attributes.width = allocation.width;
   attributes.height = allocation.height;
   window = gdk_window_new(gtk_widget_get_parent_window(widget),
                           &attributes, mask);
   gtk_widget_set_window(widget, window);
   gdk_window_set_user_data(window, that);
#if !GTK_CHECK_VERSION(3, 0, 0)
   gtk_widget_set_style(widget, gtk_style_attach(gtk_widget_get_style(widget), window));
#endif

   /*
    * The order in which we create the children X window matters: the child
    * created last is stacked on top. --hpreg
    */

   ViewOvBoxGetUnderGeometry(that, &attributes.x, &attributes.y,
                             &attributes.width, &attributes.height);
   priv->underWin = gdk_window_new(window, &attributes, mask);
   gdk_window_set_user_data(priv->underWin, that);
   if (priv->under) {
      gtk_widget_set_parent_window(priv->under, priv->underWin);
   }
   gdk_window_show(priv->underWin);

   ViewOvBoxGetOverGeometry(that, &attributes.x, &attributes.y,
                            &attributes.width, &attributes.height);
   priv->overWin = gdk_window_new(window, &attributes, mask);
   gdk_window_set_user_data(priv->overWin, that);
   if (priv->over) {
      gtk_widget_set_parent_window(priv->over, priv->overWin);
   }
   gdk_window_show(priv->overWin);

   ViewOvBoxSetBackground(that);
}
Ejemplo n.º 5
0
GtkWidget *
ViewOvBox_New(void)
{
   ViewOvBox *that;

   that = VIEW_OV_BOX(g_object_new(VIEW_TYPE_OV_BOX, NULL));

   return GTK_WIDGET(that);
}
Ejemplo n.º 6
0
static void
ViewOvBoxSizeRequest(GtkWidget *widget,           // IN
                     GtkRequisition *requisition) // OUT
{
   ViewOvBoxPrivate *priv = VIEW_OV_BOX(widget)->priv;
   GtkRequisition min;

   gtk_widget_size_request(priv->under, &min);

   ViewOvBoxRealSizeRequest(widget, &min, NULL, requisition, NULL);
}
Ejemplo n.º 7
0
static void
ViewOvBoxStyleSet(GtkWidget *widget,       // IN
                  GtkStyle *previousStyle) // IN: Unused
{
   ViewOvBox *that;

   that = VIEW_OV_BOX(widget);

   if (gtk_widget_get_realized(widget)) {
      ViewOvBoxSetBackground(that);
   }

   GTK_WIDGET_CLASS(parentClass)->style_set(widget, previousStyle);
}
Ejemplo n.º 8
0
static void
ViewOvBox_get_preferred_height (GtkWidget *widget,
                                gint      *minimal_height,
                                gint      *natural_height)
{
   ViewOvBoxPrivate *priv = VIEW_OV_BOX(widget)->priv;
   GtkRequisition min_in, nat_in, min_out, nat_out;

   gtk_widget_get_preferred_size(priv->under, &min_in, &nat_in);

   ViewOvBoxRealSizeRequest(widget, &min_in, &nat_in, &min_out, &nat_out);

   *minimal_height = min_out.height;
   *natural_height = nat_out.height;
}
Ejemplo n.º 9
0
static void
ViewAutoDrawerEnforce(ViewAutoDrawer *that, // IN
                      gboolean animate)     // IN
{
   double fraction;
   ViewAutoDrawerPrivate *priv = that->priv;

   if (!priv->active) {
      ViewOvBox_SetMin(VIEW_OV_BOX(that), -1);
      ViewOvBox_SetFraction(VIEW_OV_BOX(that), 0);
      return;
   }

   g_assert(priv->over != NULL);
   g_assert(GTK_IS_WIDGET(priv->over));

   ViewOvBox_SetMin(VIEW_OV_BOX(that), priv->noOverlapPixels);
   fraction = priv->opened
      ? 1 : ((double)priv->overlapPixels / priv->over->allocation.height);
   if (!animate) {
      ViewOvBox_SetFraction(VIEW_OV_BOX(that), fraction);
   }
   ViewDrawer_SetGoal(VIEW_DRAWER(that), fraction);
}
Ejemplo n.º 10
0
static void
ViewAutoDrawerInit(GTypeInstance *instance, // IN
                   gpointer klass)          // Unused
{
   ViewAutoDrawer *that;
   ViewAutoDrawerPrivate *priv;

   that = VIEW_AUTODRAWER(instance);
   that->priv = VIEW_AUTODRAWER_GET_PRIVATE(that);
   priv = that->priv;

   priv->active = TRUE;
   priv->pinned = FALSE;
   priv->forceClosing = FALSE;
   priv->inputUngrabbed = TRUE;
   priv->delayConnection = 0;
   priv->delayValue = 250;
   priv->overlapPixels = 0;
   priv->noOverlapPixels = 1;

   priv->fill = TRUE;
   priv->offset = -1;

   priv->evBox = gtk_event_box_new();
   gtk_widget_show(priv->evBox);
   VIEW_OV_BOX_CLASS(parentClass)->set_over(VIEW_OV_BOX(that), priv->evBox);

   g_signal_connect(priv->evBox, "enter-notify-event",
                    G_CALLBACK(ViewAutoDrawerOnOverEnterLeave), that);
   g_signal_connect(priv->evBox, "leave-notify-event",
                    G_CALLBACK(ViewAutoDrawerOnOverEnterLeave), that);
   g_signal_connect(priv->evBox, "grab-notify",
                    G_CALLBACK(ViewAutoDrawerOnGrabNotify), that);

   g_signal_connect(that, "hierarchy-changed",
                    G_CALLBACK(ViewAutoDrawerOnHierarchyChanged), NULL);

   /* This change happens programmatically. Always react to it immediately. */
   ViewAutoDrawerUpdate(that, TRUE);

   ViewAutoDrawerRefreshPacking(that);
}
Ejemplo n.º 11
0
/*
 *-----------------------------------------------------------------------------
 *
 * ViewOvBoxRealSizeRequest --
 *
 *      "size_request" method, generalized to work with both gtk-2 and 3.
 *
 * Results:
 *      None
 *
 * Side effects:
 *      None
 *
 *-----------------------------------------------------------------------------
 */
static void
ViewOvBoxRealSizeRequest(GtkWidget *widget,           // IN
   GtkRequisition *min_in, GtkRequisition *nat_in,      // IN
   GtkRequisition *min_out, GtkRequisition *nat_out)    // OUT
{
   ViewOvBox *that;
   ViewOvBoxPrivate *priv;
   gboolean expand;
   gboolean fill;
   guint padding;
   unsigned int min;

   that = VIEW_OV_BOX(widget);
   priv = that->priv;

#if GTK_CHECK_VERSION(3, 0, 0)
   gtk_widget_get_preferred_size(priv->over, NULL, &priv->overR);
#else
   gtk_widget_size_request(priv->over, &priv->overR);
#endif

   gtk_container_child_get(GTK_CONTAINER(that), priv->over,
                           "expand", &expand,
                           "fill", &fill,
                           "padding", &padding,
                           NULL);

   min = ViewOvBoxGetActualMin(that);

   if (min_out) {
      min_out->width = MAX(min_in->width, priv->overR.width +
                                            ((expand || fill) ? 0 : padding));
      min_out->height = MAX(min_in->height + min, priv->overR.height);
   }
   if (nat_out) {
      nat_out->width = MAX(nat_in->width, priv->overR.width +
                                            ((expand || fill) ? 0 : padding));
      nat_out->height = MAX(nat_in->height + min, priv->overR.height);
   }
}
Ejemplo n.º 12
0
static void
ViewOvBoxInit(GTypeInstance *instance, // IN
              gpointer klass G_GNUC_UNUSED)          // Unused
{
   ViewOvBox *that;
   ViewOvBoxPrivate *priv;

   that = VIEW_OV_BOX(instance);
   that->priv = VIEW_OV_BOX_GET_PRIVATE(that);
   priv = that->priv;

   gtk_widget_set_has_window (GTK_WIDGET (that), TRUE);

   priv->underWin = NULL;
   priv->under = NULL;
   priv->overWin = NULL;
   priv->over = NULL;
   priv->overR.height = -1;
   priv->overR.width = -1;
   priv->min = 0;
   priv->fraction = 0;
   priv->verticalOffset = 0;
}