~ubuntu-branches/ubuntu/wily/gpaste/wily

« back to all changes in this revision

Viewing changes to src/libgpaste/keybinder/gpaste-upload-keybinding.c

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2015-06-19 11:05:16 UTC
  • mfrom: (6.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20150619110516-h53wz9xi9i4k3smb
Tags: 3.16.2.1-1
* Imported Upstream version 3.16.2.1 (Closes: #789255)
* gpaste-applet does not need a manpage - upstream dropped it
* Build-Depends gtk >= 3.16
* Depends gnome-shell >= 3.16
* Major API changes, bump soname to 3 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *      This file is part of GPaste.
 
3
 *
 
4
 *      Copyright 2015 Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
 
5
 *
 
6
 *      GPaste is free software: you can redistribute it and/or modify
 
7
 *      it under the terms of the GNU General Public License as published by
 
8
 *      the Free Software Foundation, either version 3 of the License, or
 
9
 *      (at your option) any later version.
 
10
 *
 
11
 *      GPaste is distributed in the hope that it will be useful,
 
12
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *      GNU General Public License for more details.
 
15
 *
 
16
 *      You should have received a copy of the GNU General Public License
 
17
 *      along with GPaste.  If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
#include "gpaste-keybinding-private.h"
 
21
 
 
22
#include <gpaste-gsettings-keys.h>
 
23
#include <gpaste-upload-keybinding.h>
 
24
 
 
25
struct _GPasteUploadKeybinding
 
26
{
 
27
    GPasteKeybinding parent_instance;
 
28
};
 
29
 
 
30
typedef struct
 
31
{
 
32
    GPasteDaemon *daemon;
 
33
} GPasteUploadKeybindingPrivate;
 
34
 
 
35
G_DEFINE_TYPE_WITH_PRIVATE (GPasteUploadKeybinding, g_paste_upload_keybinding, G_PASTE_TYPE_KEYBINDING)
 
36
 
 
37
static void
 
38
g_paste_upload_keybinding_dispose (GObject *object)
 
39
{
 
40
    GPasteUploadKeybindingPrivate *priv = g_paste_upload_keybinding_get_instance_private (G_PASTE_UPLOAD_KEYBINDING (object));
 
41
 
 
42
    g_clear_object (&priv->daemon);
 
43
 
 
44
    G_OBJECT_CLASS (g_paste_upload_keybinding_parent_class)->dispose (object);
 
45
}
 
46
 
 
47
static void
 
48
g_paste_upload_keybinding_class_init (GPasteUploadKeybindingClass *klass)
 
49
{
 
50
    G_OBJECT_CLASS (klass)->dispose = g_paste_upload_keybinding_dispose;
 
51
}
 
52
 
 
53
static void
 
54
g_paste_upload_keybinding_init (GPasteUploadKeybinding *self G_GNUC_UNUSED)
 
55
{
 
56
}
 
57
 
 
58
static void
 
59
upload (GPasteKeybinding *self,
 
60
        gpointer          data G_GNUC_UNUSED)
 
61
{
 
62
    GPasteUploadKeybindingPrivate *priv = g_paste_upload_keybinding_get_instance_private (G_PASTE_UPLOAD_KEYBINDING (self));
 
63
 
 
64
    g_paste_daemon_upload (priv->daemon, 0);
 
65
}
 
66
 
 
67
/**
 
68
 * g_paste_upload_keybinding_new:
 
69
 * @daemon: a #GPasteDaemon instance
 
70
 *
 
71
 * Create a new instance of #GPasteUploadKeybinding
 
72
 *
 
73
 * Returns: a newly allocated #GPasteUploadKeybinding
 
74
 *          free it with g_object_unref
 
75
 */
 
76
G_PASTE_VISIBLE GPasteKeybinding *
 
77
g_paste_upload_keybinding_new (GPasteDaemon *daemon)
 
78
{
 
79
    g_return_val_if_fail (G_PASTE_IS_DAEMON (daemon), NULL);
 
80
 
 
81
    GPasteKeybinding *self = _g_paste_keybinding_new (G_PASTE_TYPE_UPLOAD_KEYBINDING,
 
82
                                                      G_PASTE_UPLOAD_SETTING,
 
83
                                                      g_paste_settings_get_upload,
 
84
                                                      upload,
 
85
                                                      NULL);
 
86
    GPasteUploadKeybindingPrivate *priv = g_paste_upload_keybinding_get_instance_private (G_PASTE_UPLOAD_KEYBINDING (self));
 
87
 
 
88
    priv->daemon = g_object_ref (daemon);
 
89
 
 
90
    return self;
 
91
}