Commit 4c94c2a8 authored by Andrei Lișiță's avatar Andrei Lișiță 🎮

task-list-view: Done button has maximum width

This patch adds a maximum width to the Done button in
the task list view.

A subclass of the GtkButton is created. This class is
named GtdDoneButton. In this class the get_preferred_width()
method is overrided by gtd_row_get_preferred_width_with_max()
from gtd-commons.

The type of the Done button is changed in list-view.ui from
GtkButton to GtdDoneButton and also the halign(center) property
is added.
parent 3fe22fd1
Pipeline #3428 passed with stage
in 9 minutes and 9 seconds
......@@ -106,13 +106,14 @@
</packing>
</child>
<child>
<object class="GtkButton" id="done_button">
<object class="GtdDoneButton" id="done_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Show or hide completed tasks</property>
<property name="border_width">12</property>
<property name="relief">none</property>
<property name="halign">center</property>
<signal name="clicked" handler="gtd_task_list_view__done_button_clicked" object="GtdTaskListView" swapped="no" />
<child>
<object class="GtkBox" id="done_button_box">
......
......@@ -19,6 +19,7 @@
#define G_LOG_DOMAIN "GtdTaskListView"
#include "gtd-dnd-row.h"
#include "gtd-done-button.h"
#include "gtd-edit-pane.h"
#include "gtd-empty-list-widget.h"
#include "gtd-task-list-view.h"
......@@ -1523,6 +1524,7 @@ gtd_task_list_view_class_init (GtdTaskListViewClass *klass)
g_type_ensure (GTD_TYPE_TASK_ROW);
g_type_ensure (GTD_TYPE_DND_ROW);
g_type_ensure (GTD_TYPE_EMPTY_LIST_WIDGET);
g_type_ensure (GTD_TYPE_DONE_BUTTON);
/**
* GtdTaskListView::color:
......
......@@ -27,6 +27,7 @@ G_BEGIN_DECLS
typedef struct _GtdActivatable GtdActivatable;
typedef struct _GtdApplication GtdApplication;
typedef struct _GtdDoneButton GtdDoneButton;
typedef struct _GtdInitialSetupWindow GtdInitialSetupWindow;
typedef struct _GtdListView GtdListView;
typedef struct _GtdManager GtdManager;
......
......@@ -58,6 +58,7 @@ sources = files(
'views/gtd-list-selector-list.c',
'views/gtd-list-selector-list-item.c',
'views/gtd-list-selector-panel.c',
'widgets/gtd-done-button.c',
'widgets/gtd-expandable-entry.c',
'gtd-application.c',
'gtd-dnd-row.c',
......
/* gtd-done-button.c
*
* Copyright (C) 2018 Andrei Lisita <andreii.lisita@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "gtd-done-button.h"
#include "gtd-rows-common-private.h"
#include <gtk/gtk.h>
struct _GtdDoneButton
{
GtkButton parent;
};
G_DEFINE_TYPE (GtdDoneButton, gtd_done_button, GTK_TYPE_BUTTON)
static void
gtd_done_button_class_init (GtdDoneButtonClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
widget_class->get_preferred_width = gtd_row_get_preferred_width_with_max;
}
static void
gtd_done_button_init (GtdDoneButton *self)
{
}
/* gtd-done-button.h
*
* Copyright (C) 2018 Andrei Lisita <andreii.lisita@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define GTD_TYPE_DONE_BUTTON (gtd_done_button_get_type())
G_DECLARE_FINAL_TYPE (GtdDoneButton, gtd_done_button, GTD, DONE_BUTTON, GtkButton)
G_END_DECLS
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