summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/trg-general-panel.c95
-rw-r--r--src/trg-general-panel.h4
2 files changed, 44 insertions, 55 deletions
diff --git a/src/trg-general-panel.c b/src/trg-general-panel.c
index 46e3a42..cec641a 100644
--- a/src/trg-general-panel.c
+++ b/src/trg-general-panel.c
@@ -41,7 +41,7 @@ static GtkLabel *trg_general_panel_add_label(TrgGeneralPanel * gp,
char *key, guint col,
guint row);
-G_DEFINE_TYPE(TrgGeneralPanel, trg_general_panel, GTK_TYPE_GRID)
+G_DEFINE_TYPE(TrgGeneralPanel, trg_general_panel, GTK_TYPE_TABLE)
#define TRG_GENERAL_PANEL_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), TRG_TYPE_GENERAL_PANEL, TrgGeneralPanelPrivate))
typedef struct _TrgGeneralPanelPrivate TrgGeneralPanelPrivate;
@@ -226,11 +226,11 @@ static GtkLabel *trg_general_panel_add_label_with_width(TrgGeneralPanel *
guint row,
gint width)
{
- GtkWidget *value, *keyLabel, *keyAlignment, *valueAlignment;
+ GtkWidget *value, *keyLabel, *alignment;
int startCol = col * 2;
- keyAlignment = gtk_alignment_new(0, 0, 0, 0);
+ alignment = gtk_alignment_new(0, 0, 0, 0);
keyLabel = gtk_label_new(NULL);
if (strlen(key) > 0) {
gchar *keyMarkup =
@@ -239,18 +239,22 @@ static GtkLabel *trg_general_panel_add_label_with_width(TrgGeneralPanel *
gtk_label_set_markup(GTK_LABEL(keyLabel), keyMarkup);
g_free(keyMarkup);
}
- gtk_container_add(GTK_CONTAINER(keyAlignment), keyLabel);
+ gtk_container_add(GTK_CONTAINER(alignment), keyLabel);
+ gtk_table_attach(GTK_TABLE(gp), alignment, startCol, startCol + 1, row,
+ row + 1, GTK_FILL, 0, TRG_GENERAL_PANEL_SPACING_X,
+ TRG_GENERAL_PANEL_SPACING_Y);
- gtk_grid_attach(GTK_GRID(gp), keyAlignment, startCol, row, 1, 1);
-
- valueAlignment = gtk_alignment_new(0, 0, 0, 0);
+ alignment = gtk_alignment_new(0, 0, 0, 0);
value = gtk_label_new(NULL);
g_object_set_data(G_OBJECT(value), "key-label", keyLabel);
gtk_label_set_selectable(GTK_LABEL(value), TRUE);
- gtk_container_add(GTK_CONTAINER(valueAlignment), value);
- gtk_widget_set_hexpand (valueAlignment, TRUE);
- gtk_grid_attach_next_to(GTK_GRID(gp), valueAlignment, keyAlignment, GTK_POS_RIGHT, width <
- 0 ? TRG_GENERAL_PANEL_COLUMNS_TOTAL - 1 : width, 1);
+ gtk_container_add(GTK_CONTAINER(alignment), value);
+ gtk_table_attach(GTK_TABLE(gp), alignment, startCol + 1,
+ width <
+ 0 ? TRG_GENERAL_PANEL_COLUMNS_TOTAL - 1 : startCol +
+ 1 + width, row, row + 1, GTK_FILL | GTK_SHRINK, 0,
+ TRG_GENERAL_PANEL_SPACING_X,
+ TRG_GENERAL_PANEL_SPACING_Y);
return GTK_LABEL(value);
}
@@ -262,77 +266,62 @@ static GtkLabel *trg_general_panel_add_label(TrgGeneralPanel * gp,
return trg_general_panel_add_label_with_width(gp, key, col, row, 1);
}
-static void trg_general_panel_new_row(GtkGrid *grid, guint *row)
-{
- gtk_grid_insert_column(grid, *row);
- *row = *row + 1;
-}
-
static void trg_general_panel_init(TrgGeneralPanel * self)
{
TrgGeneralPanelPrivate *priv = TRG_GENERAL_PANEL_GET_PRIVATE(self);
- GtkGrid *grid = GTK_GRID(self);
- guint row = 0;
+ int i;
- /*g_object_set(G_OBJECT(self), "n-columns",
- TRG_GENERAL_PANEL_COLUMNS_TOTAL, "n-rows", 7, NULL);*/
-
- gtk_grid_set_row_spacing(grid, TRG_GENERAL_PANEL_SPACING_Y);
-
- trg_general_panel_new_row(grid, &row);
+ g_object_set(G_OBJECT(self), "n-columns",
+ TRG_GENERAL_PANEL_COLUMNS_TOTAL, "n-rows", 7, NULL);
priv->gen_name_label =
- trg_general_panel_add_label_with_width(self, _("Name"), 0, row, -1);
-
- trg_general_panel_new_row(grid, &row);
+ trg_general_panel_add_label_with_width(self, _("Name"), 0, 0, -1);
priv->gen_size_label =
- trg_general_panel_add_label(self, _("Size"), 0, row);
+ trg_general_panel_add_label(self, _("Size"), 0, 1);
priv->gen_eta_label =
- trg_general_panel_add_label(self, _("ETA"), 1, row);
+ trg_general_panel_add_label(self, _("ETA"), 1, 1);
priv->gen_completed_label =
- trg_general_panel_add_label(self, _("Completed"), 2, row);
-
- trg_general_panel_new_row(grid, &row);
+ trg_general_panel_add_label(self, _("Completed"), 2, 1);
priv->gen_seeders_label =
- trg_general_panel_add_label(self, _("Seeders"), 0, row);
+ trg_general_panel_add_label(self, _("Seeders"), 0, 2);
priv->gen_down_rate_label =
- trg_general_panel_add_label(self, _("Rate Down"), 1, row);
+ trg_general_panel_add_label(self, _("Rate Down"), 1, 2);
priv->gen_downloaded_label =
- trg_general_panel_add_label(self, _("Downloaded"), 2, row);
-
- trg_general_panel_new_row(grid, &row);
+ trg_general_panel_add_label(self, _("Downloaded"), 2, 2);
priv->gen_leechers_label =
- trg_general_panel_add_label(self, _("Leechers"), 0, row);
+ trg_general_panel_add_label(self, _("Leechers"), 0, 3);
priv->gen_up_rate_label =
- trg_general_panel_add_label(self, _("Rate Up"), 1, row);
+ trg_general_panel_add_label(self, _("Rate Up"), 1, 3);
priv->gen_uploaded_label =
- trg_general_panel_add_label(self, _("Uploaded"), 2, row);
-
- trg_general_panel_new_row(grid, &row);
+ trg_general_panel_add_label(self, _("Uploaded"), 2, 3);
priv->gen_status_label =
- trg_general_panel_add_label(self, _("Status"), 0, row);
+ trg_general_panel_add_label(self, _("Status"), 0, 4);
priv->gen_ratio_label =
- trg_general_panel_add_label(self, _("Ratio"), 1, row);
+ trg_general_panel_add_label(self, _("Ratio"), 1, 4);
priv->gen_comment_label =
- trg_general_panel_add_label(self, _("Comment"), 3, row);
-
- trg_general_panel_new_row(grid, &row);
+ trg_general_panel_add_label(self, _("Comment"), 2, 4);
priv->gen_completedat_label =
- trg_general_panel_add_label(self, _("Completed At"), 0, row);
+ trg_general_panel_add_label_with_width(self, _("Completed At"), 0,
+ 5, -1);
priv->gen_downloaddir_label =
- trg_general_panel_add_label_with_width(self, _("Location"), 1, row, -1);
-
- trg_general_panel_new_row(grid, &row);
+ trg_general_panel_add_label_with_width(self, _("Location"), 1, 5,
+ -1);
priv->gen_error_label =
- trg_general_panel_add_label_with_width(self, "", 0, row, -1);
+ trg_general_panel_add_label_with_width(self, "", 0, 6, -1);
+
+ for (i = 0; i < TRG_GENERAL_PANEL_COLUMNS_TOTAL; i++)
+ gtk_table_set_col_spacing(GTK_TABLE(self), i,
+ i % 2 ==
+ 0 ? TRG_GENERAL_PANEL_WIDTH_FROM_KEY :
+ TRG_GENERAL_PANEL_WIDTH_FROM_VALUE);
gtk_widget_set_sensitive(GTK_WIDGET(self), FALSE);
}
diff --git a/src/trg-general-panel.h b/src/trg-general-panel.h
index 2317cf6..e1a75bb 100644
--- a/src/trg-general-panel.h
+++ b/src/trg-general-panel.h
@@ -41,11 +41,11 @@ G_BEGIN_DECLS
#define TRG_GENERAL_PANEL_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), TRG_TYPE_GENERAL_PANEL, TrgGeneralPanelClass))
typedef struct {
- GtkGrid parent;
+ GtkTable parent;
} TrgGeneralPanel;
typedef struct {
- GtkGridClass parent_class;
+ GtkTableClass parent_class;
} TrgGeneralPanelClass;
GType trg_general_panel_get_type(void);