aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main-window.vala40
-rw-r--r--src/menubar.vala219
-rw-r--r--src/prompt-box.vala75
-rw-r--r--src/settings.vala2
4 files changed, 132 insertions, 204 deletions
diff --git a/src/main-window.vala b/src/main-window.vala
index e1e39d2..621b115 100644
--- a/src/main-window.vala
+++ b/src/main-window.vala
@@ -129,40 +129,30 @@ public class MainWindow : Gtk.Window
login_box.add (content_box);
var content_align = AGSettings.get_string(AGSettings.KEY_CONTENT_ALIGN);
- var x_align = 0.5f;
+ var x_align = Gtk.Align.CENTER;
if (content_align == "left")
{
- x_align = 0.0f;
+ x_align = Gtk.Align.START;
}
else if (content_align == "right")
{
- x_align = 1.0f;
+ x_align = Gtk.Align.END;
}
- var align = new Gtk.Alignment (x_align, 0.0f, 0.0f, 1.0f);
+ hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
+ hbox.expand = true;
+ hbox.show ();
+ hbox.halign = x_align;
+ hbox.valign = Gtk.Align.CENTER;
if (content_align == "center")
{
// offset for back button
- align.margin_end = greeter.grid_size;
+ hbox.margin_end = greeter.grid_size;
}
- align.show ();
- content_box.add (align);
-
- hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
- hbox.expand = true;
- hbox.show ();
- align.add (hbox);
-
- align = new Gtk.Alignment (0.5f, 0.5f, 0.0f, 0.0f);
- align.resize_mode = Gtk.ResizeMode.QUEUE;
- align.set_size_request (greeter.grid_size, -1);
- align.margin_bottom = greeter.menubar_height; /* offset for menubar at top */
- align.show ();
- hbox.add (align);
-
+ content_box.add (hbox);
back_button = new FlatButton ();
back_button.get_accessible ().set_name (_("Back"));
Gtk.button_set_focus_on_click (back_button, false);
@@ -191,8 +181,14 @@ public class MainWindow : Gtk.Window
back_button.add (image);
back_button.clicked.connect (pop_list);
-
- align.add (back_button);
+ back_button.halign = Gtk.Align.CENTER;
+ back_button.valign = Gtk.Align.CENTER;
+ back_button.hexpand = false;
+ back_button.vexpand = false;
+ back_button.resize_mode = Gtk.ResizeMode.QUEUE;
+ back_button.set_size_request (greeter.grid_size, -1);
+ back_button.margin_bottom = greeter.menubar_height;
+ hbox.add (back_button);
stack = new ListStack ();
stack.show ();
diff --git a/src/menubar.vala b/src/menubar.vala
index 8ce73d7..f449afa 100644
--- a/src/menubar.vala
+++ b/src/menubar.vala
@@ -101,7 +101,7 @@ private class IndicatorMenuItem : Gtk.MenuItem
}
}
-public class MenuBar : Gtk.MenuBar
+public class MenuBar : Gtk.Grid
{
public Background? background { get; construct; default = null; }
public Gtk.Window? keyboard_window { get; private set; default = null; }
@@ -112,70 +112,6 @@ public class MenuBar : Gtk.MenuBar
Object (background: bg, accel_group: ag);
}
- public override bool draw (Cairo.Context c)
- {
- if (background != null)
- {
- /* Disable background drawing to see how it changes the visuals. */
- /*
- int x, y;
- background.translate_coordinates (this, 0, 0, out x, out y);
- c.save ();
- c.translate (x, y);
- background.draw_full (c, Background.DrawFlags.NONE);
- c.restore ();
- */
- }
-
- /* Get the style and dimensions. */
- var style_ctx = this.get_style_context ();
-
- var w = this.get_allocated_width ();
- var h = this.get_allocated_height ();
-
- /* Add a group. */
- c.push_group ();
-
- /* Draw the background normally. */
- style_ctx.render_background (c, 0, 0, w, h);
-
- /* Draw the frame normally. */
- style_ctx.render_frame (c, 0, 0, w, h);
-
- /* Go back to the original widget. */
- c.pop_group_to_source ();
-
- var agsettings = new AGSettings ();
- if (agsettings.high_contrast) {
- /*
- * In case the high contrast mode is enabled, do not add any
- * transparency. While the GTK theme might define one (even though
- * it better should not, given that we are also switching to a
- * high contrast theme), we certainly do not want to make the look
- * fuzzy.
- */
- c.paint ();
- }
- else {
- /*
- * And finally repaint it with additional transparency.
- * Note that most GTK styles already define a transparency for OSD
- * menus. We want to have something more transparent, but also
- * make sure that it is not too transparent, so do not choose a
- * value that is too low here - certainly not your desired final
- * alpha value.
- */
- c.paint_with_alpha (AGSettings.get_double (AGSettings.KEY_MENUBAR_ALPHA));
- }
-
- foreach (var child in get_children ())
- {
- propagate_draw (child, c);
- }
-
- return false;
- }
-
public static void add_style_class (Gtk.Widget widget)
{
/*
@@ -187,32 +123,60 @@ public class MenuBar : Gtk.MenuBar
}
private List<Indicator.Object> indicator_objects;
+ private Gtk.MenuBar pMenubar;
construct
{
+ this.pMenubar = new Gtk.MenuBar ();
+ this.pMenubar.halign = Gtk.Align.END;
+ this.pMenubar.hexpand = true;
+ this.pMenubar.pack_direction = Gtk.PackDirection.RTL;
+ this.pMenubar.show ();
+ this.attach (this.pMenubar, 1, 0, 1, 1);
+ this.show ();
add_style_class (this);
+ Gtk.CssProvider pGridProvider = new Gtk.CssProvider ();
+ string sBackGround = AGSettings.get_string (AGSettings.KEY_MENUBAR_BGCOLOR);
+ Gdk.RGBA pBackGround = Gdk.RGBA ();
+ pBackGround.parse (sBackGround);
+ int nRed = (int)(pBackGround.red * 255.0);
+ int nGreen = (int)(pBackGround.green * 255.0);
+ int nBlue = (int)(pBackGround.blue * 255.0);
+ double fApha = AGSettings.get_double (AGSettings.KEY_MENUBAR_ALPHA);
+
+ // Assure that printf operates in C.UTF-8 locale for float-to-string conversions.
+ Intl.setlocale(LocaleCategory.NUMERIC, "C.UTF-8");
+
+ try
+ {
+ pGridProvider.load_from_data ("* { background-color: rgba(%i, %i, %i, %f); } *.high_contrast { background-color: #ffffff; color: #000000; text-shadow: none; }".printf (nRed, nGreen, nBlue, fApha), -1);
+ }
+ catch (Error pError)
+ {
+ error ("Panic: Failed loading menubar grid colours: %s", pError.message);
+ }
- /* Handle high contrast background color */
- var menubar_style = new Gtk.CssProvider ();
+ this.get_style_context ().add_provider (pGridProvider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+
+ Gtk.CssProvider pMenubarProvider = new Gtk.CssProvider ();
try
{
- menubar_style.load_from_data ("*.high_contrast { background-color: #ffffff; }", -1);
+ pMenubarProvider.load_from_data ("* { background-color: transparent; } *.high_contrast { color: #000000; text-shadow: none; }", -1);
}
catch (Error pError)
{
- error ("Panic: Failed adding high contrast background-color: %s", pError.message);
+ error ("Panic: Failed loading menubar colours: %s", pError.message);
}
- this.get_style_context ().add_provider (menubar_style,
- Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+
+ this.pMenubar.get_style_context ().add_provider (pMenubarProvider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
/* Add shadow. */
var shadow_style = new Gtk.CssProvider ();
try
{
- Intl.setlocale(LocaleCategory.NUMERIC, "C.UTF-8");
- shadow_style.load_from_data ("* { box-shadow: 0px 0px 5px 5px rgba(0.2,0.2,0.2,%f); }".printf(AGSettings.get_double (AGSettings.KEY_MENUBAR_ALPHA)), -1);
+ shadow_style.load_from_data ("* { box-shadow: 0px 0px 5px 5px rgba(%i, %i, %i, %f); }".printf (nRed, nGreen, nBlue, fApha), -1);
}
catch (Error pError)
{
@@ -222,97 +186,13 @@ public class MenuBar : Gtk.MenuBar
this.get_style_context ().add_provider (shadow_style,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
- pack_direction = Gtk.PackDirection.RTL;
-
if (AGSettings.get_boolean (AGSettings.KEY_SHOW_HOSTNAME))
{
- var hostname_item = new Gtk.MenuItem.with_label (Posix.utsname ().nodename);
- append (hostname_item);
- hostname_item.show ();
-
- /*
- * Even though this (menu) item is insensitive, we want its label
- * text to have the sensitive color as to not look out of place
- * and difficult to read.
- *
- * There's a really weird bug that leads to always fetch the
- * sensitive color after the widget (menuitem in this case) has
- * been set to insensitive once - at least in this constructor.
- *
- * I haven't found a way to fix that, or, for that matter, what is
- * actually causing the issue. Even waiting on the main event loop
- * until all events are processed didn't help.
- *
- * We'll work around this issue by fetching the color before
- * setting the widget to insensitive and call it proper.
- */
- var insensitive_override_style = new Gtk.CssProvider ();
-
- /*
- * First, fetch the associated GtkStyleContext and save the state,
- * we'll override the state later on.
- */
- var hostname_item_ctx = hostname_item.get_style_context ();
- hostname_item_ctx.save ();
-
- try {
- /* Get the actual color. */
- var sensitive_color = hostname_item_ctx.get_color (Gtk.StateFlags.NORMAL);
- debug ("Directly fetched sensitive color: %s", sensitive_color.to_string ());
-
- insensitive_override_style.load_from_data ("*:disabled { color: %s; }
- *.high_contrast:disabled { color: #000000; }".printf(sensitive_color.to_string ()), -1);
- }
- catch (Error e)
- {
- debug ("Internal error loading hostname menu item text color: %s", e.message);
- }
- finally {
- /*
- * Restore the context, which we might have changed through the
- * previous get_color () call.
- */
- hostname_item_ctx.restore ();
- }
-
- try {
- /* And finally override the insensitive color. */
- hostname_item_ctx.add_provider (insensitive_override_style,
- Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
-
- /*
- * Just overriding the color for the Gtk.MenuItem widget
- * doesn't help, we'll also apply it to the children.
- *
- * In theory, we could just use the get_child () method to
- * fetch the only child we should ever have on that widget,
- * namely a GtkAccelLabel, but that isn't future-proof enough,
- * especially if that is ever extended into having a submenu.
- *
- * Thus, iterate over all children and override the style for
- * all of them.
- */
- if (gtk_is_container (hostname_item)) {
- var children = hostname_item.get_children ();
- foreach (Gtk.Widget element in children) {
- var child_ctx = element.get_style_context ();
- debug ("Adding override style provider to child widget %s", element.name);
- child_ctx.add_provider (insensitive_override_style,
- Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
- }
- }
- }
- catch (Error e)
- {
- debug ("Internal error overriding hostname menu item text color: %s", e.message);
- }
-
- hostname_item.set_sensitive (false);
-
- /* The below does not work, so for now we need to stick to "set_right_justified"
- hostname_item.set_hexpand (true);
- hostname_item.set_halign (Gtk.Align.END);*/
- hostname_item.set_right_justified (true);
+ Gtk.Label pLabel = new Gtk.Label (Posix.utsname ().nodename);
+ pLabel.vexpand = true;
+ pLabel.margin_start = 6;
+ pLabel.show ();
+ this.attach (pLabel, 0, 0, 1, 1);
}
/* Prevent dragging the window by the menubar */
@@ -320,7 +200,7 @@ public class MenuBar : Gtk.MenuBar
{
var style = new Gtk.CssProvider ();
style.load_from_data ("* {-GtkWidget-window-dragging: false;}", -1);
- get_style_context ().add_provider (style, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+ this.pMenubar.get_style_context ().add_provider (style, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
}
catch (Error e)
{
@@ -330,6 +210,11 @@ public class MenuBar : Gtk.MenuBar
setup_indicators ();
}
+ public void select_first (bool bSearchSensitive)
+ {
+ this.pMenubar.select_first (bSearchSensitive);
+ }
+
public override void get_preferred_height (out int min, out int nat)
{
var greeter = new ArcticaGreeter ();
@@ -482,7 +367,7 @@ public class MenuBar : Gtk.MenuBar
{
var index = get_indicator_index (object);
var pos = 0;
- foreach (var child in get_children ())
+ foreach (var child in this.pMenubar.get_children ())
{
if (!(child is IndicatorMenuItem))
break;
@@ -499,19 +384,19 @@ public class MenuBar : Gtk.MenuBar
var menuitem = new IndicatorMenuItem (entry);
menuitem.set_data ("indicator-object", object);
- insert (menuitem, pos);
+ this.pMenubar.insert (menuitem, pos);
}
private void indicator_removed_cb (Indicator.Object object, Indicator.ObjectEntry entry)
{
debug ("Removing indicator object %p", entry);
- foreach (var child in get_children ())
+ foreach (var child in this.pMenubar.get_children ())
{
var menuitem = (IndicatorMenuItem) child;
if (menuitem.entry == entry)
{
- remove (child);
+ this.pMenubar.remove (child);
return;
}
}
diff --git a/src/prompt-box.vala b/src/prompt-box.vala
index b102887..fb3d4ab 100644
--- a/src/prompt-box.vala
+++ b/src/prompt-box.vala
@@ -247,13 +247,12 @@ public class PromptBox : FadableBox
message_image = new CachedImage (null);
message_image.set_from_icon_name("mail-unread", Gtk.IconSize.BUTTON);
-
- var align = new Gtk.Alignment (0.5f, 0.5f, 0.0f, 0.0f);
- align.valign = Gtk.Align.START;
- align.set_size_request (-1, greeter.grid_size);
- align.add (message_image);
- align.show ();
- name_grid.attach (align, COL_NAME_MESSAGE, ROW_NAME, 1, 1);
+ message_image.halign = Gtk.Align.CENTER;
+ message_image.valign = Gtk.Align.START;
+ message_image.hexpand = false;
+ message_image.vexpand = false;
+ message_image.set_size_request (-1, greeter.grid_size);
+ name_grid.attach (message_image, COL_NAME_MESSAGE, ROW_NAME, 1, 1);
option_button = new FlatButton ();
var option_button_ctx = option_button.get_style_context ();
@@ -343,12 +342,12 @@ public class PromptBox : FadableBox
small_message_image = new CachedImage (null);
small_message_image.set_from_icon_name("mail-unread", Gtk.IconSize.BUTTON);
-
- var align = new Gtk.Alignment (0.5f, 0.5f, 0.0f, 0.0f);
- align.set_size_request (-1, greeter.grid_size);
- align.add (small_message_image);
- align.show ();
- small_name_grid.attach (align, 2, 0, 1, 1);
+ small_message_image.halign = Gtk.Align.CENTER;
+ small_message_image.valign = Gtk.Align.CENTER;
+ small_message_image.hexpand = false;
+ small_message_image.vexpand = false;
+ small_message_image.set_size_request (-1, greeter.grid_size);
+ small_name_grid.attach (small_message_image, 2, 0, 1, 1);
small_name_grid.show ();
return small_name_grid;
@@ -560,7 +559,19 @@ public class PromptBox : FadableBox
ArcticaGreeter.add_style_class (w);
last_row += 1;
- box_grid.attach (w, COL_ENTRIES_START, last_row, COL_ENTRIES_WIDTH, 1);
+ bool bErrorBelow = AGSettings.get_boolean (AGSettings.KEY_ERROR_BELOW_ENTRY);
+
+ if (has_errors && bErrorBelow)
+ {
+ Gtk.Widget pChild = box_grid.get_child_at (COL_ENTRIES_START, last_row-1);
+ box_grid.remove (pChild);
+ box_grid.attach (w, COL_ENTRIES_START, last_row-1, COL_ENTRIES_WIDTH, 1);
+ box_grid.attach (pChild, COL_ENTRIES_START, last_row, COL_ENTRIES_WIDTH, 1);
+ }
+ else
+ {
+ box_grid.attach (w, COL_ENTRIES_START, last_row, COL_ENTRIES_WIDTH, 1);
+ }
update_prompt_visibility (w);
queue_resize ();
@@ -568,7 +579,7 @@ public class PromptBox : FadableBox
public void add_message (string text, bool is_error)
{
- var label = new FadingLabel (text);
+ var label = new FadingLabel ("");
var style_ctx = label.get_style_context();
@@ -601,6 +612,40 @@ public class PromptBox : FadableBox
label.xalign = 0.0f;
label.set_data<bool> ("prompt-box-is-error", is_error);
+ // Wrap the text if needed
+ ArcticaGreeter pGreeter = new ArcticaGreeter ();
+ Pango.Context pContext = label.get_pango_context ();
+ Pango.Layout pLayout = new Pango.Layout (pContext);
+ Pango.FontDescription pDescription = null;
+ Gtk.StateFlags nFlags = style_ctx.get_state ();
+ style_ctx.get (nFlags, "font", out pDescription, null);
+ pLayout.set_font_description (pDescription);
+ StringBuilder pBuilder = new StringBuilder ();
+ string[] lWords = text.split (" ");
+ string sLine = "";
+
+ foreach (string sWord in lWords)
+ {
+ string sTest = sLine == "" ? sWord : sLine + " " + sWord;
+ pLayout.set_text (sTest, -1);
+ int nWidth = 0;
+ pLayout.get_size (out nWidth, null);
+
+ if (nWidth / Pango.SCALE > (pGreeter.grid_size * GreeterList.BOX_WIDTH - (int)(GreeterList.BORDER * pGreeter.scaling_factor_widgets * 8)) && sLine != "")
+ {
+ pBuilder.append (sLine + "\n");
+ sLine = sWord;
+ }
+ else
+ {
+ sLine = sTest;
+ }
+ }
+
+ pBuilder.append (sLine);
+ label.set_text (pBuilder.str);
+ //~Wrap the text if needed
+
attach_item (label);
if (is_error)
diff --git a/src/settings.vala b/src/settings.vala
index 414020d..12c1265 100644
--- a/src/settings.vala
+++ b/src/settings.vala
@@ -98,6 +98,8 @@ public class AGSettings : Object
public const string KEY_LOGO_POSITION = "logo-position";
public const string KEY_LOGO_OFFSET_HORIZONTAL = "logo-offset-horizontal";
public const string KEY_LOGO_OFFSET_VERTICAL = "logo-offset-vertical";
+ public const string KEY_ERROR_BELOW_ENTRY = "error-below-entry";
+ public const string KEY_MENUBAR_BGCOLOR = "menubar-bgcolor";
public static bool get_boolean (string key)
{