void handle_delete(GFile* f) { _remove_monitor_directory(f); JSObjectRef json = json_create(); json_append_nobject(json, "entry", f, g_object_ref, g_object_unref); js_post_message("item_delete", json); }
PRIVATE gboolean update_workarea_size(GSettings* dock_gsettings) { int x, y, width, height; get_workarea_size(&x, &y, &width, &height); if (width == 0 || height == 0) { g_timeout_add(200, (GSourceFunc)update_workarea_size, dock_gsettings); return FALSE; } int hide_mode = g_settings_get_enum (dock_gsettings, DOCK_HIDE_MODE); g_debug ("hide mode: %d", hide_mode); if ((hide_mode==HIDE_MODE_AUTOHIDDEN)|| (hide_mode==HIDE_MODE_INTELLIGENT)) { //reserve the bottom (60 x width) area even dock is not show int root_height = gdk_screen_get_height (gdk_screen_get_default ()); if (y + height + 60 > root_height) height = root_height - 60 -y; } JSObjectRef workarea_info = json_create(); json_append_number(workarea_info, "x", x); json_append_number(workarea_info, "y", y); json_append_number(workarea_info, "width", width); json_append_number(workarea_info, "height", height); js_post_message("workarea_changed", workarea_info); return FALSE; }
DBUS_EXPORT_API void dock_bus_message_notify(gchar* appid, gchar* itemid) { JSObjectRef info = json_create(); json_append_string(info, "appid", appid); json_append_string(info, "itemid", itemid); js_post_message("message_notify", info); }
void trash_changed() { GFileInfo* info = g_file_query_info(_trash_can, G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT, G_FILE_QUERY_INFO_NONE, NULL, NULL); int count = g_file_info_get_attribute_uint32(info, G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT); g_object_unref(info); JSObjectRef value = json_create(); json_append_number(value, "value", count); js_post_message("trash_count_changed", value); }
void _update_notify_area_width() { if (_fcitx_tray) _na_width = _deepin_tray_width + _fcitx_tray_width + DEFAULT_INTERVAL; else _na_width = _deepin_tray_width - DEFAULT_INTERVAL + _fcitx_tray_width; g_hash_table_foreach(_icons, (GHFunc)accumulate_na_width, NULL); JSObjectRef width = json_create(); json_append_number(width, "width", _na_width + 2 * DEFAULT_INTERVAL); js_post_message("tray_icon_area_changed", width); }
void notify_primary_size() { struct DisplayInfo info; update_primary_info(&info); JSObjectRef size_info = json_create(); json_append_number(size_info, "x", info.x); json_append_number(size_info, "y", info.y); json_append_number(size_info, "width", info.width); json_append_number(size_info, "height", info.height); js_post_message("primary_size_changed", size_info); }
void update_install_progress(int v) { static int current_per = 0; if (v < current_per) { g_debug("[%s] INSTALL progress small previous PROGRESS: %d <= %d\n", __func__, v, current_per); return; } current_per= v; js_post_message("install_progress", jsvalue_from_number(get_global_context(), v)); }
//TODO: multiple copy, single cut. // or single copy, single cut. void fileops_paste (GFile* dest_dir) { if (copied_files_atom == GDK_NONE) copied_files_atom = gdk_atom_intern ("x-special/gnome-copied-files", FALSE); //TODO: we may not own the clipboard now //cut : move files //use clipboard_info or clipboard_info_tmp FileOpsClipboardInfo* real_info = NULL; //cleanup tmp clipboard info g_debug ("free tmp clipboard info"); __clear_clipboard_info (&clipboard_info_tmp); if (__request_clipboard_contents (&clipboard_info_tmp)) real_info = &clipboard_info_tmp; if (real_info == NULL || real_info->num == 0) return; if (real_info->cut) { fileops_move (real_info->file_list, real_info->num, dest_dir, true); //post messages event paste cancelled or failed. JSObjectRef json = json_array_create(); for (int i = 0; i < real_info->num; i++) { json_array_insert_nobject (json, i, real_info->file_list[i], g_object_ref, g_object_unref); g_debug ("send file: %d : %s", i, g_file_get_uri (real_info->file_list[i])); } js_post_message ("cut_completed", json); gtk_clipboard_clear (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD)); g_debug ("free tmp clipboard info"); __clear_clipboard_info (&clipboard_info_tmp); //though maybe we're not the clipboard owner, we still //free clipboard_info here to avoid possible memory leak g_debug ("free clipboard info"); __clear_clipboard_info (&clipboard_info); } else { //copy can be done multiple times. so we should not free real_info; fileops_copy (real_info->file_list, real_info->num, dest_dir); } }
void handle_update(GFile* f) { // g_message("handle_update"); if (g_file_query_file_type(f, G_FILE_QUERY_INFO_NONE ,NULL) != G_FILE_TYPE_UNKNOWN) { char* path = g_file_get_path(f); Entry* entry = dentry_create_by_path(path); g_free(path); JSObjectRef json = json_create(); json_append_nobject(json, "entry", entry, g_object_ref, g_object_unref); js_post_message("item_update", json); desktop_item_update(); g_object_unref(entry); } }
void handle_rename(GFile* old_f, GFile* new_f) { _add_monitor_directory(new_f); _remove_monitor_directory(old_f); char* path = g_file_get_path(new_f); Entry* entry = dentry_create_by_path(path); g_free(path); JSObjectRef json = json_create(); json_append_nobject(json, "old", old_f, g_object_ref, g_object_unref); json_append_nobject(json, "new", entry, g_object_ref, g_object_unref); js_post_message("item_rename", json); g_object_unref(entry); }
static gboolean not_recognize_handler(gpointer data) { g_debug("[%s] not recognized", __func__); g_debug("[%s] send auth-failed signal", __func__); JSObjectRef json = json_create(); recognition_info.DELAY_TIME = 4.0; char* msg = g_strdup_printf(_("%sRetry automatically in %ds"), ERR_POST_PREFIX, (int)recognition_info.DELAY_TIME); json_append_string(json, "error", msg); g_free(msg); js_post_message("auth-failed", json); g_timer_start(recognition_info.timer); recognition_info.reco_state = NOT_START_RECOGNIZING; return G_SOURCE_REMOVE; }
/* * clear clipboard_info_prev, * keep clipboard_info */ static void _clear_clipboard_callback (GtkClipboard *clipboard, gpointer user_data) { g_debug ("_clear_clipboard_callback: begin"); GList* file_list = NULL; g_debug ("prev: num = %d; operation = %s", clipboard_info_prev.num, clipboard_info_prev.cut?"cut":"copy"); if (clipboard_info_prev.cut == FALSE) { if (clipboard_info.cut == TRUE) { for (int i = 0; i < clipboard_info.num; i++) { file_list = g_list_append (file_list, g_object_ref (clipboard_info.file_list[i])); } } } //clipboard_info_prev.cut == TRUE) else if (clipboard_info_prev.num != 0) { file_list = __set_diff_clipboard_info (&clipboard_info, &clipboard_info_prev); } // send message. int i = 0; GList* l = NULL; JSObjectRef json = json_array_create(); for (l = file_list; l != NULL; l = l->next) { json_array_insert_nobject (json, i, l->data, g_object_ref, g_object_unref); g_debug ("send file: %d : %s", i, g_file_get_uri (l->data)); i++; } js_post_message ("cut_completed", json); // g_list_free_full (file_list, g_object_unref); __clear_clipboard_info (&clipboard_info_prev); g_debug ("_clear_clipboard_callback: end"); }
void reco() { // RESOURCE_DIR defined in CMakeLists.txt char* args[] = {"/usr/bin/python", RESOURCE_DIR"/greeter/scripts/reco", recognition_info.current_username, NULL}; GError* err = NULL; char* is_same_person = NULL; g_spawn_sync(NULL, args, NULL, 0, NULL, NULL, &is_same_person, NULL, NULL, &err); if (err != NULL) { g_warning("[%s] %s", __func__, err->message); g_error_free(err); } g_debug("[%s] #%s#", __func__, is_same_person); if (g_strcmp0(is_same_person, "True") == 0) { recognition_info.reco_state = RECOGNIZED; g_free(is_same_person); } else { g_debug("[%s] not recognized", __func__); recognition_info.reco_times += 1; if (recognition_info.reco_times == MAX_RECO_TIME) { g_debug("[%s] reach the max recognition time", __func__); JSObjectRef json = json_create(); char* msg = g_strdup_printf("%s%s", ERR_POST_PREFIX, _("Please login with your password or click your picture to retry.")); json_append_string(json, "error", msg); g_free(msg); js_post_message("failed-too-much", json); recognition_info.detect_is_enabled = FALSE; recognition_info.reco_state = RECOGNIZE_FINISH; g_free(is_same_person); return; } recognition_info.reco_state = NOT_RECOGNIZED; } }
void installer_terminate() { g_message("[%s]\n", __func__); js_post_message("install_terminate", NULL); }
JS_EXPORT_API gboolean lock_try_unlock (const gchar *username,const gchar *password) { if (lock_is_guest()) { js_post_signal("auth-succeed"); gtk_main_quit(); return TRUE; } gboolean succeed = FALSE; GDBusProxy *lock_proxy = NULL; GVariant *lock_succeed = NULL; GError *error = NULL; lock_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, NULL, "com.deepin.dde.lock", "/com/deepin/dde/lock", "com.deepin.dde.lock", NULL, &error); if (error != NULL) { g_warning ("connect com.deepin.dde.lock failed"); g_error_free (error); } error = NULL; lock_succeed = g_dbus_proxy_call_sync (lock_proxy, "UnlockCheck", g_variant_new ("(ss)", username, password), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); //g_assert (lock_succeed != NULL); if (error != NULL) { g_warning ("try unlock:UnlockCheck %s\n", error->message); g_error_free (error); } error = NULL; g_variant_get (lock_succeed, "(b)", &succeed); g_variant_unref (lock_succeed); g_object_unref (lock_proxy); if (succeed) { js_post_signal("auth-succeed"); } else { JSObjectRef error_message = json_create(); json_append_string(error_message, "error", _("Wrong Password")); js_post_message("auth-failed", error_message); } return succeed; }