"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/e-util/e-color-combo.c" between
evolution-3.32.4.tar.xz and evolution-3.34.0.tar.xz

About: Evolution is a personal information management application that provides integrated mail, calendaring and address book functionality (GNOME desktop).

e-color-combo.c  (evolution-3.32.4.tar.xz):e-color-combo.c  (evolution-3.34.0.tar.xz)
skipping to change at line 37 skipping to change at line 37
#include <cairo/cairo.h> #include <cairo/cairo.h>
#define E_COLOR_COMBO_GET_PRIVATE(obj) \ #define E_COLOR_COMBO_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \ (G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_COLOR_COMBO, EColorComboPrivate)) ((obj), E_TYPE_COLOR_COMBO, EColorComboPrivate))
struct _EColorComboPrivate { struct _EColorComboPrivate {
GtkWidget *color_frame; /* not referenced */ GtkWidget *color_frame; /* not referenced */
GtkWidget *arrow; /* not referenced */ GtkWidget *arrow; /* not referenced */
GtkWidget *window; GtkWidget *popover;
GtkWidget *default_button; /* not referenced */ GtkWidget *default_button; /* not referenced */
GtkWidget *chooser_widget; /* not referenced */ GtkWidget *chooser_widget; /* not referenced */
guint popup_shown : 1; guint popup_shown : 1;
guint popup_in_progress : 1; guint popup_in_progress : 1;
guint default_transparent: 1; guint default_transparent: 1;
GdkRGBA *current_color; GdkRGBA *current_color;
GdkRGBA *default_color; GdkRGBA *default_color;
GList *palette; GList *palette;
GdkDevice *grab_keyboard;
GdkDevice *grab_mouse;
}; };
enum { enum {
PROP_0, PROP_0,
PROP_CURRENT_COLOR, PROP_CURRENT_COLOR,
PROP_DEFAULT_COLOR, PROP_DEFAULT_COLOR,
PROP_DEFAULT_LABEL, PROP_DEFAULT_LABEL,
PROP_DEFAULT_TRANSPARENT, PROP_DEFAULT_TRANSPARENT,
PROP_PALETTE, PROP_PALETTE,
PROP_POPUP_SHOWN PROP_POPUP_SHOWN
skipping to change at line 131 skipping to change at line 128
{ "#CC99FF", N_("light purple") }, { "#CC99FF", N_("light purple") },
{ "#FFFFFF", N_("white") } { "#FFFFFF", N_("white") }
}; };
G_DEFINE_TYPE ( G_DEFINE_TYPE (
EColorCombo, EColorCombo,
e_color_combo, e_color_combo,
GTK_TYPE_BUTTON); GTK_TYPE_BUTTON);
static void static void
color_combo_reposition_window (EColorCombo *combo)
{
GdkScreen *screen;
GdkWindow *window;
GdkRectangle monitor;
GtkAllocation allocation;
gint monitor_num;
gint x, y, width, height;
screen = gtk_widget_get_screen (GTK_WIDGET (combo));
window = gtk_widget_get_window (GTK_WIDGET (combo));
monitor_num = gdk_screen_get_monitor_at_window (screen, window);
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
gdk_window_get_origin (window, &x, &y);
if (!gtk_widget_get_has_window (GTK_WIDGET (combo))) {
gtk_widget_get_allocation (GTK_WIDGET (combo), &allocation);
x += allocation.x;
y += allocation.y;
}
gtk_widget_get_allocation (combo->priv->window, &allocation);
width = allocation.width;
height = allocation.height;
x = CLAMP (x, monitor.x, monitor.x + monitor.width - width);
y = CLAMP (y, monitor.y, monitor.y + monitor.height - height);
gtk_window_move (GTK_WINDOW (combo->priv->window), x, y);
}
static void
color_combo_popup (EColorCombo *combo) color_combo_popup (EColorCombo *combo)
{ {
GdkWindow *window;
GtkWidget *toplevel;
gboolean grab_status;
GdkDevice *device, *mouse, *keyboard;
guint32 activate_time;
device = gtk_get_current_event_device ();
g_return_if_fail (device != NULL);
if (!gtk_widget_get_realized (GTK_WIDGET (combo))) if (!gtk_widget_get_realized (GTK_WIDGET (combo)))
return; return;
if (combo->priv->popup_shown) if (combo->priv->popup_shown)
return; return;
activate_time = gtk_get_current_event_time ();
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD) {
keyboard = device;
mouse = gdk_device_get_associated_device (device);
} else {
keyboard = gdk_device_get_associated_device (device);
mouse = device;
}
/* Position the window over the button. */
color_combo_reposition_window (combo);
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (combo));
if (GTK_IS_WINDOW (toplevel))
gtk_window_set_transient_for (GTK_WINDOW (combo->priv->window), G
TK_WINDOW (toplevel));
/* Try to grab the pointer and keyboard. */
window = gtk_widget_get_window (toplevel);
grab_status =
(keyboard == NULL) ||
(gdk_device_grab (
keyboard, window,
GDK_OWNERSHIP_WINDOW, TRUE,
GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
NULL, activate_time) == GDK_GRAB_SUCCESS);
if (grab_status) {
grab_status =
(mouse == NULL) ||
(gdk_device_grab (
mouse, window,
GDK_OWNERSHIP_WINDOW, TRUE,
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK,
NULL, activate_time) == GDK_GRAB_SUCCESS);
if (!grab_status && keyboard)
gdk_device_ungrab (keyboard, activate_time);
}
if (grab_status) {
gtk_device_grab_add (combo->priv->window, mouse, TRUE);
combo->priv->grab_keyboard = keyboard;
combo->priv->grab_mouse = mouse;
} else {
gtk_widget_hide (combo->priv->window);
}
/* Always make sure the editor-mode is OFF */ /* Always make sure the editor-mode is OFF */
g_object_set ( g_object_set (
G_OBJECT (combo->priv->chooser_widget), G_OBJECT (combo->priv->chooser_widget),
"show-editor", FALSE, NULL); "show-editor", FALSE, NULL);
/* Show the pop-up. */ /* Show the pop-up. */
gtk_widget_show_all (combo->priv->window); gtk_widget_show_all (combo->priv->popover);
gtk_widget_grab_focus (combo->priv->window); gtk_widget_grab_focus (combo->priv->chooser_widget);
} }
static void static void
color_combo_popdown (EColorCombo *combo) color_combo_popdown (EColorCombo *combo)
{ {
if (!gtk_widget_get_realized (GTK_WIDGET (combo))) if (!gtk_widget_get_realized (GTK_WIDGET (combo)))
return; return;
if (!combo->priv->popup_shown) if (!combo->priv->popup_shown)
return; return;
/* Hide the pop-up. */ gtk_widget_hide (combo->priv->popover);
gtk_device_grab_remove (combo->priv->window, combo->priv->grab_mouse);
gtk_widget_hide (combo->priv->window);
if (combo->priv->grab_keyboard)
gdk_device_ungrab (combo->priv->grab_keyboard, GDK_CURRENT_TIME);
if (combo->priv->grab_mouse)
gdk_device_ungrab (combo->priv->grab_mouse, GDK_CURRENT_TIME);
combo->priv->grab_keyboard = NULL;
combo->priv->grab_mouse = NULL;
} }
static gboolean static gboolean
color_combo_window_button_press_event_cb (EColorCombo *combo, color_combo_window_button_press_event_cb (EColorCombo *combo,
GdkEvent *event, GdkEvent *event,
gpointer user_data) gpointer user_data)
{ {
GtkWidget *event_widget; GtkWidget *event_widget;
event_widget = gtk_get_event_widget ((GdkEvent *) event); event_widget = gtk_get_event_widget ((GdkEvent *) event);
if (event_widget == combo->priv->window) if (event_widget == combo->priv->popover)
return TRUE; return TRUE;
if (combo->priv->popup_shown == TRUE) if (combo->priv->popup_shown)
return FALSE; return FALSE;
combo->priv->popup_in_progress = TRUE; combo->priv->popup_in_progress = TRUE;
color_combo_popup (combo); color_combo_popup (combo);
return TRUE; return TRUE;
} }
static gboolean static gboolean
color_combo_window_button_release_event_cb (EColorCombo *combo, color_combo_window_button_release_event_cb (EColorCombo *combo,
skipping to change at line 571 skipping to change at line 469
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
} }
static void static void
color_combo_dispose (GObject *object) color_combo_dispose (GObject *object)
{ {
EColorComboPrivate *priv; EColorComboPrivate *priv;
priv = E_COLOR_COMBO_GET_PRIVATE (object); priv = E_COLOR_COMBO_GET_PRIVATE (object);
if (priv->window != NULL) { if (priv->popover) {
gtk_widget_destroy (priv->window); gtk_widget_destroy (priv->popover);
priv->window = NULL; priv->popover = NULL;
} }
if (priv->current_color != NULL) { if (priv->current_color != NULL) {
gdk_rgba_free (priv->current_color); gdk_rgba_free (priv->current_color);
priv->current_color = NULL; priv->current_color = NULL;
} }
if (priv->default_color != NULL) { if (priv->default_color != NULL) {
gdk_rgba_free (priv->default_color); gdk_rgba_free (priv->default_color);
priv->default_color = NULL; priv->default_color = NULL;
skipping to change at line 724 skipping to change at line 622
GDK_KEY_KP_Up, GDK_MOD1_MASK, "popdown", 0); GDK_KEY_KP_Up, GDK_MOD1_MASK, "popdown", 0);
gtk_binding_entry_add_signal ( gtk_binding_entry_add_signal (
gtk_binding_set_by_class (class), gtk_binding_set_by_class (class),
GDK_KEY_Escape, 0, "popdown", 0); GDK_KEY_Escape, 0, "popdown", 0);
} }
static void static void
e_color_combo_init (EColorCombo *combo) e_color_combo_init (EColorCombo *combo)
{ {
GtkWidget *container; GtkWidget *container;
GtkWidget *toplevel;
GtkWidget *widget; GtkWidget *widget;
GList *palette; GList *palette;
guint ii; guint ii;
combo->priv = E_COLOR_COMBO_GET_PRIVATE (combo); combo->priv = E_COLOR_COMBO_GET_PRIVATE (combo);
widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4); widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
gtk_container_add (GTK_CONTAINER (combo), widget); gtk_container_add (GTK_CONTAINER (combo), widget);
container = widget; container = widget;
skipping to change at line 754 skipping to change at line 651
widget = gtk_separator_new (GTK_ORIENTATION_VERTICAL); widget = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
gtk_box_pack_start (GTK_BOX (container), widget, FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (container), widget, FALSE, TRUE, 0);
widget = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); widget = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
gtk_box_pack_start (GTK_BOX (container), widget, FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (container), widget, FALSE, TRUE, 0);
combo->priv->arrow = widget; /* do not reference */ combo->priv->arrow = widget; /* do not reference */
gtk_widget_show_all (container); gtk_widget_show_all (container);
/* Build the drop-down menu */ /* Build the drop-down menu */
widget = gtk_window_new (GTK_WINDOW_POPUP); widget = gtk_popover_new (GTK_WIDGET (combo));
gtk_container_set_border_width (GTK_CONTAINER (widget), 5); gtk_popover_set_position (GTK_POPOVER (widget), GTK_POS_BOTTOM);
gtk_window_set_resizable (GTK_WINDOW (widget), FALSE); gtk_popover_set_modal (GTK_POPOVER (widget), TRUE);
gtk_window_set_type_hint ( combo->priv->popover = g_object_ref_sink (widget);
GTK_WINDOW (widget), GDK_WINDOW_TYPE_HINT_COMBO);
combo->priv->window = g_object_ref_sink (widget);
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (combo));
if (GTK_IS_WINDOW (toplevel)) {
gtk_window_group_add_window (
gtk_window_get_group (GTK_WINDOW (toplevel)),
GTK_WINDOW (widget));
gtk_window_set_transient_for (
GTK_WINDOW (widget), GTK_WINDOW (toplevel));
}
g_signal_connect_swapped ( g_signal_connect_swapped (
widget, "show", widget, "show",
G_CALLBACK (color_combo_child_show_cb), combo); G_CALLBACK (color_combo_child_show_cb), combo);
g_signal_connect_swapped ( g_signal_connect_swapped (
widget, "hide", widget, "hide",
G_CALLBACK (color_combo_child_hide_cb), combo); G_CALLBACK (color_combo_child_hide_cb), combo);
g_signal_connect_swapped ( g_signal_connect_swapped (
widget, "button-press-event", widget, "button-press-event",
G_CALLBACK (color_combo_window_button_press_event_cb), combo); G_CALLBACK (color_combo_window_button_press_event_cb), combo);
skipping to change at line 803 skipping to change at line 689
combo->priv->default_button = widget; /* do not reference */ combo->priv->default_button = widget; /* do not reference */
g_signal_connect_swapped ( g_signal_connect_swapped (
widget, "clicked", widget, "clicked",
G_CALLBACK (color_combo_set_default_color_cb), combo); G_CALLBACK (color_combo_set_default_color_cb), combo);
g_signal_connect_swapped ( g_signal_connect_swapped (
widget, "clicked", widget, "clicked",
G_CALLBACK (color_combo_popdown), combo); G_CALLBACK (color_combo_popdown), combo);
widget = e_color_chooser_widget_new (); widget = e_color_chooser_widget_new ();
g_object_set_data (G_OBJECT (widget), "window", combo->priv->window); g_object_set_data (G_OBJECT (widget), "window", combo->priv->popover);
gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1); gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
combo->priv->chooser_widget = widget; /* do not reference */ combo->priv->chooser_widget = widget; /* do not reference */
g_signal_connect_swapped ( g_signal_connect_swapped (
widget, "color-activated", widget, "color-activated",
G_CALLBACK (color_combo_swatch_color_changed), combo); G_CALLBACK (color_combo_swatch_color_changed), combo);
g_signal_connect_swapped ( g_signal_connect_swapped (
widget, "editor-activated", widget, "editor-activated",
G_CALLBACK (color_combo_popdown), combo); G_CALLBACK (color_combo_popdown), combo);
 End of changes. 13 change blocks. 
129 lines changed or deleted 14 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)