Commit eb6bef33 authored by Martin Nordholts's avatar Martin Nordholts

Use gtk_widget_set_visible()

In places where the pattern

  if (show)
    gtk_widget_show (widget);
  else
    gtk_widget_hide (widget);

is used, change to

  gtk_widget_set_visible (widget, show);

Also do some other minor cleanups.
parent 15f86a80
......@@ -417,6 +417,7 @@ dialog_info_update (GimpModuleDB *db,
gchar *location = NULL;
gboolean iter_valid;
gint i;
gboolean show_error;
for (iter_valid = gtk_tree_model_get_iter_first (model, &iter);
iter_valid;
......@@ -473,17 +474,12 @@ dialog_info_update (GimpModuleDB *db,
gtk_label_set_text (GTK_LABEL (dialog->label[i]),
text[i] ? text[i] : "--");
if (module->state == GIMP_MODULE_STATE_ERROR && module->last_module_error)
{
gtk_label_set_text (GTK_LABEL (dialog->error_label),
module->last_module_error);
gtk_widget_show (dialog->error_box);
}
else
{
gtk_label_set_text (GTK_LABEL (dialog->error_label), NULL);
gtk_widget_hide (dialog->error_box);
}
/* Show errors */
show_error = (module->state == GIMP_MODULE_STATE_ERROR &&
module->last_module_error);
gtk_label_set_text (GTK_LABEL (dialog->error_label),
show_error ? module->last_module_error : NULL);
gtk_widget_set_visible (dialog->error_box, show_error);
}
static void
......
......@@ -868,8 +868,6 @@ palette_import_make_palette (ImportDialog *dialog)
dialog->palette = palette;
}
if (dialog->palette && dialog->palette->n_colors > 0)
gtk_widget_hide (dialog->no_colors_label);
else
gtk_widget_show (dialog->no_colors_label);
gtk_widget_set_visible (dialog->no_colors_label,
dialog->palette && dialog->palette->n_colors > 0);
}
......@@ -177,24 +177,12 @@ gimp_display_shell_set_show_rulers (GimpDisplayShell *shell,
table = GTK_TABLE (gtk_widget_get_parent (GTK_WIDGET (shell->canvas)));
if (show)
{
gtk_widget_show (shell->origin);
gtk_widget_show (shell->hrule);
gtk_widget_show (shell->vrule);
gtk_widget_set_visible (shell->origin, show);
gtk_widget_set_visible (shell->hrule, show);
gtk_widget_set_visible (shell->vrule, show);
gtk_table_set_col_spacing (table, 0, 1);
gtk_table_set_row_spacing (table, 0, 1);
}
else
{
gtk_widget_hide (shell->origin);
gtk_widget_hide (shell->hrule);
gtk_widget_hide (shell->vrule);
gtk_table_set_col_spacing (table, 0, 0);
gtk_table_set_row_spacing (table, 0, 0);
}
gtk_table_set_col_spacing (table, 0, show ? 1 : 0);
gtk_table_set_row_spacing (table, 0, show ? 1 : 0);
appearance_set_action_active (shell, "view-show-rulers", show);
}
......@@ -228,28 +216,14 @@ gimp_display_shell_set_show_scrollbars (GimpDisplayShell *shell,
parent = gtk_widget_get_parent (shell->hsb);
vbox = GTK_BOX (gtk_widget_get_parent (parent));
if (show)
{
gtk_widget_show (shell->nav_ebox);
gtk_widget_show (shell->hsb);
gtk_widget_show (shell->vsb);
gtk_widget_show (shell->quick_mask_button);
gtk_widget_show (shell->zoom_button);
gtk_box_set_spacing (hbox, 1);
gtk_box_set_spacing (vbox, 1);
}
else
{
gtk_widget_hide (shell->nav_ebox);
gtk_widget_hide (shell->hsb);
gtk_widget_hide (shell->vsb);
gtk_widget_hide (shell->quick_mask_button);
gtk_widget_hide (shell->zoom_button);
gtk_box_set_spacing (hbox, 0);
gtk_box_set_spacing (vbox, 0);
}
gtk_widget_set_visible (shell->nav_ebox, show);
gtk_widget_set_visible (shell->hsb, show);
gtk_widget_set_visible (shell->vsb, show);
gtk_widget_set_visible (shell->quick_mask_button, show);
gtk_widget_set_visible (shell->zoom_button, show);
gtk_box_set_spacing (hbox, show ? 1 : 0);
gtk_box_set_spacing (vbox, show ? 1 : 0);
appearance_set_action_active (shell, "view-show-scrollbars", show);
}
......
......@@ -736,10 +736,7 @@ gimp_image_window_set_show_menubar (GimpImageWindow *window,
private = GIMP_IMAGE_WINDOW_GET_PRIVATE (window);
if (show)
gtk_widget_show (private->menubar);
else
gtk_widget_hide (private->menubar);
gtk_widget_set_visible (private->menubar, show);
}
gboolean
......@@ -764,16 +761,8 @@ gimp_image_window_set_show_docks (GimpImageWindow *window,
private = GIMP_IMAGE_WINDOW_GET_PRIVATE (window);
if (show)
{
gtk_widget_show (private->left_docks);
gtk_widget_show (private->right_docks);
}
else
{
gtk_widget_hide (private->left_docks);
gtk_widget_hide (private->right_docks);
}
gtk_widget_set_visible (private->left_docks, show);
gtk_widget_set_visible (private->right_docks, show);
}
gboolean
......
......@@ -722,10 +722,7 @@ gimp_statusbar_set_visible (GimpStatusbar *statusbar,
}
}
if (visible)
gtk_widget_show (GTK_WIDGET (statusbar));
else
gtk_widget_hide (GTK_WIDGET (statusbar));
gtk_widget_set_visible (GTK_WIDGET (statusbar), visible);
}
void
......
......@@ -416,11 +416,9 @@ gimp_device_status_update (GimpDeviceStatus *status)
{
GimpDeviceStatusEntry *entry = list->data;
if (entry->device_info->device &&
entry->device_info->device == status->current_device)
gtk_widget_show (entry->arrow);
else
gtk_widget_hide (entry->arrow);
gtk_widget_set_visible (entry->arrow,
entry->device_info->device &&
entry->device_info->device == status->current_device);
}
}
......
......@@ -392,12 +392,7 @@ gimp_editor_set_show_button_bar (GimpDocked *docked,
editor->show_button_bar = show;
if (editor->button_box)
{
if (show)
gtk_widget_show (editor->button_box);
else
gtk_widget_hide (editor->button_box);
}
gtk_widget_set_visible (editor->button_box, show);
}
}
......
......@@ -459,10 +459,7 @@ gimp_menu_dock_set_show_image_menu (GimpMenuDock *menu_dock,
parent = gtk_widget_get_parent (menu_dock->image_combo);
if (show)
gtk_widget_show (parent);
else
gtk_widget_hide (parent);
gtk_widget_set_visible (parent, show);
menu_dock->show_image_menu = show ? TRUE : FALSE;
}
......
......@@ -923,10 +923,7 @@ toolbox_tool_visible_notify (GimpToolInfo *tool_info,
GParamSpec *pspec,
GtkWidget *button)
{
if (tool_info->visible)
gtk_widget_show (button);
else
gtk_widget_hide (button);
gtk_widget_set_visible (button, tool_info->visible);
}
static void
......
......@@ -1002,10 +1002,8 @@ gimp_toggle_button_set_visible (GtkToggleButton *toggle,
g_return_if_fail (GTK_IS_TOGGLE_BUTTON (toggle));
g_return_if_fail (GTK_IS_WIDGET (widget));
if (gtk_toggle_button_get_active (toggle))
gtk_widget_show (widget);
else
gtk_widget_hide (widget);
gtk_widget_set_visible (widget,
gtk_toggle_button_get_active (toggle));
}
static gboolean
......
......@@ -207,12 +207,7 @@ gimp_color_scales_togg_visible (GimpColorSelector *selector,
gint i;
for (i = 0; i < 6; i++)
{
if (visible)
gtk_widget_show (scales->toggles[i]);
else
gtk_widget_hide (scales->toggles[i]);
}
gtk_widget_set_visible (scales->toggles[i], visible);
}
static void
......@@ -236,18 +231,9 @@ gimp_color_scales_set_show_alpha (GimpColorSelector *selector,
show_alpha ? 3 : 0);
}
if (show_alpha)
{
gtk_widget_show (label);
gtk_widget_show (scale);
gtk_widget_show (spin);
}
else
{
gtk_widget_hide (label);
gtk_widget_hide (scale);
gtk_widget_hide (spin);
}
gtk_widget_set_visible (label, show_alpha);
gtk_widget_set_visible (scale, show_alpha);
gtk_widget_set_visible (spin, show_alpha);
}
static void
......
......@@ -373,10 +373,7 @@ gimp_color_select_togg_visible (GimpColorSelector *selector,
{
GimpColorSelect *select = GIMP_COLOR_SELECT (selector);
if (visible)
gtk_widget_show (select->toggle_box);
else
gtk_widget_hide (select->toggle_box);
gtk_widget_set_visible (select->toggle_box, visible);
}
static void
......
......@@ -306,10 +306,8 @@ gimp_scrolled_preview_area_size_allocate (GtkWidget *widget,
switch (priv->hscr_policy)
{
case GTK_POLICY_AUTOMATIC:
if (width > GIMP_PREVIEW (preview)->width)
gtk_widget_show (preview->hscr);
else
gtk_widget_hide (preview->hscr);
gtk_widget_set_visible (preview->hscr,
width > GIMP_PREVIEW (preview)->width);
break;
case GTK_POLICY_ALWAYS:
......@@ -326,10 +324,8 @@ gimp_scrolled_preview_area_size_allocate (GtkWidget *widget,
switch (priv->vscr_policy)
{
case GTK_POLICY_AUTOMATIC:
if (height > GIMP_PREVIEW (preview)->height)
gtk_widget_show (preview->vscr);
else
gtk_widget_hide (preview->vscr);
gtk_widget_set_visible (preview->vscr,
height > GIMP_PREVIEW (preview)->height);
break;
case GTK_POLICY_ALWAYS:
......@@ -341,16 +337,10 @@ gimp_scrolled_preview_area_size_allocate (GtkWidget *widget,
break;
}
if (GTK_WIDGET_VISIBLE (preview->vscr) &&
GTK_WIDGET_VISIBLE (preview->hscr) &&
GIMP_PREVIEW_GET_CLASS (preview)->draw_thumb)
{
gtk_widget_show (preview->nav_icon);
}
else
{
gtk_widget_hide (preview->nav_icon);
}
gtk_widget_set_visible (preview->nav_icon,
GTK_WIDGET_VISIBLE (preview->vscr) &&
GTK_WIDGET_VISIBLE (preview->hscr) &&
GIMP_PREVIEW_GET_CLASS (preview)->draw_thumb);
gimp_scrolled_preview_thaw (preview);
}
......
......@@ -1343,10 +1343,7 @@ gimp_size_entry_show_unit_menu (GimpSizeEntry *gse,
{
g_return_if_fail (GIMP_IS_SIZE_ENTRY (gse));
if (show)
gtk_widget_show (gse->unitmenu);
else
gtk_widget_hide (gse->unitmenu);
gtk_widget_set_visible (gse->unitmenu, show);
}
......
......@@ -788,10 +788,8 @@ size_adjustment_callback (GtkWidget *widget,
*(adj->count) = newn;
if (newn * *(adj->value) != size)
gtk_widget_show (GTK_WIDGET (adj->warning_label));
else
gtk_widget_hide (GTK_WIDGET (adj->warning_label));
gtk_widget_set_visible (GTK_WIDGET (adj->warning_label),
newn * *(adj->value) != size);
if (adj->ncells != NULL)
gtk_adjustment_set_value (GTK_ADJUSTMENT (adj->ncells),
......
......@@ -496,8 +496,5 @@ ico_dialog_check_compat (GtkWidget *dialog,
warning = g_object_get_data (G_OBJECT (dialog), "warning");
if (warn)
gtk_widget_show (warning);
else
gtk_widget_hide (warning);
gtk_widget_set_visible (warning, warn);
}
......@@ -838,14 +838,8 @@ static void
show_index_callback (GtkAction *action,
gpointer data)
{
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
{
gtk_widget_show (sidebar);
}
else
{
gtk_widget_hide (sidebar);
}
gtk_widget_set_visible (sidebar,
gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
}
static void
......
......@@ -471,13 +471,12 @@ make_selection(ObjectList_t *object_list)
void
selection_toggle_visibility(Selection_t *selection)
{
if (selection->is_visible) {
gtk_widget_hide (selection->container);
selection->is_visible = FALSE;
} else {
gtk_widget_show (selection->container);
selection->is_visible = TRUE;
}
/* Toggle */
selection->is_visible = ! selection->is_visible;
/* Adapt to new state */
gtk_widget_set_visible (selection->container,
selection->is_visible);
}
void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment