elementaryart team mailing list archive
-
elementaryart team
-
Mailing list archive
-
Message #01830
[Merge] lp:~elementary-pantheon/granite/about_dialog_fixs2 into lp:granite
ammonkey has proposed merging lp:~elementary-pantheon/granite/about_dialog_fixs2 into lp:granite.
Requested reviews:
elementary Pantheon team (elementary-pantheon)
For more details, see:
https://code.launchpad.net/~elementary-pantheon/granite/about_dialog_fixs2/+merge/78858
second try ;)
--
https://code.launchpad.net/~elementary-pantheon/granite/about_dialog_fixs2/+merge/78858
Your team elementaryart (old) is subscribed to branch lp:granite.
=== modified file 'lib/CMakeLists.txt'
--- lib/CMakeLists.txt 2011-09-18 09:22:02 +0000
+++ lib/CMakeLists.txt 2011-10-10 15:35:18 +0000
@@ -53,6 +53,7 @@
Services/Logger.vala
Services/Paths.vala
Services/System.vala
+ Widgets/WrapLabel.vala
Widgets/AboutDialog.vala
Widgets/ModeButton.vala
Widgets/DatePicker.vala
=== modified file 'lib/GtkPatch/AboutDialog.vala'
--- lib/GtkPatch/AboutDialog.vala 2011-09-18 13:15:19 +0000
+++ lib/GtkPatch/AboutDialog.vala 2011-10-10 15:35:18 +0000
@@ -30,442 +30,418 @@
public class Granite.GtkPatch.AboutDialog : Gtk.Dialog
{
- /**
- * The people who contributed artwork to the program, as a null-terminated array of strings.
- */
- public string[] artists {
- set {
- _artists = value;
- if (_artists == null || _artists.length == 0) {
- artists_label.hide();
- artists_label.set_text("");
- }
- else {
- artists_label.set_text(set_string_from_string_array("Designed by" + ":\n", _artists));
- artists_label.show();
- }
- }
- get { return _artists; }
- }
- string[] _artists = new string[0];
-
- /**
- * The authors of the program, as a null-terminated array of strings.
- */
- public string[] authors {
- set {
- _authors = value;
- if (_authors == null || _authors.length == 0) {
- authors_label.hide();
- authors_label.set_text("");
- }
- else {
- authors_label.set_text(set_string_from_string_array("Written by" + ":\n", _authors));
- authors_label.show();
- }
- }
- get { return _authors; }
- }
- string[] _authors = new string[0];
-
- /**
- * Comments about the program.
- */
- public string comments {
- set {
- _comments = value;
- if (_comments == null || _comments == "") {
- comments_label.hide();
- comments_label.set_text("");
- }
- else {
- comments_label.set_text(_comments + "\n");
- comments_label.show();
- }
- }
- get { return _comments; }
- }
- string _comments = "";
-
- /**
- * Copyright information for the program.
- */
- public string copyright {
- set {
- _copyright = value;
- if (_copyright == null || _copyright == "") {
- copyright_label.hide();
- copyright_label.set_text("");
- }
- else {
- copyright_label.set_text("Copyright © " + _copyright + "\n");
- copyright_label.show();
- }
- }
- get { return _copyright; }
- }
- string _copyright = "";
-
- /**
- * The people documenting the program, as a null-terminated array of strings.
- */
- public string[] documenters {
- set {
- _documenters = value;
- if (documenters.length == 0 || documenters == null)
- documenters_label.hide();
- else {
- documenters_label.show();
- documenters_label.set_text(set_string_from_string_array("Documented by:\n", documenters));
- }
- }
- get { return _documenters; }
- }
- string[] _documenters = new string[0];
-
- /**
- * The license of the program.
- */
- public string license {
- set { _license = value; update_license(); }
- get { return _license; }
- }
- string _license = "";
-
- public License license_type {
- set { _license_type = value; update_license(); }
- get { return _license_type; }
- }
- License _license_type = License.UNKNOWN;
-
- /**
- * A logo for the about box.
- */
- public Pixbuf logo {
- set { _logo = value; update_logo_image(); }
- get { return _logo; }
- }
- Pixbuf _logo = null;
-
- /**
- * A named icon to use as the logo for the about box.
- */
- public string logo_icon_name {
- set { _logo_icon_name = value; update_logo_image(); }
- get { return _logo_icon_name; }
- }
- string _logo_icon_name = "";
-
- /**
- * The name of the program.
- */
- public string program_name {
- set { _program_name = value; set_name_and_version(); }
- get { return _program_name; }
- }
- string _program_name = "";
-
- /**
- * Credits to the translators.
- */
- public string translator_credits {
- set {
- _translator_credits = value;
- if (_translator_credits == null || _translator_credits == "") {
- translators_label.hide();
- translators_label.set_text("");
- }
- else {
- translators_label.set_text("Translated by: " + _translator_credits + "\n");
- translators_label.show();
- }
- }
- get { return _translator_credits; }
- }
- string _translator_credits = "";
-
- /**
- * The version of the program.
- */
- public string version {
- set { _version = value; set_name_and_version(); }
- get { return _version; }
- }
- string _version = "";
-
- /**
- * The URL for the link to the website of the program.
- */
- public string website {
- set { _website = value; update_website(); }
- get { return _website; }
- }
- string _website = "";
-
- /**
- * The label for the link to the website of the program.
- */
- public string website_label {
- set { _website_label = value; update_website(); }
- get { return _website_label; }
- }
- string _website_label = "";
-
- /**
- * Whether to wrap the text in the license dialog.
- */
- public bool wrap_license {
- set {
- _wrap_license = value;
- license_label.set_line_wrap(_wrap_license);
- }
- get { return _wrap_license; }
- }
- bool _wrap_license = true;
-
- // Signals
- public virtual signal bool activate_link (string uri) {
- // Improve error management FIXME
- bool result = false;
- if (uri != null)
- {
- try {
- result = Gtk.show_uri(get_screen(), uri, Gtk.get_current_event_time());
- } catch (Error err) {
- stderr.printf ("Unable to open the URI: %s", err.message);
- }
- }
- return result;
- }
-
- // UI elements
- Image logo_image;
- Label name_label;
- Label copyright_label;
- Label comments_label;
- Label authors_label;
- Label artists_label;
- Label documenters_label;
- Label translators_label;
- Label license_label;
- Label website_url_label;
- Button close_button;
-
- public HBox action_hbox;
- public HBox action_homogeneous_hbox;
-
- string big_text_markup_start;
- string big_text_markup_end;
-
- /**
- * Creates a new Granite.AboutDialog
- */
- public AboutDialog()
- {
- has_resize_grip = false;
- resizable = false;
- set_default_response(ResponseType.CANCEL);
-
- // Set the markup used for big text (program name and version)
- big_text_markup_start = "<span weight='heavy' size='x-large'>";
- big_text_markup_end = "</span>";
-
- // Set the default containers
- Box content_area = (Box)get_content_area();
- Box action_area = (Box)get_action_area();
- action_area.realize();
- var content_hbox = new HBox(false, 12);
- var content_scrolled = new ScrolledWindow(null, new Adjustment(0, 0, 100, 1, 10, 0));
- var content_viewport = new Viewport(null, null);
- var content_vbox = new VBox(false, 0);
- action_hbox = new HBox(false, action_area.spacing);
- action_homogeneous_hbox = new HBox(true, action_area.spacing);
-
- content_viewport.shadow_type = ShadowType.NONE;
- content_scrolled.hscrollbar_policy = PolicyType.NEVER;
- content_area.pack_start(content_hbox);
- action_area.pack_start(action_hbox);
-
- logo_image = new Image();
-
- // Adjust sizes
- content_hbox.margin = 12;
- action_hbox.margin = 6;
- content_hbox.height_request = 160;
- content_vbox.width_request = 288;
- logo_image.set_size_request(128, 128);
-
- name_label = new Label("");
- name_label.xalign = 0;
- name_label.set_line_wrap(true);
- name_label.use_markup = true;
-
- close_button = new Button.from_stock(Stock.CLOSE);
-
- copyright_label = new Label("");
- copyright_label.set_sensitive(false);
- copyright_label.xalign = 0;
- copyright_label.set_line_wrap(true);
-
- comments_label = new Label("");
- comments_label.set_sensitive(false);
- comments_label.xalign = 0;
- comments_label.set_line_wrap(true);
-
- authors_label = new Label("");
- authors_label.set_sensitive(false);
- authors_label.xalign = 0;
- authors_label.set_line_wrap(true);
-
- artists_label = new Label("");
- artists_label.set_sensitive(false);
- artists_label.xalign = 0;
- artists_label.set_line_wrap(true);
-
- documenters_label = new Label("");
- documenters_label.set_sensitive(false);
- documenters_label.xalign = 0;
- documenters_label.set_line_wrap(true);
-
- translators_label = new Label("");
- translators_label.set_sensitive(false);
- translators_label.xalign = 0;
- translators_label.set_line_wrap(true);
-
- license_label = new Label("");
- license_label.set_sensitive(false);
- license_label.xalign = 0;
- license_label.set_line_wrap(wrap_license);
-
- website_url_label = new Label("");
- website_url_label.set_sensitive(false);
- website_url_label.xalign = 0;
- website_url_label.set_line_wrap(true);
-
- content_hbox.pack_start(logo_image);
- content_hbox.pack_start(content_scrolled);
- content_scrolled.add(content_viewport);
- content_viewport.add(content_vbox);
-
- content_vbox.pack_start(name_label);
- content_vbox.pack_start(comments_label);
- content_vbox.pack_start(website_url_label);
-
- content_vbox.pack_start(copyright_label);
- content_vbox.pack_start(license_label);
-
- content_vbox.pack_start(authors_label);
- content_vbox.pack_start(artists_label);
- content_vbox.pack_start(documenters_label);
- content_vbox.pack_start(translators_label);
-
- action_hbox.pack_start(action_homogeneous_hbox);
- action_homogeneous_hbox.pack_start(close_button);
-
- action_area.show_all();
- content_area.show();
- content_hbox.show();
- content_scrolled.show();
- content_viewport.show();
- content_vbox.show();
- logo_image.show();
-
- close_button.clicked.connect(() => { response(ResponseType.CANCEL); });
+ /**
+ * The people who contributed artwork to the program, as a null-terminated array of strings.
+ */
+ public string[] artists {
+ set {
+ _artists = value;
+ if (_artists == null || _artists.length == 0) {
+ artists_label.hide();
+ artists_label.set_text("");
+ }
+ else {
+ artists_label.set_text(set_string_from_string_array("Designed by" + ":\n", _artists));
+ artists_label.show();
+ }
+ }
+ get { return _artists; }
+ }
+ string[] _artists = new string[0];
+
+ /**
+ * The authors of the program, as a null-terminated array of strings.
+ */
+ public string[] authors {
+ set {
+ _authors = value;
+ if (_authors == null || _authors.length == 0) {
+ authors_label.hide();
+ authors_label.set_text("");
+ }
+ else {
+ authors_label.set_text(set_string_from_string_array("Written by" + ":\n", _authors));
+ authors_label.show();
+ }
+ }
+ get { return _authors; }
+ }
+ string[] _authors = new string[0];
+
+ /**
+ * Comments about the program.
+ */
+ public string comments {
+ set {
+ _comments = value;
+ if (_comments == null || _comments == "") {
+ comments_label.hide();
+ comments_label.set_text("");
+ }
+ else {
+ comments_label.set_text(_comments + "\n");
+ comments_label.show();
+ }
+ }
+ get { return _comments; }
+ }
+ string _comments = "";
+
+ /**
+ * Copyright information for the program.
+ */
+ public string copyright {
+ set {
+ _copyright = value;
+ if (_copyright == null || _copyright == "") {
+ copyright_label.hide();
+ copyright_label.set_text("");
+ }
+ else {
+ copyright_label.set_text("Copyright © " + _copyright + "\n");
+ copyright_label.show();
+ }
+ }
+ get { return _copyright; }
+ }
+ string _copyright = "";
+
+ /**
+ * The people documenting the program, as a null-terminated array of strings.
+ */
+ public string[] documenters {
+ set {
+ _documenters = value;
+ if (documenters.length == 0 || documenters == null)
+ documenters_label.hide();
+ else {
+ documenters_label.show();
+ documenters_label.set_text(set_string_from_string_array("Documented by:\n", documenters));
+ }
+ }
+ get { return _documenters; }
+ }
+ string[] _documenters = new string[0];
+
+ /**
+ * The license of the program.
+ */
+ public string license {
+ set { _license = value; update_license(); }
+ get { return _license; }
+ }
+ string _license = "";
+
+ public License license_type {
+ set { _license_type = value; update_license(); }
+ get { return _license_type; }
+ }
+ License _license_type = License.UNKNOWN;
+
+ /**
+ * A logo for the about box.
+ */
+ public Pixbuf logo {
+ set { _logo = value; update_logo_image(); }
+ get { return _logo; }
+ }
+ Pixbuf _logo = null;
+
+ /**
+ * A named icon to use as the logo for the about box.
+ */
+ public string logo_icon_name {
+ set { _logo_icon_name = value; update_logo_image(); }
+ get { return _logo_icon_name; }
+ }
+ string _logo_icon_name = "";
+
+ /**
+ * The name of the program.
+ */
+ public string program_name {
+ set { _program_name = value; set_name_and_version(); }
+ get { return _program_name; }
+ }
+ string _program_name = "";
+
+ /**
+ * Credits to the translators.
+ */
+ public string translator_credits {
+ set {
+ _translator_credits = value;
+ if (_translator_credits == null || _translator_credits == "") {
+ translators_label.hide();
+ translators_label.set_text("");
+ }
+ else {
+ translators_label.set_text("Translated by: " + _translator_credits + "\n");
+ translators_label.show();
+ }
+ }
+ get { return _translator_credits; }
+ }
+ string _translator_credits = "";
+
+ /**
+ * The version of the program.
+ */
+ public string version {
+ set { _version = value; set_name_and_version(); }
+ get { return _version; }
+ }
+ string _version = "";
+
+ /**
+ * The URL for the link to the website of the program.
+ */
+ public string website {
+ set { _website = value; update_website(); }
+ get { return _website; }
+ }
+ string _website = "";
+
+ /**
+ * The label for the link to the website of the program.
+ */
+ public string website_label {
+ set { _website_label = value; update_website(); }
+ get { return _website_label; }
+ }
+ string _website_label = "";
+
+ // Signals
+ public virtual signal bool activate_link (string uri) {
+ // Improve error management FIXME
+ bool result = false;
+ if (uri != null)
+ {
+ try {
+ result = Gtk.show_uri(get_screen(), uri, Gtk.get_current_event_time());
+ } catch (Error err) {
+ stderr.printf ("Unable to open the URI: %s", err.message);
+ }
+ }
+ return result;
+ }
+
+ // UI elements
+ Image logo_image;
+ Label name_label;
+ Label copyright_label;
+ Label comments_label;
+ Label authors_label;
+ Label artists_label;
+ Label documenters_label;
+ Label translators_label;
+ Label license_label;
+ Label website_url_label;
+ Button close_button;
+
+ string big_text_markup_start;
+ string big_text_markup_end;
+
+ /**
+ * Creates a new Granite.AboutDialog
+ */
+ public AboutDialog()
+ {
+ has_resize_grip = false;
+ resizable = false;
+ set_default_response(ResponseType.CANCEL);
+
+ // Set the markup used for big text (program name and version)
+ big_text_markup_start = "<span weight='heavy' size='x-large'>";
+ big_text_markup_end = "</span>";
+
+ // Set the default containers
+ Box content_area = (Box)get_content_area();
+ Box action_area = (Box)get_action_area();
+ action_area.set_border_width (5);
+
+ var content_hbox = new HBox(false, 12);
+ var content_scrolled = new ScrolledWindow(null, new Adjustment(0, 0, 100, 1, 10, 0));
+ var content_vbox = new VBox(false, 0);
+
+ content_scrolled.shadow_type = ShadowType.NONE;
+ content_scrolled.hscrollbar_policy = PolicyType.NEVER;
+ content_scrolled.vscrollbar_policy = PolicyType.AUTOMATIC;
+ content_area.pack_start(content_hbox);
+
+ logo_image = new Image();
+
+ // Adjust sizes
+ content_hbox.margin = 12;
+ content_hbox.height_request = 160;
+ content_vbox.width_request = 288;
+ logo_image.set_size_request(128, 128);
+
+ name_label = new Label("");
+ name_label.xalign = 0;
+ name_label.set_line_wrap(true);
+ name_label.set_selectable(true);
+ name_label.use_markup = true;
+
+ copyright_label = new Label("");
+ copyright_label.set_selectable(true);
+ copyright_label.xalign = 0;
+ copyright_label.set_line_wrap(true);
+
+ comments_label = new Label("");
+ comments_label.set_selectable(true);
+ comments_label.xalign = 0;
+ comments_label.set_line_wrap(true);
+
+ authors_label = new Label("");
+ authors_label.set_selectable(true);
+ authors_label.xalign = 0;
+ authors_label.set_line_wrap(true);
+
+ artists_label = new Label("");
+ artists_label.set_selectable(true);
+ artists_label.xalign = 0;
+ artists_label.set_line_wrap(true);
+
+ documenters_label = new Label("");
+ documenters_label.set_selectable(true);
+ documenters_label.xalign = 0;
+ documenters_label.set_line_wrap(true);
+
+ translators_label = new Label("");
+ translators_label.set_selectable(true);
+ translators_label.xalign = 0;
+ translators_label.set_line_wrap(true);
+
+ license_label = new WrapLabel("");
+ license_label.set_selectable(true);
+
+ website_url_label = new Label("");
+ website_url_label.xalign = 0;
+ website_url_label.set_line_wrap(true);
+
+ content_hbox.pack_start(logo_image);
+ content_hbox.pack_start(content_scrolled);
+ content_scrolled.add_with_viewport(content_vbox);
+
+ content_vbox.pack_start(name_label);
+ content_vbox.pack_start(comments_label);
+ content_vbox.pack_start(website_url_label);
+
+ content_vbox.pack_start(copyright_label);
+ content_vbox.pack_start(license_label);
+
+ content_vbox.pack_start(authors_label);
+ content_vbox.pack_start(artists_label);
+ content_vbox.pack_start(documenters_label);
+ content_vbox.pack_start(translators_label);
+
+ close_button = new Button.from_stock(Stock.CLOSE);
+ close_button.clicked.connect(() => { response(ResponseType.CANCEL); });
+ action_area.pack_end (close_button, false, false, 0);
+
+ content_area.show();
+ content_hbox.show();
+ content_scrolled.show();
+ content_vbox.show();
+ logo_image.show();
+
+ action_area.show_all();
close_button.grab_focus();
- }
-
- private string set_string_from_string_array(string title, string[] list)
- {
- string text = title;
- foreach (string i in list)
- text += i + "\n";
- return text;
- }
-
- private void update_logo_image()
- {
- try {
- logo_image.set_from_pixbuf(IconTheme.get_default ().load_icon ("application-default-icon", 128, 0));
- } catch (Error err) {
- stderr.printf ("Unable to load terminal icon: %s", err.message);
- }
- if (logo_icon_name != null && logo_icon_name != "") {
- try {
- logo_image.set_from_pixbuf(IconTheme.get_default ().load_icon (logo_icon_name, 128, 0));
- } catch (Error err) {
- stderr.printf ("Unable to load terminal icon: %s", err.message);
- }
- }
- else if (logo != null)
- logo_image.set_from_pixbuf(logo);
- }
-
- private void update_license()
- {
- switch (license_type) {
- case License.GPL_2_0:
- set_generic_license("http://www.gnu.org/licenses/old-licenses/gpl-2.0.html");
- break;
- case License.GPL_3_0:
- set_generic_license("http://www.gnu.org/licenses/gpl.html");
- break;
- case License.LGPL_2_1:
- set_generic_license("http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html");
- break;
- case License.LGPL_3_0:
- set_generic_license("http://www.gnu.org/licenses/lgpl.html");
- break;
- case License.BSD:
- set_generic_license("http://opensource.org/licenses/bsd-license.php");
- break;
- case License.MIT_X11:
- set_generic_license("http://opensource.org/licenses/mit-license.php");
- break;
- case License.ARTISTIC:
- set_generic_license("http://opensource.org/licenses/artistic-license-2.0.php");
- break;
- default:
- if (license != null && license != "") {
- license_label.set_markup(license + "\n");
- license_label.show();
- }
- else
- license_label.hide();
- break;
- }
- }
-
- private void set_generic_license(string url)
- {
- license_label.set_markup("This program comes with ABSOLUTELY NO WARRANTY; for details, visit <a href=\"" + url + "\">" + url + "</a>\n");
- license_label.show();
- }
-
- private void set_name_and_version()
- {
- if (program_name != null && program_name != "")
- {
- name_label.set_text(program_name);
- if (version != null && version != "")
- name_label.set_text(name_label.get_text() + " " + version);
- name_label.set_markup(big_text_markup_start + name_label.get_text() + big_text_markup_end + "\n");
- name_label.show();
- }
- else
- name_label.hide();
- }
-
- private void update_website()
- {
- if (website != null && website != "") {
- if (website != null && website != "") {
- website_url_label.set_markup("<a href=\"" + website + "\">" + website_label + "</a>\n");
- }
- else
- website_url_label.set_markup("<a href=\"" + website + "\">" + website + "</a>\n");
- website_url_label.show();
- }
- else
- website_url_label.hide();
- }
+ }
+
+ private string set_string_from_string_array(string title, string[] list)
+ {
+ string text = title;
+ foreach (string i in list)
+ text += i + "\n";
+ return text;
+ }
+
+ private void update_logo_image()
+ {
+ try {
+ logo_image.set_from_pixbuf(IconTheme.get_default ().load_icon ("application-default-icon", 128, 0));
+ } catch (Error err) {
+ stderr.printf ("Unable to load terminal icon: %s", err.message);
+ }
+ if (logo_icon_name != null && logo_icon_name != "") {
+ try {
+ logo_image.set_from_pixbuf(IconTheme.get_default ().load_icon (logo_icon_name, 128, 0));
+ } catch (Error err) {
+ stderr.printf ("Unable to load terminal icon: %s", err.message);
+ }
+ }
+ else if (logo != null)
+ logo_image.set_from_pixbuf(logo);
+ }
+
+ private void update_license()
+ {
+ switch (license_type) {
+ case License.GPL_2_0:
+ set_generic_license("http://www.gnu.org/licenses/old-licenses/gpl-2.0.html");
+ break;
+ case License.GPL_3_0:
+ set_generic_license("http://www.gnu.org/licenses/gpl.html");
+ break;
+ case License.LGPL_2_1:
+ set_generic_license("http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html");
+ break;
+ case License.LGPL_3_0:
+ set_generic_license("http://www.gnu.org/licenses/lgpl.html");
+ break;
+ case License.BSD:
+ set_generic_license("http://opensource.org/licenses/bsd-license.php");
+ break;
+ case License.MIT_X11:
+ set_generic_license("http://opensource.org/licenses/mit-license.php");
+ break;
+ case License.ARTISTIC:
+ set_generic_license("http://opensource.org/licenses/artistic-license-2.0.php");
+ break;
+ default:
+ if (license != null && license != "") {
+ license_label.set_markup(license + "\n");
+ license_label.show();
+ }
+ else
+ license_label.hide();
+ break;
+ }
+ }
+
+ private void set_generic_license(string url)
+ {
+ license_label.set_markup("This program comes with ABSOLUTELY NO WARRANTY; for details, visit <a href=\"" + url + "\">" + url + "</a>\n");
+ license_label.show();
+ }
+
+ private void set_name_and_version()
+ {
+ if (program_name != null && program_name != "")
+ {
+ name_label.set_text(program_name);
+ if (version != null && version != "")
+ name_label.set_text(name_label.get_text() + " " + version);
+ name_label.set_markup(big_text_markup_start + name_label.get_text() + big_text_markup_end + "\n");
+ name_label.show();
+ }
+ else
+ name_label.hide();
+ }
+
+ private void update_website()
+ {
+ if (website != null && website != "") {
+ if (website != null && website != "") {
+ website_url_label.set_markup("<a href=\"" + website + "\">" + website_label + "</a>\n");
+ }
+ else
+ website_url_label.set_markup("<a href=\"" + website + "\">" + website + "</a>\n");
+ website_url_label.show();
+ }
+ else
+ website_url_label.hide();
+ }
}
=== modified file 'lib/Widgets/AboutDialog.vala'
--- lib/Widgets/AboutDialog.vala 2011-10-04 17:46:01 +0000
+++ lib/Widgets/AboutDialog.vala 2011-10-10 15:35:18 +0000
@@ -25,73 +25,78 @@
public class Granite.Widgets.AboutDialog : Granite.GtkPatch.AboutDialog
{
- /**
- * The URL for the link to the website of the program.
- */
- public string help {
- set {
- _help = value;
- help_button.sensitive = !(_help == null || _help == "");
- }
- get { return _help; }
- }
- string _help = "";
-
- /**
- * The URL for the link to the website of the program.
- */
- public string translate {
- set {
- _translate = value;
- translate_button.sensitive = !(_translate == null || _translate == "");
- }
- get { return _translate; }
- }
- string _translate = "";
-
- /**
- * The URL for the link to the website of the program.
- */
- public string bug {
- set {
- _bug = value;
- bug_button.sensitive = !(_bug == null || _bug == "");
- }
- get { return _bug; }
- }
- string _bug = "";
-
- Button help_button;
- Button translate_button;
- Button bug_button;
-
- /**
- * Creates a new Granite.AboutDialog
- */
- public AboutDialog()
- {
- // Creating the buttons
- help_button = new Button.with_label(" ? ");
+ /**
+ * The URL for the link to the website of the program.
+ */
+ public string help {
+ set {
+ _help = value;
+ help_button.sensitive = !(_help == null || _help == "");
+ }
+ get { return _help; }
+ }
+ string _help = "";
+
+ /**
+ * The URL for the link to the website of the program.
+ */
+ public string translate {
+ set {
+ _translate = value;
+ translate_button.sensitive = !(_translate == null || _translate == "");
+ }
+ get { return _translate; }
+ }
+ string _translate = "";
+
+ /**
+ * The URL for the link to the website of the program.
+ */
+ public string bug {
+ set {
+ _bug = value;
+ bug_button.sensitive = !(_bug == null || _bug == "");
+ }
+ get { return _bug; }
+ }
+ string _bug = "";
+
+ Button help_button;
+ Button translate_button;
+ Button bug_button;
+
+ /**
+ * Creates a new Granite.AboutDialog
+ */
+ public AboutDialog()
+ {
+ Box action_area = (Box)get_action_area();
+
+ /* help button */
+ help_button = new Button.with_label(" ? ");
help_button.get_style_context ().add_class ("help_button");
- help_button.pressed.connect(() => { activate_link(help); });
-
- translate_button = new Button.with_label("Translate this app");
- translate_button.pressed.connect(() => { activate_link(translate); });
-
- bug_button = new Button.with_label("Report a problem");
- bug_button.pressed.connect(() => { activate_link(bug); });
-
- // Pack
- action_hbox.pack_start(help_button);
- action_hbox.reorder_child(help_button, 0);
- action_homogeneous_hbox.pack_start(translate_button);
- action_homogeneous_hbox.pack_start(bug_button);
- action_homogeneous_hbox.reorder_child(bug_button, 0);
- action_homogeneous_hbox.reorder_child(translate_button, 0);
-
- // Show
- help_button.show();
- translate_button.show();
- bug_button.show();
- }
+ help_button.halign = Gtk.Align.CENTER;
+ /* FIXME test & discuss and fix this ugly hack */
+ help_button.set_size_request (25, -1);
+ help_button.pressed.connect(() => { activate_link(help); });
+ action_area.pack_end (help_button, false, false, 0);
+ ((Gtk.ButtonBox) action_area).set_child_secondary (help_button, true);
+ ((Gtk.ButtonBox) action_area).set_child_non_homogeneous (help_button, true);
+
+ /* translate button */
+ translate_button = new Button.with_label("Translate this app");
+ translate_button.pressed.connect(() => { activate_link(translate); });
+ action_area.pack_start (translate_button, false, false, 0);
+
+ /* bug button */
+ bug_button = new Button.with_label("Report a problem");
+ bug_button.pressed.connect(() => { activate_link(bug); });
+ action_area.pack_start (bug_button, false, false, 0);
+
+ action_area.reorder_child(bug_button, 0);
+ action_area.reorder_child(translate_button, 0);
+
+ action_area.show_all();
+
+ }
}
=== added file 'lib/Widgets/WrapLabel.vala'
--- lib/Widgets/WrapLabel.vala 1970-01-01 00:00:00 +0000
+++ lib/Widgets/WrapLabel.vala 2011-10-10 15:35:18 +0000
@@ -0,0 +1,57 @@
+using Gtk;
+
+/** Label with NORMAL wrapping. Thanks to VMWare team */
+public class Granite.WrapLabel : Label {
+
+ public int m_wrap_width = 0;
+ public int m_wrap_height = 0;
+
+ public signal void link_activated(string prot, string uri);
+
+ public WrapLabel(string? str = null) {
+ wrap = true;
+ get_layout().set_wrap(Pango.WrapMode.WORD_CHAR);
+ set_alignment(0, 0);
+
+ set_text(str);
+ set_wrap_width(m_wrap_width);
+
+ activate_link.connect(link_clicked);
+ }
+
+ private bool link_clicked(string url) {
+ link_activated(url.split("://")[0], url.split("://")[1]);
+ return true;
+ }
+
+ private void set_wrap_width(int width) {
+ if (width == 0) {
+ return;
+ }
+
+ get_layout().set_width((int) (width * Pango.SCALE));
+
+ int unused = 0;
+ get_layout().get_pixel_size(out unused, out m_wrap_height);
+
+ if (m_wrap_width != width) {
+ m_wrap_width = width;
+ queue_resize();
+ }
+ }
+
+ public override void get_preferred_width (out int minimum_width, out int natural_width)
+ {
+ minimum_width = natural_width = m_wrap_width;
+ }
+
+ public override void size_allocate(Gtk.Allocation alloc) {
+ base.size_allocate(alloc);
+ set_wrap_width(alloc.width);
+ }
+
+ public void set_markup_plus(string txt) {
+ set_markup(txt);
+ set_wrap_width(m_wrap_width);
+ }
+}
Follow ups