1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-25 13:55:34 -05:00

Merge remote-tracking branch 'origin/next'

This commit is contained in:
Dave Davenport 2017-08-29 11:17:36 +02:00
commit d7c432fecf
15 changed files with 304 additions and 222 deletions

View file

@ -59,7 +59,7 @@ before_install:
# TODO: We install xkbcommon here, until Travis use an up-to-date enough Ubuntu
install:
- sudo apt-get install -y --force-yes libxkbcommon-dev libxkbcommon-x11-dev flex/trusty-backports libfl-dev/trusty-backports
- pip3 install meson
- pip3 install meson==0.41.2
- wget https://github.com/ninja-build/ninja/releases/download/v1.7.2/ninja-linux.zip
- unzip ninja-linux.zip
- export PATH=$(pwd):$PATH

View file

@ -29,6 +29,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <glib.h>
#include "rofi-types.h"
#include "settings.h"
Settings config = {

View file

@ -1,6 +1,217 @@
#ifndef INCLUDE_ROFI_TYPES_H
#define INCLUDE_ROFI_TYPES_H
extern const char *PropertyTypeName[];
#include <glib.h>
/**
* Type of property
*/
typedef enum
{
/** Integer */
P_INTEGER,
/** Double */
P_DOUBLE,
/** String */
P_STRING,
/** Boolean */
P_BOOLEAN,
/** Color */
P_COLOR,
/** RofiPadding */
P_PADDING,
/** Link to global setting */
P_LINK,
/** Position */
P_POSITION,
/** Highlight */
P_HIGHLIGHT,
/** List */
P_LIST,
/** Orientation */
P_ORIENTATION,
/** Number of types. */
P_NUM_TYPES,
} PropertyType;
/**
* This array maps PropertyType to a user-readable name.
* It is important this is kept in sync.
*/
extern const char * const PropertyTypeName[P_NUM_TYPES];
/** Style of text highlight */
typedef enum
{
/** no highlight */
ROFI_HL_NONE = 0,
/** bold */
ROFI_HL_BOLD = 1,
/** underline */
ROFI_HL_UNDERLINE = 2,
/** strikethrough */
ROFI_HL_STRIKETHROUGH = 16,
/** small caps */
ROFI_HL_SMALL_CAPS = 32,
/** italic */
ROFI_HL_ITALIC = 4,
/** color */
ROFI_HL_COLOR = 8
} RofiHighlightStyle;
/** Style of line */
typedef enum
{
/** Solid line */
ROFI_HL_SOLID,
/** Dashed line */
ROFI_HL_DASH
} RofiLineStyle;
/**
* Distance unit type.
*/
typedef enum
{
/** PixelWidth in pixels. */
ROFI_PU_PX,
/** PixelWidth in EM. */
ROFI_PU_EM,
/** PixelWidget in percentage */
ROFI_PU_PERCENT,
} RofiPixelUnit;
/**
* Structure representing a distance.
*/
typedef struct
{
/** Distance */
double distance;
/** Unit type of the distance */
RofiPixelUnit type;
/** Style of the line (optional)*/
RofiLineStyle style;
} RofiDistance;
/**
* Type of orientation.
*/
typedef enum
{
ROFI_ORIENTATION_VERTICAL,
ROFI_ORIENTATION_HORIZONTAL
} RofiOrientation;
/**
* Represent the color in theme.
*/
typedef struct
{
/** red channel */
double red;
/** green channel */
double green;
/** blue channel */
double blue;
/** alpha channel */
double alpha;
} ThemeColor;
/**
* RofiPadding
*/
typedef struct
{
RofiDistance top;
RofiDistance right;
RofiDistance bottom;
RofiDistance left;
} RofiPadding;
/**
* Theme highlight.
*/
typedef struct
{
/** style to display */
RofiHighlightStyle style;
/** Color */
ThemeColor color;
} RofiHighlightColorStyle;
/**
* Enumeration indicating location or gravity of window.
*
* \verbatim WL_NORTH_WEST WL_NORTH WL_NORTH_EAST \endverbatim
* \verbatim WL_EAST WL_CENTER WL_EAST \endverbatim
* \verbatim WL_SOUTH_WEST WL_SOUTH WL_SOUTH_EAST\endverbatim
*
* @ingroup CONFIGURATION
*/
typedef enum
{
/** Center */
WL_CENTER = 0,
/** Top middle */
WL_NORTH = 1,
/** Middle right */
WL_EAST = 2,
/** Bottom middle */
WL_SOUTH = 4,
/** Middle left */
WL_WEST = 8,
/** Left top corner. */
WL_NORTH_WEST = WL_NORTH | WL_WEST,
/** Top right */
WL_NORTH_EAST = WL_NORTH | WL_EAST,
/** Bottom right */
WL_SOUTH_EAST = WL_SOUTH | WL_EAST,
/** Bottom left */
WL_SOUTH_WEST = WL_SOUTH | WL_WEST,
} WindowLocation;
typedef union
{
/** integer */
int i;
/** Double */
double f;
/** String */
char *s;
/** boolean */
gboolean b;
/** Color */
ThemeColor color;
/** RofiPadding */
RofiPadding padding;
/** Reference */
struct
{
/** Name */
char *name;
/** Cached looked up ref */
struct Property *ref;
} link;
/** Highlight Style */
RofiHighlightColorStyle highlight;
/** List */
GList *list;
} PropertyValue;
/**
* Property structure.
*/
typedef struct Property
{
/** Name of property */
char *name;
/** Type of property. */
PropertyType type;
/** Value */
PropertyValue value;
} Property;
#endif // INCLUDE_ROFI_TYPES_H

View file

@ -32,6 +32,7 @@
#include <glib.h>
#include <string.h>
#include <stdlib.h>
#include "rofi-types.h"
#include "keyb.h"
#include "mode.h"
#include "view.h"

View file

@ -43,37 +43,6 @@ typedef enum
MM_FUZZY = 3
} MatchingMethod;
/**
* Enumeration indicating location or gravity of window.
*
* \verbatim WL_NORTH_WEST WL_NORTH WL_NORTH_EAST \endverbatim
* \verbatim WL_EAST WL_CENTER WL_EAST \endverbatim
* \verbatim WL_SOUTH_WEST WL_SOUTH WL_SOUTH_EAST\endverbatim
*
* @ingroup CONFIGURATION
*/
typedef enum
{
/** Center */
WL_CENTER = 0,
/** Top middle */
WL_NORTH = 1,
/** Middle right */
WL_EAST = 2,
/** Bottom middle */
WL_SOUTH = 4,
/** Middle left */
WL_WEST = 8,
/** Left top corner. */
WL_NORTH_WEST = WL_NORTH | WL_WEST,
/** Top right */
WL_NORTH_EAST = WL_NORTH | WL_EAST,
/** Bottom right */
WL_SOUTH_EAST = WL_SOUTH | WL_EAST,
/** Bottom left */
WL_SOUTH_WEST = WL_SOUTH | WL_WEST,
} WindowLocation;
/**
* Settings structure holding all (static) configurable options.
* @ingroup CONFIGURATION

View file

@ -30,177 +30,8 @@
#include <glib.h>
#include <cairo.h>
#include <widgets/widget.h>
#include <settings.h>
#include "theme.h"
#include "rofi-types.h"
/** Style of text highlight */
typedef enum
{
/** no highlight */
ROFI_HL_NONE = 0,
/** bold */
ROFI_HL_BOLD = 1,
/** underline */
ROFI_HL_UNDERLINE = 2,
/** strikethrough */
ROFI_HL_STRIKETHROUGH = 16,
/** small caps */
ROFI_HL_SMALL_CAPS = 32,
/** italic */
ROFI_HL_ITALIC = 4,
/** color */
ROFI_HL_COLOR = 8
} RofiHighlightStyle;
/** Style of line */
typedef enum
{
/** Solid line */
ROFI_HL_SOLID,
/** Dashed line */
ROFI_HL_DASH
} RofiLineStyle;
/**
* Distance unit type.
*/
typedef enum
{
/** PixelWidth in pixels. */
ROFI_PU_PX,
/** PixelWidth in EM. */
ROFI_PU_EM,
/** PixelWidget in percentage */
ROFI_PU_PERCENT,
} RofiPixelUnit;
/**
* Structure representing a distance.
*/
typedef struct
{
/** Distance */
double distance;
/** Unit type of the distance */
RofiPixelUnit type;
/** Style of the line (optional)*/
RofiLineStyle style;
} RofiDistance;
/**
* Type of orientation.
*/
typedef enum
{
ROFI_ORIENTATION_VERTICAL,
ROFI_ORIENTATION_HORIZONTAL
} RofiOrientation;
/**
* Type of property
*/
typedef enum
{
/** Integer */
P_INTEGER,
/** Double */
P_DOUBLE,
/** String */
P_STRING,
/** Boolean */
P_BOOLEAN,
/** Color */
P_COLOR,
/** RofiPadding */
P_PADDING,
/** Link to global setting */
P_LINK,
/** Position */
P_POSITION,
/** Highlight */
P_HIGHLIGHT,
/** List */
P_LIST,
/** Orientation */
P_ORIENTATION,
} PropertyType;
/**
* Represent the color in theme.
*/
typedef struct
{
/** red channel */
double red;
/** green channel */
double green;
/** blue channel */
double blue;
/** alpha channel */
double alpha;
} ThemeColor;
/**
* RofiPadding
*/
typedef struct
{
RofiDistance top;
RofiDistance right;
RofiDistance bottom;
RofiDistance left;
} RofiPadding;
/**
* Theme highlight.
*/
typedef struct
{
/** style to display */
RofiHighlightStyle style;
/** Color */
ThemeColor color;
} RofiHighlightColorStyle;
typedef union
{
/** integer */
int i;
/** Double */
double f;
/** String */
char *s;
/** boolean */
gboolean b;
/** Color */
ThemeColor color;
/** RofiPadding */
RofiPadding padding;
/** Reference */
struct
{
/** Name */
char *name;
/** Cached looked up ref */
struct Property *ref;
} link;
/** Highlight Style */
RofiHighlightColorStyle highlight;
/** List */
GList *list;
} PropertyValue;
/**
* Property structure.
*/
typedef struct Property
{
/** Name of property */
char *name;
/** Type of property. */
PropertyType type;
/** Value */
PropertyValue value;
} Property;
/**
* ThemeWidget.
*/

