Skip to content

Commit

Permalink
Port to gtk3
Browse files Browse the repository at this point in the history
  • Loading branch information
thjaeger committed Feb 19, 2013
1 parent 203bb77 commit 6905475
Show file tree
Hide file tree
Showing 15 changed files with 335 additions and 385 deletions.
11 changes: 3 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ DFLAGS =
OFLAGS = -O2
AOFLAGS = -O3
STROKEFLAGS = -Wall -std=c99 $(DFLAGS)
CXXFLAGS = -Wall $(DFLAGS) -DLOCALEDIR=\"$(LOCALEDIR)\" `pkg-config gtkmm-2.4 dbus-glib-1 --cflags`
CXXFLAGS = -Wall $(DFLAGS) -DLOCALEDIR=\"$(LOCALEDIR)\" `pkg-config gtkmm-3.0 dbus-glib-1 --cflags`
LDFLAGS = $(DFLAGS)

LIBS = $(DFLAGS) -lboost_serialization -lX11 -lXext -lXi -lXfixes -lXtst `pkg-config gtkmm-2.4 dbus-glib-1 --libs`
LIBS = $(DFLAGS) -lboost_serialization -lX11 -lXext -lXi -lXfixes -lXtst `pkg-config gtkmm-3.0 dbus-glib-1 --libs`

BINARY = easystroke
ICON = easystroke.svg
Expand All @@ -39,7 +39,7 @@ POFILES = $(wildcard po/*.po)
MOFILES = $(patsubst po/%.po,po/%/LC_MESSAGES/easystroke.mo,$(POFILES))
MODIRS = $(patsubst po/%.po,po/%,$(POFILES))
DEPFILES = $(wildcard *.Po)
GENFILES = gui.c desktop.c dbus-server.h po/POTFILES.in easystroke.desktop
GENFILES = gui.c desktop.c po/POTFILES.in easystroke.desktop
GZFILES = $(wildcard *.gz)

VERSION = $(shell test -e debian/changelog && grep '(.*)' debian/changelog | sed 's/.*(//' | sed 's/).*//' | head -n1 || (test -e version && cat version || git describe))
Expand Down Expand Up @@ -83,11 +83,6 @@ desktop.c: easystroke.desktop
sed 's/Exec=easystroke/Exec=%s/' $< | sed 's/"/\\"/g' | sed 's/.*/&\\n\\/' >> $@
echo "\";" >> $@

dbus-server.cc: dbus-server.h

dbus-server.h: dbus.xml
dbus-binding-tool --prefix=server --mode=glib-server --output=$@ $<

po/POTFILES.in: $(CCFILES) $(HFILES)
$(RM) $@
for f in `grep -El "\<_\(" $^`; do echo $$f >> $@; done
Expand Down
32 changes: 19 additions & 13 deletions actions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void TreeViewMulti::on_drag_begin(const Glib::RefPtr<Gdk::DragContext> &context)
pending = false;
if (get_selection()->count_selected_rows() <= 1)
return Gtk::TreeView::on_drag_begin(context);
Glib::RefPtr<Gdk::Pixbuf> pb = render_icon(Gtk::Stock::DND_MULTIPLE, Gtk::ICON_SIZE_DND);
Glib::RefPtr<Gdk::Pixbuf> pb = render_icon_pixbuf(Gtk::Stock::DND_MULTIPLE, Gtk::ICON_SIZE_DND);
context->set_icon(pb, pb->get_width(), pb->get_height());
}

Expand All @@ -67,26 +67,29 @@ class CellEditableAccel : public Gtk::EventBox, public Gtk::CellEditable {
WIDGET(Gtk::Label, label, _("Key combination..."));
label.set_alignment(0.0, 0.5);
add(label);
modify_bg(Gtk::STATE_NORMAL, widget.get_style()->get_bg(Gtk::STATE_SELECTED));
label.modify_fg(Gtk::STATE_NORMAL, widget.get_style()->get_fg(Gtk::STATE_SELECTED));
override_background_color(widget.get_style_context()->get_background_color(Gtk::STATE_FLAG_SELECTED), Gtk::STATE_FLAG_NORMAL);
label.override_color(widget.get_style_context()->get_color(Gtk::STATE_FLAG_SELECTED), Gtk::STATE_FLAG_NORMAL);
show_all();
}
protected:

virtual void start_editing_vfunc(GdkEvent *event) {
add_modal_grab();
get_window()->keyboard_grab(false, gdk_event_get_time(event));
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
gdk_keyboard_grab(get_window()->gobj(), false, gdk_event_get_time(event));
#pragma GCC diagnostic pop
signal_key_press_event().connect(sigc::mem_fun(*this, &CellEditableAccel::on_key));
}

