Commit 513feada authored by Nikita Churaev's avatar Nikita Churaev
Browse files

Port NautilusPathBar to DzlBoldingLabel

parent 650ee79e
Pipeline #6216 failed with stage
in 27 minutes and 8 seconds
......@@ -78,6 +78,17 @@
}
]
},
{
"buildsystem": "meson",
"builddir": true,
"name": "libdazzle",
"sources": [
{
"type": "git",
"url": "https://gitlab.gnome.org/GNOME/libdazzle.git"
}
]
},
{
"buildsystem": "meson",
"builddir": true,
......
......@@ -80,6 +80,7 @@ gmodule = dependency('gmodule-no-export-2.0', version: glib_ver)
gnome_autoar = dependency('gnome-autoar-0', version: '>= 0.2.1')
gnome_desktop = dependency('gnome-desktop-3.0', version: '>= 3.0.0')
gtk = dependency('gtk+-3.0', version: '>= 3.22.26')
libdazzle = dependency('libdazzle-1.0', version: '>= 3.28')
selinux = []
if get_option('selinux')
selinux = dependency('libselinux', version: '>= 2.0')
......
......@@ -266,6 +266,7 @@ libnautilus_sources = [
]
nautilus_deps = [
libdazzle,
eel_2,
gio_unix,
gmodule,
......
......@@ -21,6 +21,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
#include <dazzle.h>
#include "nautilus-pathbar.h"
#include "nautilus-properties-window.h"
......@@ -59,7 +60,7 @@ typedef enum
static guint path_bar_signals [LAST_SIGNAL] = { 0 };
#define NAUTILUS_PATH_BAR_ICON_SIZE 16
#define NAUTILUS_PATH_BAR_BUTTON_MAX_WIDTH 250
#define NAUTILUS_PATH_BAR_BUTTON_MAX_CHARS 32
typedef struct
{
......@@ -76,6 +77,7 @@ typedef struct
guint ignore_changes : 1;
guint is_root : 1;
guint current_dir : 1;
} ButtonData;
typedef struct
......@@ -465,30 +467,6 @@ get_dir_name (ButtonData *button_data)
}
}
/* We always want to request the same size for the label, whether
* or not the contents are bold
*/
static void
set_label_size_request (ButtonData *button_data)
{
gint width, height;
GtkRequisition nat_req, bold_req;
if (button_data->label == NULL)
{
return;
}
gtk_widget_get_preferred_size (button_data->label, NULL, &nat_req);
gtk_widget_get_preferred_size (button_data->bold_label, &bold_req, NULL);
width = MAX (nat_req.width, bold_req.width);
width = MIN (width, NAUTILUS_PATH_BAR_BUTTON_MAX_WIDTH);
height = MAX (nat_req.height, bold_req.height);
gtk_widget_set_size_request (button_data->label, width, height);
}
/* Size requisition:
*
* Ideally, our size is determined by another widget, and we are just filling
......@@ -518,7 +496,6 @@ nautilus_path_bar_get_preferred_width (GtkWidget *widget,
for (list = priv->button_list; list; list = list->next)
{
button_data = BUTTON_DATA (list->data);
set_label_size_request (button_data);
gtk_widget_get_preferred_width (button_data->button, &child_min, &child_nat);
gtk_widget_get_preferred_height (button_data->button, &child_height, NULL);
......@@ -528,7 +505,7 @@ nautilus_path_bar_get_preferred_width (GtkWidget *widget,
{
/* Use 2*Height as button width because of ellipsized label. */
child_min = MAX (child_min, child_height * 2);
child_nat = MAX (child_min, child_height * 2);
child_nat = MAX (child_nat, child_height * 2);
}
*minimum = MAX (*minimum, child_min);
......@@ -572,7 +549,6 @@ nautilus_path_bar_get_preferred_height (GtkWidget *widget,
for (list = priv->button_list; list; list = list->next)
{
button_data = BUTTON_DATA (list->data);
set_label_size_request (button_data);
gtk_widget_get_preferred_height (button_data->button, &child_min, &child_nat);
......@@ -723,13 +699,13 @@ nautilus_path_bar_size_allocate (GtkWidget *widget,
width = 0;
gtk_widget_get_preferred_size (BUTTON_DATA (priv->button_list->data)->button,
&child_requisition, NULL);
NULL, &child_requisition);
width += child_requisition.width;
for (list = priv->button_list->next; list; list = list->next)
{
child = BUTTON_DATA (list->data)->button;
gtk_widget_get_preferred_size (child, &child_requisition, NULL);
gtk_widget_get_preferred_size (child, NULL, &child_requisition);
width += child_requisition.width;
}
......@@ -760,13 +736,13 @@ nautilus_path_bar_size_allocate (GtkWidget *widget,
*/
/* Count down the path chain towards the end. */
gtk_widget_get_preferred_size (BUTTON_DATA (first_button->data)->button,
&child_requisition, NULL);
NULL, &child_requisition);
width = child_requisition.width;
list = first_button->prev;
while (list && !reached_end)
{
child = BUTTON_DATA (list->data)->button;
gtk_widget_get_preferred_size (child, &child_requisition, NULL);
gtk_widget_get_preferred_size (child, NULL, &child_requisition);
if (width + child_requisition.width + slider_space > allocation->width)
{
......@@ -785,7 +761,7 @@ nautilus_path_bar_size_allocate (GtkWidget *widget,
while (first_button->next && !reached_end)
{
child = BUTTON_DATA (first_button->next->data)->button;
gtk_widget_get_preferred_size (child, &child_requisition, NULL);
gtk_widget_get_preferred_size (child, NULL, &child_requisition);
if (width + child_requisition.width + slider_space > allocation->width)
{
......@@ -832,7 +808,7 @@ nautilus_path_bar_size_allocate (GtkWidget *widget,
for (list = first_button; list; list = list->prev)
{
child = BUTTON_DATA (list->data)->button;
gtk_widget_get_preferred_size (child, &child_requisition, NULL);
gtk_widget_get_preferred_size (child, NULL, &child_requisition);
child_allocation.width = MIN (child_requisition.width, largest_width);
if (direction == GTK_TEXT_DIR_RTL)
......@@ -1845,21 +1821,9 @@ nautilus_path_bar_update_button_appearance (ButtonData *button_data)
if (button_data->label != NULL)
{
char *markup;
markup = g_markup_printf_escaped ("<b>%s</b>", dir_name);
if (gtk_label_get_use_markup (GTK_LABEL (button_data->label)))
{
gtk_label_set_markup (GTK_LABEL (button_data->label), markup);
}
else
{
gtk_label_set_text (GTK_LABEL (button_data->label), dir_name);
}
gtk_label_set_markup (GTK_LABEL (button_data->bold_label), markup);
g_free (markup);
gtk_label_set_text (GTK_LABEL (button_data->label), dir_name);
dzl_bolding_label_set_bold (DZL_BOLDING_LABEL (button_data->label),
button_data->current_dir);
}
icon = get_gicon (button_data);
......@@ -1887,7 +1851,7 @@ nautilus_path_bar_update_button_state (ButtonData *button_data,
{
gtk_label_set_label (GTK_LABEL (button_data->label), NULL);
gtk_label_set_label (GTK_LABEL (button_data->bold_label), NULL);
gtk_label_set_use_markup (GTK_LABEL (button_data->label), current_dir);
button_data->current_dir = current_dir;
}
nautilus_path_bar_update_button_appearance (button_data);
......@@ -2111,7 +2075,7 @@ make_button_data (NautilusPathBar *self,
case NORMAL_BUTTON:
default:
{
button_data->label = gtk_label_new (NULL);
button_data->label = g_object_new (DZL_TYPE_BOLDING_LABEL, NULL);
child = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
gtk_box_pack_start (GTK_BOX (child), button_data->image, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (child), button_data->label, FALSE, FALSE, 0);
......@@ -2121,13 +2085,9 @@ make_button_data (NautilusPathBar *self,
if (button_data->label != NULL)
{
gtk_label_set_max_width_chars (GTK_LABEL (button_data->label), NAUTILUS_PATH_BAR_BUTTON_MAX_CHARS);
gtk_label_set_ellipsize (GTK_LABEL (button_data->label), PANGO_ELLIPSIZE_MIDDLE);
gtk_label_set_single_line_mode (GTK_LABEL (button_data->label), TRUE);
button_data->bold_label = gtk_label_new (NULL);
gtk_widget_set_no_show_all (button_data->bold_label, TRUE);
gtk_label_set_single_line_mode (GTK_LABEL (button_data->bold_label), TRUE);
gtk_box_pack_start (GTK_BOX (child), button_data->bold_label, FALSE, FALSE, 0);
}
if (button_data->path == NULL)
......
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