Skip to content

Commit

Permalink
Merge pull request #352 from paolostivanin/dev
Browse files Browse the repository at this point in the history
Release 3.5.1
  • Loading branch information
paolostivanin authored Mar 5, 2024
2 parents 691f105 + dd32860 commit dc157db
Show file tree
Hide file tree
Showing 10 changed files with 698 additions and 757 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
version: 2.0

jobs:
ubuntu2304:
ubuntu2404:
docker:
- image: ubuntu:23.04
- image: ubuntu:24.04
steps:
- checkout
- run: apt update && DEBIAN_FRONTEND=noninteractive apt -y install git gcc clang cmake libgcrypt20-dev libgtk-3-dev libzip-dev libjansson-dev libpng-dev libzbar-dev libprotobuf-c-dev libsecret-1-dev uuid-dev libprotobuf-dev libqrencode-dev
Expand Down Expand Up @@ -50,7 +50,7 @@ workflows:
version: 2
build:
jobs:
- ubuntu2304
- ubuntu2404
- ubuntuLatestRolling
- debianLatestStable
- fedoraLatestStable
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.16)
project(OTPClient VERSION "3.5.0" LANGUAGES "C")
project(OTPClient VERSION "3.5.1" LANGUAGES "C")
include(GNUInstallDirs)

