Skip to content

Commit c85aaec

Browse files
e7appewraveit65
authored andcommitted
Remove deprecated glib2.0 API calls
origin commit from: dropbox/nautilus-dropbox#62
1 parent 167bfab commit c85aaec

File tree

4 files changed

+15
-24
lines changed

4 files changed

+15
-24
lines changed

‎src/caja-dropbox.c‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -693,17 +693,12 @@ caja_dropbox_get_file_items(CajaMenuProvider *provider,
693693
CajaDropbox *cvs = CAJA_DROPBOX(provider);
694694
dropbox_command_client_request(&(cvs->dc.dcc), (DropboxCommand *) dgc);
695695

696-
GTimeVal gtv;
697-
698696
/*
699697
* 4. We have to block until it's done because caja expects a reply. But we will
700698
* only block for 50 ms for a reply.
701699
*/
702700

703-
g_get_current_time(&gtv);
704-
g_time_val_add(&gtv, 50000);
705-
706-
GHashTable *context_options_response = g_async_queue_timed_pop(reply_queue, &gtv);
701+
GHashTable *context_options_response = g_async_queue_timeout_pop(reply_queue, 50000);
707702
g_async_queue_unref(reply_queue);
708703

709704
if (!context_options_response) {
@@ -831,13 +826,13 @@ void get_emblem_paths_cb(GHashTable *emblem_paths_response, CajaDropbox *cvs)
831826
g_hash_table_ref(emblem_paths_response);
832827
}
833828

834-
g_mutex_lock(cvs->emblem_paths_mutex);
829+
g_mutex_lock(&(cvs->emblem_paths_mutex));
835830
if (cvs->emblem_paths) {
836831
g_idle_add((GSourceFunc) remove_emblem_paths, cvs->emblem_paths);
837832
cvs->emblem_paths = NULL;
838833
}
839834
cvs->emblem_paths = emblem_paths_response;
840-
g_mutex_unlock(cvs->emblem_paths_mutex);
835+
g_mutex_unlock(&(cvs->emblem_paths_mutex));
841836

842837
g_idle_add((GSourceFunc) add_emblem_paths, g_hash_table_ref(emblem_paths_response));
843838
g_idle_add((GSourceFunc) reset_all_files, cvs);
@@ -856,11 +851,11 @@ static void
856851
on_disconnect(CajaDropbox *cvs) {
857852
reset_all_files(cvs);
858853

859-
g_mutex_lock(cvs->emblem_paths_mutex);
854+
g_mutex_lock(&(cvs->emblem_paths_mutex));
860855
/* This call will free the data too. */
861856
g_idle_add((GSourceFunc) remove_emblem_paths, cvs->emblem_paths);
862857
cvs->emblem_paths = NULL;
863-
g_mutex_unlock(cvs->emblem_paths_mutex);
858+
g_mutex_unlock(&(cvs->emblem_paths_mutex));
864859
}
865860

866861

@@ -887,7 +882,7 @@ caja_dropbox_instance_init (CajaDropbox *cvs) {
887882
(GEqualFunc) g_direct_equal,
888883
(GDestroyNotify) NULL,
889884
(GDestroyNotify) g_free);
890-
cvs->emblem_paths_mutex = g_mutex_new();
885+
g_mutex_init(&(cvs->emblem_paths_mutex));
891886
cvs->emblem_paths = NULL;
892887

893888
/* setup the connection obj*/

‎src/caja-dropbox.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct _CajaDropbox {
4949
GObject parent_slot;
5050
GHashTable *filename2obj;
5151
GHashTable *obj2filename;
52-
GMutex *emblem_paths_mutex;
52+
GMutex emblem_paths_mutex;
5353
GHashTable *emblem_paths;
5454
DropboxClient dc;
5555
};

‎src/dropbox-command-client.c‎

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -645,9 +645,9 @@ dropbox_command_client_thread(DropboxCommandClient *dcc) {
645645
g_io_channel_set_line_term(chan, "\n", -1);
646646

647647
#define SET_CONNECTED_STATE(s) { \
648-
g_mutex_lock(dcc->command_connected_mutex); \
648+
g_mutex_lock(&(dcc->command_connected_mutex)); \
649649
dcc->command_connected = s; \
650-
g_mutex_unlock(dcc->command_connected_mutex); \
650+
g_mutex_unlock(&(dcc->command_connected_mutex)); \
651651
}
652652

653653
SET_CONNECTED_STATE(TRUE);
@@ -658,12 +658,9 @@ dropbox_command_client_thread(DropboxCommandClient *dcc) {
658658
DropboxCommand *dc;
659659

660660
while (1) {
661-
GTimeVal gtv;
662661

663-
g_get_current_time(&gtv);
664-
g_time_val_add(&gtv, G_USEC_PER_SEC / 10);
665662
/* get a request from caja */
666-
dc = g_async_queue_timed_pop(dcc->command_queue, &gtv);
663+
dc = g_async_queue_timeout_pop(dcc->command_queue, G_USEC_PER_SEC / 10);
667664
if (dc != NULL) {
668665
break;
669666
}
@@ -735,9 +732,9 @@ gboolean
735732
dropbox_command_client_is_connected(DropboxCommandClient *dcc) {
736733
gboolean command_connected;
737734

738-
g_mutex_lock(dcc->command_connected_mutex);
735+
g_mutex_lock(&(dcc->command_connected_mutex));
739736
command_connected = dcc->command_connected;
740-
g_mutex_unlock(dcc->command_connected_mutex);
737+
g_mutex_unlock(&(dcc->command_connected_mutex));
741738

742739
return command_connected;
743740
}
@@ -760,7 +757,7 @@ dropbox_command_client_request(DropboxCommandClient *dcc, DropboxCommand *dc) {
760757
void
761758
dropbox_command_client_setup(DropboxCommandClient *dcc) {
762759
dcc->command_queue = g_async_queue_new();
763-
dcc->command_connected_mutex = g_mutex_new();
760+
g_mutex_init(&(dcc->command_connected_mutex));
764761
dcc->command_connected = FALSE;
765762
dcc->ca_hooklist = NULL;
766763

@@ -814,8 +811,7 @@ void
814811
dropbox_command_client_start(DropboxCommandClient *dcc) {
815812
/* setup the connect to the command server */
816813
debug("starting command thread");
817-
g_thread_create((gpointer (*)(gpointer data)) dropbox_command_client_thread,
818-
dcc, FALSE, NULL);
814+
g_thread_new(NULL, (GThreadFunc) dropbox_command_client_thread, dcc);
819815
}
820816

821817
/* thread safe */

‎src/dropbox-command-client.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ typedef void (*DropboxCommandClientConnectionAttemptHook)(guint, gpointer);
6565
typedef GHookFunc DropboxCommandClientConnectHook;
6666

6767
typedef struct {
68-
GMutex *command_connected_mutex;
68+
GMutex command_connected_mutex;
6969
gboolean command_connected;
7070
GAsyncQueue *command_queue;
7171
GList *ca_hooklist;

0 commit comments

Comments
 (0)