[geary/wip/csd-generalisations: 1/2] Update util-gtk.vala to follow source code conventions better
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/csd-generalisations: 1/2] Update util-gtk.vala to follow source code conventions better
- Date: Fri, 2 Aug 2019 03:15:54 +0000 (UTC)
commit 99f3b3525c66d8759ef7e273a82ce93301ffc1d0
Author: Michael Gratton <mike vee net>
Date: Fri Aug 2 12:58:32 2019 +1000
Update util-gtk.vala to follow source code conventions better
Fix package name, indenting.
src/client/components/count-badge.vala | 2 +-
src/client/composer/composer-headerbar.vala | 3 +-
src/client/composer/composer-widget.vala | 4 +-
.../formatted-conversation-data.vala | 2 +-
.../conversation-viewer/conversation-email.vala | 2 +-
.../conversation-viewer/conversation-list-box.vala | 4 +-
src/client/util/util-gtk.vala | 133 +++++++++++----------
7 files changed, 75 insertions(+), 75 deletions(-)
---
diff --git a/src/client/components/count-badge.vala b/src/client/components/count-badge.vala
index a21d5246..c2de5cea 100644
--- a/src/client/components/count-badge.vala
+++ b/src/client/components/count-badge.vala
@@ -77,7 +77,7 @@ public class CountBadge : Geary.BaseObject {
ctx.close_path();
// Colorize our shape.
- GtkUtil.set_source_color_from_string(ctx, UNREAD_BG_COLOR);
+ Util.Gtk.set_source_color_from_string(ctx, UNREAD_BG_COLOR);
ctx.fill_preserve();
ctx.set_line_width(2.0);
ctx.stroke();
diff --git a/src/client/composer/composer-headerbar.vala b/src/client/composer/composer-headerbar.vala
index a947b021..146bf607 100644
--- a/src/client/composer/composer-headerbar.vala
+++ b/src/client/composer/composer-headerbar.vala
@@ -68,10 +68,9 @@ public class ComposerHeaderbar : Gtk.HeaderBar {
detach_start.visible = false;
detach_end.visible = true;
} else {
- bool at_end = GtkUtil.close_button_at_end();
+ bool at_end = Util.Gtk.close_button_at_end();
detach_start.visible = !at_end;
detach_end.visible = at_end;
}
}
}
-
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index c744668b..380c6ac4 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -1967,7 +1967,7 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
// Step 3.
- GtkUtil.menu_foreach(context_menu_model, (label, name, target, section) => {
+ Util.Gtk.menu_foreach(context_menu_model, (label, name, target, section) => {
if (context_menu.last() != null) {
context_menu.append(new WebKit.ContextMenuItem.separator());
}
@@ -2005,7 +2005,7 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
private inline void append_menu_section(WebKit.ContextMenu context_menu,
Menu section) {
- GtkUtil.menu_foreach(section, (label, name, target, section) => {
+ Util.Gtk.menu_foreach(section, (label, name, target, section) => {
string simple_name = name;
if ("." in simple_name) {
simple_name = simple_name.split(".")[1];
diff --git a/src/client/conversation-list/formatted-conversation-data.vala
b/src/client/conversation-list/formatted-conversation-data.vala
index c969731f..aaec9ae0 100644
--- a/src/client/conversation-list/formatted-conversation-data.vala
+++ b/src/client/conversation-list/formatted-conversation-data.vala
@@ -325,7 +325,7 @@ public class FormattedConversationData : Geary.BaseObject {
// Draw separator line.
if (ctx != null && cell_area != null) {
ctx.set_line_width(1.0);
- GtkUtil.set_source_color_from_string(ctx, CountBadge.UNREAD_BG_COLOR);
+ Util.Gtk.set_source_color_from_string(ctx, CountBadge.UNREAD_BG_COLOR);
ctx.move_to(cell_area.x - 1, cell_area.y + cell_area.height);
ctx.line_to(cell_area.x + cell_area.width + 1, cell_area.y + cell_area.height);
ctx.stroke();
diff --git a/src/client/conversation-viewer/conversation-email.vala
b/src/client/conversation-viewer/conversation-email.vala
index 87a84b28..8fe728b9 100644
--- a/src/client/conversation-viewer/conversation-email.vala
+++ b/src/client/conversation-viewer/conversation-email.vala
@@ -955,7 +955,7 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
bool supports_trash = get_action_enabled(ACTION_TRASH_MESSAGE);
bool supports_delete = get_action_enabled(ACTION_DELETE_MESSAGE);
bool show_trash_button = !this.shift_key_down && (supports_trash || !supports_delete);
- GtkUtil.menu_foreach(this.email_menu_model, (label, name, target, section) => {
+ Util.Gtk.menu_foreach(this.email_menu_model, (label, name, target, section) => {
if ((section != this.email_menu_trash || show_trash_button) &&
(section != this.email_menu_delete || !show_trash_button)) {
this.email_menu.append_item(new MenuItem.section(label, section));
diff --git a/src/client/conversation-viewer/conversation-list-box.vala
b/src/client/conversation-viewer/conversation-list-box.vala
index 39333946..e6a3babf 100644
--- a/src/client/conversation-viewer/conversation-list-box.vala
+++ b/src/client/conversation-viewer/conversation-list-box.vala
@@ -822,7 +822,7 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
Gtk.ListBoxRow initial_row = get_row_at_index(0);
int loading_height = 0;
if (initial_row is LoadingRow) {
- loading_height = GtkUtil.get_border_box_height(initial_row);
+ loading_height = Util.Gtk.get_border_box_height(initial_row);
remove(initial_row);
}
@@ -839,7 +839,7 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
// same place.
row.enable_should_scroll();
row.should_scroll.connect(() => {
- listbox_adj.value += GtkUtil.get_border_box_height(row);
+ listbox_adj.value += Util.Gtk.get_border_box_height(row);
});
// Only adjust for the loading row going away once
diff --git a/src/client/util/util-gtk.vala b/src/client/util/util-gtk.vala
index bcc6aa33..3b871c3e 100644
--- a/src/client/util/util-gtk.vala
+++ b/src/client/util/util-gtk.vala
@@ -1,82 +1,83 @@
-/* Copyright 2016 Software Freedom Conservancy Inc.
+/*
+ * Copyright 2016 Software Freedom Conservancy Inc.
*
* This software is licensed under the GNU Lesser General Public License
- * (version 2.1 or later). See the COPYING file in this distribution.
+ * (version 2.1 or later). See the COPYING file in this distribution.
*/
-namespace GtkUtil {
+namespace Util.Gtk {
-/**
- * Given an HTML-style color spec, parses the color and sets it to the source RGB of the Cairo context.
- * (Borrowed from Shotwell.)
- */
-void set_source_color_from_string(Cairo.Context ctx, string spec) {
- Gdk.RGBA rgba = Gdk.RGBA();
- if (!rgba.parse(spec))
- error("Can't parse color %s", spec);
- ctx.set_source_rgb(rgba.red, rgba.green, rgba.blue);
-}
+ /**
+ * Given an HTML-style color spec, parses the color and sets it to the source RGB of the Cairo context.
+ * (Borrowed from Shotwell.)
+ */
+ void set_source_color_from_string(Cairo.Context ctx, string spec) {
+ Gdk.RGBA rgba = Gdk.RGBA();
+ if (!rgba.parse(spec))
+ error("Can't parse color %s", spec);
+ ctx.set_source_rgb(rgba.red, rgba.green, rgba.blue);
+ }
-/**
- * Returns whether the close button is at the end of the headerbar.
- */
-bool close_button_at_end() {
- string layout = Gtk.Settings.get_default().gtk_decoration_layout;
- bool at_end = false;
- // Based on logic of close_button_at_end in gtkheaderbar.c: Close button appears
- // at end iff "close" follows a colon in the layout string.
- if (layout != null) {
- int colon_ind = layout.index_of(":");
- at_end = (colon_ind >= 0 && layout.index_of("close", colon_ind) >= 0);
+ /**
+ * Returns whether the close button is at the end of the headerbar.
+ */
+ bool close_button_at_end() {
+ string layout = global::Gtk.Settings.get_default().gtk_decoration_layout;
+ bool at_end = false;
+ // Based on logic of close_button_at_end in gtkheaderbar.c: Close button appears
+ // at end iff "close" follows a colon in the layout string.
+ if (layout != null) {
+ int colon_ind = layout.index_of(":");
+ at_end = (colon_ind >= 0 && layout.index_of("close", colon_ind) >= 0);
+ }
+ return at_end;
}
- return at_end;
-}
-/**
- * Allows iterating over a GMenu, without having to handle MenuItems
- * @param menu - The menu to iterate over
- * @param foreach_func - The function which will be called on the attributes of menu's children
- */
-void menu_foreach(Menu menu, MenuForeachFunc foreach_func) {
- for (int i = 0; i < menu.get_n_items(); i++) {
- // Get the attributes we're interested in
- Variant? label = menu.get_item_attribute_value(i, Menu.ATTRIBUTE_LABEL, VariantType.STRING);
- Variant? action_name = menu.get_item_attribute_value(i, Menu.ATTRIBUTE_ACTION, VariantType.STRING);
- Variant? action_target = menu.get_item_attribute_value(i, Menu.ATTRIBUTE_TARGET, VariantType.STRING);
+ /**
+ * Allows iterating over a GMenu, without having to handle MenuItems
+ * @param menu - The menu to iterate over
+ * @param foreach_func - The function which will be called on the attributes of menu's children
+ */
+ void menu_foreach(Menu menu, MenuForeachFunc foreach_func) {
+ for (int i = 0; i < menu.get_n_items(); i++) {
+ // Get the attributes we're interested in
+ Variant? label = menu.get_item_attribute_value(i, Menu.ATTRIBUTE_LABEL, VariantType.STRING);
+ Variant? action_name = menu.get_item_attribute_value(i, Menu.ATTRIBUTE_ACTION,
VariantType.STRING);
+ Variant? action_target = menu.get_item_attribute_value(i, Menu.ATTRIBUTE_TARGET,
VariantType.STRING);
- // Check if the child is a section
- Menu? section = (Menu) menu.get_item_link(i, Menu.LINK_SECTION);
+ // Check if the child is a section
+ Menu? section = (Menu) menu.get_item_link(i, Menu.LINK_SECTION);
- // Callback
- foreach_func((label != null) ? label.get_string() : null,
- (action_name != null) ? action_name.get_string() : null,
- action_target,
- section);
+ // Callback
+ foreach_func((label != null) ? label.get_string() : null,
+ (action_name != null) ? action_name.get_string() : null,
+ action_target,
+ section);
+ }
}
-}
-/*
- * Used for menu_foreach()
- * @param id - The id if one was set
- * @param label - The label if one was set
- * @param action_name - The action name, if set
- * @param action_target - The action target, if set
- * @param section - If the item represents a section, this will return that section (or null otherwise)
- */
-delegate void MenuForeachFunc(string? label, string? action_name, Variant? target, Menu? section);
+ /*
+ * Used for menu_foreach()
+ * @param id - The id if one was set
+ * @param label - The label if one was set
+ * @param action_name - The action name, if set
+ * @param action_target - The action target, if set
+ * @param section - If the item represents a section, this will return that section (or null otherwise)
+ */
+ delegate void MenuForeachFunc(string? label, string? action_name, Variant? target, Menu? section);
-/**
- * Returns the CSS border box height for a widget.
- *
- * This adjusts the GTK widget's allocated height to exclude extra
- * space added by the CSS margin property, if any.
- */
-public inline int get_border_box_height(Gtk.Widget widget) {
- Gtk.StyleContext style = widget.get_style_context();
- Gtk.StateFlags flags = style.get_state();
- Gtk.Border margin = style.get_margin(flags);
+ /**
+ * Returns the CSS border box height for a widget.
+ *
+ * This adjusts the GTK widget's allocated height to exclude extra
+ * space added by the CSS margin property, if any.
+ */
+ public inline int get_border_box_height(global::Gtk.Widget widget) {
+ global::Gtk.StyleContext style = widget.get_style_context();
+ global::Gtk.StateFlags flags = style.get_state();
+ global::Gtk.Border margin = style.get_margin(flags);
- return widget.get_allocated_height() - margin.top - margin.bottom;
-}
+ return widget.get_allocated_height() - margin.top - margin.bottom;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]