configure_file("src/common/version.h.in" "version.h")
Expand Down Expand Up @@ -264,6 +264,8 @@ install(FILES data/com.github.paolostivanin.OTPClient.desktop DESTINATION share/
install(FILES data/com.github.paolostivanin.OTPClient.appdata.xml DESTINATION share/metainfo)

install(FILES src/ui/otpclient.ui DESTINATION share/otpclient)
install(FILES src/ui/add_popover.ui DESTINATION share/otpclient)
install(FILES src/ui/settings_popover.ui DESTINATION share/otpclient)
install(FILES src/ui/shortcuts.ui DESTINATION share/otpclient)

install(FILES man/otpclient.1.gz DESTINATION share/man/man1)
Expand Down
12 changes: 11 additions & 1 deletion data/com.github.paolostivanin.OTPClient.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,17 @@
</content_rating>

<releases>
<release version="3.5.0" date="2024-03-01x">
<release version="3.5.0" date="2024-03-05">
<description>
<p>OTPClient 3.5.1 brings a small improvement and some code clean-up:</p>
<ul>
<li>NEW: add back buttons to the various popover menus</li>
<li>FIX: split popovers into their own UI files</li>
<li>FIX: remove upgrade message when upgrading from a version older than 2.6.0</li>
</ul>
</description>
</release>
<release version="3.5.0" date="2024-03-01">
<description>
<p>OTPClient 3.5.0 brings some new features and improvements:</p>
<ul>
Expand Down
File renamed without changes.
111 changes: 13 additions & 98 deletions src/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,6 @@ static void create_main_window (gint width,
gint height,
AppData *app_data);

static gboolean show_upgrade_msg (void);

static void set_info_bar (AppData *app_data,
const gchar *msg);

static void on_bar_response (GtkInfoBar *ib,
gint response_id,
gpointer user_data);

static gboolean set_action_group (GtkBuilder *builder,
AppData *app_data);

static void get_window_size_cb (GtkWidget *window,
GtkAllocation *allocation,
gpointer user_data);
Expand Down Expand Up @@ -116,6 +104,8 @@ activate (GtkApplication *app,
// open_db_file_action is set only on first startup and not when the db is deleted but the cfg file is there, therefore we need a default action
app_data->open_db_file_action = GTK_FILE_CHOOSER_ACTION_SAVE;
app_data->builder = get_builder_from_partial_path (UI_PARTIAL_PATH);
app_data->add_popover_builder = get_builder_from_partial_path (AP_PARTIAL_PATH);
app_data->settings_popover_builder = get_builder_from_partial_path (SP_PARTIAL_PATH);

set_config_data (&width, &height, app_data);

Expand Down Expand Up @@ -285,13 +275,6 @@ activate (GtkApplication *app,
app_data->source_id_last_activity = g_timeout_add_seconds (1, check_inactivity, app_data);

gtk_widget_show_all (app_data->main_window);

app_data->info_bar = GTK_WIDGET(gtk_builder_get_object (app_data->builder, "info_bar_id"));
if (show_upgrade_msg ()) {
set_info_bar (app_data, _("Not asking for password? Please check the 'Secret Service Integration' new feature <a href=\"https://github.com/paolostivanin/OTPClient/wiki/How-to-use-OTPClient#secret-service-integration\">HERE</a>"));
} else {
gtk_widget_hide (app_data->info_bar);
}
}


Expand Down Expand Up @@ -444,9 +427,9 @@ set_warn_data (gboolean show_warning)


static void
create_main_window (gint width,
gint height,
AppData *app_data)
create_main_window (gint width,
gint height,
AppData *app_data)
{
app_data->main_window = GTK_WIDGET(gtk_builder_get_object (app_data->builder, "appwindow_id"));
gtk_window_set_icon_name (GTK_WINDOW(app_data->main_window), "otpclient");
Expand All @@ -460,76 +443,6 @@ create_main_window (gint width,
gtk_widget_set_sensitive (lock_btn, FALSE);
}

set_action_group (app_data->builder, app_data);
}


static gboolean
show_upgrade_msg (void)
{
gboolean show_msg = TRUE;
GKeyFile *kf = get_kf_ptr ();
if (kf != NULL) {
gchar *up_msg = g_key_file_get_string (kf, "config", "upgrade_msg", NULL);
if (up_msg == NULL) {
show_msg = TRUE;
} else {
show_msg = (g_strcmp0 (up_msg, "v2_6") == 0) ? FALSE : TRUE;
}
}

g_key_file_free (kf);

return show_msg;
}


static void
set_info_bar (AppData *app_data,
const gchar *msg)
{
GtkWidget *label = GTK_WIDGET(gtk_builder_get_object (app_data->builder, "info_bar_label_id"));

g_signal_connect (app_data->info_bar, "response", G_CALLBACK(on_bar_response), NULL);

gtk_label_set_markup (GTK_LABEL(label), msg);
gtk_info_bar_set_message_type (GTK_INFO_BAR(app_data->info_bar), GTK_MESSAGE_INFO);
gtk_widget_show (app_data->info_bar);
}


static void
on_bar_response (GtkInfoBar *ib,
gint response_id __attribute__((unused)),
gpointer user_data __attribute__((unused)))
{
GError *err = NULL;
GKeyFile *kf = get_kf_ptr ();
if (kf != NULL) {
g_key_file_set_string (kf, "config", "upgrade_msg", "v2_6");
gchar *cfg_file_path;
#ifndef USE_FLATPAK_APP_FOLDER
cfg_file_path = g_build_filename (g_get_user_config_dir (), "otpclient.cfg", NULL);
#else
cfg_file_path = g_build_filename (g_get_user_data_dir (), "otpclient.cfg", NULL);
#endif
if (!g_key_file_save_to_file (kf, cfg_file_path, &err)) {
g_printerr ("%s\n", err->message);
g_clear_error (&err);
}
g_free (cfg_file_path);
}

g_key_file_free (kf);

gtk_widget_hide (GTK_WIDGET(ib));
}


static gboolean
set_action_group (GtkBuilder *builder,
AppData *app_data)
{
static GActionEntry settings_menu_entries[] = {
{ .name = ANDOTP_IMPORT_ACTION_NAME, .activate = select_file_cb },
{ .name = ANDOTP_IMPORT_PLAIN_ACTION_NAME, .activate = select_file_cb },
Expand Down Expand Up @@ -569,20 +482,20 @@ set_action_group (GtkBuilder *builder,
{ .name = "manual", .activate = manual_add_cb }
};

GtkWidget *settings_popover = GTK_WIDGET (gtk_builder_get_object (builder, "settings_pop_id"));
GtkWidget *settings_popover = GTK_WIDGET(gtk_builder_get_object (app_data->settings_popover_builder, "settings_pop_id"));
gtk_menu_button_set_popover (GTK_MENU_BUTTON(gtk_builder_get_object (app_data->builder, "settings_btn_id")), settings_popover);
GActionGroup *settings_actions = (GActionGroup *)g_simple_action_group_new ();
g_action_map_add_action_entries (G_ACTION_MAP (settings_actions), settings_menu_entries, G_N_ELEMENTS (settings_menu_entries), app_data);
g_action_map_add_action_entries (G_ACTION_MAP(settings_actions), settings_menu_entries, G_N_ELEMENTS (settings_menu_entries), app_data);
gtk_widget_insert_action_group (settings_popover, "settings_menu", settings_actions);

GtkWidget *add_popover = GTK_WIDGET (gtk_builder_get_object (builder, "add_pop_id"));
GtkWidget *add_popover = GTK_WIDGET(gtk_builder_get_object (app_data->add_popover_builder, "add_pop_id"));
gtk_menu_button_set_popover (GTK_MENU_BUTTON(gtk_builder_get_object (app_data->builder, "add_btn_main_id")), add_popover);
GActionGroup *add_actions = (GActionGroup *)g_simple_action_group_new ();
g_action_map_add_action_entries (G_ACTION_MAP (add_actions), add_menu_entries, G_N_ELEMENTS (add_menu_entries), app_data);
g_action_map_add_action_entries (G_ACTION_MAP(add_actions), add_menu_entries, G_N_ELEMENTS (add_menu_entries), app_data);
gtk_widget_insert_action_group (add_popover, "add_menu", add_actions);

gtk_popover_set_constrain_to (GTK_POPOVER(add_popover), GTK_POPOVER_CONSTRAINT_NONE);
gtk_popover_set_constrain_to (GTK_POPOVER(settings_popover), GTK_POPOVER_CONSTRAINT_NONE);

return TRUE;
}


Expand Down Expand Up @@ -765,6 +678,8 @@ destroy_cb (GtkWidget *window,
#pragma GCC diagnostic pop
save_window_size (w, h);
g_object_unref (app_data->builder);
g_object_unref (app_data->add_popover_builder);
g_object_unref (app_data->settings_popover_builder);
g_free (app_data);
gcry_control (GCRYCTL_TERM_SECMEM);
}
Expand Down
2 changes: 2 additions & 0 deletions src/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ typedef struct db_data_t {

typedef struct app_data_t {
GtkBuilder *builder;
GtkBuilder *add_popover_builder;
GtkBuilder *settings_popover_builder;

GtkWidget *main_window;
GtkWidget *info_bar;
Expand Down
2 changes: 2 additions & 0 deletions src/get-builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
G_BEGIN_DECLS

#define UI_PARTIAL_PATH "share/otpclient/otpclient.ui"
#define AP_PARTIAL_PATH "share/otpclient/add_popover.ui"
#define SP_PARTIAL_PATH "share/otpclient/settings_popover.ui"

GtkBuilder *get_builder_from_partial_path (const gchar *partial_path);

Expand Down
116 changes: 116 additions & 0 deletions src/ui/add_popover.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.40.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkPopoverMenu" id="add_pop_id">
<property name="can-focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkModelButton" id="add_qr_back_btn_id">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="inverted">True</property>
<property name="centered">True</property>
<property name="menu-name">main</property>
<property name="text" translatable="yes">Back</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkModelButton" id="add_qr_file_btn_id">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="action-name">add_menu.import_qr_file</property>
<property name="text" translatable="yes">From file</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkModelButton" id="add_qr_clipboard_btn_id">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="action-name">add_menu.import_qr_clipboard</property>
<property name="text" translatable="yes">From clipboard</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="submenu">import_qr_menu</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkModelButton" id="webcam_model_btn_id">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="action-name">add_menu.webcam</property>
<property name="text" translatable="yes">Scan using webcam</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkModelButton" id="import_qr_model_btn_id">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="text" translatable="yes">Using a QR Code</property>
<property name="menu-name">import_qr_menu</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkModelButton" id="manual_model_btn_id">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="action-name">add_menu.manual</property>
<property name="text" translatable="yes">Manually</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="submenu">main</property>
<property name="position">2</property>
</packing>
</child>
</object>
</interface>
Loading

0 comments on commit dc157db

Please sign in to comment.