messenger-gtk

Gtk+3 graphical user interfaces for GNUnet Messenger
Log | Files | Refs | Submodules | README | LICENSE

file_entry.c (2071B)


      1 /*
      2    This file is part of GNUnet.
      3    Copyright (C) 2024 GNUnet e.V.
      4 
      5    GNUnet is free software: you can redistribute it and/or modify it
      6    under the terms of the GNU Affero General Public License as published
      7    by the Free Software Foundation, either version 3 of the License,
      8    or (at your option) any later version.
      9 
     10    GNUnet is distributed in the hope that it will be useful, but
     11    WITHOUT ANY WARRANTY; without even the implied warranty of
     12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13    Affero General Public License for more details.
     14 
     15    You should have received a copy of the GNU Affero General Public License
     16    along with this program.  If not, see <http://www.gnu.org/licenses/>.
     17 
     18    SPDX-License-Identifier: AGPL3.0-or-later
     19  */
     20 /*
     21  * @author Tobias Frisch
     22  * @file ui/file_entry.c
     23  */
     24 
     25 #include "file_entry.h"
     26 
     27 #include "../application.h"
     28 #include "../ui.h"
     29 #include <gnunet/gnunet_chat_lib.h>
     30 #include <stdint.h>
     31 
     32 UI_FILE_ENTRY_Handle*
     33 ui_file_entry_new(MESSENGER_Application *app)
     34 {
     35   g_assert(app);
     36 
     37   UI_FILE_ENTRY_Handle* handle = g_malloc(sizeof(UI_FILE_ENTRY_Handle));
     38 
     39   handle->builder = ui_builder_from_resource(
     40     application_get_resource_path(app, "ui/file_entry.ui")
     41   );
     42 
     43   handle->entry_box = GTK_WIDGET(
     44     gtk_builder_get_object(handle->builder, "entry_box")
     45   );
     46 
     47   handle->file_image = GTK_IMAGE(
     48     gtk_builder_get_object(handle->builder, "file_image")
     49   );
     50 
     51   handle->name_label = GTK_LABEL(
     52     gtk_builder_get_object(handle->builder, "name_label")
     53   );
     54 
     55   handle->size_label = GTK_LABEL(
     56     gtk_builder_get_object(handle->builder, "size_label")
     57   );
     58 
     59   return handle;
     60 }
     61 
     62 void
     63 ui_file_entry_update(UI_FILE_ENTRY_Handle *handle,
     64                      struct GNUNET_CHAT_File *file)
     65 {
     66   g_assert((handle) && (file));
     67 
     68   ui_label_set_text(handle->name_label, GNUNET_CHAT_file_get_name(file));
     69   ui_label_set_size(handle->size_label, GNUNET_CHAT_file_get_size(file));
     70 }
     71 
     72 void
     73 ui_file_entry_delete(UI_FILE_ENTRY_Handle *handle)
     74 {
     75   g_assert(handle);
     76 
     77   g_object_unref(handle->builder);
     78 
     79   g_free(handle);
     80 }