[nautilus] properties-window: port GtkTable to GtkGrid
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] properties-window: port GtkTable to GtkGrid
- Date: Wed, 5 Oct 2011 14:12:21 +0000 (UTC)
commit 0026899cd9f5cd636b4a44ec838e2ec228b210bb
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue Oct 4 20:59:51 2011 -0400
properties-window: port GtkTable to GtkGrid
Except for the pie chart, which will be ported in a separate commit
src/nautilus-properties-window.c | 792 +++++++++++++++++---------------------
1 files changed, 346 insertions(+), 446 deletions(-)
---
diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c
index 3f8185d..1c33d50 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -92,9 +92,7 @@ struct NautilusPropertiesWindowDetails {
GtkNotebook *notebook;
- GtkTable *basic_table;
- GtkTable *permissions_table;
- gboolean advanced_permissions;
+ GtkGrid *basic_grid;
GtkWidget *icon_button;
GtkWidget *icon_image;
@@ -144,19 +142,11 @@ struct NautilusPropertiesWindowDetails {
GdkRGBA free_stroke_color;
};
-enum {
- PERMISSIONS_CHECKBOXES_OWNER_ROW,
- PERMISSIONS_CHECKBOXES_GROUP_ROW,
- PERMISSIONS_CHECKBOXES_OTHERS_ROW,
- PERMISSIONS_CHECKBOXES_ROW_COUNT
-};
-
-enum {
- PERMISSIONS_CHECKBOXES_READ_COLUMN,
- PERMISSIONS_CHECKBOXES_WRITE_COLUMN,
- PERMISSIONS_CHECKBOXES_EXECUTE_COLUMN,
- PERMISSIONS_CHECKBOXES_COLUMN_COUNT
-};
+typedef enum {
+ PERMISSIONS_CHECKBOXES_READ,
+ PERMISSIONS_CHECKBOXES_WRITE,
+ PERMISSIONS_CHECKBOXES_EXECUTE
+} CheckboxType;
enum {
TITLE_COLUMN,
@@ -229,15 +219,13 @@ static gboolean name_field_focus_out (NautilusEntry *name_field,
gpointer callback_data);
static void name_field_activate (NautilusEntry *name_field,
gpointer callback_data);
-static GtkLabel *attach_ellipsizing_value_label (GtkTable *table,
- int row,
- int column,
+static GtkLabel *attach_ellipsizing_value_label (GtkGrid *grid,
+ GtkWidget *sibling,
const char *initial_text);
static GtkWidget* create_pie_widget (NautilusPropertiesWindow *window);
G_DEFINE_TYPE (NautilusPropertiesWindow, nautilus_properties_window, GTK_TYPE_DIALOG);
-#define parent_class nautilus_properties_window_parent_class
static gboolean
is_multi_file_window (NautilusPropertiesWindow *window)
@@ -562,8 +550,9 @@ create_image_widget (NautilusPropertiesWindow *window,
}
static void
-set_name_field (NautilusPropertiesWindow *window, const gchar *original_name,
- const gchar *name)
+set_name_field (NautilusPropertiesWindow *window,
+ const gchar *original_name,
+ const gchar *name)
{
gboolean new_widget;
gboolean use_label;
@@ -583,23 +572,18 @@ set_name_field (NautilusPropertiesWindow *window, const gchar *original_name,
}
if (use_label) {
- window->details->name_field =
- GTK_WIDGET (attach_ellipsizing_value_label
- (window->details->basic_table,
- window->details->name_row,
- VALUE_COLUMN, name));
+ window->details->name_field = GTK_WIDGET
+ (attach_ellipsizing_value_label (window->details->basic_grid,
+ GTK_WIDGET (window->details->name_label),
+ name));
} else {
window->details->name_field = nautilus_entry_new ();
gtk_entry_set_text (GTK_ENTRY (window->details->name_field), name);
gtk_widget_show (window->details->name_field);
- gtk_table_attach (window->details->basic_table,
- window->details->name_field,
- VALUE_COLUMN,
- VALUE_COLUMN + 1,
- window->details->name_row,
- window->details->name_row + 1,
- GTK_FILL, 0,
- 0, 0);
+
+ gtk_grid_attach_next_to (window->details->basic_grid, window->details->name_field,
+ GTK_WIDGET (window->details->name_label),
+ GTK_POS_RIGHT, 1, 1);
gtk_label_set_mnemonic_widget (GTK_LABEL (window->details->name_label), window->details->name_field);
/* FIXME bugzilla.gnome.org 42151:
@@ -1199,9 +1183,8 @@ value_field_update (NautilusPropertiesWindow *window, GtkLabel *label)
}
static GtkLabel *
-attach_label (GtkTable *table,
- int row,
- int column,
+attach_label (GtkGrid *grid,
+ GtkWidget *sibling,
const char *initial_text,
gboolean right_aligned,
gboolean bold,
@@ -1231,41 +1214,41 @@ attach_label (GtkTable *table,
}
gtk_misc_set_alignment (GTK_MISC (label_field), right_aligned ? 1 : 0, 0.5);
gtk_widget_show (label_field);
- gtk_table_attach (table, label_field,
- column, column + 1,
- row, row + 1,
- ellipsize_text
- ? GTK_FILL | GTK_EXPAND
- : GTK_FILL,
- 0,
- 0, 0);
+
+ if (ellipsize_text) {
+ gtk_widget_set_hexpand (label_field, TRUE);
+ }
+
+ if (sibling != NULL) {
+ gtk_grid_attach_next_to (grid, label_field, sibling,
+ GTK_POS_RIGHT, 1, 1);
+ } else {
+ gtk_container_add (GTK_CONTAINER (grid), label_field);
+ }
return GTK_LABEL (label_field);
}
static GtkLabel *
-attach_value_label (GtkTable *table,
- int row,
- int column,
- const char *initial_text)
+attach_value_label (GtkGrid *grid,
+ GtkWidget *sibling,
+ const char *initial_text)
{
- return attach_label (table, row, column, initial_text, FALSE, FALSE, FALSE, TRUE, FALSE);
+ return attach_label (grid, sibling, initial_text, FALSE, FALSE, FALSE, TRUE, FALSE);
}
static GtkLabel *
-attach_ellipsizing_value_label (GtkTable *table,
- int row,
- int column,
+attach_ellipsizing_value_label (GtkGrid *grid,
+ GtkWidget *sibling,
const char *initial_text)
{
- return attach_label (table, row, column, initial_text, FALSE, FALSE, TRUE, TRUE, FALSE);
+ return attach_label (grid, sibling, initial_text, FALSE, FALSE, TRUE, TRUE, FALSE);
}
static GtkWidget*
attach_value_field_internal (NautilusPropertiesWindow *window,
- GtkTable *table,
- int row,
- int column,
+ GtkGrid *grid,
+ GtkWidget *sibling,
const char *file_attribute_name,
const char *inconsistent_string,
gboolean show_original,
@@ -1274,9 +1257,9 @@ attach_value_field_internal (NautilusPropertiesWindow *window,
GtkLabel *value_field;
if (ellipsize_text) {
- value_field = attach_ellipsizing_value_label (table, row, column, "");
+ value_field = attach_ellipsizing_value_label (grid, sibling, "");
} else {
- value_field = attach_value_label (table, row, column, "");
+ value_field = attach_value_label (grid, sibling, "");
}
/* Stash a copy of the file attribute name in this field for the callback's sake. */
@@ -1295,36 +1278,34 @@ attach_value_field_internal (NautilusPropertiesWindow *window,
static GtkWidget*
attach_value_field (NautilusPropertiesWindow *window,
- GtkTable *table,
- int row,
- int column,
+ GtkGrid *grid,
+ GtkWidget *sibling,
const char *file_attribute_name,
const char *inconsistent_string,
gboolean show_original)
{
return attach_value_field_internal (window,
- table, row, column,
- file_attribute_name,
- inconsistent_string,
- show_original,
- FALSE);
+ grid, sibling,
+ file_attribute_name,
+ inconsistent_string,
+ show_original,
+ FALSE);
}
static GtkWidget*
attach_ellipsizing_value_field (NautilusPropertiesWindow *window,
- GtkTable *table,
- int row,
- int column,
+ GtkGrid *grid,
+ GtkWidget *sibling,
const char *file_attribute_name,
const char *inconsistent_string,
gboolean show_original)
{
return attach_value_field_internal (window,
- table, row, column,
- file_attribute_name,
- inconsistent_string,
- show_original,
- TRUE);
+ grid, sibling,
+ file_attribute_name,
+ inconsistent_string,
+ show_original,
+ TRUE);
}
static void
@@ -1676,8 +1657,8 @@ combo_box_row_separator_func (GtkTreeModel *model,
}
static GtkComboBox *
-attach_combo_box (GtkTable *table,
- int row,
+attach_combo_box (GtkGrid *grid,
+ GtkWidget *sibling,
gboolean two_columns)
{
GtkWidget *combo_box;
@@ -1708,28 +1689,25 @@ attach_combo_box (GtkTable *table,
/* Put combo box in alignment to make it left-justified
* but minimally sized.
- */
+ */
aligner = gtk_alignment_new (0, 0.5, 0, 0);
gtk_widget_show (aligner);
gtk_container_add (GTK_CONTAINER (aligner), combo_box);
- gtk_table_attach (table, aligner,
- VALUE_COLUMN, VALUE_COLUMN + 1,
- row, row + 1,
- GTK_FILL, 0,
- 0, 0);
+ gtk_grid_attach_next_to (grid, aligner, sibling,
+ GTK_POS_RIGHT, 1, 1);
return GTK_COMBO_BOX (combo_box);
}
static GtkComboBox*
-attach_group_combo_box (GtkTable *table,
- int row,
+attach_group_combo_box (GtkGrid *grid,
+ GtkWidget *sibling,
NautilusFile *file)
{
GtkComboBox *combo_box;
- combo_box = attach_combo_box (table, row, FALSE);
+ combo_box = attach_combo_box (grid, sibling, FALSE);
synch_groups_combo_box (combo_box, file);
@@ -2007,13 +1985,13 @@ synch_user_menu (GtkComboBox *combo_box, NautilusFile *file)
}
static GtkComboBox*
-attach_owner_combo_box (GtkTable *table,
- int row,
+attach_owner_combo_box (GtkGrid *grid,
+ GtkWidget *sibling,
NautilusFile *file)
{
GtkComboBox *combo_box;
- combo_box = attach_combo_box (table, row, TRUE);
+ combo_box = attach_combo_box (grid, sibling, TRUE);
synch_user_menu (combo_box, file);
@@ -2029,22 +2007,6 @@ attach_owner_combo_box (GtkTable *table,
return combo_box;
}
-static guint
-append_row (GtkTable *table)
-{
- guint new_row_count;
- gint nrows, ncols;
-
- g_object_get (table, "n-rows", &nrows, "n-columns", &ncols, NULL);
-
- new_row_count = nrows + 1;
-
- gtk_table_resize (table, new_row_count, ncols);
- gtk_table_set_row_spacing (table, new_row_count - 1, ROW_PAD);
-
- return new_row_count - 1;
-}
-
static gboolean
file_has_prefix (NautilusFile *file,
GList *prefix_candidates)
@@ -2225,14 +2187,14 @@ schedule_directory_contents_update (NautilusPropertiesWindow *window)
static GtkLabel *
attach_directory_contents_value_field (NautilusPropertiesWindow *window,
- GtkTable *table,
- int row)
+ GtkGrid *grid,
+ GtkWidget *sibling)
{
GtkLabel *value_field;
GList *l;
NautilusFile *file;
- value_field = attach_value_label (table, row, VALUE_COLUMN, "");
+ value_field = attach_value_label (grid, sibling, "");
g_assert (window->details->directory_contents_value_field == NULL);
window->details->directory_contents_value_field = value_field;
@@ -2256,56 +2218,37 @@ attach_directory_contents_value_field (NautilusPropertiesWindow *window,
}
static GtkLabel *
-attach_title_field (GtkTable *table,
- int row,
- const char *title)
+attach_title_field (GtkGrid *grid,
+ const char *title)
{
- return attach_label (table, row, TITLE_COLUMN, title, FALSE, FALSE, FALSE, FALSE, TRUE);
+ return attach_label (grid, NULL, title, FALSE, FALSE, FALSE, FALSE, TRUE);
}
-static guint
-append_title_field (GtkTable *table, const char *title, GtkLabel **label)
-{
- guint last_row;
- GtkLabel *title_label;
-
- last_row = append_row (table);
- title_label = attach_title_field (table, last_row, title);
-
- if (label) {
- *label = title_label;
- }
-
- return last_row;
-}
-
#define INCONSISTENT_STATE_STRING \
"\xE2\x80\x92"
-static guint
+static void
append_title_value_pair (NautilusPropertiesWindow *window,
- GtkTable *table,
+ GtkGrid *grid,
const char *title,
const char *file_attribute_name,
const char *inconsistent_state,
gboolean show_original)
{
- guint last_row;
GtkLabel *title_label;
GtkWidget *value;
- last_row = append_title_field (table, title, &title_label);
- value = attach_value_field (window, table, last_row, VALUE_COLUMN,
- file_attribute_name,
- inconsistent_state,
- show_original);
+ title_label = attach_title_field (grid, title);
+ value = attach_value_field (window, grid, GTK_WIDGET (title_label),
+ file_attribute_name,
+ inconsistent_state,
+ show_original);
gtk_label_set_mnemonic_widget (title_label, value);
- return last_row;
}
-static guint
+static void
append_title_and_ellipsizing_value (NautilusPropertiesWindow *window,
- GtkTable *table,
+ GtkGrid *grid,
const char *title,
const char *file_attribute_name,
const char *inconsistent_state,
@@ -2313,36 +2256,30 @@ append_title_and_ellipsizing_value (NautilusPropertiesWindow *window,
{
GtkLabel *title_label;
GtkWidget *value;
- guint last_row;
- last_row = append_title_field (table, title, &title_label);
- value = attach_ellipsizing_value_field (window, table, last_row, VALUE_COLUMN,
- file_attribute_name,
- inconsistent_state,
- show_original);
+ title_label = attach_title_field (grid, title);
+ value = attach_ellipsizing_value_field (window, grid,
+ GTK_WIDGET (title_label),
+ file_attribute_name,
+ inconsistent_state,
+ show_original);
gtk_label_set_mnemonic_widget (title_label, value);
-
- return last_row;
}
-static guint
+static void
append_directory_contents_fields (NautilusPropertiesWindow *window,
- GtkTable *table)
+ GtkGrid *grid)
{
GtkLabel *title_field, *value_field;
- guint last_row;
-
- last_row = append_row (table);
- title_field = attach_title_field (table, last_row, "");
+ title_field = attach_title_field (grid, "");
window->details->directory_contents_title_field = title_field;
gtk_label_set_line_wrap (title_field, TRUE);
value_field = attach_directory_contents_value_field
- (window, table, last_row);
+ (window, grid, GTK_WIDGET (title_field));
- gtk_label_set_mnemonic_widget(title_field, GTK_WIDGET(value_field));
- return last_row;
+ gtk_label_set_mnemonic_widget (title_field, GTK_WIDGET(value_field));
}
static GtkWidget *
@@ -2385,33 +2322,44 @@ create_page_with_vbox (GtkNotebook *notebook,
}
static GtkWidget *
-append_blank_row (GtkTable *table)
+append_blank_row (GtkGrid *grid)
{
- GtkWidget *separator;
-
- append_title_field (table, "", (GtkLabel **) &separator);
-
- return separator;
+ return GTK_WIDGET (attach_title_field (grid, ""));
}
static void
-apply_standard_table_padding (GtkTable *table)
+append_blank_slim_row (GtkGrid *grid)
{
- gtk_table_set_row_spacings (table, ROW_PAD);
- gtk_table_set_col_spacings (table, 12);
+ GtkWidget *w;
+ PangoAttribute *attribute;
+ PangoAttrList *attr_list;
+
+ attr_list = pango_attr_list_new ();
+ attribute = pango_attr_scale_new (0.30);
+ pango_attr_list_insert (attr_list, attribute);
+
+ w = gtk_label_new (NULL);
+ gtk_label_set_attributes (GTK_LABEL (w), attr_list);
+ gtk_widget_show (w);
+
+ pango_attr_list_unref (attr_list);
+
+ gtk_container_add (GTK_CONTAINER (grid), w);
}
static GtkWidget *
-create_attribute_value_table (GtkWidget *vbox, int row_count)
+create_grid_with_standard_properties (void)
{
- GtkWidget *table;
+ GtkWidget *grid;
- table = gtk_table_new (row_count, COLUMN_COUNT, FALSE);
- apply_standard_table_padding (GTK_TABLE (table));
- gtk_widget_show (table);
- gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
+ grid = gtk_grid_new ();
+ gtk_container_set_border_width (GTK_CONTAINER (grid), 6);
+ gtk_grid_set_row_spacing (GTK_GRID (grid), ROW_PAD);
+ gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_VERTICAL);
+ gtk_widget_show (grid);
- return table;
+ return grid;
}
static gboolean
@@ -2902,7 +2850,7 @@ static GtkWidget*
create_pie_widget (NautilusPropertiesWindow *window)
{
NautilusFile *file;
- GtkTable *table;
+ GtkTable *table;
GtkStyleContext *style;
GtkWidget *pie_canvas;
GtkWidget *used_canvas;
@@ -3041,13 +2989,11 @@ create_volume_usage_widget (NautilusPropertiesWindow *window)
static void
create_basic_page (NautilusPropertiesWindow *window)
{
- GtkTable *table;
+ GtkGrid *grid;
GtkWidget *icon_aligner;
GtkWidget *icon_pixmap_widget;
GtkWidget *volume_usage;
GtkWidget *hbox, *vbox;
-
- guint last_row, row;
hbox = create_page_with_hbox (window->details->notebook, _("Basic"),
"help:gnome-help/nautilus-file-properties-basic");
@@ -3072,12 +3018,12 @@ create_basic_page (NautilusPropertiesWindow *window)
gtk_widget_show (vbox);
gtk_container_add (GTK_CONTAINER (hbox), vbox);
- table = GTK_TABLE (create_attribute_value_table (vbox, 0));
- window->details->basic_table = table;
+ grid = GTK_GRID (create_grid_with_standard_properties ());
+ gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (grid), FALSE, FALSE, 0);
+ window->details->basic_grid = grid;
/* Name label. The text will be determined in update_name_field */
- row = append_title_field (table, NULL, &window->details->name_label);
- window->details->name_row = row;
+ window->details->name_label = attach_title_field (grid, NULL);
/* Name field */
window->details->name_field = NULL;
@@ -3093,31 +3039,27 @@ create_basic_page (NautilusPropertiesWindow *window)
GtkSizeGroup *label_size_group;
GtkWidget *box;
- row = append_row (table);
-
label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
gtk_size_group_add_widget (label_size_group,
GTK_WIDGET (window->details->name_label));
box = nautilus_desktop_item_properties_make_box (label_size_group,
window->details->target_files);
- gtk_table_attach (window->details->basic_table, box,
- TITLE_COLUMN, VALUE_COLUMN + 1,
- row, row + 1,
- GTK_FILL, 0,
- 0, 0);
+ gtk_grid_attach_next_to (window->details->basic_grid, box,
+ GTK_WIDGET (window->details->name_label),
+ GTK_POS_BOTTOM, 1, 1);
}
if (should_show_file_type (window)) {
append_title_value_pair (window,
- table, _("Type:"),
+ grid, _("Type:"),
"type",
INCONSISTENT_STATE_STRING,
FALSE);
}
if (should_show_link_target (window)) {
- append_title_and_ellipsizing_value (window, table,
+ append_title_and_ellipsizing_value (window, grid,
_("Link target:"),
"link_target",
INCONSISTENT_STATE_STRING,
@@ -3126,23 +3068,23 @@ create_basic_page (NautilusPropertiesWindow *window)
if (is_multi_file_window (window) ||
nautilus_file_is_directory (get_target_file (window))) {
- append_directory_contents_fields (window, table);
+ append_directory_contents_fields (window, grid);
} else {
- append_title_value_pair (window, table, _("Size:"),
+ append_title_value_pair (window, grid, _("Size:"),
"size_detail",
INCONSISTENT_STATE_STRING,
FALSE);
}
- append_blank_row (table);
+ append_blank_row (grid);
if (should_show_location_info (window)) {
- append_title_and_ellipsizing_value (window, table, _("Location:"),
+ append_title_and_ellipsizing_value (window, grid, _("Location:"),
"where",
INCONSISTENT_STATE_STRING,
TRUE);
- append_title_and_ellipsizing_value (window, table,
+ append_title_and_ellipsizing_value (window, grid,
_("Volume:"),
"volume",
INCONSISTENT_STATE_STRING,
@@ -3150,31 +3092,32 @@ create_basic_page (NautilusPropertiesWindow *window)
}
if (should_show_accessed_date (window)) {
- append_blank_row (table);
+ append_blank_row (grid);
- append_title_value_pair (window, table, _("Accessed:"),
+ append_title_value_pair (window, grid, _("Accessed:"),
"date_accessed",
INCONSISTENT_STATE_STRING,
FALSE);
- append_title_value_pair (window, table, _("Modified:"),
+ append_title_value_pair (window, grid, _("Modified:"),
"date_modified",
INCONSISTENT_STATE_STRING,
FALSE);
}
if (should_show_free_space (window)) {
- append_blank_row (table);
+ append_blank_row (grid);
- append_title_value_pair (window, table, _("Free space:"),
+ append_title_value_pair (window, grid, _("Free space:"),
"free_space",
INCONSISTENT_STATE_STRING,
FALSE);
}
if (should_show_volume_usage (window)) {
- last_row = append_row (table);
volume_usage = create_volume_usage_widget (window);
- gtk_table_attach_defaults (GTK_TABLE(table), volume_usage, 0, 2, last_row, last_row+1);
+ gtk_container_add_with_properties (GTK_CONTAINER (grid), volume_usage,
+ "width", 2,
+ NULL);
}
}
@@ -3537,10 +3480,10 @@ set_up_permissions_checkbox (NautilusPropertiesWindow *window,
0);
}
-static void
+static GtkWidget *
add_permissions_checkbox_with_label (NautilusPropertiesWindow *window,
- GtkTable *table,
- int row, int column,
+ GtkGrid *grid,
+ GtkWidget *sibling,
const char *label,
guint32 permission_to_check,
GtkLabel *label_for,
@@ -3551,11 +3494,9 @@ add_permissions_checkbox_with_label (NautilusPropertiesWindow *window,
check_button = gtk_check_button_new_with_mnemonic (label);
gtk_widget_show (check_button);
- gtk_table_attach (table, check_button,
- column, column + 1,
- row, row + 1,
- GTK_FILL, 0,
- 0, 0);
+
+ gtk_grid_attach_next_to (grid, check_button, sibling,
+ GTK_POS_RIGHT, 1, 1);
set_up_permissions_checkbox (window,
check_button,
@@ -3567,32 +3508,35 @@ add_permissions_checkbox_with_label (NautilusPropertiesWindow *window,
eel_accessibility_set_up_label_widget_relation (GTK_WIDGET (label_for),
check_button);
}
+
+ return check_button;
}
-static void
+static GtkWidget *
add_permissions_checkbox (NautilusPropertiesWindow *window,
- GtkTable *table,
- int row, int column,
+ GtkGrid *grid,
+ GtkWidget *sibling,
+ CheckboxType type,
guint32 permission_to_check,
GtkLabel *label_for,
gboolean is_folder)
{
- gchar *label;
+ const gchar *label;
- if (column == PERMISSIONS_CHECKBOXES_READ_COLUMN) {
+ if (type == PERMISSIONS_CHECKBOXES_READ) {
label = _("_Read");
- } else if (column == PERMISSIONS_CHECKBOXES_WRITE_COLUMN) {
+ } else if (type == PERMISSIONS_CHECKBOXES_WRITE) {
label = _("_Write");
} else {
label = _("E_xecute");
}
- add_permissions_checkbox_with_label (window, table,
- row, column,
- label,
- permission_to_check,
- label_for,
- is_folder);
+ return add_permissions_checkbox_with_label (window, grid,
+ sibling,
+ label,
+ permission_to_check,
+ label_for,
+ is_folder);
}
enum {
@@ -3914,7 +3858,7 @@ permission_combo_update (NautilusPropertiesWindow *window,
}
static void
-add_permissions_combo_box (NautilusPropertiesWindow *window, GtkTable *table,
+add_permissions_combo_box (NautilusPropertiesWindow *window, GtkGrid *grid,
PermissionType type, gboolean is_folder,
gboolean short_label)
{
@@ -3923,14 +3867,13 @@ add_permissions_combo_box (NautilusPropertiesWindow *window, GtkTable *table,
GtkListStore *store;
GtkCellRenderer *cell;
GtkTreeIter iter;
- int row;
if (short_label) {
- row = append_title_field (table, _("Access:"), &label);
+ label = attach_title_field (grid, _("Access:"));
} else if (is_folder) {
- row = append_title_field (table, _("Folder access:"), &label);
+ label = attach_title_field (grid, _("Folder access:"));
} else {
- row = append_title_field (table, _("File access:"), &label);
+ label = attach_title_field (grid, _("File access:"));
}
store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_INT, G_TYPE_BOOLEAN);
@@ -3983,34 +3926,32 @@ add_permissions_combo_box (NautilusPropertiesWindow *window, GtkTable *table,
gtk_label_set_mnemonic_widget (label, combo);
gtk_widget_show (combo);
-
- gtk_table_attach (table, combo,
- VALUE_COLUMN, VALUE_COLUMN + 1,
- row, row + 1,
- GTK_FILL, 0,
- 0, 0);
+
+ gtk_grid_attach_next_to (grid, combo, GTK_WIDGET (label),
+ GTK_POS_RIGHT, 1, 1);
}
static GtkWidget *
append_special_execution_checkbox (NautilusPropertiesWindow *window,
- GtkTable *table,
+ GtkGrid *grid,
+ GtkWidget *sibling,
const char *label_text,
guint32 permission_to_check)
{
GtkWidget *check_button;
- guint last_row;
-
- last_row = append_row (table);
check_button = gtk_check_button_new_with_mnemonic (label_text);
gtk_widget_show (check_button);
- gtk_table_attach (table, check_button,
- VALUE_COLUMN, VALUE_COLUMN + 1,
- last_row, last_row + 1,
- GTK_FILL, 0,
- 0, 0);
+ if (sibling != NULL) {
+ gtk_grid_attach_next_to (grid, check_button, sibling,
+ GTK_POS_RIGHT, 1, 1);
+ } else {
+ gtk_container_add_with_properties (GTK_CONTAINER (grid), check_button,
+ "left-attach", 1,
+ NULL);
+ }
set_up_permissions_checkbox (window,
check_button,
@@ -4023,21 +3964,16 @@ append_special_execution_checkbox (NautilusPropertiesWindow *window,
}
static void
-append_special_execution_flags (NautilusPropertiesWindow *window, GtkTable *table)
+append_special_execution_flags (NautilusPropertiesWindow *window, GtkGrid *grid)
{
- gint nrows;
+ GtkWidget *title;
- append_special_execution_checkbox
- (window, table, _("Set _user ID"), UNIX_PERM_SUID);
+ append_blank_slim_row (grid);
+ title = GTK_WIDGET (attach_title_field (grid, _("Special flags:")));
- g_object_get (table, "n-rows", &nrows, NULL);
- attach_title_field (table, nrows - 1, _("Special flags:"));
-
- append_special_execution_checkbox (window, table, _("Set gro_up ID"), UNIX_PERM_SGID);
- append_special_execution_checkbox (window, table, _("_Sticky"), UNIX_PERM_STICKY);
-
- g_object_get (table, "n-rows", &nrows, NULL);
- gtk_table_set_row_spacing (table, nrows - 1, 18);
+ append_special_execution_checkbox (window, grid, title, _("Set _user ID"), UNIX_PERM_SUID);
+ append_special_execution_checkbox (window, grid, NULL, _("Set gro_up ID"), UNIX_PERM_SGID);
+ append_special_execution_checkbox (window, grid, NULL, _("_Sticky"), UNIX_PERM_STICKY);
}
static gboolean
@@ -4098,7 +4034,7 @@ get_initial_permissions (GList *file_list)
}
static void
-create_simple_permissions (NautilusPropertiesWindow *window, GtkTable *page_table)
+create_simple_permissions (NautilusPropertiesWindow *window, GtkGrid *page_grid)
{
gboolean has_file, has_directory;
GtkLabel *group_label;
@@ -4107,102 +4043,91 @@ create_simple_permissions (NautilusPropertiesWindow *window, GtkTable *page_tabl
GtkWidget *value;
GtkComboBox *group_combo_box;
GtkComboBox *owner_combo_box;
- guint last_row;
- gint nrows;
- last_row = 0;
-
has_file = files_has_file (window);
has_directory = files_has_directory (window);
if (!is_multi_file_window (window) && nautilus_file_can_set_owner (get_target_file (window))) {
- owner_label = attach_title_field (page_table, last_row, _("_Owner:"));
+ owner_label = attach_title_field (page_grid, _("_Owner:"));
/* Combo box in this case. */
- owner_combo_box = attach_owner_combo_box (page_table, last_row, get_target_file (window));
+ owner_combo_box = attach_owner_combo_box (page_grid,
+ GTK_WIDGET (owner_label),
+ get_target_file (window));
gtk_label_set_mnemonic_widget (owner_label,
GTK_WIDGET (owner_combo_box));
} else {
- owner_label = attach_title_field (page_table, last_row, _("Owner:"));
+ owner_label = attach_title_field (page_grid, _("Owner:"));
/* Static text in this case. */
value = attach_value_field (window,
- page_table, last_row, VALUE_COLUMN,
- "owner",
- INCONSISTENT_STATE_STRING,
- FALSE);
+ page_grid, GTK_WIDGET (owner_label),
+ "owner",
+ INCONSISTENT_STATE_STRING,
+ FALSE);
gtk_label_set_mnemonic_widget (owner_label, value);
}
if (has_directory) {
- add_permissions_combo_box (window, page_table,
+ add_permissions_combo_box (window, page_grid,
PERMISSION_USER, TRUE, FALSE);
}
if (has_file || window->details->has_recursive_apply) {
- add_permissions_combo_box (window, page_table,
+ add_permissions_combo_box (window, page_grid,
PERMISSION_USER, FALSE, !has_directory);
}
- g_object_get (page_table, "n-rows", &nrows, NULL);
- gtk_table_set_row_spacing (page_table, nrows - 1, 18);
-
+ append_blank_slim_row (page_grid);
+
if (!is_multi_file_window (window) && nautilus_file_can_set_group (get_target_file (window))) {
- last_row = append_title_field (page_table,
- _("_Group:"),
- &group_label);
+ group_label = attach_title_field (page_grid, _("_Group:"));
+
/* Combo box in this case. */
- group_combo_box = attach_group_combo_box (page_table, last_row,
+ group_combo_box = attach_group_combo_box (page_grid, GTK_WIDGET (group_label),
get_target_file (window));
gtk_label_set_mnemonic_widget (group_label,
GTK_WIDGET (group_combo_box));
} else {
- last_row = append_title_field (page_table,
- _("Group:"),
- &group_label);
+ group_label = attach_title_field (page_grid, _("Group:"));
+
/* Static text in this case. */
- value = attach_value_field (window, page_table, last_row,
- VALUE_COLUMN,
- "group",
- INCONSISTENT_STATE_STRING,
- FALSE);
+ value = attach_value_field (window, page_grid,
+ GTK_WIDGET (group_label),
+ "group",
+ INCONSISTENT_STATE_STRING,
+ FALSE);
gtk_label_set_mnemonic_widget (group_label, value);
}
if (has_directory) {
- add_permissions_combo_box (window, page_table,
+ add_permissions_combo_box (window, page_grid,
PERMISSION_GROUP, TRUE,
FALSE);
}
if (has_file || window->details->has_recursive_apply) {
- add_permissions_combo_box (window, page_table,
+ add_permissions_combo_box (window, page_grid,
PERMISSION_GROUP, FALSE,
!has_directory);
}
- g_object_get (page_table, "n-rows", &nrows, NULL);
- gtk_table_set_row_spacing (page_table, nrows - 1, 18);
-
- append_title_field (page_table,
- _("Others"),
- &group_label);
+ append_blank_slim_row (page_grid);
+
+ group_label = attach_title_field (page_grid, _("Others"));
if (has_directory) {
- add_permissions_combo_box (window, page_table,
+ add_permissions_combo_box (window, page_grid,
PERMISSION_OTHER, TRUE,
FALSE);
}
if (has_file || window->details->has_recursive_apply) {
- add_permissions_combo_box (window, page_table,
+ add_permissions_combo_box (window, page_grid,
PERMISSION_OTHER, FALSE,
!has_directory);
}
- g_object_get (page_table, "n-rows", &nrows, NULL);
- gtk_table_set_row_spacing (page_table, nrows - 1, 18);
+ append_blank_slim_row (page_grid);
- last_row = append_title_field (page_table,
- _("Execute:"),
- &execute_label);
- add_permissions_checkbox_with_label (window, page_table,
- last_row, 1,
+ execute_label = attach_title_field (page_grid, _("Execute:"));
+ add_permissions_checkbox_with_label (window, page_grid,
+ GTK_WIDGET (execute_label),
_("Allow _executing file as program"),
UNIX_PERM_USER_EXEC|UNIX_PERM_GROUP_EXEC|UNIX_PERM_OTHER_EXEC,
execute_label, FALSE);
@@ -4211,192 +4136,174 @@ create_simple_permissions (NautilusPropertiesWindow *window, GtkTable *page_tabl
static void
create_permission_checkboxes (NautilusPropertiesWindow *window,
- GtkTable *page_table,
+ GtkGrid *page_grid,
gboolean is_folder)
{
- guint checkbox_titles_row;
GtkLabel *owner_perm_label;
GtkLabel *group_perm_label;
GtkLabel *other_perm_label;
- GtkTable *check_button_table;
-
- checkbox_titles_row = append_title_field (page_table, _("Owner:"), &owner_perm_label);
- append_title_field (page_table, _("Group:"), &group_perm_label);
- append_title_field (page_table, _("Others:"), &other_perm_label);
+ GtkGrid *check_button_grid;
+ GtkWidget *w;
- check_button_table = GTK_TABLE (gtk_table_new
- (PERMISSIONS_CHECKBOXES_ROW_COUNT,
- PERMISSIONS_CHECKBOXES_COLUMN_COUNT,
- FALSE));
- apply_standard_table_padding (check_button_table);
- gtk_widget_show (GTK_WIDGET (check_button_table));
- gtk_table_attach (page_table, GTK_WIDGET (check_button_table),
- VALUE_COLUMN, VALUE_COLUMN + 1,
- checkbox_titles_row, checkbox_titles_row + PERMISSIONS_CHECKBOXES_ROW_COUNT,
- 0, 0,
- 0, 0);
-
- add_permissions_checkbox (window,
- check_button_table,
- PERMISSIONS_CHECKBOXES_OWNER_ROW,
- PERMISSIONS_CHECKBOXES_READ_COLUMN,
- UNIX_PERM_USER_READ,
- owner_perm_label,
- is_folder);
-
- add_permissions_checkbox (window,
- check_button_table,
- PERMISSIONS_CHECKBOXES_OWNER_ROW,
- PERMISSIONS_CHECKBOXES_WRITE_COLUMN,
- UNIX_PERM_USER_WRITE,
- owner_perm_label,
- is_folder);
-
- add_permissions_checkbox (window,
- check_button_table,
- PERMISSIONS_CHECKBOXES_OWNER_ROW,
- PERMISSIONS_CHECKBOXES_EXECUTE_COLUMN,
- UNIX_PERM_USER_EXEC,
- owner_perm_label,
- is_folder);
-
- add_permissions_checkbox (window,
- check_button_table,
- PERMISSIONS_CHECKBOXES_GROUP_ROW,
- PERMISSIONS_CHECKBOXES_READ_COLUMN,
- UNIX_PERM_GROUP_READ,
- group_perm_label,
- is_folder);
+ owner_perm_label = attach_title_field (page_grid, _("Owner:"));
+ group_perm_label = attach_title_field (page_grid, _("Group:"));
+ other_perm_label = attach_title_field (page_grid, _("Others:"));
+
+ check_button_grid = GTK_GRID (create_grid_with_standard_properties ());
+ gtk_widget_show (GTK_WIDGET (check_button_grid));
+
+ gtk_grid_attach_next_to (page_grid, GTK_WIDGET (check_button_grid),
+ GTK_WIDGET (owner_perm_label),
+ GTK_POS_RIGHT, 1, 3);
- add_permissions_checkbox (window,
- check_button_table,
- PERMISSIONS_CHECKBOXES_GROUP_ROW,
- PERMISSIONS_CHECKBOXES_WRITE_COLUMN,
- UNIX_PERM_GROUP_WRITE,
- group_perm_label,
- is_folder);
+ w = add_permissions_checkbox (window,
+ check_button_grid,
+ NULL,
+ PERMISSIONS_CHECKBOXES_READ,
+ UNIX_PERM_USER_READ,
+ owner_perm_label,
+ is_folder);
+
+ w = add_permissions_checkbox (window,
+ check_button_grid,
+ w,
+ PERMISSIONS_CHECKBOXES_WRITE,
+ UNIX_PERM_USER_WRITE,
+ owner_perm_label,
+ is_folder);
+
+ w = add_permissions_checkbox (window,
+ check_button_grid,
+ w,
+ PERMISSIONS_CHECKBOXES_EXECUTE,
+ UNIX_PERM_USER_EXEC,
+ owner_perm_label,
+ is_folder);
+
+ w = add_permissions_checkbox (window,
+ check_button_grid,
+ NULL,
+ PERMISSIONS_CHECKBOXES_READ,
+ UNIX_PERM_GROUP_READ,
+ group_perm_label,
+ is_folder);
- add_permissions_checkbox (window,
- check_button_table,
- PERMISSIONS_CHECKBOXES_GROUP_ROW,
- PERMISSIONS_CHECKBOXES_EXECUTE_COLUMN,
- UNIX_PERM_GROUP_EXEC,
- group_perm_label,
- is_folder);
+ w = add_permissions_checkbox (window,
+ check_button_grid,
+ w,
+ PERMISSIONS_CHECKBOXES_WRITE,
+ UNIX_PERM_GROUP_WRITE,
+ group_perm_label,
+ is_folder);
- add_permissions_checkbox (window,
- check_button_table,
- PERMISSIONS_CHECKBOXES_OTHERS_ROW,
- PERMISSIONS_CHECKBOXES_READ_COLUMN,
- UNIX_PERM_OTHER_READ,
- other_perm_label,
- is_folder);
+ w = add_permissions_checkbox (window,
+ check_button_grid,
+ w,
+ PERMISSIONS_CHECKBOXES_EXECUTE,
+ UNIX_PERM_GROUP_EXEC,
+ group_perm_label,
+ is_folder);
- add_permissions_checkbox (window,
- check_button_table,
- PERMISSIONS_CHECKBOXES_OTHERS_ROW,
- PERMISSIONS_CHECKBOXES_WRITE_COLUMN,
- UNIX_PERM_OTHER_WRITE,
- other_perm_label,
- is_folder);
+ w = add_permissions_checkbox (window,
+ check_button_grid,
+ NULL,
+ PERMISSIONS_CHECKBOXES_READ,
+ UNIX_PERM_OTHER_READ,
+ other_perm_label,
+ is_folder);
+ w = add_permissions_checkbox (window,
+ check_button_grid,
+ w,
+ PERMISSIONS_CHECKBOXES_WRITE,
+ UNIX_PERM_OTHER_WRITE,
+ other_perm_label,
+ is_folder);
+
add_permissions_checkbox (window,
- check_button_table,
- PERMISSIONS_CHECKBOXES_OTHERS_ROW,
- PERMISSIONS_CHECKBOXES_EXECUTE_COLUMN,
+ check_button_grid,
+ w,
+ PERMISSIONS_CHECKBOXES_EXECUTE,
UNIX_PERM_OTHER_EXEC,
other_perm_label,
is_folder);
}
static void
-create_advanced_permissions (NautilusPropertiesWindow *window, GtkTable *page_table)
+create_advanced_permissions (NautilusPropertiesWindow *window, GtkGrid *page_grid)
{
- guint last_row;
GtkLabel *group_label;
GtkLabel *owner_label;
GtkComboBox *group_combo_box;
GtkComboBox *owner_combo_box;
gboolean has_directory, has_file;
- gint nrows;
-
- last_row = 0;
if (!is_multi_file_window (window) && nautilus_file_can_set_owner (get_target_file (window))) {
- owner_label = attach_title_field (page_table, last_row, _("_Owner:"));
+ owner_label = attach_title_field (page_grid, _("_Owner:"));
/* Combo box in this case. */
- owner_combo_box = attach_owner_combo_box (page_table, last_row, get_target_file (window));
+ owner_combo_box = attach_owner_combo_box (page_grid,
+ GTK_WIDGET (owner_label),
+ get_target_file (window));
gtk_label_set_mnemonic_widget (owner_label,
GTK_WIDGET (owner_combo_box));
} else {
GtkWidget *value;
- owner_label = attach_title_field (page_table, last_row, _("Owner:"));
+ owner_label = attach_title_field (page_grid, _("Owner:"));
/* Static text in this case. */
value = attach_value_field (window,
- page_table, last_row, VALUE_COLUMN,
- "owner",
- INCONSISTENT_STATE_STRING,
- FALSE);
+ page_grid,
+ GTK_WIDGET (owner_label),
+ "owner",
+ INCONSISTENT_STATE_STRING,
+ FALSE);
gtk_label_set_mnemonic_widget (owner_label, value);
}
if (!is_multi_file_window (window) && nautilus_file_can_set_group (get_target_file (window))) {
- last_row = append_title_field (page_table,
- _("_Group:"),
- &group_label);
+ group_label = attach_title_field (page_grid, _("_Group:"));
+
/* Combo box in this case. */
- group_combo_box = attach_group_combo_box (page_table, last_row,
+ group_combo_box = attach_group_combo_box (page_grid, GTK_WIDGET (group_label),
get_target_file (window));
gtk_label_set_mnemonic_widget (group_label,
GTK_WIDGET (group_combo_box));
} else {
- last_row = append_title_field (page_table,
- _("Group:"),
- NULL);
+ group_label = attach_title_field (page_grid, _("Group:"));
+
/* Static text in this case. */
- attach_value_field (window, page_table, last_row,
- VALUE_COLUMN,
+ attach_value_field (window, page_grid, GTK_WIDGET (group_label),
"group",
INCONSISTENT_STATE_STRING,
FALSE);
}
- g_object_get (page_table, "n-rows", &nrows, NULL);
- gtk_table_set_row_spacing (page_table, nrows - 1, 18);
+ append_blank_slim_row (page_grid);
has_directory = files_has_directory (window);
has_file = files_has_file (window);
if (has_directory) {
if (has_file || window->details->has_recursive_apply) {
- append_title_field (page_table,
- _("Folder Permissions:"),
- NULL);
+ attach_title_field (page_grid, _("Folder Permissions:"));
}
- create_permission_checkboxes (window, page_table, TRUE);
- g_object_get (page_table, "n-rows", &nrows, NULL);
- gtk_table_set_row_spacing (page_table, nrows - 1, 18);
-
+ create_permission_checkboxes (window, page_grid, TRUE);
}
if (has_file || window->details->has_recursive_apply) {
if (has_directory) {
- append_title_field (page_table,
- _("File Permissions:"),
- NULL);
+ attach_title_field (page_grid, _("File Permissions:"));
}
- create_permission_checkboxes (window, page_table, FALSE);
- g_object_get (page_table, "n-rows", &nrows, NULL);
- gtk_table_set_row_spacing (page_table, nrows - 1, 18);
+ create_permission_checkboxes (window, page_grid, FALSE);
}
-
- append_special_execution_flags (window, page_table);
+
+ append_blank_slim_row (page_grid);
+ append_special_execution_flags (window, page_grid);
append_title_value_pair
- (window, page_table, _("Text view:"),
+ (window, page_grid, _("Text view:"),
"permissions", INCONSISTENT_STATE_STRING,
FALSE);
}
@@ -4524,11 +4431,9 @@ static void
create_permissions_page (NautilusPropertiesWindow *window)
{
GtkWidget *vbox, *button, *hbox;
- GtkTable *page_table;
+ GtkGrid *page_grid;
char *file_name, *prompt_text;
GList *file_list;
- guint last_row;
- gint nrows;
vbox = create_page_with_vbox (window->details->notebook,
_("Permissions"),
@@ -4548,46 +4453,39 @@ create_permissions_page (NautilusPropertiesWindow *window)
_("You are not the owner, so you cannot change these permissions."));
}
- page_table = GTK_TABLE (gtk_table_new (1, COLUMN_COUNT, FALSE));
- window->details->permissions_table = page_table;
+ page_grid = GTK_GRID (create_grid_with_standard_properties ());
- apply_standard_table_padding (page_table);
- gtk_widget_show (GTK_WIDGET (page_table));
+ gtk_widget_show (GTK_WIDGET (page_grid));
gtk_box_pack_start (GTK_BOX (vbox),
- GTK_WIDGET (page_table),
+ GTK_WIDGET (page_grid),
TRUE, TRUE, 0);
if (g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_SHOW_ADVANCED_PERMISSIONS)) {
- window->details->advanced_permissions = TRUE;
- create_advanced_permissions (window, page_table);
+ create_advanced_permissions (window, page_grid);
} else {
- window->details->advanced_permissions = FALSE;
- create_simple_permissions (window, page_table);
+ create_simple_permissions (window, page_grid);
}
- g_object_get (page_table, "n-rows", &nrows, NULL);
- gtk_table_set_row_spacing (page_table, nrows - 1, 18);
+ append_blank_slim_row (page_grid);
#ifdef HAVE_SELINUX
append_title_value_pair
- (window, page_table, _("SELinux context:"),
+ (window, page_grid, _("SELinux context:"),
"selinux_context", INCONSISTENT_STATE_STRING,
FALSE);
#endif
append_title_value_pair
- (window, page_table, _("Last changed:"),
+ (window, page_grid, _("Last changed:"),
"date_permissions", INCONSISTENT_STATE_STRING,
FALSE);
if (window->details->has_recursive_apply) {
- last_row = append_row (page_table);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_show (hbox);
- gtk_table_attach (page_table, hbox,
- 0, 2,
- last_row, last_row+1,
- GTK_FILL, 0,
- 0, 0);
+
+ gtk_container_add_with_properties (GTK_CONTAINER (page_grid), hbox,
+ "width", 2,
+ NULL);
button = gtk_button_new_with_mnemonic (_("Apply Permissions to Enclosed Files"));
gtk_widget_show (button);
@@ -5244,7 +5142,7 @@ real_destroy (GtkWidget *object)
window->details->update_files_timeout_id = 0;
}
- GTK_WIDGET_CLASS (parent_class)->destroy (object);
+ GTK_WIDGET_CLASS (nautilus_properties_window_parent_class)->destroy (object);
}
static void
@@ -5257,9 +5155,8 @@ real_finalize (GObject *object)
g_list_free_full (window->details->mime_list, g_free);
g_free (window->details->pending_name);
- g_free (window->details);
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (nautilus_properties_window_parent_class)->finalize (object);
}
/* converts
@@ -5505,10 +5402,13 @@ nautilus_properties_window_class_init (NautilusPropertiesWindowClass *class)
binding_set = gtk_binding_set_by_class (class);
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0,
"close", 0);
+
+ g_type_class_add_private (class, sizeof (NautilusPropertiesWindowDetails));
}
static void
nautilus_properties_window_init (NautilusPropertiesWindow *window)
{
- window->details = g_new0 (NautilusPropertiesWindowDetails, 1);
+ window->details = G_TYPE_INSTANCE_GET_PRIVATE (window, NAUTILUS_TYPE_PROPERTIES_WINDOW,
+ NautilusPropertiesWindowDetails);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]