Skip to content

Commit 06d0bb0

Browse files
authored
Merge pull request #20 from alainm23/master
Update for elementary 8
2 parents 3544dd6 + cf23fb1 commit 06d0bb0

File tree

10 files changed

+145
-31
lines changed

10 files changed

+145
-31
lines changed

data/Indicator.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
button:selected {
2+
background: @selected_bg_color;
3+
color: @selected_fg_color;
4+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<gresources>
3+
<gresource prefix="/com/github/tom95/indicator-synapse/">
4+
<file alias="Indicator.css">Indicator.css</file>
5+
</gresource>
6+
</gresources>

meson.build

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,37 @@
11
project('synapse', 'vala', 'c')
22

3-
gettext_name = meson.project_name() + '-indicator'
43
gnome = import('gnome')
54
i18n = import('i18n')
5+
gettext_name = meson.project_name() + '-indicator'
66

7-
add_global_arguments('-DGETTEXT_PACKAGE="@0@"'.format(gettext_name), language:'c')
7+
prefix = get_option('prefix')
8+
libdir = prefix / get_option('libdir')
89

9-
#asresources = gnome.compile_resources(
10-
#'as-resources', 'data/com.github.tom95.indicator-synapse.gresource.xml',
11-
#source_dir: 'data',
12-
#c_name: 'as'
13-
#)
10+
add_global_arguments('-DGETTEXT_PACKAGE="@0@"'.format(gettext_name), language:'c')
1411

15-
wingpanel_dep = dependency('wingpanel-2.0')
12+
wingpanel_dep = dependency('wingpanel')
13+
wingpanel_indicatorsdir = wingpanel_dep.get_variable('indicatorsdir', pkgconfig_define: ['libdir', libdir])
1614

1715
add_project_arguments(['--vapidir', join_paths(meson.current_source_dir(), 'vapi')], language: 'vala')
1816

17+
gresource = gnome.compile_resources(
18+
'as-resources',
19+
'data' / 'com.github.tom95.indicator-synapse.gresource.xml',
20+
source_dir: 'data'
21+
)
22+
23+
config_data = configuration_data()
24+
config_data.set_quoted('LOCALEDIR', prefix / get_option('localedir'))
25+
config_data.set_quoted('GETTEXT_PACKAGE', meson.project_name() + '-indicator')
26+
config_data.set_quoted('DATADIR', prefix / get_option('datadir') / meson.project_name())
27+
1928
shared_module(
2029
meson.project_name(),
2130
'src/indicator/main.vala',
2231
'src/indicator/menu.vala',
2332
'src/indicator/match-item.vala',
2433
'src/indicator/selectable-list.vala',
34+
'src/indicator/AutomaticScrollBox.vala',
2535

2636
'src/core/common-actions.vala',
2737
'src/core/config-service.vala',
@@ -53,7 +63,7 @@ shared_module(
5363
'src/plugins/gnome-session-plugin.vala',
5464
'src/plugins/hello-world-plugin.vala',
5565
'src/plugins/hybrid-search-plugin.vala',
56-
'src/plugins/imgur-plugin.vala',
66+
# 'src/plugins/imgur-plugin.vala',
5767
'src/plugins/launchpad-plugin.vala',
5868
'src/plugins/locate-plugin.vala',
5969
'src/plugins/opensearch.vala',
@@ -68,21 +78,22 @@ shared_module(
6878
'src/plugins/xnoise-media-player-plugin.vala',
6979
'src/plugins/zeitgeist-plugin.vala',
7080
'src/plugins/zeitgeist-related.vala',
71-
72-
#asresources,
81+
gresource,
7382
dependencies: [
7483
dependency('zeitgeist-2.0'),
7584
dependency('json-glib-1.0'),
76-
dependency('rest-0.7'),
85+
# dependency('rest-0.9'),
7786
dependency('libnotify'),
7887
dependency('glib-2.0'),
7988
dependency('gobject-2.0'),
8089
dependency('gtk+-3.0'),
8190
dependency('gio-2.0'),
8291
dependency('gio-unix-2.0'),
92+
dependency('libsoup-3.0'),
93+
dependency('granite', version: '>=6.0.0'),
8394
wingpanel_dep
8495
],
8596
install: true,
86-
install_dir : get_option('libdir') + '/wingpanel' #'/usr/lib/x86_64-linux-gnu/wingpanel' #wingpanel_dep.get_pkgconfig_variable('indicatorsdir')
97+
install_dir : wingpanel_indicatorsdir
8798
)
8899

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright (c) 2011-2015 Wingpanel Developers (http://launchpad.net/wingpanel)
3+
*
4+
* This program is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU General Public
6+
* License as published by the Free Software Foundation; either
7+
* version 2 of the License, or (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public
15+
* License along with this program; if not, write to the
16+
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17+
* Boston, MA 02111-1307, USA.
18+
*/
19+
20+
/**
21+
* A scroll box that takes its child's height, unless that height is more than max_height.
22+
* If it is actually higher than max_height, then it will stick to max_height.
23+
*/
24+
public class AutomaticScrollBox : Gtk.ScrolledWindow {
25+
/**
26+
* The maximal height of the scroll box before it starts scrolling.
27+
*/
28+
public int max_height { default = 512; get; set; }
29+
30+
/**
31+
* The adjustments are here to ensure the compatibility with Gtk.ScrolledWindow,
32+
* but you should probably not use them, as the height of this widget is dynamic.
33+
*/
34+
public AutomaticScrollBox (Gtk.Adjustment? hadj = null, Gtk.Adjustment? vadj = null) {
35+
Object (hadjustment : hadj, vadjustment : vadj);
36+
}
37+
38+
construct {
39+
notify["max-height"].connect (queue_resize);
40+
}
41+
42+
public override void get_preferred_height_for_width (int width, out int minimum_height, out int natural_height) {
43+
unowned Gtk.Widget child = get_child ();
44+
45+
if (child != null) {
46+
child.get_preferred_height_for_width (width, out minimum_height, out natural_height);
47+
48+
minimum_height = int.min (max_height, minimum_height);
49+
natural_height = int.min (max_height, natural_height);
50+
} else {
51+
minimum_height = natural_height = 0;
52+
}
53+
}
54+
55+
public override void get_preferred_height (out int minimum_height, out int natural_height) {
56+
unowned Gtk.Widget child = get_child ();
57+
58+
if (child != null) {
59+
child.get_preferred_height (out minimum_height, out natural_height);
60+
61+
minimum_height = int.min (max_height, minimum_height);
62+
natural_height = int.min (max_height, natural_height);
63+
} else {
64+
minimum_height = natural_height = 0;
65+
}
66+
}
67+
}

src/indicator/main.vala

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,34 +51,48 @@ public class Main : Wingpanel.Indicator
5151

5252
public static SynapseIndicator.DataSink sink;
5353

54-
private Wingpanel.Widgets.OverlayIcon? indicator_icon = null;
54+
private Gtk.Image? indicator_icon = null;
5555
private Menu? popover_widget = null;
5656

5757
const string CODE_NAME = "com.github.tom95.indicator-synapse";
5858

5959
Cancellable? current_search = null;
6060

6161
public Main (Wingpanel.IndicatorManager.ServerType server_type) {
62-
Object (code_name: CODE_NAME,
63-
display_name: _("Synapse"),
64-
description: _("Synapse Search Indicator"));
62+
Object (
63+
code_name: CODE_NAME
64+
);
6565

6666
sink = new SynapseIndicator.DataSink ();
6767
foreach (var plugin in plugins) {
6868
sink.register_static_plugin (plugin);
6969
}
70+
71+
visible = true;
7072
}
7173

7274
public override Gtk.Widget get_display_widget () {
7375
if (indicator_icon == null) {
74-
indicator_icon = new Wingpanel.Widgets.OverlayIcon ("edit-find-symbolic");
75-
}
76+
indicator_icon = new Gtk.Image () {
77+
icon_name = "edit-find-symbolic",
78+
pixel_size = 16
79+
};
80+
}
7681

77-
return indicator_icon;
82+
return indicator_icon;
7883
}
7984

8085
public override Gtk.Widget? get_widget () {
8186
if (popover_widget == null) {
87+
var provider = new Gtk.CssProvider ();
88+
provider.load_from_resource ("com/github/tom95/indicator-synapse/Indicator.css");
89+
90+
Gtk.StyleContext.add_provider_for_screen (
91+
Gdk.Screen.get_default (),
92+
provider,
93+
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
94+
);
95+
8296
popover_widget = new Menu ();
8397
popover_widget.close.connect (() => {close (); print("restuqest close\n"); });
8498

@@ -97,8 +111,6 @@ public class Main : Wingpanel.Indicator
97111
});
98112
}
99113

100-
visible = true;
101-
102114
return popover_widget;
103115
}
104116

src/indicator/match-item.vala

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
*/
2020

21-
public class MatchItem : Wingpanel.Widgets.Container
21+
public class MatchItem : Gtk.Button
2222
{
2323
public SynapseIndicator.Match? match { get; private set; }
2424
public SynapseIndicator.Match? target { get; private set; }
@@ -76,7 +76,12 @@ public class MatchItem : Wingpanel.Widgets.Container
7676
{
7777
this ();
7878

79-
get_content_widget ().add (get_box (action.description, action.icon_name, large));
79+
add (get_box (action.description, action.icon_name, large));
80+
81+
var style_context = this.get_style_context ();
82+
style_context.add_class (Gtk.STYLE_CLASS_FLAT);
83+
hexpand = true;
84+
8085
match = action;
8186
target = _target;
8287
}
@@ -96,7 +101,11 @@ public class MatchItem : Wingpanel.Widgets.Container
96101
outer_box.pack_start (category, false);
97102
outer_box.pack_start (inner_box);
98103
outer_box.margin_right = 12;
99-
get_content_widget ().add (outer_box);
104+
add (outer_box);
105+
106+
var style_context = this.get_style_context ();
107+
style_context.add_class (Gtk.STYLE_CLASS_FLAT);
108+
hexpand = true;
100109

101110
if (no_hover) {
102111
leave_notify_event.connect (() => { return true; });

src/indicator/menu.vala

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ public class Menu : Gtk.Grid
3939
{
4040
orientation = Gtk.Orientation.VERTICAL;
4141

42-
stack = new Gtk.Stack ();
42+
stack = new Gtk.Stack () {
43+
hexpand = true,
44+
hhomogeneous = true
45+
};
4346
stack.transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT;
4447

4548
entry = new Gtk.Entry ();
@@ -108,16 +111,18 @@ public class Menu : Gtk.Grid
108111
});
109112

110113
results = new SelectableList ();
111-
var scroll = new Wingpanel.Widgets.AutomaticScrollBox ();
114+
115+
var scroll = new AutomaticScrollBox ();
112116
results.scroll = scroll;
117+
113118
scroll.add (results);
114119

115120
context_results = new SelectableList ();
116121

117122
stack.add_named (scroll, SEARCH_VIEW);
118123
stack.add_named (context_results, CONTEXT_VIEW);
119-
add (stack);
120124

125+
add (stack);
121126
width_request = 480;
122127
}
123128

src/plugins/chromium-plugin.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ namespace SynapseIndicator
189189
UNWANTED_SCHEME.add ("place");
190190
UNWANTED_SCHEME.add ("javascript");
191191

192-
List<unowned Json.Node> folders = new List<Json.Node> ();
192+
List<unowned Json.Node> folders = new List<unowned Json.Node> ();
193193

194194
try
195195
{

src/plugins/hybrid-search-plugin.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ namespace SynapseIndicator
278278
}
279279
else
280280
{
281-
var sort_array = new Gee.ArrayList<Gee.Map.Entry<unowned string, int>> ();
281+
var sort_array = new Gee.ArrayList<Gee.Map.Entry<string, int>> ();
282282
int min_hit = int.MAX;
283283
foreach (var entry in directory_hits.entries)
284284
{

src/plugins/wolframalpha-plugin.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace SynapseIndicator
5252
{
5353
try
5454
{
55-
AppInfo.launch_default_for_uri ("https://www.wolframalpha.com/input/?i=" + (Soup.URI.encode (match.title, "+").replace (" ", "+")),
55+
AppInfo.launch_default_for_uri ("https://www.wolframalpha.com/input/?i=" + (GLib.Uri.escape_string (match.title, "+").replace (" ", "+")),
5656
Gdk.Display.get_default ().get_app_launch_context ());
5757
}
5858
catch (Error err)

0 commit comments

Comments
 (0)