mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Merge branch 'gtk3-update5' of https://github.com/Bob-IT/gnucash
This commit is contained in:
commit
135055764b
@ -669,7 +669,7 @@ verify_children_compatible (AccountWindow *aw)
|
||||
gnc_label_set_alignment (label, 0.0, 0.0);
|
||||
|
||||
/* make label large */
|
||||
gnc_widget_set_style_context (GTK_WIDGET(label), "primary_label_size");
|
||||
gnc_widget_set_style_context (GTK_WIDGET(label), "emphasize-label");
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
||||
|
||||
|
@ -69,9 +69,9 @@ gnc_set_label_color(GtkWidget *label, gnc_numeric value)
|
||||
deficit = gnc_numeric_negative_p (value);
|
||||
|
||||
if (deficit)
|
||||
gnc_widget_set_style_context (GTK_WIDGET(label), "css_red_color");
|
||||
gnc_widget_set_style_context (GTK_WIDGET(label), "negative-numbers");
|
||||
else
|
||||
gnc_widget_set_style_context (GTK_WIDGET(label), "css_default_color");
|
||||
gnc_widget_set_style_context (GTK_WIDGET(label), "default-color");
|
||||
}
|
||||
|
||||
|
||||
@ -293,6 +293,38 @@ gnc_widget_set_style_context (GtkWidget *widget, const char *gnc_class)
|
||||
gtk_style_context_add_class (context, gnc_class);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* Draw an arrow on a Widget so it can be altered with css *
|
||||
* *
|
||||
* Args: widget - widget to add arrow to in the draw callback *
|
||||
* cr - cairo context for the draw callback *
|
||||
* direction - 0 for up, 1 for down *
|
||||
* Returns: TRUE, stop other handlers being invoked for the event *
|
||||
\********************************************************************/
|
||||
gboolean
|
||||
gnc_draw_arrow_cb (GtkWidget *widget, cairo_t *cr, gpointer direction)
|
||||
{
|
||||
GtkStyleContext *context = gtk_widget_get_style_context (widget);
|
||||
gint width = gtk_widget_get_allocated_width (widget);
|
||||
gint height = gtk_widget_get_allocated_height (widget);
|
||||
gint size;
|
||||
|
||||
gtk_render_background (context, cr, 0, 0, width, height);
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_ARROW);
|
||||
|
||||
size = MIN(width / 2, height / 2);
|
||||
|
||||
if (GPOINTER_TO_INT(direction) == 0)
|
||||
gtk_render_arrow (context, cr, 0,
|
||||
(width - size)/2, (height - size)/2, size);
|
||||
else
|
||||
gtk_render_arrow (context, cr, G_PI,
|
||||
(width - size)/2, (height - size)/2, size);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
gnc_handle_date_accelerator (GdkEventKey *event,
|
||||
struct tm *tm,
|
||||
|
@ -88,6 +88,16 @@ GtkTreeViewGridLines gnc_tree_view_get_grid_lines_pref (void);
|
||||
\********************************************************************/
|
||||
void gnc_widget_set_style_context (GtkWidget *widget, const char *gnc_class);
|
||||
|
||||
/********************************************************************\
|
||||
* Draw an arrow on a Widget so it can be altered with css *
|
||||
* *
|
||||
* Args: widget - widget to add arrow to in the draw callback *
|
||||
* cr - cairo context for the draw callback *
|
||||
* direction - 0 for up, 1 for down *
|
||||
* Returns: TRUE, stop other handlers being invoked for the event *
|
||||
\********************************************************************/
|
||||
gboolean gnc_draw_arrow_cb (GtkWidget *widget, cairo_t *cr, gpointer direction);
|
||||
|
||||
gboolean gnc_handle_date_accelerator (GdkEventKey *event,
|
||||
struct tm *tm,
|
||||
const char *date_str);
|
||||
|
@ -111,6 +111,9 @@ gnc_popup_entry_init (GncPopupEntry *widget)
|
||||
arrow = gtk_image_new_from_icon_name ("go-down", GTK_ICON_SIZE_BUTTON);
|
||||
gtk_widget_show (arrow);
|
||||
|
||||
g_signal_connect (G_OBJECT (arrow), "draw",
|
||||
G_CALLBACK (gnc_draw_arrow_cb), GINT_TO_POINTER(1));
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (widget->button), arrow);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (widget->hbox), widget->entry, TRUE, TRUE, 0);
|
||||
|
@ -229,6 +229,9 @@ gctt_init (GncCombott *combott)
|
||||
|
||||
arrow = gtk_image_new_from_icon_name ("go-down", GTK_ICON_SIZE_BUTTON);
|
||||
|
||||
g_signal_connect (G_OBJECT (arrow), "draw",
|
||||
G_CALLBACK (gnc_draw_arrow_cb), GINT_TO_POINTER(1));
|
||||
|
||||
#if GTK_CHECK_VERSION(3,12,0)
|
||||
gtk_widget_set_margin_start (GTK_WIDGET(arrow), 5);
|
||||
#else
|
||||
|
@ -928,6 +928,9 @@ create_children (GNCDateEdit *gde)
|
||||
/* Graphic for the popup button. */
|
||||
arrow = gtk_image_new_from_icon_name ("go-down", GTK_ICON_SIZE_BUTTON);
|
||||
|
||||
g_signal_connect (G_OBJECT (arrow), "draw",
|
||||
G_CALLBACK (gnc_draw_arrow_cb), GINT_TO_POINTER(1));
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), arrow, TRUE, FALSE, 0);
|
||||
gtk_widget_show (GTK_WIDGET(arrow));
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "gnc-dense-cal.h"
|
||||
#include "gnc-dense-cal-model.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-gtk-utils.h"
|
||||
#include <glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
@ -69,11 +70,6 @@ static const int DENSE_CAL_DEFAULT_HEIGHT = 105;
|
||||
static const int MINOR_BORDER_SIZE = 1;
|
||||
static const int COL_BORDER_SIZE = 3;
|
||||
|
||||
static const gchar* MONTH_THIS_COLOR = "lavender";
|
||||
static const gchar* MONTH_THAT_COLOR = "SlateGray1";
|
||||
|
||||
static const gchar* MARK_COLOR = "Yellow";
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
#define G_LOG_DOMAIN "gnc.gui.dense-cal"
|
||||
|
||||
@ -226,6 +222,10 @@ gnc_dense_cal_class_init(GncDenseCalClass *klass)
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
#if GTK_CHECK_VERSION(3,20,0)
|
||||
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS(klass), "calendar");
|
||||
#endif
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gnc_dense_cal_finalize;
|
||||
@ -262,13 +262,16 @@ _gdc_get_view_options(void)
|
||||
static void
|
||||
gnc_dense_cal_init(GncDenseCal *dcal)
|
||||
{
|
||||
gboolean colorAllocSuccess[MAX_COLORS];
|
||||
GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET(dcal));
|
||||
|
||||
gtk_orientable_set_orientation (GTK_ORIENTABLE(dcal), GTK_ORIENTATION_VERTICAL);
|
||||
|
||||
// Set the style context for this widget so it can be easily manipulated with css
|
||||
gnc_widget_set_style_context (GTK_WIDGET(dcal), "GncDenseCal");
|
||||
gnc_widget_set_style_context (GTK_WIDGET(dcal), "calendar");
|
||||
|
||||
gtk_widget_set_name (GTK_WIDGET(dcal), "dense-cal");
|
||||
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_CALENDAR);
|
||||
{
|
||||
GtkTreeModel *options;
|
||||
GtkCellRenderer *text_rend;
|
||||
@ -300,6 +303,7 @@ gnc_dense_cal_init(GncDenseCal *dcal)
|
||||
gtk_box_pack_start(GTK_BOX(dcal), GTK_WIDGET(hbox), FALSE, FALSE, 0);
|
||||
}
|
||||
dcal->cal_drawing_area = GTK_DRAWING_AREA(gtk_drawing_area_new());
|
||||
|
||||
gtk_widget_add_events(GTK_WIDGET(dcal->cal_drawing_area), (GDK_EXPOSURE_MASK
|
||||
| GDK_BUTTON_PRESS_MASK
|
||||
| GDK_BUTTON_RELEASE_MASK
|
||||
@ -331,6 +335,8 @@ gnc_dense_cal_init(GncDenseCal *dcal)
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
|
||||
gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
|
||||
|
||||
gtk_widget_set_name (GTK_WIDGET(dcal->transPopup), "dense-cal-popup");
|
||||
|
||||
l = gtk_label_new(_("Date: "));
|
||||
gtk_container_add(GTK_CONTAINER(hbox), l);
|
||||
l = gtk_label_new("YY/MM/DD");
|
||||
@ -344,6 +350,7 @@ gnc_dense_cal_init(GncDenseCal *dcal)
|
||||
tree_view = GTK_TREE_VIEW(gtk_tree_view_new_with_model(GTK_TREE_MODEL(tree_data)));
|
||||
gtk_tree_view_insert_column_with_attributes(tree_view, -1, _("Name"), gtk_cell_renderer_text_new(), "text", 0, NULL);
|
||||
gtk_tree_view_insert_column_with_attributes(tree_view, -1, _("Frequency"), gtk_cell_renderer_text_new(), "text", 1, NULL);
|
||||
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW(tree_view)), GTK_SELECTION_NONE);
|
||||
g_object_set_data(G_OBJECT(dcal->transPopup), "model", tree_data);
|
||||
gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(tree_view));
|
||||
|
||||
@ -354,12 +361,6 @@ gnc_dense_cal_init(GncDenseCal *dcal)
|
||||
gtk_widget_realize(GTK_WIDGET(dcal->transPopup));
|
||||
}
|
||||
|
||||
gdk_rgba_parse(&dcal->weekColors[MONTH_THIS], MONTH_THIS_COLOR);
|
||||
gdk_rgba_parse(&dcal->weekColors[MONTH_THAT], MONTH_THAT_COLOR);
|
||||
|
||||
/* success array must be as big as number of colors */
|
||||
g_assert(MAX_COLORS == (sizeof(colorAllocSuccess)/sizeof(gboolean)));
|
||||
|
||||
/* Deal with the various label sizes. */
|
||||
{
|
||||
PangoLayout *layout = gtk_widget_create_pango_layout(GTK_WIDGET(dcal), NULL);
|
||||
@ -877,52 +878,16 @@ gnc_dense_cal_draw(GtkWidget *widget, cairo_t *cr, gpointer user_data)
|
||||
g_return_val_if_fail(GNC_IS_DENSE_CAL(user_data), FALSE);
|
||||
|
||||
dcal = GNC_DENSE_CAL(user_data);
|
||||
|
||||
cairo_save (cr);;
|
||||
cairo_set_source_surface (cr, dcal->surface, 0, 0);
|
||||
cairo_paint (cr);
|
||||
cairo_restore (cr);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#define LOG_AND_RESET(timer, msg) do { g_debug("%s: %f", msg, g_timer_elapsed(timer, NULL) * 1000.); g_timer_reset(timer); } while (0);
|
||||
|
||||
static void
|
||||
gnc_style_context_get_background_color (GtkStyleContext *context,
|
||||
GtkStateFlags state,
|
||||
GdkRGBA *color)
|
||||
{
|
||||
GdkRGBA *c;
|
||||
|
||||
g_return_if_fail (color != NULL);
|
||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||
|
||||
gtk_style_context_get (context,
|
||||
state,
|
||||
GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &c,
|
||||
NULL);
|
||||
*color = *c;
|
||||
gdk_rgba_free (c);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_style_context_get_border_color (GtkStyleContext *context,
|
||||
GtkStateFlags state,
|
||||
GdkRGBA *color)
|
||||
{
|
||||
GdkRGBA *c;
|
||||
|
||||
g_return_if_fail (color != NULL);
|
||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||
|
||||
gtk_style_context_get (context,
|
||||
state,
|
||||
GTK_STYLE_PROPERTY_BORDER_COLOR, &c,
|
||||
NULL);
|
||||
*color = *c;
|
||||
gdk_rgba_free (c);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_dense_cal_draw_to_buffer(GncDenseCal *dcal)
|
||||
{
|
||||
@ -930,12 +895,12 @@ gnc_dense_cal_draw_to_buffer(GncDenseCal *dcal)
|
||||
GtkStyleContext *stylectxt;
|
||||
GtkStateFlags state_flags;
|
||||
GtkAllocation alloc;
|
||||
GdkRGBA color, test_color;
|
||||
gint i;
|
||||
int maxWidth;
|
||||
PangoLayout *layout;
|
||||
GTimer *timer;
|
||||
cairo_t *cr;
|
||||
gchar *primary_color_class, *secondary_color_class, *marker_color_class;
|
||||
|
||||
timer = g_timer_new();
|
||||
g_debug("drawing");
|
||||
@ -949,22 +914,31 @@ gnc_dense_cal_draw_to_buffer(GncDenseCal *dcal)
|
||||
layout = gtk_widget_create_pango_layout(GTK_WIDGET(dcal), NULL);
|
||||
LOG_AND_RESET(timer, "create_pango_layout");
|
||||
|
||||
gdk_rgba_parse (&test_color, "rgba(0, 0, 0, 0)");
|
||||
|
||||
gtk_widget_get_allocation (GTK_WIDGET(dcal->cal_drawing_area), &alloc);
|
||||
stylectxt = gtk_widget_get_style_context (widget);
|
||||
stylectxt = gtk_widget_get_style_context (GTK_WIDGET(dcal->cal_drawing_area));
|
||||
state_flags = gtk_style_context_get_state (stylectxt);
|
||||
gnc_style_context_get_background_color (stylectxt, state_flags, &color);
|
||||
|
||||
// test for no color set
|
||||
if (gdk_rgba_equal (&color, &test_color))
|
||||
gdk_rgba_parse (&color, "white");
|
||||
gtk_style_context_add_class (stylectxt, GTK_STYLE_CLASS_CALENDAR);
|
||||
|
||||
cairo_set_source_rgb (cr, color.red, color.green, color.blue);
|
||||
cairo_rectangle (cr, 0, 0,
|
||||
gtk_render_background (stylectxt, cr, 0, 0,
|
||||
cairo_image_surface_get_width (dcal->surface),
|
||||
cairo_image_surface_get_height (dcal->surface));
|
||||
cairo_fill (cr);
|
||||
|
||||
/* get the colors */
|
||||
{
|
||||
GdkRGBA color;
|
||||
gchar *class_extension = NULL;
|
||||
|
||||
gtk_style_context_get_color (stylectxt, GTK_STATE_FLAG_NORMAL, &color);
|
||||
|
||||
if (gnc_is_dark_theme (&color))
|
||||
class_extension = "-dark";
|
||||
|
||||
primary_color_class = g_strconcat ("primary", class_extension, NULL);
|
||||
secondary_color_class = g_strconcat ("secondary", class_extension, NULL);
|
||||
marker_color_class = g_strconcat ("markers", class_extension, NULL);
|
||||
}
|
||||
|
||||
|
||||
/* Fill in alternating month colors. */
|
||||
{
|
||||
@ -978,6 +952,8 @@ gnc_dense_cal_draw_to_buffer(GncDenseCal *dcal)
|
||||
dcal->monthPositions[i].x = dcal->monthPositions[i].y = -1;
|
||||
}
|
||||
|
||||
gtk_style_context_save (stylectxt);
|
||||
|
||||
/* Paint the weeks for the upcoming N months. */
|
||||
for (i = 0; i < dcal->numMonths; i++)
|
||||
{
|
||||
@ -990,25 +966,35 @@ gnc_dense_cal_draw_to_buffer(GncDenseCal *dcal)
|
||||
for (mcListIter = mcList; mcListIter != NULL; mcListIter = mcListIter->next)
|
||||
{
|
||||
rect = (GdkRectangle*)mcListIter->data;
|
||||
color = dcal->weekColors[ i % 2 ];
|
||||
cairo_set_source_rgb (cr, color.red, color.green, color.blue);
|
||||
cairo_rectangle (cr, rect->x, rect->y,
|
||||
rect->width, rect->height);
|
||||
cairo_fill (cr);
|
||||
gtk_style_context_save (stylectxt);
|
||||
|
||||
if (i % 2 == 0)
|
||||
gtk_style_context_add_class (stylectxt, primary_color_class);
|
||||
else
|
||||
gtk_style_context_add_class (stylectxt, secondary_color_class);
|
||||
|
||||
gtk_render_background (stylectxt, cr, rect->x, rect->y, rect->width, rect->height);
|
||||
gtk_style_context_restore (stylectxt);
|
||||
}
|
||||
g_list_foreach(mcList, free_rect, NULL);
|
||||
g_list_free(mcList);
|
||||
}
|
||||
gtk_style_context_restore (stylectxt);
|
||||
}
|
||||
LOG_AND_RESET(timer, "alternating month colors");
|
||||
|
||||
|
||||
/* Highlight the marked days. */
|
||||
{
|
||||
int i;
|
||||
int x1, x2, y1, y2;
|
||||
|
||||
gdk_rgba_parse(&color, MARK_COLOR);
|
||||
cairo_set_source_rgb (cr, color.red, color.green, color.blue);
|
||||
gtk_style_context_save (stylectxt);
|
||||
gtk_style_context_add_class (stylectxt, marker_color_class);
|
||||
#if GTK_CHECK_VERSION(3,22,0)
|
||||
gtk_style_context_add_class (stylectxt, GTK_STYLE_CLASS_VIEW);
|
||||
gtk_style_context_set_state (stylectxt, GTK_STATE_FLAG_SELECTED);
|
||||
#endif
|
||||
|
||||
for (i = 0; i < dcal->numMarks; i++)
|
||||
{
|
||||
@ -1021,21 +1007,33 @@ gnc_dense_cal_draw_to_buffer(GncDenseCal *dcal)
|
||||
center_y = (y1 + y2 ) / 2;
|
||||
radius = MIN((x2 - x1), (y2 - y1)) * .75;
|
||||
|
||||
cairo_arc (cr, center_x, center_y, radius, 0.0, 2 * M_PI);
|
||||
cairo_fill (cr);
|
||||
// try to compensate for row height being odd or even
|
||||
if (((y2 -y1) % 2) == 0)
|
||||
gtk_render_background (stylectxt, cr,
|
||||
center_x - radius - 2, center_y - radius - 1,
|
||||
(radius * 2) + 4, radius * 2);
|
||||
else
|
||||
gtk_render_background (stylectxt, cr,
|
||||
center_x - radius - 2, center_y - radius,
|
||||
(radius * 2) + 4, (radius * 2) + 1);
|
||||
}
|
||||
}
|
||||
gtk_style_context_restore (stylectxt);
|
||||
}
|
||||
LOG_AND_RESET(timer, "marked days");
|
||||
|
||||
for (i = 0; i < num_cols(dcal); i++)
|
||||
{
|
||||
GdkRGBA color;
|
||||
gint x, y, w, h;
|
||||
gint j;
|
||||
|
||||
cairo_save (cr);
|
||||
pango_layout_set_text(layout, "S", -1);
|
||||
pango_layout_get_pixel_size(layout, NULL, &dcal->dayLabelHeight);
|
||||
|
||||
gdk_rgba_parse (&color, "black");
|
||||
|
||||
x = dcal->leftPadding
|
||||
+ (i * (col_width(dcal) + COL_BORDER_SIZE))
|
||||
+ dcal->label_width;
|
||||
@ -1043,12 +1041,16 @@ gnc_dense_cal_draw_to_buffer(GncDenseCal *dcal)
|
||||
w = col_width(dcal) - COL_BORDER_SIZE - dcal->label_width;
|
||||
h = col_height(dcal);
|
||||
|
||||
gtk_style_context_save (stylectxt);
|
||||
|
||||
/* draw the outside border [inside the month labels] */
|
||||
gtk_style_context_add_class (stylectxt, GTK_STYLE_CLASS_FRAME);
|
||||
|
||||
gtk_render_frame (stylectxt, cr, x, y, w + 1, h + 1);
|
||||
|
||||
gnc_style_context_get_border_color (stylectxt, state_flags, &color);
|
||||
cairo_set_source_rgb (cr, color.red, color.green, color.blue);
|
||||
cairo_set_line_width (cr, 1);
|
||||
cairo_rectangle (cr, x + 0.5, y + 0.5, w, h);
|
||||
cairo_stroke (cr);
|
||||
|
||||
/* draw the week separations */
|
||||
for (j = 0; j < num_weeks_per_col(dcal); j++)
|
||||
@ -1067,20 +1069,27 @@ gnc_dense_cal_draw_to_buffer(GncDenseCal *dcal)
|
||||
cairo_line_to (cr, dx + 0.5, y + col_height(dcal));
|
||||
cairo_stroke (cr);
|
||||
}
|
||||
cairo_restore (cr);
|
||||
gtk_style_context_restore (stylectxt);
|
||||
|
||||
/* draw the day labels */
|
||||
|
||||
/* draw the day of the week labels */
|
||||
pango_layout_set_text(layout, "88", -1);
|
||||
pango_layout_get_pixel_size(layout, &maxWidth, NULL);
|
||||
|
||||
if (dcal->x_scale > maxWidth)
|
||||
{
|
||||
gtk_style_context_save (stylectxt);
|
||||
gtk_style_context_add_class (stylectxt, GTK_STYLE_CLASS_HEADER);
|
||||
|
||||
gtk_render_background (stylectxt, cr, x, y - dcal->dayLabelHeight, (day_width(dcal) * 7) + 1, dcal->dayLabelHeight);
|
||||
|
||||
for (j = 0; j < 7; j++)
|
||||
{
|
||||
int day_label_width;
|
||||
gint label_x_offset, label_y_offset;
|
||||
gint day_label_str_len = 3;
|
||||
gint day_label_str_len = 4;
|
||||
gchar day_label_str[day_label_str_len+1];
|
||||
|
||||
day_label(day_label_str, day_label_str_len, (j + dcal->week_starts_monday) % 7);
|
||||
pango_layout_set_text(layout, day_label_str, -1);
|
||||
pango_layout_get_pixel_size(layout, &day_label_width, NULL);
|
||||
@ -1090,18 +1099,31 @@ gnc_dense_cal_draw_to_buffer(GncDenseCal *dcal)
|
||||
- (day_label_width / 2);
|
||||
label_y_offset = y - dcal->dayLabelHeight;
|
||||
pango_layout_set_text(layout, day_label_str, -1);
|
||||
gtk_style_context_get_color (stylectxt, state_flags, &color);
|
||||
cairo_set_source_rgb (cr, color.red, color.green, color.blue);
|
||||
cairo_move_to (cr, label_x_offset, label_y_offset);
|
||||
pango_cairo_show_layout (cr, layout);
|
||||
gtk_render_layout (stylectxt, cr, label_x_offset, label_y_offset, layout);
|
||||
}
|
||||
gtk_style_context_restore (stylectxt);
|
||||
}
|
||||
}
|
||||
LOG_AND_RESET(timer, "lines and labels");
|
||||
|
||||
|
||||
/* Month labels. */
|
||||
{
|
||||
gint i;
|
||||
gint x_offset = dcal->label_height - (dcal->leftPadding * 2);
|
||||
|
||||
gtk_style_context_save (stylectxt);
|
||||
gtk_style_context_add_class (stylectxt, GTK_STYLE_CLASS_HEADER);
|
||||
|
||||
for (i = 0; i < 12; i++)
|
||||
{
|
||||
if (dcal->monthPositions[i].x == -1)
|
||||
break;
|
||||
|
||||
gtk_render_background (stylectxt, cr, dcal->monthPositions[i].x + x_offset + 1, dcal->topPadding,
|
||||
dcal->dayLabelHeight, col_height(dcal) + dcal->dayLabelHeight + 1);
|
||||
}
|
||||
|
||||
for (i = 0; i < 12; i++)
|
||||
{
|
||||
guint idx;
|
||||
@ -1110,19 +1132,18 @@ gnc_dense_cal_draw_to_buffer(GncDenseCal *dcal)
|
||||
break;
|
||||
idx = (dcal->month - 1 + i) % 12;
|
||||
pango_layout_set_text(layout, month_name(idx), -1);
|
||||
|
||||
cairo_save (cr);
|
||||
cairo_translate (cr, dcal->leftPadding + dcal->monthPositions[i].x,
|
||||
dcal->monthPositions[i].y);
|
||||
cairo_move_to (cr, 0, 0);
|
||||
cairo_translate (cr, dcal->monthPositions[i].x + x_offset, dcal->monthPositions[i].y);
|
||||
cairo_rotate (cr, -G_PI / 2.);
|
||||
pango_cairo_show_layout (cr, layout);
|
||||
gtk_render_layout (stylectxt, cr, 0, 0, layout);
|
||||
cairo_restore (cr);
|
||||
}
|
||||
gtk_style_context_restore (stylectxt);
|
||||
}
|
||||
LOG_AND_RESET(timer, "month labels");
|
||||
|
||||
/* Try the per-day strings [dates] */
|
||||
|
||||
/* Day number strings [dates] */
|
||||
{
|
||||
GDate d, eoc;
|
||||
gint doc;
|
||||
@ -1130,6 +1151,10 @@ gnc_dense_cal_draw_to_buffer(GncDenseCal *dcal)
|
||||
gint numW, numH;
|
||||
gint x1, y1, x2, y2, w, h;
|
||||
|
||||
gtk_style_context_save (stylectxt);
|
||||
gtk_style_context_add_class (stylectxt, "day-number");
|
||||
|
||||
cairo_save (cr);
|
||||
g_date_set_dmy(&d, 1, dcal->month, dcal->year);
|
||||
eoc = d;
|
||||
g_date_add_months(&eoc, dcal->numMonths);
|
||||
@ -1142,10 +1167,10 @@ gnc_dense_cal_draw_to_buffer(GncDenseCal *dcal)
|
||||
pango_layout_get_pixel_size(layout, &numW, &numH);
|
||||
w = (x2 - x1) + 1;
|
||||
h = (y2 - y1) + 1;
|
||||
cairo_move_to (cr, x1 + (w / 2) - (numW / 2),
|
||||
y1 + (h / 2) - (numH / 2));
|
||||
pango_cairo_show_layout (cr, layout);
|
||||
gtk_render_layout (stylectxt, cr, x1 + (w / 2) - (numW / 2), y1 + (h / 2) - (numH / 2), layout);
|
||||
}
|
||||
cairo_restore (cr);
|
||||
gtk_style_context_restore (stylectxt);
|
||||
}
|
||||
LOG_AND_RESET(timer, "dates");
|
||||
|
||||
@ -1158,6 +1183,10 @@ gnc_dense_cal_draw_to_buffer(GncDenseCal *dcal)
|
||||
|
||||
LOG_AND_RESET(timer, "queue draw");
|
||||
|
||||
g_free (primary_color_class);
|
||||
g_free (secondary_color_class);
|
||||
g_free (marker_color_class);
|
||||
|
||||
g_object_unref(layout);
|
||||
cairo_destroy (cr);
|
||||
|
||||
|
@ -44,13 +44,6 @@ typedef struct _gdc_month_coords
|
||||
gint x, y;
|
||||
} gdc_month_coords;
|
||||
|
||||
enum GDC_COLORS
|
||||
{
|
||||
MONTH_THIS = 0,
|
||||
MONTH_THAT,
|
||||
MAX_COLORS
|
||||
};
|
||||
|
||||
struct _GncDenseCal
|
||||
{
|
||||
GtkBox widget;
|
||||
@ -84,8 +77,6 @@ struct _GncDenseCal
|
||||
|
||||
gdc_month_coords monthPositions[12];
|
||||
|
||||
GdkRGBA weekColors[MAX_COLORS];
|
||||
|
||||
guint label_width;
|
||||
guint label_height;
|
||||
gint dayLabelHeight;
|
||||
|
@ -172,7 +172,7 @@ gnc_configure_date_completion (void)
|
||||
void
|
||||
gnc_add_css_file (void)
|
||||
{
|
||||
GtkCssProvider *provider_user, *provider_app;
|
||||
GtkCssProvider *provider_user, *provider_app, *provider_fallback;
|
||||
GdkDisplay *display;
|
||||
GdkScreen *screen;
|
||||
const gchar *var;
|
||||
@ -182,13 +182,20 @@ gnc_add_css_file (void)
|
||||
|
||||
provider_user = gtk_css_provider_new ();
|
||||
provider_app = gtk_css_provider_new ();
|
||||
provider_fallback = gtk_css_provider_new ();
|
||||
display = gdk_display_get_default ();
|
||||
screen = gdk_display_get_default_screen (display);
|
||||
|
||||
gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider_fallback), GTK_STYLE_PROVIDER_PRIORITY_FALLBACK);
|
||||
gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider_app), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider_user), GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
|
||||
if (pkgdatadir)
|
||||
{
|
||||
str = g_build_filename (pkgdatadir, "ui", "gnucash-fallback.css", (char *)NULL);
|
||||
gtk_css_provider_load_from_path (provider_fallback, str, &error);
|
||||
g_free (str);
|
||||
|
||||
str = g_build_filename (pkgdatadir, "ui", "gnucash.css", (char *)NULL);
|
||||
gtk_css_provider_load_from_path (provider_app, str, &error);
|
||||
g_free (str);
|
||||
@ -204,6 +211,7 @@ gnc_add_css_file (void)
|
||||
}
|
||||
g_object_unref (provider_user);
|
||||
g_object_unref (provider_app);
|
||||
g_object_unref (provider_fallback);
|
||||
}
|
||||
|
||||
#ifdef MAC_INTEGRATION
|
||||
|
@ -223,3 +223,74 @@ gnc_cbwe_require_list_item (GtkComboBox *cbwe)
|
||||
|
||||
g_object_set_data(G_OBJECT(cbwe), CHANGED_ID, GINT_TO_POINTER(id));
|
||||
}
|
||||
|
||||
/** Test to see if fg_color is a light one which should be a foreground
|
||||
* one and hence would be on a dark background
|
||||
*
|
||||
* @param fg_color The foreground color to test.
|
||||
*/
|
||||
gboolean
|
||||
gnc_is_dark_theme (GdkRGBA *fg_color)
|
||||
{
|
||||
gboolean is_dark = FALSE;
|
||||
|
||||
// Counting the perceptive luminance - human eye favors green color...
|
||||
double lightness = (0.299 * fg_color->red + 0.587 * fg_color->green + 0.114 * fg_color->blue);
|
||||
|
||||
if (lightness > 0.5)
|
||||
is_dark = TRUE;
|
||||
|
||||
return is_dark;
|
||||
}
|
||||
|
||||
/** Wrapper to get the background color of a widget for a given state
|
||||
*
|
||||
* @param context Style context of widget.
|
||||
*
|
||||
* @param state The stateflag of the widget.
|
||||
*
|
||||
* @param color The returned background color of the widget.
|
||||
*/
|
||||
void
|
||||
gnc_style_context_get_background_color (GtkStyleContext *context,
|
||||
GtkStateFlags state,
|
||||
GdkRGBA *color)
|
||||
{
|
||||
GdkRGBA *c;
|
||||
|
||||
g_return_if_fail (color != NULL);
|
||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||
|
||||
gtk_style_context_get (context,
|
||||
state,
|
||||
GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &c,
|
||||
NULL);
|
||||
*color = *c;
|
||||
gdk_rgba_free (c);
|
||||
}
|
||||
|
||||
/** Wrapper to get the border color of a widget for a given state
|
||||
*
|
||||
* @param context Style context of widget.
|
||||
*
|
||||
* @param state The stateflag of the widget.
|
||||
*
|
||||
* @param color The returned border color of the widget.
|
||||
*/
|
||||
void
|
||||
gnc_style_context_get_border_color (GtkStyleContext *context,
|
||||
GtkStateFlags state,
|
||||
GdkRGBA *color)
|
||||
{
|
||||
GdkRGBA *c;
|
||||
|
||||
g_return_if_fail (color != NULL);
|
||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||
|
||||
gtk_style_context_get (context,
|
||||
state,
|
||||
GTK_STYLE_PROPERTY_BORDER_COLOR, &c,
|
||||
NULL);
|
||||
*color = *c;
|
||||
gdk_rgba_free (c);
|
||||
}
|
||||
|
@ -45,6 +45,14 @@ void gnc_cbwe_set_by_string(GtkComboBox *cbwe, const gchar *text);
|
||||
void gnc_cbwe_add_completion (GtkComboBox *cbwe);
|
||||
void gnc_cbwe_require_list_item (GtkComboBox *cbwe);
|
||||
|
||||
gboolean gnc_is_dark_theme (GdkRGBA *fg_color);
|
||||
void gnc_style_context_get_background_color (GtkStyleContext *context,
|
||||
GtkStateFlags state,
|
||||
GdkRGBA *color);
|
||||
void gnc_style_context_get_border_color (GtkStyleContext *context,
|
||||
GtkStateFlags state,
|
||||
GdkRGBA *color);
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* GNC_GTK_UTILS_H */
|
||||
|
@ -106,6 +106,17 @@ typedef struct GncTreeModelAccountPrivate
|
||||
/************************************************************/
|
||||
/* Account Tree Model - Misc Functions */
|
||||
/************************************************************/
|
||||
static gchar*
|
||||
get_negative_color (void)
|
||||
{
|
||||
GdkRGBA color;
|
||||
GtkWidget *label = gtk_label_new ("Color");
|
||||
GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET(label));
|
||||
gtk_style_context_add_class (context, "negative-numbers");
|
||||
gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &color);
|
||||
|
||||
return gdk_rgba_to_string (&color);
|
||||
}
|
||||
|
||||
/** Tell the GncTreeModelAccount code to update the color that it will
|
||||
* use for negative numbers. This function will iterate over all
|
||||
@ -124,7 +135,7 @@ gnc_tree_model_account_update_color (gpointer gsettings, gchar *key, gpointer us
|
||||
model = user_data;
|
||||
priv = GNC_TREE_MODEL_ACCOUNT_GET_PRIVATE(model);
|
||||
use_red = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED);
|
||||
priv->negative_color = use_red ? "red" : NULL;
|
||||
priv->negative_color = use_red ? get_negative_color () : NULL;
|
||||
}
|
||||
/************************************************************/
|
||||
/* g_object required functions */
|
||||
@ -205,7 +216,7 @@ gnc_tree_model_account_init (GncTreeModelAccount *model)
|
||||
priv = GNC_TREE_MODEL_ACCOUNT_GET_PRIVATE(model);
|
||||
priv->book = NULL;
|
||||
priv->root = NULL;
|
||||
priv->negative_color = red ? "red" : NULL;
|
||||
priv->negative_color = red ? get_negative_color () : NULL;
|
||||
|
||||
gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED,
|
||||
gnc_tree_model_account_update_color,
|
||||
|
@ -1017,7 +1017,7 @@ gnc_tree_view_split_reg_new_with_model (GncTreeModelSplitReg *model)
|
||||
view->help_text = g_strdup ("Help Text");
|
||||
|
||||
/* Set the grid lines to be solid */
|
||||
gnc_widget_set_style_context (GTK_WIDGET(view), "treeview_grid_lines");
|
||||
gnc_widget_set_style_context (GTK_WIDGET(view), "register2_grid_lines");
|
||||
|
||||
/* TreeView Grid lines */
|
||||
if (view->priv->use_horizontal_lines)
|
||||
|
@ -247,9 +247,6 @@ gnc_tree_view_init (GncTreeView *view, GncTreeViewClass *klass)
|
||||
priv->sort_column_changed_cb_id = 0;
|
||||
priv->size_allocate_cb_id = 0;
|
||||
|
||||
/* Ask gtk to help the user keep track of rows. */
|
||||
g_object_set(view, "rules-hint", TRUE, NULL);
|
||||
|
||||
// Set the style context for this page so it can be easily manipulated with css
|
||||
gnc_widget_set_style_context (GTK_WIDGET(view), "GncTreeView");
|
||||
|
||||
@ -276,9 +273,12 @@ gnc_tree_view_init (GncTreeView *view, GncTreeViewClass *klass)
|
||||
/* Create the last column which contains the column selection
|
||||
* widget. gnc_tree_view_add_text_column will do most of the
|
||||
* work. */
|
||||
icon = gtk_image_new_from_icon_name ("go-down",
|
||||
GTK_ICON_SIZE_SMALL_TOOLBAR);
|
||||
icon = gtk_image_new_from_icon_name ("go-down", GTK_ICON_SIZE_SMALL_TOOLBAR);
|
||||
gtk_widget_show(icon);
|
||||
|
||||
g_signal_connect (G_OBJECT (icon), "draw",
|
||||
G_CALLBACK (gnc_draw_arrow_cb), GINT_TO_POINTER(1));
|
||||
|
||||
gtk_widget_get_preferred_size(icon, &requisition, NULL);
|
||||
column = gnc_tree_view_add_text_column (view, NULL, NULL, NULL, NULL,
|
||||
-1, -1, NULL);
|
||||
|
@ -16,6 +16,7 @@ SET(gnome_utils_ui_DIST_local
|
||||
Makefile.am
|
||||
osx_accel_map
|
||||
gnucash.css
|
||||
gnucash-fallback.css
|
||||
)
|
||||
|
||||
SET_DIST_LIST(gnome_utils_ui_DIST ${gnome_utils_ui_DIST_local})
|
||||
|
@ -4,6 +4,7 @@ ui_DATA = \
|
||||
gnc-windows-menu-ui.xml \
|
||||
gnc-windows-menu-ui-quartz.xml \
|
||||
osx_accel_map \
|
||||
gnucash.css
|
||||
gnucash.css \
|
||||
gnucash-fallback.css
|
||||
|
||||
EXTRA_DIST = $(ui_DATA) CMakeLists.txt
|
||||
|
83
gnucash/gnome-utils/ui/gnucash-fallback.css
Normal file
83
gnucash/gnome-utils/ui/gnucash-fallback.css
Normal file
@ -0,0 +1,83 @@
|
||||
/* Note: Widgets obtained from Glade files will not be addressable
|
||||
unless they have been named or have style classes added. Only
|
||||
the widget type can be configured unless they are named in code */
|
||||
|
||||
|
||||
/* Import Matcher, amount of intervention required */
|
||||
@define-color intervention-required_bg_color brown1;
|
||||
@define-color intervention-probably-required_bg_color gold;
|
||||
@define-color intervention-not-required_bg_color DarkSeaGreen1;
|
||||
|
||||
.intervention-required {
|
||||
background-color: @intervention-required_bg_color;
|
||||
}
|
||||
|
||||
.intervention-probably-required {
|
||||
background-color: @intervention-probably-required_bg_color;
|
||||
}
|
||||
|
||||
.intervention-not-required {
|
||||
background-color: @intervention-not-required_bg_color;
|
||||
}
|
||||
|
||||
.intervention-required-dark {
|
||||
background-color: shade (@intervention-required_bg_color, 0.7);
|
||||
}
|
||||
|
||||
.intervention-probably-required-dark {
|
||||
background-color: shade (@intervention-probably-required_bg_color, 0.8);
|
||||
}
|
||||
|
||||
.intervention-not-required-dark {
|
||||
background-color: shade (@intervention-not-required_bg_color, 0.3);
|
||||
}
|
||||
|
||||
/* Negative value label colors */
|
||||
.default-color {
|
||||
color: currentColor;
|
||||
}
|
||||
|
||||
.negative-numbers {
|
||||
color: rgb(75%, 0%, 0%);
|
||||
}
|
||||
|
||||
/* Register2 grid lines color */
|
||||
.register2_grid_lines {
|
||||
border-color: black;
|
||||
}
|
||||
|
||||
/* Make label more important */
|
||||
.emphasize-label {
|
||||
font-size: large;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* The Dense Calendar defaults */
|
||||
@define-color primary_bg_color lavender;
|
||||
@define-color secondary_bg_color SlateGray1;
|
||||
@define-color marker_bg_color yellow;
|
||||
|
||||
*.primary {
|
||||
background-color: @primary_bg_color;
|
||||
}
|
||||
|
||||
*.primary-dark {
|
||||
background-color: shade (@primary_bg_color, 0.7);
|
||||
}
|
||||
|
||||
*.secondary {
|
||||
background-color: @secondary_bg_color;
|
||||
}
|
||||
|
||||
*.secondary-dark {
|
||||
background-color: shade (@secondary_bg_color, 0.7);
|
||||
}
|
||||
|
||||
*.markers {
|
||||
background-color: @marker_bg_color;
|
||||
}
|
||||
|
||||
*.markers-dark {
|
||||
background-color: shade (@marker_bg_color, 0.8);
|
||||
}
|
||||
|
@ -1,37 +1,4 @@
|
||||
/* Note: Widgets obtained from Glade files will not be addressable
|
||||
directly by name as these are not brought in when loaded, only
|
||||
unless they have been named or have style classes added. Only
|
||||
the widget type can be configured unless they are named in code */
|
||||
|
||||
/* Import Matcher # import-main-matcher.*/
|
||||
.color_back_red {
|
||||
background-color: brown1;
|
||||
}
|
||||
|
||||
.color_back_yellow {
|
||||
background-color: gold;
|
||||
}
|
||||
|
||||
.color_back_green {
|
||||
background-color: DarkSeaGreen1;
|
||||
}
|
||||
|
||||
/* label colors # dialog-utils.c */
|
||||
.css_default_color {
|
||||
color: currentColor;
|
||||
}
|
||||
|
||||
.css_red_color {
|
||||
color: rgb(75%, 0%, 0%);
|
||||
}
|
||||
|
||||
/* Set the grid lines to be solid # gnc-tree-view-split-reg.c */
|
||||
.treeview_grid_lines {
|
||||
border-color: black;
|
||||
}
|
||||
|
||||
/* Increase label size # dialog-account.c */
|
||||
.primary_label_size {
|
||||
font-size: large;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,8 @@ typedef struct
|
||||
int component_id;
|
||||
int cnxn_id;
|
||||
gboolean combo_popped;
|
||||
gboolean show_negative_color;
|
||||
gchar *negative_color;
|
||||
} GNCMainSummary;
|
||||
|
||||
#define WINDOW_SUMMARYBAR_CM_CLASS "summary-bar"
|
||||
@ -327,6 +329,8 @@ enum
|
||||
COLUMN_ASSETS_VALUE,
|
||||
COLUMN_PROFITS,
|
||||
COLUMN_PROFITS_VALUE,
|
||||
COLUMN_ASSETS_NEG,
|
||||
COLUMN_PROFITS_NEG,
|
||||
N_COLUMNS
|
||||
};
|
||||
|
||||
@ -417,8 +421,10 @@ gnc_main_window_summary_refresh (GNCMainSummary * summary)
|
||||
COLUMN_MNEMONIC_TYPE, total_mode_label,
|
||||
COLUMN_ASSETS, _("Net Assets:"),
|
||||
COLUMN_ASSETS_VALUE, asset_amount_string,
|
||||
COLUMN_ASSETS_NEG, gnc_numeric_negative_p(currency_accum->assets),
|
||||
COLUMN_PROFITS, _("Profits:"),
|
||||
COLUMN_PROFITS_VALUE, profit_amount_string,
|
||||
COLUMN_PROFITS_NEG, gnc_numeric_negative_p(currency_accum->profits),
|
||||
-1);
|
||||
g_free(total_mode_label);
|
||||
}
|
||||
@ -439,11 +445,47 @@ gnc_main_window_summary_refresh (GNCMainSummary * summary)
|
||||
g_list_free(currency_list);
|
||||
}
|
||||
|
||||
static gchar*
|
||||
get_negative_color (void)
|
||||
{
|
||||
GdkRGBA color;
|
||||
GdkRGBA *rgba;
|
||||
gchar *color_str;
|
||||
GtkWidget *label = gtk_label_new ("Color");
|
||||
GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET(label));
|
||||
gtk_style_context_add_class (context, "negative-numbers");
|
||||
gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &color);
|
||||
rgba = gdk_rgba_copy (&color);
|
||||
|
||||
color_str = g_strdup_printf ("#%02X%02X%02X",
|
||||
(int)(0.5 + CLAMP (rgba->red, 0., 1.) * 255.),
|
||||
(int)(0.5 + CLAMP (rgba->green, 0., 1.) * 255.),
|
||||
(int)(0.5 + CLAMP (rgba->blue, 0., 1.) * 255.));
|
||||
gdk_rgba_free (rgba);
|
||||
return color_str;
|
||||
}
|
||||
|
||||
static void
|
||||
summarybar_update_color (gpointer gsettings, gchar *key, gpointer user_data)
|
||||
{
|
||||
GNCMainSummary *summary = user_data;
|
||||
|
||||
summary->negative_color = get_negative_color();
|
||||
summary->show_negative_color = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED);
|
||||
|
||||
gnc_main_window_summary_refresh (summary);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_main_window_summary_destroy_cb(GNCMainSummary *summary, gpointer data)
|
||||
{
|
||||
gnc_prefs_remove_cb_by_id (GNC_PREFS_GROUP, summary->cnxn_id);
|
||||
gnc_unregister_gui_component(summary->component_id);
|
||||
|
||||
gnc_prefs_remove_cb_by_func(GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED,
|
||||
summarybar_update_color, summary);
|
||||
|
||||
g_free (summary->negative_color);
|
||||
g_free (summary);
|
||||
}
|
||||
|
||||
@ -461,12 +503,57 @@ prefs_changed_cb (gpointer prefs, gchar *pref, gpointer user_data)
|
||||
gnc_main_window_summary_refresh(summary);
|
||||
}
|
||||
|
||||
static gchar*
|
||||
check_string_for_markup (gchar *string)
|
||||
{
|
||||
gchar **strings;
|
||||
gchar *ret_string = g_strdup (string);
|
||||
|
||||
if (g_strrstr (ret_string, "&") != NULL)
|
||||
{
|
||||
strings = g_strsplit (ret_string, "&", -1);
|
||||
g_free (ret_string);
|
||||
ret_string = g_strjoinv ("&", strings);
|
||||
g_strfreev (strings);
|
||||
}
|
||||
if (g_strrstr (ret_string, "<") != NULL)
|
||||
{
|
||||
strings = g_strsplit (ret_string, "<", -1);
|
||||
g_free (ret_string);
|
||||
ret_string = g_strjoinv ("<", strings);
|
||||
g_strfreev (strings);
|
||||
}
|
||||
if (g_strrstr (ret_string, ">") != NULL)
|
||||
{
|
||||
strings = g_strsplit (ret_string, ">", -1);
|
||||
g_free (ret_string);
|
||||
ret_string = g_strjoinv (">", strings);
|
||||
g_strfreev (strings);
|
||||
}
|
||||
if (g_strrstr (ret_string, "\"") != NULL)
|
||||
{
|
||||
strings = g_strsplit (ret_string, "\"", -1);
|
||||
g_free (ret_string);
|
||||
ret_string = g_strjoinv (""", strings);
|
||||
g_strfreev (strings);
|
||||
}
|
||||
if (g_strrstr (ret_string, "'") != NULL)
|
||||
{
|
||||
strings = g_strsplit (ret_string, "'", -1);
|
||||
g_free (ret_string);
|
||||
ret_string = g_strjoinv ("'", strings);
|
||||
g_strfreev (strings);
|
||||
}
|
||||
return ret_string;
|
||||
}
|
||||
|
||||
static void
|
||||
cdf (GtkCellLayout *cell_layout, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter,
|
||||
gpointer user_data)
|
||||
{
|
||||
GNCMainSummary * summary = user_data;
|
||||
gchar *type, *assets, *assets_val, *profits, *profits_val;
|
||||
gboolean assets_neg, profits_neg;
|
||||
gint viewcol;
|
||||
|
||||
viewcol = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "view_column"));
|
||||
@ -481,23 +568,37 @@ cdf (GtkCellLayout *cell_layout, GtkCellRenderer *cell, GtkTreeModel *tree_model
|
||||
COLUMN_ASSETS, &assets,
|
||||
COLUMN_ASSETS_VALUE, &assets_val,
|
||||
COLUMN_PROFITS, &profits,
|
||||
COLUMN_PROFITS_VALUE, &profits_val, -1);
|
||||
COLUMN_PROFITS_VALUE, &profits_val,
|
||||
COLUMN_ASSETS_NEG, &assets_neg,
|
||||
COLUMN_PROFITS_NEG, &profits_neg, -1);
|
||||
|
||||
if (viewcol == 0)
|
||||
g_object_set (cell, "text", type, NULL);
|
||||
|
||||
if (viewcol == 2)
|
||||
{
|
||||
gchar *a_string = g_strconcat (assets, " ", assets_val, NULL);
|
||||
g_object_set (cell, "text", a_string, NULL);
|
||||
gchar *a_string, *checked_string = check_string_for_markup (assets_val);
|
||||
if ((summary->show_negative_color == TRUE) && (assets_neg == TRUE))
|
||||
a_string = g_strconcat (assets, " <span foreground='", summary->negative_color, "'>", checked_string, "</span>", NULL);
|
||||
else
|
||||
a_string = g_strconcat (assets, " ", checked_string, NULL);
|
||||
|
||||
g_object_set (cell, "markup", a_string, NULL);
|
||||
g_free (a_string);
|
||||
g_free (checked_string);
|
||||
}
|
||||
|
||||
if (viewcol == 4)
|
||||
{
|
||||
gchar *p_string = g_strconcat (profits, " ", profits_val, NULL);
|
||||
g_object_set (cell, "text", p_string, NULL);
|
||||
gchar *p_string, *checked_string = check_string_for_markup (profits_val);
|
||||
if ((summary->show_negative_color == TRUE) && (profits_neg == TRUE))
|
||||
p_string = g_strconcat (profits, " <span foreground='", summary->negative_color, "'>", checked_string, "</span>", NULL);
|
||||
else
|
||||
p_string = g_strconcat (profits, " ", checked_string, NULL);
|
||||
|
||||
g_object_set (cell, "markup", p_string, NULL);
|
||||
g_free (p_string);
|
||||
g_free (checked_string);
|
||||
}
|
||||
|
||||
g_free (type);
|
||||
@ -529,17 +630,24 @@ gnc_main_window_summary_new (void)
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_STRING);
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_BOOLEAN,
|
||||
G_TYPE_BOOLEAN);
|
||||
|
||||
retval->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
|
||||
gtk_box_set_homogeneous (GTK_BOX (retval->hbox), FALSE);
|
||||
|
||||
// Set the style context for this widget so it can be easily manipulated with css
|
||||
gnc_widget_set_style_context (GTK_WIDGET(retval->hbox), "GncSummaryBar");
|
||||
gnc_widget_set_style_context (GTK_WIDGET(retval->hbox), "summary-bar");
|
||||
|
||||
retval->totals_combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (retval->datamodel));
|
||||
g_object_unref (retval->datamodel);
|
||||
|
||||
retval->negative_color = get_negative_color();
|
||||
retval->show_negative_color = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED);
|
||||
gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED,
|
||||
summarybar_update_color, retval);
|
||||
|
||||
retval->component_id = gnc_register_gui_component (WINDOW_SUMMARYBAR_CM_CLASS,
|
||||
summarybar_refresh_handler,
|
||||
NULL, retval);
|
||||
@ -553,7 +661,7 @@ gnc_main_window_summary_new (void)
|
||||
|
||||
retval->combo_popped = FALSE;
|
||||
|
||||
for (i = 0; i <= N_COLUMNS; i += 2)
|
||||
for (i = 0; i <= N_COLUMNS - 2; i += 2)
|
||||
{
|
||||
textRenderer = GTK_CELL_RENDERER(gtk_cell_renderer_text_new());
|
||||
|
||||
|
@ -1004,7 +1004,7 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEventBox" id="red">
|
||||
<object class="GtkEventBox" id="intervention_required_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
@ -1021,7 +1021,7 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEventBox" id="yellow">
|
||||
<object class="GtkEventBox" id="intervention_probably_required_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
@ -1038,7 +1038,7 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEventBox" id="green">
|
||||
<object class="GtkEventBox" id="intervention_not_required_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "gnc-ui.h"
|
||||
#include "gnc-ui-util.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-gtk-utils.h"
|
||||
#include "import-settings.h"
|
||||
#include "import-match-picker.h"
|
||||
#include "import-backend.h"
|
||||
@ -60,6 +61,7 @@ struct _main_matcher_info
|
||||
GtkTreeView *view;
|
||||
GNCImportSettings *user_settings;
|
||||
int selected_row;
|
||||
gboolean dark_theme;
|
||||
GNCTransactionProcessedCB transaction_processed_cb;
|
||||
gpointer user_data;
|
||||
GNCImportPendingMatches *pending_matches;
|
||||
@ -82,9 +84,9 @@ enum downloaded_cols
|
||||
NUM_DOWNLOADED_COLS
|
||||
};
|
||||
|
||||
#define COLOR_RED "brown1"
|
||||
#define COLOR_YELLOW "gold"
|
||||
#define COLOR_GREEN "DarkSeaGreen1"
|
||||
#define CSS_INT_REQUIRED_CLASS "intervention-required"
|
||||
#define CSS_INT_PROB_REQUIRED_CLASS "intervention-probably-required"
|
||||
#define CSS_INT_NOT_REQUIRED_CLASS "intervention-not-required"
|
||||
|
||||
static QofLogModule log_module = GNC_MOD_IMPORT;
|
||||
|
||||
@ -206,6 +208,8 @@ on_matcher_help_clicked (GtkButton *button, gpointer user_data)
|
||||
GNCImportMainMatcher *info = user_data;
|
||||
GtkBuilder *builder;
|
||||
GtkWidget *help_dialog, *box;
|
||||
gchar *int_required_class, *int_prob_required_class, *int_not_required_class;
|
||||
gchar *class_extension = NULL;
|
||||
|
||||
builder = gtk_builder_new();
|
||||
gnc_builder_add_from_file (builder, "dialog-import.glade", "textbuffer2");
|
||||
@ -214,14 +218,21 @@ on_matcher_help_clicked (GtkButton *button, gpointer user_data)
|
||||
gnc_builder_add_from_file (builder, "dialog-import.glade", "textbuffer5");
|
||||
gnc_builder_add_from_file (builder, "dialog-import.glade", "matcher_help_dialog");
|
||||
|
||||
box = GTK_WIDGET(gtk_builder_get_object (builder, "red"));
|
||||
gnc_widget_set_style_context (GTK_WIDGET(box), "color_back_red");
|
||||
if (info->dark_theme == TRUE)
|
||||
class_extension = "-dark";
|
||||
|
||||
box = GTK_WIDGET(gtk_builder_get_object (builder, "yellow"));
|
||||
gnc_widget_set_style_context (GTK_WIDGET(box), "color_back_yellow");
|
||||
int_required_class = g_strconcat (CSS_INT_REQUIRED_CLASS, class_extension, NULL);
|
||||
int_prob_required_class = g_strconcat (CSS_INT_PROB_REQUIRED_CLASS, class_extension, NULL);
|
||||
int_not_required_class = g_strconcat (CSS_INT_NOT_REQUIRED_CLASS, class_extension, NULL);
|
||||
|
||||
box = GTK_WIDGET(gtk_builder_get_object (builder, "green"));
|
||||
gnc_widget_set_style_context (GTK_WIDGET(box), "color_back_green");
|
||||
box = GTK_WIDGET(gtk_builder_get_object (builder, "intervention_required_box"));
|
||||
gnc_widget_set_style_context (GTK_WIDGET(box), int_required_class);
|
||||
|
||||
box = GTK_WIDGET(gtk_builder_get_object (builder, "intervention_probably_required_box"));
|
||||
gnc_widget_set_style_context (GTK_WIDGET(box), int_prob_required_class);
|
||||
|
||||
box = GTK_WIDGET(gtk_builder_get_object (builder, "intervention_not_required_box"));
|
||||
gnc_widget_set_style_context (GTK_WIDGET(box), int_not_required_class);
|
||||
|
||||
help_dialog = GTK_WIDGET(gtk_builder_get_object (builder, "matcher_help_dialog"));
|
||||
gtk_window_set_transient_for(GTK_WINDOW(help_dialog),
|
||||
@ -232,6 +243,10 @@ on_matcher_help_clicked (GtkButton *button, gpointer user_data)
|
||||
|
||||
g_object_unref(G_OBJECT(builder));
|
||||
|
||||
g_free (int_required_class);
|
||||
g_free (int_prob_required_class);
|
||||
g_free (int_not_required_class);
|
||||
|
||||
gtk_widget_show(help_dialog);
|
||||
}
|
||||
|
||||
@ -398,10 +413,6 @@ add_text_column(GtkTreeView *view, const gchar *title, int col_num)
|
||||
GtkTreeViewColumn *column;
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
g_object_set(G_OBJECT(renderer),
|
||||
"foreground", "black",
|
||||
"foreground-set", TRUE,
|
||||
NULL);
|
||||
column = gtk_tree_view_column_new_with_attributes
|
||||
(title, renderer,
|
||||
"text", col_num,
|
||||
@ -481,10 +492,6 @@ gnc_gen_trans_init_view (GNCImportMainMatcher *info,
|
||||
"cell-background", DOWNLOADED_COL_COLOR,
|
||||
NULL);
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
g_object_set(G_OBJECT(renderer),
|
||||
"foreground", "black",
|
||||
"foreground-set", TRUE,
|
||||
NULL);
|
||||
gtk_tree_view_column_pack_start(column, renderer, TRUE);
|
||||
gtk_tree_view_column_set_attributes(column, renderer,
|
||||
"text", DOWNLOADED_COL_ACTION_INFO,
|
||||
@ -505,6 +512,8 @@ gnc_gen_trans_init_view (GNCImportMainMatcher *info,
|
||||
G_CALLBACK(gnc_gen_trans_row_changed_cb), info);
|
||||
}
|
||||
|
||||
|
||||
|
||||
GNCImportMainMatcher *gnc_gen_trans_list_new (GtkWidget *parent,
|
||||
const gchar* heading,
|
||||
gboolean all_from_same_account,
|
||||
@ -515,6 +524,8 @@ GNCImportMainMatcher *gnc_gen_trans_list_new (GtkWidget *parent,
|
||||
GtkWidget *heading_label;
|
||||
GtkWidget *box, *pbox;
|
||||
gboolean show_update;
|
||||
GtkStyleContext *stylectxt;
|
||||
GdkRGBA color;
|
||||
|
||||
info = g_new0 (GNCImportMainMatcher, 1);
|
||||
info->pending_matches = gnc_import_PendingMatches_new();
|
||||
@ -523,6 +534,10 @@ GNCImportMainMatcher *gnc_gen_trans_list_new (GtkWidget *parent,
|
||||
info->user_settings = gnc_import_Settings_new ();
|
||||
gnc_import_Settings_set_match_date_hardlimit (info->user_settings, match_date_hardlimit);
|
||||
|
||||
stylectxt = gtk_widget_get_style_context (GTK_WIDGET(parent));
|
||||
gtk_style_context_get_color (stylectxt, GTK_STATE_FLAG_NORMAL, &color);
|
||||
info->dark_theme = gnc_is_dark_theme (&color);
|
||||
|
||||
/* Initialize the GtkDialog. */
|
||||
builder = gtk_builder_new();
|
||||
gnc_builder_add_from_file (builder, "dialog-import.glade", "transaction_matcher_dialog");
|
||||
@ -578,6 +593,8 @@ GNCImportMainMatcher * gnc_gen_trans_assist_new (GtkWidget *parent,
|
||||
GtkWidget *heading_label;
|
||||
GtkWidget *box;
|
||||
gboolean show_update;
|
||||
GtkStyleContext *stylectxt;
|
||||
GdkRGBA color;
|
||||
|
||||
info = g_new0 (GNCImportMainMatcher, 1);
|
||||
info->pending_matches = gnc_import_PendingMatches_new();
|
||||
@ -586,6 +603,10 @@ GNCImportMainMatcher * gnc_gen_trans_assist_new (GtkWidget *parent,
|
||||
info->user_settings = gnc_import_Settings_new ();
|
||||
gnc_import_Settings_set_match_date_hardlimit (info->user_settings, match_date_hardlimit);
|
||||
|
||||
stylectxt = gtk_widget_get_style_context (GTK_WIDGET(parent));
|
||||
gtk_style_context_get_color (stylectxt, GTK_STATE_FLAG_NORMAL, &color);
|
||||
info->dark_theme = gnc_is_dark_theme (&color);
|
||||
|
||||
/* load the interface */
|
||||
builder = gtk_builder_new();
|
||||
gnc_builder_add_from_file (builder, "dialog-import.glade", "transaction_matcher_content");
|
||||
@ -650,6 +671,17 @@ gboolean gnc_gen_trans_list_run (GNCImportMainMatcher *info)
|
||||
return result;
|
||||
}
|
||||
|
||||
static gchar*
|
||||
get_required_color (const gchar *class_name)
|
||||
{
|
||||
GdkRGBA color;
|
||||
GtkWidget *label = gtk_label_new ("Color");
|
||||
GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET(label));
|
||||
gtk_style_context_add_class (context, class_name);
|
||||
gnc_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &color);
|
||||
return gdk_rgba_to_string (&color);
|
||||
}
|
||||
|
||||
static void
|
||||
refresh_model_row (GNCImportMainMatcher *gui,
|
||||
GtkTreeModel *model,
|
||||
@ -660,6 +692,8 @@ refresh_model_row (GNCImportMainMatcher *gui,
|
||||
GtkTreeSelection *selection;
|
||||
gchar *tmp, *imbalance, *text, *color;
|
||||
const gchar *ro_text;
|
||||
gchar *int_required_class, *int_prob_required_class, *int_not_required_class;
|
||||
gchar *class_extension = NULL;
|
||||
Split *split;
|
||||
g_assert (gui);
|
||||
g_assert (model);
|
||||
@ -669,6 +703,13 @@ refresh_model_row (GNCImportMainMatcher *gui,
|
||||
store = GTK_LIST_STORE(model);
|
||||
gtk_list_store_set(store, iter, DOWNLOADED_COL_DATA, info, -1);
|
||||
|
||||
if (gui->dark_theme == TRUE)
|
||||
class_extension = "-dark";
|
||||
|
||||
int_required_class = g_strconcat (CSS_INT_REQUIRED_CLASS, class_extension, NULL);
|
||||
int_prob_required_class = g_strconcat (CSS_INT_PROB_REQUIRED_CLASS, class_extension, NULL);
|
||||
int_not_required_class = g_strconcat (CSS_INT_NOT_REQUIRED_CLASS, class_extension, NULL);
|
||||
|
||||
/*Account:*/
|
||||
split = gnc_import_TransInfo_get_fsplit (info);
|
||||
g_assert(split); // Must not be NULL
|
||||
@ -705,7 +746,7 @@ refresh_model_row (GNCImportMainMatcher *gui,
|
||||
if (gnc_import_TransInfo_is_balanced(info) == TRUE)
|
||||
{
|
||||
ro_text = _("New, already balanced");
|
||||
color = COLOR_GREEN;
|
||||
color = get_required_color (int_not_required_class);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -721,7 +762,7 @@ refresh_model_row (GNCImportMainMatcher *gui,
|
||||
TRUE) ));
|
||||
if (gnc_import_TransInfo_get_destacc (info) != NULL)
|
||||
{
|
||||
color = COLOR_GREEN;
|
||||
color = get_required_color (int_not_required_class);
|
||||
tmp = gnc_account_get_full_name
|
||||
(gnc_import_TransInfo_get_destacc (info));
|
||||
if (gnc_import_TransInfo_get_destacc_selected_manually(info)
|
||||
@ -746,7 +787,7 @@ refresh_model_row (GNCImportMainMatcher *gui,
|
||||
}
|
||||
else
|
||||
{
|
||||
color = COLOR_YELLOW;
|
||||
color = get_required_color (int_prob_required_class);
|
||||
text =
|
||||
/* Translators: %s is the amount to be transferred. */
|
||||
g_strdup_printf(_("New, UNBALANCED (need acct to transfer %s)!"),
|
||||
@ -758,7 +799,7 @@ refresh_model_row (GNCImportMainMatcher *gui,
|
||||
case GNCImport_CLEAR:
|
||||
if (gnc_import_TransInfo_get_selected_match(info))
|
||||
{
|
||||
color = COLOR_GREEN;
|
||||
color = get_required_color (int_not_required_class);
|
||||
if (gnc_import_TransInfo_get_match_selected_manually(info) == TRUE)
|
||||
{
|
||||
ro_text = _("Reconcile (manual) match");
|
||||
@ -770,14 +811,14 @@ refresh_model_row (GNCImportMainMatcher *gui,
|
||||
}
|
||||
else
|
||||
{
|
||||
color = COLOR_RED;
|
||||
color = get_required_color (int_required_class);
|
||||
ro_text = _("Match missing!");
|
||||
}
|
||||
break;
|
||||
case GNCImport_UPDATE:
|
||||
if (gnc_import_TransInfo_get_selected_match(info))
|
||||
{
|
||||
color = COLOR_GREEN;
|
||||
color = get_required_color (int_not_required_class);
|
||||
if (gnc_import_TransInfo_get_match_selected_manually(info) == TRUE)
|
||||
{
|
||||
ro_text = _("Update and reconcile (manual) match");
|
||||
@ -789,12 +830,12 @@ refresh_model_row (GNCImportMainMatcher *gui,
|
||||
}
|
||||
else
|
||||
{
|
||||
color = COLOR_RED;
|
||||
color = get_required_color (int_required_class);
|
||||
ro_text = _("Match missing!");
|
||||
}
|
||||
break;
|
||||
case GNCImport_SKIP:
|
||||
color = COLOR_RED;
|
||||
color = get_required_color (int_required_class);
|
||||
ro_text = _("Do not import (no action selected)");
|
||||
break;
|
||||
default:
|
||||
@ -810,6 +851,10 @@ refresh_model_row (GNCImportMainMatcher *gui,
|
||||
if (text)
|
||||
g_free(text);
|
||||
|
||||
g_free (int_required_class);
|
||||
g_free (int_prob_required_class);
|
||||
g_free (int_not_required_class);
|
||||
|
||||
/* Set the pixmaps */
|
||||
gtk_list_store_set(store, iter,
|
||||
DOWNLOADED_COL_ACTION_ADD,
|
||||
|
@ -167,8 +167,7 @@ gnc_item_edit_init (GncItemEdit *item_edit)
|
||||
|
||||
item_edit->popup_toggle.ebox = NULL;
|
||||
item_edit->popup_toggle.tbutton = NULL;
|
||||
item_edit->popup_toggle.arrow_up = NULL;
|
||||
item_edit->popup_toggle.arrow_down = NULL;
|
||||
item_edit->popup_toggle.arrow_down = TRUE;
|
||||
item_edit->popup_toggle.signals_connected = FALSE;
|
||||
|
||||
item_edit->popup_item = NULL;
|
||||
@ -333,6 +332,32 @@ unblock_toggle_signals(GncItemEdit *item_edit)
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
draw_arrow_cb (GtkWidget *widget, cairo_t *cr, gpointer data)
|
||||
{
|
||||
GncItemEdit *item_edit = GNC_ITEM_EDIT (data);
|
||||
GtkStyleContext *context = gtk_widget_get_style_context (widget);
|
||||
gint width = gtk_widget_get_allocated_width (widget);
|
||||
gint height = gtk_widget_get_allocated_height (widget);
|
||||
gint size;
|
||||
|
||||
gtk_render_background (context, cr, 0, 0, width, height);
|
||||
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_ARROW);
|
||||
|
||||
size = MIN(width / 2, height / 2);
|
||||
|
||||
if (item_edit->popup_toggle.arrow_down == 0)
|
||||
gtk_render_arrow (context, cr, 0,
|
||||
(width - size)/2, (height - size)/2, size);
|
||||
else
|
||||
gtk_render_arrow (context, cr, G_PI,
|
||||
(width - size)/2, (height - size)/2, size);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
connect_popup_toggle_signals (GncItemEdit *item_edit)
|
||||
{
|
||||
@ -353,6 +378,10 @@ connect_popup_toggle_signals (GncItemEdit *item_edit)
|
||||
G_CALLBACK(key_press_popup_cb),
|
||||
item_edit);
|
||||
|
||||
g_signal_connect_after (object, "draw",
|
||||
G_CALLBACK (draw_arrow_cb),
|
||||
item_edit);
|
||||
|
||||
item_edit->popup_toggle.signals_connected = TRUE;
|
||||
}
|
||||
|
||||
@ -507,7 +536,6 @@ GtkWidget *
|
||||
gnc_item_edit_new (GnucashSheet *sheet)
|
||||
{
|
||||
char *hpad_str, *vpad_str, *entry_css;
|
||||
GtkWidget *box;
|
||||
GtkStyleContext *stylecontext;
|
||||
GtkCssProvider *provider;
|
||||
GncItemEdit *item_edit =
|
||||
@ -543,17 +571,8 @@ gnc_item_edit_new (GnucashSheet *sheet)
|
||||
/* Create the popup button
|
||||
It will only be displayed when the cell being edited provides
|
||||
a popup item (like a calendar or account list) */
|
||||
item_edit->popup_toggle.arrow_down = gtk_image_new_from_icon_name ("go-down", GTK_ICON_SIZE_BUTTON);
|
||||
item_edit->popup_toggle.arrow_up = gtk_image_new_from_icon_name ("go-up", GTK_ICON_SIZE_BUTTON);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_box_pack_start (GTK_BOX(box), GTK_WIDGET(item_edit->popup_toggle.arrow_down), FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX(box), GTK_WIDGET(item_edit->popup_toggle.arrow_up),FALSE, FALSE, 0);
|
||||
|
||||
item_edit->popup_toggle.tbutton = gtk_toggle_button_new();
|
||||
gtk_toggle_button_set_mode (
|
||||
GTK_TOGGLE_BUTTON (item_edit->popup_toggle.tbutton), FALSE);
|
||||
gtk_container_add(GTK_CONTAINER(item_edit->popup_toggle.tbutton), GTK_WIDGET(box));
|
||||
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (item_edit->popup_toggle.tbutton), FALSE);
|
||||
|
||||
/* Force padding on the button to
|
||||
1. keep it small
|
||||
@ -576,8 +595,6 @@ gnc_item_edit_new (GnucashSheet *sheet)
|
||||
FALSE, TRUE, 0);
|
||||
gtk_widget_show_all(GTK_WIDGET(item_edit));
|
||||
|
||||
gtk_widget_hide (GTK_WIDGET(item_edit->popup_toggle.arrow_up));
|
||||
|
||||
return GTK_WIDGET(item_edit);
|
||||
}
|
||||
|
||||
@ -667,8 +684,8 @@ gnc_item_edit_show_popup (GncItemEdit *item_edit)
|
||||
unblock_toggle_signals (item_edit);
|
||||
}
|
||||
|
||||
gtk_widget_hide (item_edit->popup_toggle.arrow_down);
|
||||
gtk_widget_show (item_edit->popup_toggle.arrow_up);
|
||||
// set the popup arrow direction up
|
||||
item_edit->popup_toggle.arrow_down = FALSE;
|
||||
|
||||
if (item_edit->popup_set_focus)
|
||||
item_edit->popup_set_focus (item_edit->popup_item,
|
||||
@ -713,8 +730,8 @@ gnc_item_edit_hide_popup (GncItemEdit *item_edit)
|
||||
|
||||
gtk_container_remove (GTK_CONTAINER(item_edit->sheet), item_edit->popup_item);
|
||||
|
||||
gtk_widget_hide (item_edit->popup_toggle.arrow_up);
|
||||
gtk_widget_show (item_edit->popup_toggle.arrow_down);
|
||||
// set the popup arrow direction down
|
||||
item_edit->popup_toggle.arrow_down = TRUE;
|
||||
|
||||
gtk_toggle_button_set_active
|
||||
(GTK_TOGGLE_BUTTON(item_edit->popup_toggle.tbutton), FALSE);
|
||||
|
@ -61,8 +61,7 @@ struct _PopupToggle
|
||||
{
|
||||
GtkWidget *ebox;
|
||||
GtkWidget *tbutton;
|
||||
GtkWidget *arrow_up;
|
||||
GtkWidget *arrow_down;
|
||||
gboolean arrow_down;
|
||||
gboolean signals_connected;
|
||||
};
|
||||
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "gnucash-sheetP.h"
|
||||
|
||||
#include "dialog-utils.h"
|
||||
#include "gnc-gtk-utils.h"
|
||||
#include "gnc-prefs.h"
|
||||
#include "gnucash-color.h"
|
||||
#include "gnucash-cursor.h"
|
||||
@ -2330,25 +2331,6 @@ gnucash_sheet_realize_entry (GnucashSheet *sheet, GtkWidget *entry)
|
||||
* the register is rewritten.
|
||||
*/
|
||||
|
||||
static void
|
||||
gnc_style_context_get_background_color (GtkStyleContext *context,
|
||||
GtkStateFlags state,
|
||||
GdkRGBA *color)
|
||||
{
|
||||
GdkRGBA *c;
|
||||
|
||||
g_return_if_fail (color != NULL);
|
||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||
|
||||
gtk_style_context_get (context,
|
||||
state,
|
||||
GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &c,
|
||||
NULL);
|
||||
*color = *c;
|
||||
gdk_rgba_free (c);
|
||||
}
|
||||
|
||||
|
||||
/** Map a cell type to a gtkrc specified color. */
|
||||
GdkRGBA *
|
||||
get_gtkrc_color (GnucashSheet *sheet,
|
||||
|
Loading…
Reference in New Issue
Block a user