X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=libview%2Fev-annotation-window.c;h=8776dd4cf4cfd520a110690d14fbffb199a25fc3;hb=054abf70e4d37877fa12d442af5abc4e8170b046;hp=749d1a012ad53d7132bca109a2769ea10660bfd3;hpb=584f014b63c56fe3770cba9682fc21c31e09a2e9;p=evince.git diff --git a/libview/ev-annotation-window.c b/libview/ev-annotation-window.c index 749d1a01..8776dd4c 100644 --- a/libview/ev-annotation-window.c +++ b/libview/ev-annotation-window.c @@ -134,32 +134,31 @@ static void ev_annotation_window_set_color (EvAnnotationWindow *window, GdkColor *color) { - GtkRcStyle *rc_style; - GdkColor gcolor; - - gcolor = *color; - - /* Allocate these colors */ - gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (window)), - &gcolor, FALSE, TRUE); - - /* Apply colors to style */ - rc_style = gtk_widget_get_modifier_style (GTK_WIDGET (window)); - rc_style->base[GTK_STATE_NORMAL] = gcolor; - rc_style->bg[GTK_STATE_PRELIGHT] = gcolor; - rc_style->bg[GTK_STATE_NORMAL] = gcolor; - rc_style->bg[GTK_STATE_ACTIVE] = gcolor; - rc_style->color_flags[GTK_STATE_PRELIGHT] = GTK_RC_BG; - rc_style->color_flags[GTK_STATE_NORMAL] = GTK_RC_BG | GTK_RC_BASE; - rc_style->color_flags[GTK_STATE_ACTIVE] = GTK_RC_BG; - - /* Apply the style to the widgets */ - g_object_ref (rc_style); - gtk_widget_modify_style (GTK_WIDGET (window), rc_style); - gtk_widget_modify_style (window->close_button, rc_style); - gtk_widget_modify_style (window->resize_se, rc_style); - gtk_widget_modify_style (window->resize_sw, rc_style); - g_object_unref (rc_style); + GtkStyleProperties *properties; + GtkStyleProvider *provider; + GdkRGBA rgba; + + rgba.red = color->red / 65535.; + rgba.green = color->green / 65535.; + rgba.blue = color->blue / 65535.; + rgba.alpha = 1; + + properties = gtk_style_properties_new (); + gtk_style_properties_set (properties, 0, + "color", &rgba, + "background-color", &rgba, + NULL); + + provider = GTK_STYLE_PROVIDER (properties); + gtk_style_context_add_provider (gtk_widget_get_style_context (GTK_WIDGET (window)), + provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + gtk_style_context_add_provider (gtk_widget_get_style_context (window->close_button), + provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + gtk_style_context_add_provider (gtk_widget_get_style_context (window->resize_se), + provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + gtk_style_context_add_provider (gtk_widget_get_style_context (window->resize_sw), + provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + g_object_unref (properties); } static void @@ -254,7 +253,7 @@ ev_annotation_window_set_resize_cursor (GtkWidget *widget, GDK_BOTTOM_LEFT_CORNER : GDK_BOTTOM_RIGHT_CORNER); gdk_window_set_cursor (gdk_window, cursor); - gdk_cursor_unref (cursor); + g_object_unref (cursor); } else { gdk_window_set_cursor (gdk_window, NULL); } @@ -332,6 +331,7 @@ ev_annotation_window_init (EvAnnotationWindow *window) gtk_widget_show (swindow); /* Resize bar */ + gtk_window_set_has_resize_grip (GTK_WINDOW(window), FALSE); hbox = gtk_hbox_new (FALSE, 0); window->resize_sw = gtk_event_box_new (); @@ -378,7 +378,7 @@ ev_annotation_window_init (EvAnnotationWindow *window) gtk_container_set_border_width (GTK_CONTAINER (window), 2); - gtk_window_set_accept_focus (GTK_WINDOW (window), TRUE); + gtk_window_set_accept_focus (GTK_WINDOW (window), FALSE); gtk_window_set_decorated (GTK_WINDOW (window), FALSE); gtk_window_set_skip_taskbar_hint (GTK_WINDOW (window), TRUE); gtk_window_set_skip_pager_hint (GTK_WINDOW (window), TRUE); @@ -454,8 +454,8 @@ ev_annotation_window_button_press_event (GtkWidget *widget, if (event->type == GDK_BUTTON_PRESS && event->button == 1) { window->in_move = TRUE; - window->x = event->x; - window->y = event->y; + window->x = event->x_root - event->x; + window->y = event->y_root - event->y; gtk_window_begin_move_drag (GTK_WINDOW (widget), event->button, event->x_root, @@ -489,8 +489,12 @@ ev_annotation_window_focus_in_event (GtkWidget *widget, EvAnnotationWindow *window = EV_ANNOTATION_WINDOW (widget); if (window->in_move) { - window->orig_x = window->x; - window->orig_y = window->y; + if (window->orig_x != window->x || window->orig_y != window->y) { + window->orig_x = window->x; + window->orig_y = window->y; + g_signal_emit (window, signals[MOVED], 0, window->x, window->y); + } + window->in_move = FALSE; } return FALSE; @@ -502,17 +506,29 @@ ev_annotation_window_focus_out_event (GtkWidget *widget, { EvAnnotationWindow *window = EV_ANNOTATION_WINDOW (widget); - if (window->in_move && - (window->orig_x != window->x || window->orig_y != window->y)) { - window->in_move = FALSE; - g_signal_emit (window, signals[MOVED], 0, window->x, window->y); - } - ev_annotation_window_sync_contents (window); return FALSE; } +static gboolean +ev_annotation_window_enter_notify_event (GtkWidget *widget, + GdkEventCrossing *event) +{ + gtk_window_set_accept_focus (GTK_WINDOW (widget), TRUE); + + return FALSE; +} + +static gboolean +ev_annotation_window_leave_notify_event (GtkWidget *widget, + GdkEventCrossing *event) +{ + gtk_window_set_accept_focus (GTK_WINDOW (widget), FALSE); + + return FALSE; +} + static void ev_annotation_window_class_init (EvAnnotationWindowClass *klass) { @@ -527,6 +543,8 @@ ev_annotation_window_class_init (EvAnnotationWindowClass *klass) gtk_widget_class->configure_event = ev_annotation_window_configure_event; gtk_widget_class->focus_in_event = ev_annotation_window_focus_in_event; gtk_widget_class->focus_out_event = ev_annotation_window_focus_out_event; + gtk_widget_class->enter_notify_event = ev_annotation_window_enter_notify_event; + gtk_widget_class->leave_notify_event = ev_annotation_window_leave_notify_event; g_object_class_install_property (g_object_class, PROP_ANNOTATION,