bool on_key(GdkEventKey* event) {
if (event->is_modifier)
return true;
switch (event->keyval) {
case GDK_Super_L:
case GDK_Super_R:
case GDK_Hyper_L:
case GDK_Hyper_R:
case GDK_KEY_Super_L:
case GDK_KEY_Super_R:
case GDK_KEY_Hyper_L:
case GDK_KEY_Hyper_R:
return true;
}
guint mods = event->state & gtk_accelerator_get_default_mod_mask();
Expand All @@ -101,12 +104,15 @@ class CellEditableAccel : public Gtk::EventBox, public Gtk::CellEditable {

virtual void on_editing_done() {
remove_modal_grab();
get_window()->keyboard_ungrab(CurrentTime);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
gdk_keyboard_ungrab(CurrentTime);
#pragma GCC diagnostic pop
Gtk::CellEditable::on_editing_done();
}
};

class CellEditableCombo : public Gtk::ComboBoxText, public Gtk::CellEditable {
class CellEditableCombo : public Gtk::ComboBoxText {
CellRendererTextish *parent;
Glib::ustring path;
public:
Expand All @@ -115,7 +121,7 @@ class CellEditableCombo : public Gtk::ComboBoxText, public Gtk::CellEditable {
parent(parent_), path(path_)
{
while (*items)
append_text(_(*(items++)));
append(_(*(items++)));
}
protected:
virtual void on_changed() {
Expand Down Expand Up @@ -362,7 +368,7 @@ bool Actions::AppsStore::row_drop_possible_vfunc(const Gtk::TreeModel::Path &des
if (expecting && expected != dest)
expecting = false;
if (!expecting) {
if (dest.get_depth() < 2 || dest.back() != 0)
if (gtk_tree_path_get_depth((GtkTreePath *)dest.gobj()) < 2 || dest.back() != 0)
return false;
expected = dest;
expected.up();
Expand Down Expand Up @@ -437,7 +443,7 @@ bool Actions::Store::row_draggable_vfunc(const Gtk::TreeModel::Path &path) const

bool Actions::Store::row_drop_possible_vfunc(const Gtk::TreeModel::Path &dest, const Gtk::SelectionData &selection) const {
static bool ignore_next = false;
if (dest.get_depth() > 1) {
if (gtk_tree_path_get_depth((GtkTreePath *)dest.gobj()) > 1) {
ignore_next = true;
return false;
}
Expand Down
22 changes: 7 additions & 15 deletions composite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,19 @@ Popup::Popup(int x1, int y1, int x2, int y2) : Gtk::Window(Gtk::WINDOW_POPUP), r
if (!is_composited())
throw std::runtime_error(_("'composite' not available"));

Glib::RefPtr<Gdk::Colormap> colormap = get_screen()->get_rgba_colormap();
if (colormap)
set_colormap(colormap);
signal_expose_event().connect(sigc::mem_fun(*this, &Popup::on_expose));
Glib::RefPtr<Gdk::Visual> visual = get_screen()->get_rgba_visual();
gtk_widget_set_visual(Widget::gobj(), visual->gobj());
signal_draw().connect(sigc::mem_fun(*this, &Popup::on_draw));
realize();
move(x1, y1);
resize(x2-x1, y2-y1);
get_window()->input_shape_combine_region(Gdk::Region(), 0, 0);
get_window()->input_shape_combine_region(Cairo::Region::create(), 0, 0);
// tell compiz to leave this window the hell alone
get_window()->set_type_hint(Gdk::WINDOW_TYPE_HINT_DESKTOP);
}

void Popup::invalidate(int x1, int y1, int x2, int y2) {
if (is_mapped()) {
if (get_mapped()) {
Gdk::Rectangle inv(x1 - rect.get_x(), y1 - rect.get_y(), x2-x1, y2-y1);
get_window()->invalidate_rect(inv, false);
} else
Expand Down Expand Up @@ -109,17 +108,10 @@ void Popup::draw_line(Cairo::RefPtr<Cairo::Context> ctx) {

}

bool Popup::on_expose(GdkEventExpose* event) {
Cairo::RefPtr<Cairo::Context> ctx = get_window()->create_cairo_context();
bool Popup::on_draw(const ::Cairo::RefPtr< ::Cairo::Context>& ctx) {
ctx->set_operator(Cairo::OPERATOR_SOURCE);

Gdk::Region region(event->region, true);
Gdk::Cairo::add_region_to_path(ctx, region);
ctx->clip();

Gdk::Cairo::add_region_to_path(ctx, region);
ctx->set_source_rgba(0.0, 0.0, 0.0, 0.0);
ctx->fill();
ctx->paint();

ctx->translate(-rect.get_x(), -rect.get_y());
draw_line(ctx);
Expand Down
2 changes: 1 addition & 1 deletion composite.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <list>

class Popup : public Gtk::Window {
bool on_expose(GdkEventExpose* event);
bool on_draw(const ::Cairo::RefPtr< ::Cairo::Context>& ctx);
void draw_line(Cairo::RefPtr<Cairo::Context> ctx);
Gdk::Rectangle rect;
public:
Expand Down
90 changes: 0 additions & 90 deletions dbus-server.cc

This file was deleted.

13 changes: 0 additions & 13 deletions dbus.xml

This file was deleted.

7 changes: 6 additions & 1 deletion easystroke.desktop.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@ Terminal=false
Exec=easystroke
Icon=easystroke
Categories=GTK;Utility;Accessibility;
Actions=About;Enable;Disable;Quit
_Comment=Control your desktop using mouse gestures

[Desktop Action About]
_Name=About
Exec=easystroke about

[Desktop Action Enable]
_Name=Enable/Disable
_Name=Enable
Exec=easystroke enable

[Desktop Action Disable]
_Name=Disable
Exec=easystroke disable

[Desktop Action Quit]
_Name=Quit
Exec=easystroke quit
2 changes: 1 addition & 1 deletion gesture.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#define __GESTURE_H__

#include "stroke.h"
#include <gdkmm/pixbuf.h>
#include <gdkmm.h>
#include <vector>
#include <boost/shared_ptr.hpp>
#include <boost/serialization/access.hpp>
Expand Down
Loading

0 comments on commit 6905475

Please sign in to comment.