summaryrefslogtreecommitdiff
path: root/libmdock
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2015-01-25 17:06:19 +0100
committerJavier <dev.git@javispedro.com>2015-01-25 17:06:19 +0100
commit566165c32861bca7b565f4e226a9e78fa85fb3d9 (patch)
tree2cde2cceb28d0c6facf9c8ac804bf369a316ba5e /libmdock
parent4545948192a7bac1f86be840f6d883a112d8591e (diff)
downloadmdock-566165c32861bca7b565f4e226a9e78fa85fb3d9.tar.gz
mdock-566165c32861bca7b565f4e226a9e78fa85fb3d9.zip
fix dock applet resizing and other issues
Diffstat (limited to 'libmdock')
-rw-r--r--libmdock/mdock-item-menu.c1
-rw-r--r--libmdock/mdock-item.c29
-rw-r--r--libmdock/mdock-widget.c25
-rw-r--r--libmdock/mdock-widget.h3
4 files changed, 45 insertions, 13 deletions
diff --git a/libmdock/mdock-item-menu.c b/libmdock/mdock-item-menu.c
index 484277b..39495af 100644
--- a/libmdock/mdock-item-menu.c
+++ b/libmdock/mdock-item-menu.c
@@ -304,7 +304,6 @@ mdock_item_menu_constructed(GObject *object)
#ifdef HAVE_ZEITGEIST
g_signal_connect(self, "map-event",
G_CALLBACK(handle_menu_map), self);
- refresh_recent_menu(self);
#endif
}
diff --git a/libmdock/mdock-item.c b/libmdock/mdock-item.c
index 2dd1611..aa3045f 100644
--- a/libmdock/mdock-item.c
+++ b/libmdock/mdock-item.c
@@ -17,6 +17,7 @@
* along with MDock. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <math.h>
#include "mdock-item.h"
#define MDOCK_ITEM_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), MDOCK_TYPE_ITEM, MDockItemPrivate))
@@ -98,16 +99,15 @@ static void mdock_item_realize(GtkWidget *widget)
widget->window = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, attributes_mask);
+ gdk_window_set_back_pixmap(widget->window, NULL, TRUE);
gdk_window_set_user_data(widget->window, widget);
gtk_widget_set_realized(widget, TRUE);
widget->style = gtk_style_attach(widget->style, widget->window);
- gtk_style_set_background(widget->style, widget->window, GTK_STATE_NORMAL);
}
static void mdock_item_size_request(GtkWidget *widget, GtkRequisition *requisition)
{
- MDockItem *self = MDOCK_ITEM(widget);
requisition->width = requisition->height = REQUISITION_ICON_SIZE;
}
@@ -115,8 +115,8 @@ static void mdock_item_size_allocate(GtkWidget *widget, GtkAllocation *allocatio
{
MDockItem *self = MDOCK_ITEM(widget);
self->priv->icon_size = MIN(allocation->width, allocation->height);
- mdock_item_update_icon(self);
GTK_WIDGET_CLASS(mdock_item_parent_class)->size_allocate(widget, allocation);
+ mdock_item_update_icon(self);
}
static gboolean mdock_item_expose(GtkWidget *widget, GdkEventExpose *event)
@@ -125,8 +125,19 @@ static gboolean mdock_item_expose(GtkWidget *widget, GdkEventExpose *event)
cairo_t *cr = gdk_cairo_create(widget->window);
if (self->priv->icon) {
+ cairo_save(cr);
gdk_cairo_set_source_pixbuf(cr, self->priv->icon, 0, 0);
cairo_paint(cr);
+ cairo_restore(cr);
+ }
+ if (self->priv->windows) {
+ double circle_radius = self->priv->icon_size / 8.0;
+ cairo_save(cr);
+ cairo_set_source_rgba(cr, 0.0, 0.0, 0.2, 0.6);
+ cairo_translate(cr, self->priv->icon_size / 2.0, self->priv->icon_size - circle_radius / 2.0);
+ cairo_arc(cr, 0, 0, circle_radius, 0, 2 * M_PI);
+ cairo_fill(cr);
+ cairo_restore(cr);
}
cairo_destroy(cr);
@@ -198,7 +209,7 @@ static void mdock_item_init(MDockItem *self)
{
self->priv = MDOCK_ITEM_GET_PRIVATE (self);
self->priv->pinned = FALSE;
- self->priv->icon_size = 48;
+ self->priv->icon_size = REQUISITION_ICON_SIZE;
gtk_widget_add_events(GTK_WIDGET(self),
GDK_BUTTON_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
@@ -341,6 +352,11 @@ GdkPixbuf *mdock_item_get_icon_pixbuf(MDockItem *self)
void mdock_item_add_window(MDockItem *self, WnckWindow *window)
{
+ if (!self->priv->windows) {
+ // If there were no windows before adding this one,
+ // we want to redraw in order to get the "active" indicator.
+ gtk_widget_queue_draw(GTK_WIDGET(self));
+ }
self->priv->windows = g_list_append(self->priv->windows, window);
if (!self->priv->icon) {
mdock_item_update_icon(self);
@@ -354,6 +370,11 @@ void mdock_item_remove_window(MDockItem *self, WnckWindow *window)
if (self->priv->last_active == window) {
self->priv->last_active = NULL;
}
+ if (self->priv->windows) {
+ // If there are no windows left,
+ // we want to redraw in order to remove the "active" indicator.
+ gtk_widget_queue_draw(GTK_WIDGET(self));
+ }
g_object_notify_by_pspec(G_OBJECT(self), obj_properties[PROP_N_WINDOWS]);
}
diff --git a/libmdock/mdock-widget.c b/libmdock/mdock-widget.c
index cdb942e..6507fbb 100644
--- a/libmdock/mdock-widget.c
+++ b/libmdock/mdock-widget.c
@@ -33,6 +33,7 @@
#include <zeitgeist.h>
#endif
+#define POPUP_MOVE_TIMEOUT 100
#define POPUP_SHOW_TIMEOUT 200
#define POPUP_HIDE_TIMEOUT 500
@@ -413,7 +414,8 @@ static gboolean handle_popup_timer(gpointer user_data)
MDockWidget *self = MDOCK_WIDGET(user_data);
if (self->priv->current_popup_item) {
hide_item_popup(self);
- } else if (self->priv->current_pointed_item) {
+ }
+ if (self->priv->current_pointed_item) {
show_item_popup(self, self->priv->current_pointed_item);
}
@@ -423,16 +425,14 @@ static gboolean handle_popup_timer(gpointer user_data)
static gboolean handle_item_enter(MDockWidget *self, GdkEventCrossing *event, MDockItem *item)
{
- g_debug("Item enter");
+ g_warn_if_fail(!self->priv->current_pointed_item);
self->priv->current_pointed_item = item;
if (self->priv->current_popup_item) {
if (self->priv->popup_timer) {
g_source_remove(self->priv->popup_timer);
self->priv->popup_timer = 0;
}
- hide_item_popup(self);
- show_item_popup(self, item);
-
+ self->priv->popup_timer = g_timeout_add(POPUP_MOVE_TIMEOUT, handle_popup_timer, self);
} else if (!self->priv->popup_timer) {
self->priv->popup_timer = g_timeout_add(POPUP_SHOW_TIMEOUT, handle_popup_timer, self);
}
@@ -441,7 +441,6 @@ static gboolean handle_item_enter(MDockWidget *self, GdkEventCrossing *event, MD
static gboolean handle_item_leave(MDockWidget *self, GdkEventCrossing *event, MDockItem *item)
{
- g_debug("Item leave");
g_warn_if_fail(self->priv->current_pointed_item == item);
g_warn_if_fail(!self->priv->current_popup_item || self->priv->current_pointed_item == item);
self->priv->current_pointed_item = NULL;
@@ -454,7 +453,7 @@ static gboolean handle_item_leave(MDockWidget *self, GdkEventCrossing *event, MD
static gboolean handle_item_selector_enter(MDockWidget *self, GdkEventCrossing *event, MDockItemWindowSelector *selector)
{
g_debug("Item selector enter %d", event->detail);
- if (event->detail != GDK_NOTIFY_NONLINEAR) return FALSE;
+ if (event->detail == GDK_NOTIFY_INFERIOR) return FALSE;
g_warn_if_fail(self->priv->current_popup_item);
if (self->priv->popup_timer) {
g_source_remove(self->priv->popup_timer);
@@ -466,7 +465,7 @@ static gboolean handle_item_selector_enter(MDockWidget *self, GdkEventCrossing *
static gboolean handle_item_selector_leave(MDockWidget *self, GdkEventCrossing *event, MDockItemWindowSelector *selector)
{
g_debug("Item selector leave %d", event->detail);
- if (event->detail != GDK_NOTIFY_NONLINEAR) return FALSE;
+ if (event->detail == GDK_NOTIFY_INFERIOR) return FALSE;
g_warn_if_fail(self->priv->current_popup_item);
if (!self->priv->popup_timer) {
self->priv->popup_timer = g_timeout_add(POPUP_HIDE_TIMEOUT, handle_popup_timer, self);
@@ -815,7 +814,17 @@ static void mdock_widget_class_init(MDockWidgetClass *klass)
g_type_class_add_private(klass, sizeof(MDockWidgetPrivate));
}
+gint mdock_widget_get_n_items(MDockWidget *self)
+{
+ return g_sequence_get_length(self->priv->items);
+}
+
GtkWidget *mdock_widget_new(void)
{
return GTK_WIDGET(g_object_new(MDOCK_TYPE_WIDGET, NULL));
}
+
+GtkWidget *mdock_widget_new_with_settings_path(const gchar *path)
+{
+ return GTK_WIDGET(g_object_new(MDOCK_TYPE_WIDGET, "settings-path", path, NULL));
+}
diff --git a/libmdock/mdock-widget.h b/libmdock/mdock-widget.h
index 00ad496..2771095 100644
--- a/libmdock/mdock-widget.h
+++ b/libmdock/mdock-widget.h
@@ -49,7 +49,10 @@ struct _MDockWidgetClass
GType mdock_widget_get_type(void);
+gint mdock_widget_get_n_items(MDockWidget *widget);
+
GtkWidget *mdock_widget_new(void);
+GtkWidget *mdock_widget_new_with_settings_path(const gchar *path);
G_END_DECLS