GTK3 branch merged

presentation
Andreas Butti 7 years ago
parent a2531d5e75
commit c54dd28ca5
  1. 3
      src/control/Actions.h
  2. 50
      src/control/ClipboardHandler.cpp
  3. 4
      src/control/ClipboardHandler.h
  4. 5
      src/control/ScrollHandler.h
  5. 14
      src/control/ZoomControl.cpp
  6. 10
      src/control/ZoomControl.h

@ -48,6 +48,9 @@ enum ActionType
ACTION_GOTO_PAGE,
ACTION_GOTO_NEXT,
ACTION_GOTO_LAST,
ACTION_GOTO_NEXT_LAYER,
ACTION_GOTO_BACK_LAYER,
ACTION_GOTO_TOP_LAYER,
ACTION_GOTO_NEXT_ANNOTATED_PAGE,
ACTION_GOTO_PREVIOUS_ANNOTATED_PAGE,

@ -49,9 +49,7 @@ ClipboardHandler::~ClipboardHandler()
XOJ_RELEASE_TYPE(ClipboardHandler);
}
static GdkAtom atomXournal =
gdk_atom_intern_static_string("application/xournal");
static GdkAtom atomUtf8 = gdk_atom_intern_static_string("UTF8_STRING");
static GdkAtom atomXournal = gdk_atom_intern_static_string("application/xournal");
bool ClipboardHandler::paste()
{
@ -65,8 +63,8 @@ bool ClipboardHandler::paste()
}
else if (this->containsText)
{
gtk_clipboard_request_contents(this->clipboard, atomUtf8,
(GtkClipboardReceivedFunc) pasteClipboardContents, this);
gtk_clipboard_request_text(this->clipboard,
(GtkClipboardTextReceivedFunc) pasteClipboardText, this);
return true;
}
else if (this->containsImage)
@ -124,25 +122,26 @@ public:
static void getFunction(GtkClipboard* clipboard, GtkSelectionData* selection,
guint info, ClipboardContents* contents)
{
GdkAtom target = gtk_selection_data_get_target(selection);
if (selection->target == gdk_atom_intern_static_string("UTF8_STRING"))
if (target == gdk_atom_intern_static_string("UTF8_STRING"))
{
gtk_selection_data_set_text(selection, contents->text.c_str(), -1);
}
else if (selection->target == gdk_atom_intern_static_string("image/png")
|| selection->target == gdk_atom_intern_static_string("image/jpeg")
|| selection->target == gdk_atom_intern_static_string("image/gif"))
else if (target == gdk_atom_intern_static_string("image/png") ||
target == gdk_atom_intern_static_string("image/jpeg") ||
target == gdk_atom_intern_static_string("image/gif"))
{
gtk_selection_data_set_pixbuf(selection, contents->image);
}
else if (atomSvg1 == selection->target || atomSvg2 == selection->target)
else if (atomSvg1 == target || atomSvg2 == target)
{
gtk_selection_data_set(selection, selection->target, 8, (guchar*) contents->svg.c_str(),
gtk_selection_data_set(selection, target, 8, (guchar*) contents->svg.c_str(),
contents->svg.length());
}
else if (atomXournal == selection->target)
else if (atomXournal == target)
{
gtk_selection_data_set(selection, selection->target, 8, (guchar*) contents->str->str, contents->str->len);
gtk_selection_data_set(selection, target, 8, (guchar*) contents->str->str, contents->str->len);
}
}
@ -339,23 +338,20 @@ void ClipboardHandler::pasteClipboardContents(GtkClipboard* clipboard, GtkSelect
{
XOJ_CHECK_TYPE_OBJ(handler, ClipboardHandler);
if (atomXournal == selectionData->target)
{
ObjectInputStream in;
ObjectInputStream in;
if (in.read((const char*) selectionData->data, selectionData->length))
{
handler->listener->clipboardPasteXournal(in);
}
if (in.read((const char*) selectionData->data, selectionData->length))
{
handler->listener->clipboardPasteXournal(in);
}
else
}
void ClipboardHandler::pasteClipboardText(GtkClipboard* clipboard, const gchar* text,
ClipboardHandler* handler)
{
if (text)
{
guchar* text = gtk_selection_data_get_text(selectionData);
if (text != NULL)
{
handler->listener->clipboardPasteText((const char*) text);
g_free(text);
}
handler->listener->clipboardPasteText(text);
}
}

@ -56,6 +56,10 @@ private:
ClipboardHandler* handler);
static void pasteClipboardImage(GtkClipboard* clipboard, GdkPixbuf* pixbuf, ClipboardHandler* handler);
static void pasteClipboardText(GtkClipboard* clipboard,
const gchar* text,
ClipboardHandler* handler);
private:
XOJ_TYPE_ATTRIB;

@ -37,8 +37,6 @@ public:
void scrollToPage(PageRef page, double top = 0);
void scrollToPage(size_t page, double top = 0);
void scrollToSpinPange();
void scrollToAnnotatedPage(bool next);
bool isPageVisible(size_t page, int* visibleHeight = NULL);
@ -46,6 +44,9 @@ public:
public:
virtual void pageChanged(size_t page);
private:
void scrollToSpinPange();
private:
XOJ_TYPE_ATTRIB;

@ -11,6 +11,8 @@ ZoomControl::ZoomControl()
this->zoom100Value = 1.0;
this->zoomFitValue = 1.0;
this->zoomFitMode = true;
this->zoom_center_x = -1;
this->zoom_center_y = -1;
}
ZoomControl::~ZoomControl()
@ -38,14 +40,14 @@ void ZoomControl::fireZoomChanged(double lastZoom)
{
XOJ_CHECK_TYPE(ZoomControl);
if (this->zoom < 0.3)
if (this->zoom < MIN_ZOOM)
{
this->zoom = 0.3;
this->zoom = MIN_ZOOM;
}
if (this->zoom > 5)
if (this->zoom > MAX_ZOOM)
{
this->zoom = 5;
this->zoom = MAX_ZOOM;
}
for (ZoomListener* z : this->listener)
@ -172,6 +174,10 @@ bool ZoomControl::onScrolledwindowMainScrollEvent(GtkWidget* widget, GdkEventScr
if (state & GDK_CONTROL_MASK)
{
//set zoom center (for shift centered scroll)
zoom->zoom_center_x = event->x;
zoom->zoom_center_y = event->y;
if (event->direction == GDK_SCROLL_UP || event->direction == GDK_SCROLL_LEFT)
{
zoom->zoomIn();

@ -16,6 +16,11 @@
#include <gtk/gtk.h>
#include <vector>
//Hardcode max and min zoom
//this should probably be user-adjustable in future
#define MAX_ZOOM 5
#define MIN_ZOOM 0.3
class ZoomListener
{
public:
@ -48,6 +53,11 @@ public:
void initZoomHandler(GtkWidget* widget);
// TODO: Naming and getter / setter!
// Current zoom center
gdouble zoom_center_x;
gdouble zoom_center_y;
protected:
void fireZoomChanged(double lastZoom);
void fireZoomRangeValueChanged();

Loading…
Cancel
Save