static void
nautilus_floating_bar_get_property (GObject    *object,
                                    guint       property_id,
                                    GValue     *value,
                                    GParamSpec *pspec)
{
    NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (object);

    switch (property_id)
    {
        case PROP_PRIMARY_LABEL:
        {
            g_value_set_string (value, self->primary_label);
        }
        break;

        case PROP_DETAILS_LABEL:
        {
            g_value_set_string (value, self->details_label);
        }
        break;

        case PROP_SHOW_SPINNER:
        {
            g_value_set_boolean (value, self->show_spinner);
        }
        break;

        default:
        {
            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
        }
        break;
    }
}
static void
nautilus_floating_bar_constructed (GObject *obj)
{
	NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (obj);
	GtkWidget *w, *box;

	G_OBJECT_CLASS (nautilus_floating_bar_parent_class)->constructed (obj);

	box = GTK_WIDGET (obj);

	w = gtk_spinner_new ();
	gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0);
	gtk_widget_set_visible (w, self->priv->show_spinner);
	self->priv->spinner = w;

	gtk_widget_set_size_request (w, 16, 16);
	gtk_widget_set_margin_left (w, 8);

	w = gtk_label_new (NULL);
	gtk_label_set_ellipsize (GTK_LABEL (w), PANGO_ELLIPSIZE_END);
	gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0);
	g_object_set (w,
		      "margin-top", 2,
		      "margin-bottom", 2,
		      "margin-left", 12,
		      "margin-right", 12,
		      NULL);
	self->priv->label_widget = w;
	gtk_widget_show (w);
}
static gboolean
overlay_enter_notify_cb (GtkWidget        *parent,
                         GdkEventCrossing *event,
                         gpointer          user_data)
{
    GtkWidget *widget = user_data;

    if (event->window != gtk_widget_get_window (widget)) {
        return FALSE;
    }

    if (NAUTILUS_FLOATING_BAR (widget)->priv->is_interactive) {
        return FALSE;
    }

    if (gtk_widget_get_halign (widget) == GTK_ALIGN_START) {
        gtk_widget_set_halign (widget, GTK_ALIGN_END);
    } else {
        gtk_widget_set_halign (widget, GTK_ALIGN_START);
    }

    gtk_widget_queue_resize (widget);

    return FALSE;
}
static void
nautilus_floating_bar_hide (GtkWidget *widget)
{
	NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);

	GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->hide (widget);

	gtk_spinner_stop (GTK_SPINNER (self->priv->spinner));
}
static void
nautilus_floating_bar_finalize (GObject *obj)
{
	NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (obj);

	g_free (self->priv->label);

	G_OBJECT_CLASS (nautilus_floating_bar_parent_class)->finalize (obj);
}
static gboolean
overlay_enter_notify_cb (GtkWidget        *parent,
                         GdkEventCrossing *event,
                         gpointer          user_data)
{
    GtkWidget *widget = user_data;
    CheckPointerData *data;
    gint y_pos;

    NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);

    if (self->hover_timeout_id != 0)
    {
        g_source_remove (self->hover_timeout_id);
    }

    if (event->window != gtk_widget_get_window (widget))
    {
        return GDK_EVENT_PROPAGATE;
    }

    if (NAUTILUS_FLOATING_BAR (widget)->is_interactive)
    {
        return GDK_EVENT_PROPAGATE;
    }

    gdk_window_get_position (gtk_widget_get_window (widget), NULL, &y_pos);

    data = g_slice_new (CheckPointerData);
    data->overlay = parent;
    data->floating_bar = widget;
    data->device = gdk_event_get_device ((GdkEvent *) event);
    data->y_down_limit = y_pos;
    data->y_upper_limit = y_pos + gtk_widget_get_allocated_height (widget);

    self->hover_timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT, HOVER_HIDE_TIMEOUT_INTERVAL,
                                                 check_pointer_timeout, data,
                                                 check_pointer_data_free);

    g_source_set_name_by_id (self->hover_timeout_id, "[nautilus-floating-bar] overlay_enter_notify_cb");

    return GDK_EVENT_STOP;
}
static void
nautilus_floating_bar_show (GtkWidget *widget)
{
	NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);

	GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->show (widget);

	if (self->show_spinner) {
		gtk_spinner_start (GTK_SPINNER (self->spinner));
	}
}
static void
nautilus_floating_bar_finalize (GObject *obj)
{
    NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (obj);

    nautilus_floating_bar_remove_hover_timeout (self);
    g_free (self->primary_label);
    g_free (self->details_label);

    G_OBJECT_CLASS (nautilus_floating_bar_parent_class)->finalize (obj);
}
static void
real_slot_set_short_status (NautilusWindowSlot *slot,
			    const gchar *primary_status,
			    const gchar *detail_status)
{
	gboolean disable_chrome;

	nautilus_floating_bar_cleanup_actions (NAUTILUS_FLOATING_BAR (slot->floating_bar));
	nautilus_floating_bar_set_show_spinner (NAUTILUS_FLOATING_BAR (slot->floating_bar),
						FALSE);

	g_object_get (nautilus_window_slot_get_window (slot),
		      "disable-chrome", &disable_chrome,
		      NULL);

	if ((primary_status == NULL && detail_status == NULL) || disable_chrome) {
		gtk_widget_hide (slot->floating_bar);
		return;
	}

	nautilus_floating_bar_set_labels (NAUTILUS_FLOATING_BAR (slot->floating_bar),
					  primary_status, detail_status);
	gtk_widget_show (slot->floating_bar);
}
Beispiel #10
0
static void
nautilus_floating_bar_constructed (GObject *obj)
{
    NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (obj);
    GtkWidget *w, *box, *labels_box;

    G_OBJECT_CLASS (nautilus_floating_bar_parent_class)->constructed (obj);

    box = GTK_WIDGET (obj);

    w = gtk_spinner_new ();
    gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0);
    gtk_widget_set_visible (w, self->show_spinner);
    gtk_spinner_start (GTK_SPINNER (w));
    self->spinner = w;

    gtk_widget_set_size_request (w, 16, 16);
    gtk_widget_set_margin_start (w, 8);

    labels_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
    gtk_box_pack_start (GTK_BOX (box), labels_box, TRUE, TRUE, 0);
    g_object_set (labels_box,
                  "margin-top", 2,
                  "margin-bottom", 2,
                  "margin-start", 12,
                  "margin-end", 12,
                  NULL);
    gtk_widget_show (labels_box);

    w = gtk_label_new (NULL);
    gtk_label_set_ellipsize (GTK_LABEL (w), PANGO_ELLIPSIZE_MIDDLE);
    gtk_label_set_single_line_mode (GTK_LABEL (w), TRUE);
    gtk_container_add (GTK_CONTAINER (labels_box), w);
    self->primary_label_widget = w;
    gtk_widget_show (w);

    w = gtk_label_new (NULL);
    gtk_label_set_single_line_mode (GTK_LABEL (w), TRUE);
    gtk_container_add (GTK_CONTAINER (labels_box), w);
    self->details_label_widget = w;
    gtk_widget_show (w);
}
static void
nautilus_floating_bar_set_property (GObject *object,
				    guint property_id,
				    const GValue *value,
				    GParamSpec *pspec)
{
	NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (object);

	switch (property_id) {
	case PROP_LABEL:
		nautilus_floating_bar_set_label (self, g_value_get_string (value));
		break;
	case PROP_SHOW_SPINNER:
		nautilus_floating_bar_set_show_spinner (self, g_value_get_boolean (value));
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}
static void
nautilus_floating_bar_get_property (GObject *object,
				    guint property_id,
				    GValue *value,
				    GParamSpec *pspec)
{
	NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (object);

	switch (property_id) {
	case PROP_LABEL:
		g_value_set_string (value, self->priv->label);
		break;
	case PROP_SHOW_SPINNER:
		g_value_set_boolean (value, self->priv->show_spinner);
		break;
	case PROP_ESCAPING_DISTANCE:
		g_value_set_uint (value, self->priv->escaping_distance);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}
Beispiel #13
0
static gboolean
check_pointer_timeout (gpointer user_data)
{
    CheckPointerData *data = user_data;
    gint pointer_y = -1;

    gdk_window_get_device_position (gtk_widget_get_window (data->overlay), data->device,
                                    NULL, &pointer_y, NULL);

    if (pointer_y == -1 || pointer_y < data->y_down_limit || pointer_y > data->y_upper_limit)
    {
        gtk_widget_show (data->floating_bar);
        NAUTILUS_FLOATING_BAR (data->floating_bar)->hover_timeout_id = 0;

        return G_SOURCE_REMOVE;
    }
    else
    {
        gtk_widget_hide (data->floating_bar);
    }

    return G_SOURCE_CONTINUE;
}