Enhancement: Fixes #303, Explorer - switch to Internet Explorer mode for HTTP(S) addresses

This commit is contained in:
Rory Fewell
2024-06-15 18:49:09 +01:00
parent bbe17d1818
commit c0c0f195be
39 changed files with 1127 additions and 136 deletions

View File

@@ -32,6 +32,8 @@ configure_file(src/version.c.in ${PROJECT_ROOT}/src/version.c @ONLY)
add_library(
libwintc-comgtk
src/application.c
public/application.h
public/assets.h
public/debug.h
src/container.c
@@ -46,6 +48,8 @@ add_library(
public/list.h
src/marshal.c
public/marshal.h
src/memory.c
public/memory.h
src/msgbox.c
public/msgbox.h
src/profile.c

View File

@@ -0,0 +1,15 @@
#ifndef __COMGTK_APPLICATION_H__
#define __COMGTK_APPLICATION_H__
#include <gio/gio.h>
#include <glib.h>
//
// PUBLIC FUNCTIONS
//
GFile** wintc_application_command_line_get_files(
GApplicationCommandLine* command_line,
guint* n_files
);
#endif

View File

@@ -1,6 +1,7 @@
#ifndef __WINTC_COMGTK_H__
#define __WINTC_COMGTK_H__
#include "@LIB_HEADER_DIR@/application.h"
#include "@LIB_HEADER_DIR@/assets.h"
#include "@LIB_HEADER_DIR@/container.h"
#include "@LIB_HEADER_DIR@/debug.h"
@@ -9,6 +10,7 @@
#include "@LIB_HEADER_DIR@/icons.h"
#include "@LIB_HEADER_DIR@/list.h"
#include "@LIB_HEADER_DIR@/marshal.h"
#include "@LIB_HEADER_DIR@/memory.h"
#include "@LIB_HEADER_DIR@/msgbox.h"
#include "@LIB_HEADER_DIR@/profile.h"
#include "@LIB_HEADER_DIR@/regex.h"

View File

@@ -0,0 +1,20 @@
#ifndef __COMGTK_MEMORY_H__
#define __COMGTK_MEMORY_H__
#include <glib.h>
//
// PUBLIC FUNCTIONS
//
void wintc_freev(
gpointer mem,
GDestroyNotify destroy
);
void wintc_freenv(
gpointer mem,
guint n_elements,
GDestroyNotify destroy
);
#endif

View File

@@ -33,6 +33,18 @@ gchar* wintc_str_set_suffix(
const gchar* suffix
);
/**
* Duplicates a string and replaces the string at the destination with it - if
* there was a string at the destination pointer, it will be freed.
*
* @param dest Reference to the destination pointer.
* @param src Reference to the source pointer.
*/
void wintc_strdup_replace(
gchar** dest,
const gchar* src
);
/**
* Counts the number of time a string appears within another string.
*
@@ -71,4 +83,15 @@ gchar* wintc_strsubst(
const gchar* replacewith
);
/**
* Constant version of g_strv_length - returns the length of an array of
* strings. str_array must not be NULL.
*
* @param str_array A null-terminated array of gchar*.
* @return Length of str_array.
*/
guint wintc_strv_length(
const gchar** str_array
);
#endif

View File

@@ -0,0 +1,47 @@
#include <gio/gio.h>
#include <glib.h>
#include "../public/application.h"
#include "../public/strings.h"
//
// PUBLIC FUNCTIONS
//
GFile** wintc_application_command_line_get_files(
GApplicationCommandLine* command_line,
guint* n_files
)
{
const gchar** filenames = NULL;
GFile** files = NULL;
g_variant_dict_lookup(
g_application_command_line_get_options_dict(command_line),
G_OPTION_REMAINING,
"^a&ay",
&filenames
);
if (
filenames != NULL &&
(*n_files = wintc_strv_length(filenames)) > 0
)
{
// Prepare the files
//
files = g_new(GFile*, *n_files);
for (guint i = 0; i < *n_files; i++)
{
files[i] =
g_application_command_line_create_file_for_arg(
command_line,
filenames[i]
);
}
}
g_free(filenames);
return files;
}

View File

@@ -0,0 +1,37 @@
#include <glib.h>
#include "../public/memory.h"
//
// PUBLIC FUNCTIONS
//
void wintc_freev(
gpointer mem,
GDestroyNotify destroy
)
{
void** arr = (void**) mem;
for (guint i = 0; arr[i]; i++)
{
destroy(arr[i]);
}
g_free(mem);
}
void wintc_freenv(
gpointer mem,
guint n_elements,
GDestroyNotify destroy
)
{
void** arr = (void**) mem;
for (guint i = 0; i < n_elements; i++)
{
destroy(arr[i]);
}
g_free(mem);
}

View File

@@ -44,6 +44,19 @@ gchar* wintc_str_set_suffix(
}
}
void wintc_strdup_replace(
gchar** dest,
const gchar* src
)
{
if (*dest != NULL)
{
g_free(g_steal_pointer(dest));
}
*dest = g_strdup(src);
}
gint wintc_strstr_count(
const gchar* haystack,
const gchar* needle
@@ -72,12 +85,12 @@ void wintc_strsteal(
gchar** src
)
{
if (dest != NULL)
if (*dest != NULL)
{
g_free((*dest));
*dest = *src;
g_free(g_steal_pointer(dest));
}
*dest = *src;
*src = NULL;
}
@@ -141,3 +154,14 @@ gchar* wintc_strsubst(
return buffer;
}
guint wintc_strv_length(
const gchar** str_array
)
{
guint i;
for (i = 0; str_array[i]; i++);
return i;
}