Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
GNOME
gnome-builder
Commits
082edc06
Commit
082edc06
authored
Mar 10, 2017
by
Christian Hergert
Browse files
transfers: use EggProgressButton as IdeTransferButton base
parent
696cb23f
Changes
2
Hide whitespace changes
Inline
Side-by-side
libide/transfers/ide-transfer-button.c
View file @
082edc06
...
...
@@ -38,10 +38,37 @@ enum {
N_PROPS
};
G_DEFINE_TYPE_WITH_PRIVATE
(
IdeTransferButton
,
ide_transfer_button
,
GTK
_TYPE_BUTTON
)
G_DEFINE_TYPE_WITH_PRIVATE
(
IdeTransferButton
,
ide_transfer_button
,
EGG
_TYPE_
PROGRESS_
BUTTON
)
static
GParamSpec
*
properties
[
N_PROPS
];
static
void
notify_progress_cb
(
IdeTransferButton
*
self
,
GParamSpec
*
pspec
,
IdeTransfer
*
transfer
)
{
gdouble
progress
;
g_assert
(
IDE_IS_TRANSFER_BUTTON
(
self
));
g_assert
(
pspec
!=
NULL
);
g_assert
(
IDE_IS_TRANSFER
(
transfer
));
progress
=
ide_transfer_get_progress
(
transfer
);
egg_progress_button_set_progress
(
EGG_PROGRESS_BUTTON
(
self
),
progress
*
100
.
0
);
}
static
void
notify_active_cb
(
IdeTransferButton
*
self
,
GParamSpec
*
pspec
,
IdeTransfer
*
transfer
)
{
g_assert
(
IDE_IS_TRANSFER_BUTTON
(
self
));
g_assert
(
IDE_IS_TRANSFER
(
transfer
));
gtk_widget_set_sensitive
(
GTK_WIDGET
(
self
),
!
ide_transfer_get_active
(
transfer
));
}
static
void
ide_transfer_button_set_transfer
(
IdeTransferButton
*
self
,
IdeTransfer
*
transfer
)
...
...
@@ -53,8 +80,35 @@ ide_transfer_button_set_transfer (IdeTransferButton *self,
g_assert
(
IDE_IS_TRANSFER_BUTTON
(
self
));
g_assert
(
!
transfer
||
IDE_IS_TRANSFER
(
transfer
));
if
(
g_set_object
(
&
priv
->
transfer
,
transfer
))
gtk_widget_set_sensitive
(
GTK_WIDGET
(
self
),
transfer
!=
NULL
);
if
(
transfer
!=
priv
->
transfer
)
{
if
(
priv
->
transfer
!=
NULL
)
{
g_signal_handlers_disconnect_by_func
(
priv
->
transfer
,
notify_progress_cb
,
self
);
g_signal_handlers_disconnect_by_func
(
priv
->
transfer
,
notify_active_cb
,
self
);
g_clear_object
(
&
priv
->
transfer
);
gtk_widget_hide
(
GTK_WIDGET
(
self
));
}
if
(
transfer
!=
NULL
)
{
priv
->
transfer
=
g_object_ref
(
transfer
);
g_signal_connect_object
(
priv
->
transfer
,
"notify::active"
,
G_CALLBACK
(
notify_active_cb
),
self
,
G_CONNECT_SWAPPED
);
g_signal_connect_object
(
priv
->
transfer
,
"notify::progress"
,
G_CALLBACK
(
notify_progress_cb
),
self
,
G_CONNECT_SWAPPED
);
notify_active_cb
(
self
,
NULL
,
priv
->
transfer
);
gtk_widget_show
(
GTK_WIDGET
(
self
));
}
g_object_notify_by_pspec
(
G_OBJECT
(
self
),
properties
[
PROP_TRANSFER
]);
}
IDE_EXIT
;
}
...
...
@@ -76,6 +130,7 @@ ide_transfer_button_execute_cb (GObject *object,
ide_transfer_manager_execute_finish
(
transfer_manager
,
result
,
NULL
);
gtk_widget_set_sensitive
(
GTK_WIDGET
(
self
),
TRUE
);
egg_progress_button_set_show_progress
(
EGG_PROGRESS_BUTTON
(
self
),
FALSE
);
IDE_EXIT
;
}
...
...
@@ -100,6 +155,7 @@ ide_transfer_button_clicked (GtkButton *button)
if
(
context
==
NULL
)
return
;
egg_progress_button_set_show_progress
(
EGG_PROGRESS_BUTTON
(
self
),
TRUE
);
gtk_widget_set_sensitive
(
GTK_WIDGET
(
self
),
FALSE
);
transfer_manager
=
ide_context_get_transfer_manager
(
context
);
...
...
@@ -186,7 +242,7 @@ ide_transfer_button_class_init (IdeTransferButtonClass *klass)
"Transfer"
,
IDE_TYPE_TRANSFER
,
(
G_PARAM_READWRITE
|
G_PARAM_CONSTRUCT_ONLY
|
G_PARAM_STATIC_STRINGS
));
g_object_class_install_properties
(
object_class
,
N_PROPS
,
properties
);
}
...
...
libide/transfers/ide-transfer-button.h
View file @
082edc06
...
...
@@ -21,17 +21,19 @@
#include
<gtk/gtk.h>
#include
"egg-progress-button.h"
#include
"transfers/ide-transfer.h"
G_BEGIN_DECLS
#define IDE_TYPE_TRANSFER_BUTTON (ide_transfer_button_get_type())
G_DECLARE_DERIVABLE_TYPE
(
IdeTransferButton
,
ide_transfer_button
,
IDE
,
TRANSFER_BUTTON
,
Gtk
Button
)
G_DECLARE_DERIVABLE_TYPE
(
IdeTransferButton
,
ide_transfer_button
,
IDE
,
TRANSFER_BUTTON
,
EggProgress
Button
)
struct
_IdeTransferButtonClass
{
Gtk
ButtonClass
parent_class
;
EggProgress
ButtonClass
parent_class
;
gpointer
_reserved1
;
gpointer
_reserved2
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment