summaryrefslogtreecommitdiff
path: root/libmdock
diff options
context:
space:
mode:
Diffstat (limited to 'libmdock')
-rw-r--r--libmdock/mdock-item-menu.c5
-rw-r--r--libmdock/mdock-item-window-selector.c2
-rw-r--r--libmdock/mdock-window.c72
-rw-r--r--libmdock/mdock-window.h4
4 files changed, 69 insertions, 14 deletions
diff --git a/libmdock/mdock-item-menu.c b/libmdock/mdock-item-menu.c
index bdf0184..04b3571 100644
--- a/libmdock/mdock-item-menu.c
+++ b/libmdock/mdock-item-menu.c
@@ -126,8 +126,9 @@ static void recents_result_ready(GObject *source, GAsyncResult *res, gpointer us
gtk_image_menu_item_set_always_show_image(menu_item, TRUE);
gtk_menu_shell_append(GTK_MENU_SHELL(self), GTK_WIDGET(menu_item));
gtk_widget_show(GTK_WIDGET(menu_item));
- g_signal_connect_swapped(menu_item, "activate",
- G_CALLBACK(handle_recent_activate), self);
+ g_signal_connect_object(menu_item, "activate",
+ G_CALLBACK(handle_recent_activate), self,
+ G_CONNECT_SWAPPED);
} else {
gtk_menu_item_set_label(GTK_MENU_ITEM(menu_item), zeitgeist_subject_get_text(subject));
gtk_image_clear(GTK_IMAGE(gtk_image_menu_item_get_image(menu_item)));
diff --git a/libmdock/mdock-item-window-selector.c b/libmdock/mdock-item-window-selector.c
index 2885a76..7bd0199 100644
--- a/libmdock/mdock-item-window-selector.c
+++ b/libmdock/mdock-item-window-selector.c
@@ -136,6 +136,8 @@ static void mdock_item_window_selector_dispose(GObject *object)
static void mdock_item_window_selector_finalize(GObject *object)
{
+ MDockItemWindowSelector *self = MDOCK_ITEM_WINDOW_SELECTOR(object);
+ g_sequence_free(self->priv->windows);
G_OBJECT_CLASS(mdock_item_window_selector_parent_class)->finalize(object);
}
diff --git a/libmdock/mdock-window.c b/libmdock/mdock-window.c
index 5707cf5..9a21cde 100644
--- a/libmdock/mdock-window.c
+++ b/libmdock/mdock-window.c
@@ -5,13 +5,16 @@
struct _MDockWindowPrivate
{
+ GtkTable *table;
GtkImage *icon;
GtkLabel *title;
GtkWidget *close_btn;
GtkImage *img;
+ gboolean preligth : 1;
+ gboolean selected : 1;
};
-G_DEFINE_TYPE(MDockWindow, mdock_window, GTK_TYPE_TABLE)
+G_DEFINE_TYPE(MDockWindow, mdock_window, GTK_TYPE_EVENT_BOX)
enum MDockItemWindowSelectorProperties {
PROP_0,
@@ -26,6 +29,46 @@ static void handle_close_btn_clicked(MDockWindow *self, GtkToolButton *toolbtn)
wnck_window_close(self->window, gtk_get_current_event_time());
}
+static void update_state(MDockWindow *self)
+{
+ if (gtk_widget_is_sensitive(GTK_WIDGET(self))) {
+ GtkStateType state = GTK_STATE_NORMAL;
+ if (self->priv->preligth) {
+ state = GTK_STATE_PRELIGHT;
+ } else if (self->priv->selected) {
+ state = GTK_STATE_SELECTED;
+ }
+
+ gtk_widget_set_state(GTK_WIDGET(self), state);
+ }
+}
+
+static gboolean mdock_window_enter_notify(GtkWidget *widget, GdkEventCrossing *event)
+{
+ MDockWindow *self = MDOCK_WINDOW(widget);
+ GtkWidget *event_widget = gtk_get_event_widget((GdkEvent*) event);
+
+ if (event_widget == widget && event->detail != GDK_NOTIFY_INFERIOR) {
+ self->priv->preligth = TRUE;
+ update_state(self);
+ }
+
+ return FALSE;
+}
+
+static gboolean mdock_window_leave_notify(GtkWidget *widget, GdkEventCrossing *event)
+{
+ MDockWindow *self = MDOCK_WINDOW(widget);
+ GtkWidget *event_widget = gtk_get_event_widget((GdkEvent*) event);
+
+ if (event_widget == widget && event->detail != GDK_NOTIFY_INFERIOR) {
+ self->priv->preligth = FALSE;
+ update_state(self);
+ }
+
+ return FALSE;
+}
+
static void mdock_window_set_property(GObject *object,
guint property_id,
const GValue *value,
@@ -64,30 +107,29 @@ static void mdock_window_constructed(GObject *object)
G_OBJECT_CLASS(mdock_window_parent_class)->constructed(object);
thumbnailer_enable_for_window(self->window);
- gtk_table_resize(GTK_TABLE(self), 2, 3);
-
self->priv->icon = GTK_IMAGE(gtk_image_new_from_pixbuf(wnck_window_get_icon(self->window)));
- gtk_table_attach(GTK_TABLE(self), GTK_WIDGET(self->priv->icon),
+ gtk_table_attach(self->priv->table, GTK_WIDGET(self->priv->icon),
0, 1, 0, 1, 0, 0, 0, 0);
gtk_widget_show(GTK_WIDGET(self->priv->icon));
self->priv->title = GTK_LABEL(gtk_label_new(wnck_window_get_name(self->window)));
gtk_label_set_max_width_chars(self->priv->title, 20);
- gtk_table_attach(GTK_TABLE(self), GTK_WIDGET(self->priv->title),
+ gtk_table_attach(self->priv->table, GTK_WIDGET(self->priv->title),
1, 2, 0, 1, GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0);
gtk_widget_show(GTK_WIDGET(self->priv->title));
self->priv->close_btn = GTK_WIDGET(gtk_tool_button_new_from_stock(GTK_STOCK_CLOSE));
- gtk_table_attach(GTK_TABLE(self), self->priv->close_btn,
+ gtk_table_attach(self->priv->table, self->priv->close_btn,
2, 3, 0, 1, 0, 0, 0, 0);
if (wnck_window_get_actions(self->window) & WNCK_WINDOW_ACTION_CLOSE) {
gtk_widget_show(self->priv->close_btn);
- g_signal_connect_swapped(self->priv->close_btn, "clicked",
- G_CALLBACK(handle_close_btn_clicked), self);
+ g_signal_connect_object(self->priv->close_btn, "clicked",
+ G_CALLBACK(handle_close_btn_clicked), self,
+ G_CONNECT_SWAPPED);
}
self->priv->img = GTK_IMAGE(gtk_image_new());
- gtk_table_attach(GTK_TABLE(self), GTK_WIDGET(self->priv->img),
+ gtk_table_attach(self->priv->table, GTK_WIDGET(self->priv->img),
0, 3, 1, 2, GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0);
gtk_widget_show(GTK_WIDGET(self->priv->img));
}
@@ -104,12 +146,15 @@ static void mdock_window_finalize(GObject *object)
static void mdock_window_class_init (MDockWindowClass *klass)
{
- GObjectClass *obj_class = G_OBJECT_CLASS (klass);
+ GObjectClass *obj_class = G_OBJECT_CLASS(klass);
obj_class->set_property = mdock_window_set_property;
obj_class->get_property = mdock_window_get_property;
obj_class->constructed = mdock_window_constructed;
obj_class->dispose = mdock_window_dispose;
obj_class->finalize = mdock_window_finalize;
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+ widget_class->enter_notify_event = mdock_window_enter_notify;
+ widget_class->leave_notify_event = mdock_window_leave_notify;
g_type_class_add_private(obj_class, sizeof (MDockWindowPrivate));
@@ -125,6 +170,13 @@ static void mdock_window_class_init (MDockWindowClass *klass)
static void mdock_window_init(MDockWindow *self)
{
self->priv = MDOCK_WINDOW_GET_PRIVATE(self);
+ self->priv->table = GTK_TABLE(gtk_table_new(2, 3, FALSE));
+ gtk_container_add(GTK_CONTAINER(self), GTK_WIDGET(self->priv->table));
+
+ gtk_widget_add_events(GTK_WIDGET(self),
+ GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
+ | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
+ gtk_widget_show(GTK_WIDGET(self->priv->table));
}
void mdock_window_update_screenshot(MDockWindow *self)
diff --git a/libmdock/mdock-window.h b/libmdock/mdock-window.h
index 103a2d7..c044ea1 100644
--- a/libmdock/mdock-window.h
+++ b/libmdock/mdock-window.h
@@ -20,13 +20,13 @@ typedef struct _MDockWindowClass MDockWindowClass;
typedef struct _MDockWindowPrivate MDockWindowPrivate;
struct _MDockWindow {
- GtkTable parent;
+ GtkEventBox parent;
WnckWindow *window;
MDockWindowPrivate *priv;
};
struct _MDockWindowClass {
- GtkTableClass parent_class;
+ GtkEventBoxClass parent_class;
};
GType mdock_window_get_type(void) G_GNUC_CONST;