Give the samples label a minium width of "Samples: 888888"

We do this by putting the samples label and a sizer label into a
notebook where show_tabs is false. The benefits of this is that w
avoid the hack of connecting to the size request signal, and that the
samples label will be right adjusted.
This commit is contained in:
Søren Sandmann Pedersen
2009-02-21 22:37:16 -05:00
parent adb87bbcf8
commit fcfd231cb5
2 changed files with 104 additions and 34 deletions

View File

@ -1327,23 +1327,6 @@ on_screenshot_close_button_clicked (GtkWidget *widget,
update_sensitivity (app);
}
/* If the samples label bounces around in size, this can cause the
* entire toolbar to be repeatedly redrawn, consuming significant CPU and
* distorting the profile. Constraining the label to only grow wider
* means that the toolbar will only be redrawn a few times as we gain
* more digits.
*/
static void
on_samples_label_size_request (GtkWidget *widget,
GtkRequisition *requistion,
Application *app)
{
if (app->samples_label_width >= requistion->width)
requistion->width = app->samples_label_width;
else if (requistion->width > app->samples_label_width)
app->samples_label_width = requistion->width;
}
static void
on_samples_label_style_set (GtkWidget *widget,
GtkStyle *previous_style,
@ -1469,8 +1452,6 @@ connect_signals (Application *app)
{ app->descendants_view, "row-collapsed", on_descendants_row_expanded_or_collapsed, app },
{ app->screenshot_window, "delete_event", on_screenshot_window_delete, app },
{ app->screenshot_close_button, "clicked", on_screenshot_close_button_clicked, app },
{ app->samples_label, "size-request", on_samples_label_size_request, app },
{ app->samples_label, "style-set", on_samples_label_style_set, app },
};
int i;

View File

@ -18,6 +18,7 @@
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<child>
<widget class="GtkVBox" id="main_vbox">
@ -28,6 +29,8 @@
<child>
<widget class="GtkMenuBar" id="menubar">
<property name="visible">True</property>
<property name="pack_direction">GTK_PACK_DIRECTION_LTR</property>
<property name="child_pack_direction">GTK_PACK_DIRECTION_LTR</property>
<child>
<widget class="GtkMenuItem" id="menuitem1">
@ -413,22 +416,107 @@
<property name="is_important">False</property>
<child>
<widget class="GtkLabel" id="samples_label">
<widget class="GtkNotebook" id="notebook1">
<property name="visible">True</property>
<property name="label" translatable="yes">Samples: 0</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">6</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
<property name="show_tabs">False</property>
<property name="show_border">False</property>
<property name="tab_pos">GTK_POS_TOP</property>
<property name="scrollable">False</property>
<property name="enable_popup">False</property>
<child>
<widget class="GtkLabel" id="samples_label">
<property name="visible">True</property>
<property name="label" translatable="yes">Samples: 0</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_RIGHT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">1</property>
<property name="yalign">0.5</property>
<property name="xpad">6</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="label" translatable="yes">label2</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="sizer_label">
<property name="visible">True</property>
<property name="label" translatable="yes">Samples: 8888888</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="label" translatable="yes">label3</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
</widget>
</child>
</widget>
@ -592,6 +680,7 @@
<property name="type_hint">GDK_WINDOW_TYPE_HINT_UTILITY</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<child>
<widget class="GtkVBox" id="vbox4">