View file

@ -313,5 +313,12 @@ PangoAttrList *textbox_get_pango_attributes ( textbox *tb );
*/
const char *textbox_get_visible_text ( const textbox *tb );
int textbox_get_desired_width ( widget *wid );
/**
* @param tb Handle to the textbox
*
* Move the cursor to the end of the string.
*/
void textbox_cursor_end ( textbox *tb );
/*@}*/
#endif //ROFI_TEXTBOX_H

View file

@ -11,21 +11,63 @@ The great work of [SardemFF7](https://github.com/SardemFF7/) simplified the code
handling. It also made it possible to add a often requested feature of icons (correctly using the icon-theme). A feature
I never expected to be added.
A last big addition, is support for plugins. Allowing the addition of some weird/fancy features. Currently two plugins
are available, [blezz](https://gitcrate.org/qtools/rofi-blezz) a quick launch menu with it own menu definition and
[top](https://gitcrate.org/qtools/rofi-top/) displaying running processes.
A last big addition and still in beta, is support for plugins. Allowing the addition of some weird/fancy features.
Currently two plugins are available, [blezz](https://gitcrate.org/qtools/rofi-blezz) a quick launch menu with it own
menu definition and [top](https://gitcrate.org/qtools/rofi-top/) displaying running processes.
Beside these major changes, this release includes a lot of bug-fixes and small improvements. See the bottom of this
release notes for the full list of changes.
## CSS Like Theme engine
The biggest new feature of this release is the theme engine. Building on the changes made in v1.3.0 we implemented a new
theme engine and it has a completely new theme format modelled after CSS. We decided to model the theme format after
CSS because many people are familiar with it and it seems to be a reasonable fit. While the themes are a lot more
verbose now, it does allow for a lot of extra customizations.
## Flexible layout
It is now possible to theme each widget in rofi independently:
### Colors
You can now set the color on each widget independent in most of the CSS supported color formats (hsl, cmyk, rgb, etc.)
and each color can have a transparency. Each widget has three colors: background, foreground and text.
> TODO: add picture of rofi rainbow colors.
### Borders
On every widget we can now configure a border for each of the four sides, the color of the border, the style of the
border (solid or dashed0) and the radius of the corners can be set.
> TODO: Add picture of crazy borders.
This combined with (fake) transparency can make for a very nice looking, rounded rofi experience.
> TODO: Rounded corner rofi.
### Fonts
An often made request was support for different fonts for the entry box and the list. With the new theme, it is possible
to change the font and size of all widgets.
> TODO: picture of mixture of fonts.
### Flexible layout
To top all these changes, as an advanced feature the whole layout of the window can be changed. Making it possible to
mimic the original dmenu view, or make it appear as a minimal context menu.
> TODO: insert two screenshot.
## Icons
Another often made request, I never expected to be implemented, was icon support. But with the help of SardemFF7 an
implementation was possible that correctly follows the XDG icon specification and does not negatively impact the
performance.
> TODO: Screenshot with icons.
## More flexible key and mouse bindings
@ -35,6 +77,12 @@ release notes for the full list of changes.
## Screenshot
## Configuration File
The new theme format can now (as an alpha) feature be used to set rofi's configuration. In the future, when we add
wayland support, we want to get rid of the current Xresources (X11) based configuration format.
You can see how this would look using: `rofi -dump-config`.
## Detailed Changelog

View file

@ -3,7 +3,7 @@
/**
* Name of the property type
*/
const char *PropertyTypeName[] = {
const char * const PropertyTypeName[P_NUM_TYPES] = {
/** Integer */
"Integer",
/** Double */
@ -14,8 +14,8 @@ const char *PropertyTypeName[] = {
"Boolean",
/** Color */
"Color",
/** RofiPadding */
"RofiPadding",
/** Padding */
"Padding",
/** Link to global setting */
"Reference",
/** Position */

View file

@ -45,11 +45,11 @@
#include <libgwater-xcb.h>
#include "rofi.h"
#include "display.h"
#include "settings.h"
#include "mode.h"
#include "rofi.h"
#include "helper.h"
#include "widgets/textbox.h"
#include "xrmoptions.h"

View file

@ -48,11 +48,11 @@
#define SN_API_NOT_YET_FROZEN
#include <libsn/sn.h>
#include "rofi.h"
#include "timings.h"
#include "settings.h"
#include "rofi.h"
#include "mode.h"
#include "display.h"
#include "xcb-internal.h"
@ -1696,6 +1696,7 @@ RofiViewState *rofi_view_create ( Mode *sw,
if ( state->text && input ) {
textbox_text ( state->text, input );
textbox_cursor_end ( state->text );
}
state->overlay = textbox_create ( WIDGET_TYPE_TEXTBOX_TEXT, "window.overlay", TB_AUTOWIDTH | TB_AUTOHEIGHT, URGENT, "blaat", 0.5, 0 );

View file

@ -49,13 +49,6 @@ static int textbox_get_width ( widget * );
static int _textbox_get_height ( widget * );
static void __textbox_update_pango_text ( textbox *tb );
/**
* @param tb Handle to the textbox
*
* Move the cursor to the end of the string.
*/
static void textbox_cursor_end ( textbox *tb );
/** Default pango context */
static PangoContext *p_context = NULL;
/** The pango font metrics */
@ -585,7 +578,7 @@ static void textbox_cursor_dec_word ( textbox *tb )
}
// end of line
static void textbox_cursor_end ( textbox *tb )
void textbox_cursor_end ( textbox *tb )
{
if ( tb->text == NULL ) {
tb->cursor = 0;

View file

@ -52,6 +52,7 @@
#define SN_API_NOT_YET_FROZEN
/* This function is declared as sn_launcher_context_set_application_id but implemented as sn_launcher_set_application_id */
#define sn_launcher_context_set_application_id sn_launcher_set_application_id
#include "rofi-types.h"
#include <libsn/sn.h>
#include "display.h"
#include "xcb-internal.h"

View file

@ -391,7 +391,6 @@ void config_parse_cmd_options ( void )
static gboolean __config_parser_set_property ( XrmOption *option, const Property *p, char **error )
{
extern const char *PropertyTypeName[];
if ( option->type == xrm_String ) {
if ( p->type != P_STRING && p->type != P_LIST ) {
*error = g_strdup_printf ( "Option: %s needs to be set with a string not a %s.", option->name, PropertyTypeName[p->type] );

View file

@ -1233,6 +1233,25 @@ START_TEST ( test_prepare_path )
g_free ( current_dir );
}
END_TEST
START_TEST(test_properties_types_names)
{
ck_assert_str_eq ( PropertyTypeName[P_INTEGER], "Integer");
ck_assert_str_eq ( PropertyTypeName[P_DOUBLE], "Double");
ck_assert_str_eq ( PropertyTypeName[P_STRING], "String");
ck_assert_str_eq ( PropertyTypeName[P_BOOLEAN], "Boolean");
ck_assert_str_eq ( PropertyTypeName[P_COLOR], "Color");
ck_assert_str_eq ( PropertyTypeName[P_PADDING], "Padding");
ck_assert_str_eq ( PropertyTypeName[P_LINK], "Reference");
ck_assert_str_eq ( PropertyTypeName[P_POSITION], "Position");
ck_assert_str_eq ( PropertyTypeName[P_HIGHLIGHT], "Highlight");
ck_assert_str_eq ( PropertyTypeName[P_LIST], "List");
ck_assert_str_eq ( PropertyTypeName[P_ORIENTATION], "Orientation");
}
END_TEST
static Suite * theme_parser_suite (void)
{
Suite *s;
@ -1244,6 +1263,7 @@ static Suite * theme_parser_suite (void)
{
tc_core = tcase_create("Core");
tcase_add_checked_fixture(tc_core, theme_parser_setup, theme_parser_teardown);
tcase_add_test(tc_core, test_properties_types_names);
tcase_add_test(tc_core, test_core_empty_string);
tcase_add_test(tc_core, test_core_empty_global_section);
tcase_add_test(tc_core, test_core_empty_section);