Enhancement: Fixes #307, Explorer - split toolbar from XML UI, use GActions

This commit is contained in:
Rory Fewell
2024-05-30 04:28:17 +01:00
parent 4c76db2652
commit 90674a3528
25 changed files with 1531 additions and 504 deletions

View File

@@ -40,6 +40,8 @@ add_library(
public/defprocs.h
src/errors.c
public/errors.h
src/icons.c
public/icons.h
src/list.c
public/list.h
src/marshal.c

View File

@@ -0,0 +1,15 @@
#ifndef __COMGTK_ICONS_H__
#define __COMGTK_ICONS_H__
#include <glib.h>
//
// PUBLIC FUNCTIONS
//
const gchar* wintc_icon_name_first_available(
gint size,
const gchar* xdg_fallback,
...
);
#endif

View File

@@ -6,6 +6,7 @@
#include "@LIB_HEADER_DIR@/debug.h"
#include "@LIB_HEADER_DIR@/defprocs.h"
#include "@LIB_HEADER_DIR@/errors.h"
#include "@LIB_HEADER_DIR@/icons.h"
#include "@LIB_HEADER_DIR@/list.h"
#include "@LIB_HEADER_DIR@/marshal.h"
#include "@LIB_HEADER_DIR@/msgbox.h"

48
shared/comgtk/src/icons.c Normal file
View File

@@ -0,0 +1,48 @@
#include <glib.h>
#include <gtk/gtk.h>
#include "../public/icons.h"
//
// PUBLIC FUNCTIONS
//
const gchar* wintc_icon_name_first_available(
gint size,
const gchar* xdg_fallback,
...
)
{
va_list ap;
const gchar* next_name;
const gchar* ret = xdg_fallback;
va_start(ap, xdg_fallback);
next_name = va_arg(ap, gchar*);
while (next_name)
{
GtkIconInfo* icon_info =
gtk_icon_theme_lookup_icon(
gtk_icon_theme_get_default(),
next_name,
size,
0
);
if (icon_info)
{
g_object_unref(icon_info);
ret = next_name;
break;
}
next_name = va_arg(ap, gchar*);
}
va_end(ap);
return ret;
}

View File

@@ -39,6 +39,10 @@ gboolean wintc_sh_browser_activate_item(
GError** error
);
gboolean wintc_sh_browser_can_navigate_to_parent(
WinTCShBrowser* browser
);
void wintc_sh_browser_get_location(
WinTCShBrowser* browser,
WinTCShextPathInfo* path_info

View File

@@ -270,6 +270,19 @@ gboolean wintc_sh_browser_activate_item(
return success;
}
gboolean wintc_sh_browser_can_navigate_to_parent(
WinTCShBrowser* browser
)
{
if (!browser->current_view)
{
g_critical("%s", "shell: nav to parent - no view");
return FALSE;
}
return wintc_ishext_view_has_parent(browser->current_view);
}
void wintc_sh_browser_get_location(
WinTCShBrowser* browser,
WinTCShextPathInfo* path_info
@@ -277,16 +290,13 @@ void wintc_sh_browser_get_location(
{
if (!browser->current_view)
{
path_info->base_path = NULL;
path_info->extended_path = NULL;
}
else
{
wintc_ishext_view_get_path(
browser->current_view,
path_info
);
return;
}
wintc_ishext_view_get_path(
browser->current_view,
path_info
);
}
GtkTreeModel* wintc_sh_browser_get_model(
@@ -302,9 +312,9 @@ void wintc_sh_browser_navigate_to_parent(
{
WinTCShextPathInfo path_info = { 0 };
if (!browser->current_view)
if (!wintc_sh_browser_can_navigate_to_parent(browser))
{
g_critical("%s", "shell: browser can't nav to parent, no view");
g_critical("%s", "shell: browser can't nav to parent");
return;
}
@@ -313,12 +323,6 @@ void wintc_sh_browser_navigate_to_parent(
&path_info
);
if (!path_info.base_path)
{
g_critical("%s", "shell: browser can't nav to parent, no parent");
return;
}
wintc_sh_browser_set_location(browser, &path_info, NULL);
wintc_shext_path_info_free_data(&path_info);

View File

@@ -18,40 +18,44 @@ static void wintc_sh_view_cpl_finalize(
GObject* object
);
gboolean wintc_sh_view_cpl_activate_item(
static gboolean wintc_sh_view_cpl_activate_item(
WinTCIShextView* view,
WinTCShextViewItem* item,
WinTCShextPathInfo* path_info,
GError** error
);
void wintc_sh_view_cpl_refresh_items(
static void wintc_sh_view_cpl_refresh_items(
WinTCIShextView* view
);
void wintc_sh_view_cpl_get_actions_for_item(
static void wintc_sh_view_cpl_get_actions_for_item(
WinTCIShextView* view,
WinTCShextViewItem* item
);
void wintc_sh_view_cpl_get_actions_for_view(
static void wintc_sh_view_cpl_get_actions_for_view(
WinTCIShextView* view
);
const gchar* wintc_sh_view_cpl_get_display_name(
static const gchar* wintc_sh_view_cpl_get_display_name(
WinTCIShextView* view
);
void wintc_sh_view_cpl_get_parent_path(
static void wintc_sh_view_cpl_get_parent_path(
WinTCIShextView* view,
WinTCShextPathInfo* path_info
);
void wintc_sh_view_cpl_get_path(
static void wintc_sh_view_cpl_get_path(
WinTCIShextView* view,
WinTCShextPathInfo* path_info
);
static gboolean wintc_sh_view_cpl_has_parent(
WinTCIShextView* view
);
//
// GLIB OOP/CLASS INSTANCE DEFINITIONS
//
@@ -110,6 +114,7 @@ static void wintc_sh_view_cpl_ishext_view_interface_init(
iface->get_display_name = wintc_sh_view_cpl_get_display_name;
iface->get_parent_path = wintc_sh_view_cpl_get_parent_path;
iface->get_path = wintc_sh_view_cpl_get_path;
iface->has_parent = wintc_sh_view_cpl_has_parent;
}
//
@@ -133,7 +138,7 @@ static void wintc_sh_view_cpl_finalize(
//
// INTERFACE METHODS
//
gboolean wintc_sh_view_cpl_activate_item(
static gboolean wintc_sh_view_cpl_activate_item(
WINTC_UNUSED(WinTCIShextView* view),
WinTCShextViewItem* item,
WinTCShextPathInfo* path_info,
@@ -152,7 +157,7 @@ gboolean wintc_sh_view_cpl_activate_item(
return TRUE;
}
void wintc_sh_view_cpl_refresh_items(
static void wintc_sh_view_cpl_refresh_items(
WinTCIShextView* view
)
{
@@ -215,7 +220,7 @@ void wintc_sh_view_cpl_refresh_items(
_wintc_ishext_view_items_added(view, &update);
}
void wintc_sh_view_cpl_get_actions_for_item(
static void wintc_sh_view_cpl_get_actions_for_item(
WINTC_UNUSED(WinTCIShextView* view),
WINTC_UNUSED(WinTCShextViewItem* item)
)
@@ -223,14 +228,14 @@ void wintc_sh_view_cpl_get_actions_for_item(
g_critical("%s Not Implemented", __func__);
}
void wintc_sh_view_cpl_get_actions_for_view(
static void wintc_sh_view_cpl_get_actions_for_view(
WINTC_UNUSED(WinTCIShextView* view)
)
{
g_critical("%s Not Implemented", __func__);
}
const gchar* wintc_sh_view_cpl_get_display_name(
static const gchar* wintc_sh_view_cpl_get_display_name(
WINTC_UNUSED(WinTCIShextView* view)
)
{
@@ -239,7 +244,7 @@ const gchar* wintc_sh_view_cpl_get_display_name(
return "Control Panel";
}
void wintc_sh_view_cpl_get_parent_path(
static void wintc_sh_view_cpl_get_parent_path(
WINTC_UNUSED(WinTCIShextView* view),
WinTCShextPathInfo* path_info
)
@@ -250,7 +255,7 @@ void wintc_sh_view_cpl_get_parent_path(
);
}
void wintc_sh_view_cpl_get_path(
static void wintc_sh_view_cpl_get_path(
WINTC_UNUSED(WinTCIShextView* view),
WinTCShextPathInfo* path_info
)
@@ -261,6 +266,13 @@ void wintc_sh_view_cpl_get_path(
);
}
static gboolean wintc_sh_view_cpl_has_parent(
WINTC_UNUSED(WinTCIShextView* view)
)
{
return TRUE;
}
//
// PUBLIC FUNCTIONS
//

View File

@@ -46,40 +46,44 @@ static void wintc_sh_view_desktop_ishext_view_interface_init(
WinTCIShextViewInterface* iface
);
gboolean wintc_sh_view_desktop_activate_item(
static gboolean wintc_sh_view_desktop_activate_item(
WinTCIShextView* view,
WinTCShextViewItem* item,
WinTCShextPathInfo* path_info,
GError** error
);
void wintc_sh_view_desktop_refresh_items(
static void wintc_sh_view_desktop_refresh_items(
WinTCIShextView* view
);
void wintc_sh_view_desktop_get_actions_for_item(
static void wintc_sh_view_desktop_get_actions_for_item(
WinTCIShextView* view,
WinTCShextViewItem* item
);
void wintc_sh_view_desktop_get_actions_for_view(
static void wintc_sh_view_desktop_get_actions_for_view(
WinTCIShextView* view
);
const gchar* wintc_sh_view_desktop_get_display_name(
static const gchar* wintc_sh_view_desktop_get_display_name(
WinTCIShextView* view
);
void wintc_sh_view_desktop_get_parent_path(
static void wintc_sh_view_desktop_get_parent_path(
WinTCIShextView* view,
WinTCShextPathInfo* path_info
);
void wintc_sh_view_desktop_get_path(
static void wintc_sh_view_desktop_get_path(
WinTCIShextView* view,
WinTCShextPathInfo* path_info
);
static gboolean wintc_sh_view_desktop_has_parent(
WinTCIShextView* view
);
//
// GLIB OOP CLASS/INSTANCE DEFINITIONS
//
@@ -131,12 +135,13 @@ static void wintc_sh_view_desktop_ishext_view_interface_init(
iface->get_display_name = wintc_sh_view_desktop_get_display_name;
iface->get_parent_path = wintc_sh_view_desktop_get_parent_path;
iface->get_path = wintc_sh_view_desktop_get_path;
iface->has_parent = wintc_sh_view_desktop_has_parent;
}
//
// INTERFACE METHODS
//
gboolean wintc_sh_view_desktop_activate_item(
static gboolean wintc_sh_view_desktop_activate_item(
WINTC_UNUSED(WinTCIShextView* view),
WinTCShextViewItem* item,
WinTCShextPathInfo* path_info,
@@ -158,7 +163,7 @@ gboolean wintc_sh_view_desktop_activate_item(
return TRUE;
}
void wintc_sh_view_desktop_refresh_items(
static void wintc_sh_view_desktop_refresh_items(
WinTCIShextView* view
)
{
@@ -176,7 +181,7 @@ void wintc_sh_view_desktop_refresh_items(
_wintc_ishext_view_items_added(view, &items);
}
void wintc_sh_view_desktop_get_actions_for_item(
static void wintc_sh_view_desktop_get_actions_for_item(
WINTC_UNUSED(WinTCIShextView* view),
WINTC_UNUSED(WinTCShextViewItem* item)
)
@@ -184,14 +189,14 @@ void wintc_sh_view_desktop_get_actions_for_item(
g_critical("%s Not Implemented", __func__);
}
void wintc_sh_view_desktop_get_actions_for_view(
static void wintc_sh_view_desktop_get_actions_for_view(
WINTC_UNUSED(WinTCIShextView* view)
)
{
g_critical("%s Not Implemented", __func__);
}
const gchar* wintc_sh_view_desktop_get_display_name(
static const gchar* wintc_sh_view_desktop_get_display_name(
WINTC_UNUSED(WinTCIShextView* view)
)
{
@@ -199,12 +204,12 @@ const gchar* wintc_sh_view_desktop_get_display_name(
return "Desktop";
}
void wintc_sh_view_desktop_get_parent_path(
static void wintc_sh_view_desktop_get_parent_path(
WINTC_UNUSED(WinTCIShextView* view),
WINTC_UNUSED(WinTCShextPathInfo* path_info)
) {}
void wintc_sh_view_desktop_get_path(
static void wintc_sh_view_desktop_get_path(
WINTC_UNUSED(WinTCIShextView* view),
WinTCShextPathInfo* path_info
)
@@ -215,6 +220,13 @@ void wintc_sh_view_desktop_get_path(
);
}
static gboolean wintc_sh_view_desktop_has_parent(
WINTC_UNUSED(WinTCIShextView* view)
)
{
return FALSE;
}
//
// PUBLIC FUNCTIONS
//

View File

@@ -23,40 +23,44 @@ static void wintc_sh_view_drives_ishext_view_interface_init(
WinTCIShextViewInterface* iface
);
gboolean wintc_sh_view_drives_activate_item(
static gboolean wintc_sh_view_drives_activate_item(
WinTCIShextView* view,
WinTCShextViewItem* item,
WinTCShextPathInfo* path_info,
GError** error
);
void wintc_sh_view_drives_refresh_items(
static void wintc_sh_view_drives_refresh_items(
WinTCIShextView* view
);
void wintc_sh_view_drives_get_actions_for_item(
static void wintc_sh_view_drives_get_actions_for_item(
WinTCIShextView* view,
WinTCShextViewItem* item
);
void wintc_sh_view_drives_get_actions_for_view(
static void wintc_sh_view_drives_get_actions_for_view(
WinTCIShextView* view
);
const gchar* wintc_sh_view_drives_get_display_name(
static const gchar* wintc_sh_view_drives_get_display_name(
WinTCIShextView* view
);
void wintc_sh_view_drives_get_parent_path(
static void wintc_sh_view_drives_get_parent_path(
WinTCIShextView* view,
WinTCShextPathInfo* path_info
);
void wintc_sh_view_drives_get_path(
static void wintc_sh_view_drives_get_path(
WinTCIShextView* view,
WinTCShextPathInfo* path_info
);
static gboolean wintc_sh_view_drives_has_parent(
WinTCIShextView* view
);
//
// GLIB OOP/CLASS INSTANCE DEFINITIONS
//
@@ -107,12 +111,13 @@ static void wintc_sh_view_drives_ishext_view_interface_init(
iface->get_display_name = wintc_sh_view_drives_get_display_name;
iface->get_parent_path = wintc_sh_view_drives_get_parent_path;
iface->get_path = wintc_sh_view_drives_get_path;
iface->has_parent = wintc_sh_view_drives_has_parent;
}
//
// INTERFACE METHODS
//
gboolean wintc_sh_view_drives_activate_item(
static gboolean wintc_sh_view_drives_activate_item(
WINTC_UNUSED(WinTCIShextView* view),
WinTCShextViewItem* item,
WinTCShextPathInfo* path_info,
@@ -128,7 +133,7 @@ gboolean wintc_sh_view_drives_activate_item(
return TRUE;
}
void wintc_sh_view_drives_refresh_items(
static void wintc_sh_view_drives_refresh_items(
WinTCIShextView* view
)
{
@@ -146,7 +151,7 @@ void wintc_sh_view_drives_refresh_items(
_wintc_ishext_view_items_added(view, &items);
}
void wintc_sh_view_drives_get_actions_for_item(
static void wintc_sh_view_drives_get_actions_for_item(
WINTC_UNUSED(WinTCIShextView* view),
WINTC_UNUSED(WinTCShextViewItem* item)
)
@@ -154,14 +159,14 @@ void wintc_sh_view_drives_get_actions_for_item(
g_critical("%s Not Implemented", __func__);
}
void wintc_sh_view_drives_get_actions_for_view(
static void wintc_sh_view_drives_get_actions_for_view(
WINTC_UNUSED(WinTCIShextView* view)
)
{
g_critical("%s Not Implemented", __func__);
}
const gchar* wintc_sh_view_drives_get_display_name(
static const gchar* wintc_sh_view_drives_get_display_name(
WINTC_UNUSED(WinTCIShextView* view)
)
{
@@ -170,7 +175,7 @@ const gchar* wintc_sh_view_drives_get_display_name(
return "My Computer";
}
void wintc_sh_view_drives_get_parent_path(
static void wintc_sh_view_drives_get_parent_path(
WINTC_UNUSED(WinTCIShextView* view),
WinTCShextPathInfo* path_info
)
@@ -181,7 +186,7 @@ void wintc_sh_view_drives_get_parent_path(
);
}
void wintc_sh_view_drives_get_path(
static void wintc_sh_view_drives_get_path(
WINTC_UNUSED(WinTCIShextView* view),
WinTCShextPathInfo* path_info
)
@@ -192,6 +197,13 @@ void wintc_sh_view_drives_get_path(
);
}
static gboolean wintc_sh_view_drives_has_parent(
WINTC_UNUSED(WinTCIShextView* view)
)
{
return TRUE;
}
//
// PUBLIC FUNCTIONS
//

View File

@@ -35,40 +35,44 @@ static void wintc_sh_view_fs_set_property(
GParamSpec* pspec
);
gboolean wintc_sh_view_fs_activate_item(
static gboolean wintc_sh_view_fs_activate_item(
WinTCIShextView* view,
WinTCShextViewItem* item,
WinTCShextPathInfo* path_info,
GError** error
);
void wintc_sh_view_fs_refresh_items(
static void wintc_sh_view_fs_refresh_items(
WinTCIShextView* view
);
void wintc_sh_view_fs_get_actions_for_item(
static void wintc_sh_view_fs_get_actions_for_item(
WinTCIShextView* view,
WinTCShextViewItem* item
);
void wintc_sh_view_fs_get_actions_for_view(
static void wintc_sh_view_fs_get_actions_for_view(
WinTCIShextView* view
);
const gchar* wintc_sh_view_fs_get_display_name(
static const gchar* wintc_sh_view_fs_get_display_name(
WinTCIShextView* view
);
void wintc_sh_view_fs_get_parent_path(
static void wintc_sh_view_fs_get_parent_path(
WinTCIShextView* view,
WinTCShextPathInfo* path_info
);
void wintc_sh_view_fs_get_path(
static void wintc_sh_view_fs_get_path(
WinTCIShextView* view,
WinTCShextPathInfo* path_info
);
static gboolean wintc_sh_view_fs_has_parent(
WinTCIShextView* view
);
static void clear_view_item(
WinTCShextViewItem* item
);
@@ -151,6 +155,7 @@ static void wintc_sh_view_fs_ishext_view_interface_init(
iface->get_display_name = wintc_sh_view_fs_get_display_name;
iface->get_parent_path = wintc_sh_view_fs_get_parent_path;
iface->get_path = wintc_sh_view_fs_get_path;
iface->has_parent = wintc_sh_view_fs_has_parent;
}
//
@@ -222,7 +227,7 @@ static void wintc_sh_view_fs_set_property(
//
// INTERFACE METHODS
//
gboolean wintc_sh_view_fs_activate_item(
static gboolean wintc_sh_view_fs_activate_item(
WinTCIShextView* view,
WinTCShextViewItem* item,
WinTCShextPathInfo* path_info,
@@ -248,7 +253,7 @@ gboolean wintc_sh_view_fs_activate_item(
return TRUE;
}
void wintc_sh_view_fs_refresh_items(
static void wintc_sh_view_fs_refresh_items(
WinTCIShextView* view
)
{
@@ -329,7 +334,7 @@ void wintc_sh_view_fs_refresh_items(
_wintc_ishext_view_items_added(view, &update);
}
void wintc_sh_view_fs_get_actions_for_item(
static void wintc_sh_view_fs_get_actions_for_item(
WINTC_UNUSED(WinTCIShextView* view),
WINTC_UNUSED(WinTCShextViewItem* item)
)
@@ -337,14 +342,14 @@ void wintc_sh_view_fs_get_actions_for_item(
g_critical("%s Not Implemented", __func__);
}
void wintc_sh_view_fs_get_actions_for_view(
static void wintc_sh_view_fs_get_actions_for_view(
WINTC_UNUSED(WinTCIShextView* view)
)
{
g_critical("%s Not Implemented", __func__);
}
const gchar* wintc_sh_view_fs_get_display_name(
static const gchar* wintc_sh_view_fs_get_display_name(
WinTCIShextView* view
)
{
@@ -361,7 +366,7 @@ const gchar* wintc_sh_view_fs_get_display_name(
return g_strrstr(view_fs->path, G_DIR_SEPARATOR_S) + 1;
}
void wintc_sh_view_fs_get_parent_path(
static void wintc_sh_view_fs_get_parent_path(
WinTCIShextView* view,
WinTCShextPathInfo* path_info
)
@@ -384,7 +389,7 @@ void wintc_sh_view_fs_get_parent_path(
}
}
void wintc_sh_view_fs_get_path(
static void wintc_sh_view_fs_get_path(
WinTCIShextView* view,
WinTCShextPathInfo* path_info
)
@@ -395,6 +400,13 @@ void wintc_sh_view_fs_get_path(
g_strdup_printf("file://%s", view_fs->path);
}
static gboolean wintc_sh_view_fs_has_parent(
WINTC_UNUSED(WinTCIShextView* view)
)
{
return TRUE;
}
//
// PUBLIC FUNCTIONS
//

View File

@@ -60,6 +60,9 @@ struct _WinTCIShextViewInterface
WinTCIShextView* view,
WinTCShextPathInfo* path_info
);
gboolean (*has_parent) (
WinTCIShextView* view
);
void (*refresh_items) (
WinTCIShextView* view
@@ -99,6 +102,9 @@ void wintc_ishext_view_get_path(
WinTCIShextView* view,
WinTCShextPathInfo* path_info
);
gboolean wintc_ishext_view_has_parent(
WinTCIShextView* view
);
//
// PUBLIC FUNCTIONS
@@ -112,8 +118,16 @@ void _wintc_ishext_view_items_removed(
WinTCShextViewItem** items
);
void wintc_shext_path_info_copy(
WinTCShextPathInfo* dst,
WinTCShextPathInfo* src
);
void wintc_shext_path_info_free_data(
WinTCShextPathInfo* path_info
);
void wintc_shext_path_info_move(
WinTCShextPathInfo* dst,
WinTCShextPathInfo* src
);
#endif

View File

@@ -136,6 +136,16 @@ void wintc_ishext_view_get_path(
return iface->get_path(view, path_info);
}
gboolean wintc_ishext_view_has_parent(
WinTCIShextView* view
)
{
WinTCIShextViewInterface* iface =
WINTC_ISHEXT_VIEW_GET_IFACE(view);
return iface->has_parent(view);
}
void wintc_ishext_view_refresh_items(
WinTCIShextView* view
)
@@ -175,6 +185,26 @@ void _wintc_ishext_view_items_removed(
);
}
void wintc_shext_path_info_copy(
WinTCShextPathInfo* dst,
WinTCShextPathInfo* src
)
{
wintc_shext_path_info_free_data(dst);
if (!src->base_path)
{
return;
}
dst->base_path = g_strdup(src->base_path);
if (src->extended_path)
{
dst->extended_path = g_strdup(src->extended_path);
}
}
void wintc_shext_path_info_free_data(
WinTCShextPathInfo* path_info
)
@@ -182,3 +212,19 @@ void wintc_shext_path_info_free_data(
g_free(g_steal_pointer(&(path_info->base_path)));
g_free(g_steal_pointer(&(path_info->extended_path)));
}
void wintc_shext_path_info_move(
WinTCShextPathInfo* dst,
WinTCShextPathInfo* src
)
{
wintc_shext_path_info_free_data(dst);
if (!src->base_path)
{
return;
}
dst->base_path = g_steal_pointer(&(src->base_path));
dst->extended_path = g_steal_pointer(&(src->extended_path));
}

View File

@@ -23,40 +23,44 @@ static void wintc_cpl_view_printers_ishext_view_interface_init(
WinTCIShextViewInterface* iface
);
gboolean wintc_cpl_view_printers_activate_item(
static gboolean wintc_cpl_view_printers_activate_item(
WinTCIShextView* view,
WinTCShextViewItem* item,
WinTCShextPathInfo* path_info,
GError** error
);
void wintc_cpl_view_printers_refresh_items(
static void wintc_cpl_view_printers_refresh_items(
WinTCIShextView* view
);
void wintc_cpl_view_printers_get_actions_for_item(
static void wintc_cpl_view_printers_get_actions_for_item(
WinTCIShextView* view,
WinTCShextViewItem* item
);
void wintc_cpl_view_printers_get_actions_for_view(
static void wintc_cpl_view_printers_get_actions_for_view(
WinTCIShextView* view
);
const gchar* wintc_cpl_view_printers_get_display_name(
static const gchar* wintc_cpl_view_printers_get_display_name(
WinTCIShextView* view
);
void wintc_cpl_view_printers_get_parent_path(
static void wintc_cpl_view_printers_get_parent_path(
WinTCIShextView* view,
WinTCShextPathInfo* path_info
);
void wintc_cpl_view_printers_get_path(
static void wintc_cpl_view_printers_get_path(
WinTCIShextView* view,
WinTCShextPathInfo* path_info
);
static gboolean wintc_cpl_view_printers_has_parent(
WinTCIShextView* view
);
//
// GLIB OOP/CLASS INSTANCE DEFINITIONS
//
@@ -102,12 +106,13 @@ static void wintc_cpl_view_printers_ishext_view_interface_init(
iface->get_display_name = wintc_cpl_view_printers_get_display_name;
iface->get_parent_path = wintc_cpl_view_printers_get_parent_path;
iface->get_path = wintc_cpl_view_printers_get_path;
iface->has_parent = wintc_cpl_view_printers_has_parent;
}
//
// INTERFACE METHODS
//
gboolean wintc_cpl_view_printers_activate_item(
static gboolean wintc_cpl_view_printers_activate_item(
WINTC_UNUSED(WinTCIShextView* view),
WINTC_UNUSED(WinTCShextViewItem* item),
WINTC_UNUSED(WinTCShextPathInfo* path_info),
@@ -119,7 +124,7 @@ gboolean wintc_cpl_view_printers_activate_item(
return FALSE;
}
void wintc_cpl_view_printers_refresh_items(
static void wintc_cpl_view_printers_refresh_items(
WinTCIShextView* view
)
{
@@ -137,7 +142,7 @@ void wintc_cpl_view_printers_refresh_items(
_wintc_ishext_view_items_added(view, &items);
}
void wintc_cpl_view_printers_get_actions_for_item(
static void wintc_cpl_view_printers_get_actions_for_item(
WINTC_UNUSED(WinTCIShextView* view),
WINTC_UNUSED(WinTCShextViewItem* item)
)
@@ -145,14 +150,14 @@ void wintc_cpl_view_printers_get_actions_for_item(
g_critical("%s Not Implemented", __func__);
}
void wintc_cpl_view_printers_get_actions_for_view(
static void wintc_cpl_view_printers_get_actions_for_view(
WINTC_UNUSED(WinTCIShextView* view)
)
{
g_critical("%s Not Implemented", __func__);
}
const gchar* wintc_cpl_view_printers_get_display_name(
static const gchar* wintc_cpl_view_printers_get_display_name(
WINTC_UNUSED(WinTCIShextView* view)
)
{
@@ -161,7 +166,7 @@ const gchar* wintc_cpl_view_printers_get_display_name(
return "Printers and Faxes";
}
void wintc_cpl_view_printers_get_parent_path(
static void wintc_cpl_view_printers_get_parent_path(
WINTC_UNUSED(WinTCIShextView* view),
WinTCShextPathInfo* path_info
)
@@ -172,7 +177,7 @@ void wintc_cpl_view_printers_get_parent_path(
);
}
void wintc_cpl_view_printers_get_path(
static void wintc_cpl_view_printers_get_path(
WINTC_UNUSED(WinTCIShextView* view),
WinTCShextPathInfo* path_info
)
@@ -183,6 +188,13 @@ void wintc_cpl_view_printers_get_path(
);
}
static gboolean wintc_cpl_view_printers_has_parent(
WINTC_UNUSED(WinTCIShextView* view)
)
{
return TRUE;
}
//
// PUBLIC FUNCTIONS
//

View File

@@ -37,6 +37,12 @@ add_executable(
src/application.h
src/main.c
src/resources.c
src/toolbar.c
src/toolbar.h
src/toolbars/adrbar.c
src/toolbars/adrbar.h
src/toolbars/stdbar.c
src/toolbars/stdbar.h
src/window.c
src/window.h
)

View File

@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkToolbar" id="toolbar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkToolItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="sensitive">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Address</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">False</property>
</packing>
</child>
<child>
<object class="GtkToolItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkComboBoxText" id="combo-address">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="has-entry">True</property>
<child internal-child="entry">
<object class="GtkEntry">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">False</property>
</packing>
</child>
<child>
<object class="GtkToolItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkButton" id="button-nav-go">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="receives-default">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Go</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">False</property>
</packing>
</child>
</object>
</interface>

View File

@@ -534,262 +534,16 @@
</child>
<child>
<object class="GtkToolbar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkToolItem">
<object class="GtkBox" id="box-toolbars">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="receives-default">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">horizontal</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">go-previous</property>
<property name="icon-size">3</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label">Back</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkToolItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="receives-default">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">horizontal</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">go-next</property>
<property name="icon-size">3</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkToolItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkButton" id="button-nav-up">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="receives-default">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">horizontal</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">go-up</property>
<property name="icon-size">3</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkSeparatorToolItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
</child>
<child>
<object class="GtkToolItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="receives-default">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">horizontal</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">system-search</property>
<property name="icon-size">3</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label">Search</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkToolItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="receives-default">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">horizontal</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">folders</property>
<property name="icon-size">3</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label">Folders</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkToolbar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkToolItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="sensitive">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Address</property>
</object>
</child>
</object>
<packing>
<property name="orientation">vertical</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">False</property>
</packing>
</child>
<child>
<object class="GtkToolItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkComboBoxText" id="combo-address">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="has-entry">True</property>
<child internal-child="entry">
<object class="GtkEntry">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">False</property>
</packing>
</child>
<child>
<object class="GtkToolItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkButton" id="button-nav-go">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="receives-default">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">horizontal</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label">Go</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
@@ -832,7 +586,7 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">4</property>
<property name="position">3</property>
</packing>
</child>
</object>

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/uk/oddmatics/wintc/explorer">
<file>adrbar.ui</file>
<file>explorer.ui</file>
</gresource>
</gresources>

View File

@@ -0,0 +1,113 @@
#include <glib.h>
#include <gtk/gtk.h>
#include <wintc/comgtk.h>
#include "toolbar.h"
//
// PRIVATE ENUMS
//
enum
{
PROP_OWNER_EXPLORER = 1
};
//
// FORWARD DECLARATIONS
//
static void wintc_explorer_toolbar_dispose(
GObject* object
);
static void wintc_explorer_toolbar_set_property(
GObject* object,
guint prop_id,
const GValue* value,
GParamSpec* pspec
);
//
// GTK TYPE DEFINITIONS & CTORS
//
G_DEFINE_TYPE(
WinTCExplorerToolbar,
wintc_explorer_toolbar,
G_TYPE_OBJECT
)
static void wintc_explorer_toolbar_class_init(
WinTCExplorerToolbarClass* klass
)
{
GObjectClass* object_class = G_OBJECT_CLASS(klass);
object_class->dispose = wintc_explorer_toolbar_dispose;
object_class->set_property = wintc_explorer_toolbar_set_property;
g_object_class_install_property(
object_class,
PROP_OWNER_EXPLORER,
g_param_spec_object(
"owner-explorer",
"OwnerExplorer",
"The Explorer window that owns the toolbar.",
GTK_TYPE_WIDGET,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY
)
);
}
static void wintc_explorer_toolbar_init(
WinTCExplorerToolbar* self
)
{
self->toolbar = gtk_toolbar_new();
g_object_ref_sink(self->toolbar);
}
//
// CLASS VIRTUAL METHODS
//
static void wintc_explorer_toolbar_dispose(
GObject* object
)
{
WinTCExplorerToolbar* toolbar = WINTC_EXPLORER_TOOLBAR(object);
g_clear_object(&(toolbar->owner_explorer_wnd));
g_clear_object(&(toolbar->toolbar));
(G_OBJECT_CLASS(wintc_explorer_toolbar_parent_class))->dispose(object);
}
static void wintc_explorer_toolbar_set_property(
GObject* object,
guint prop_id,
const GValue* value,
GParamSpec* pspec
)
{
WinTCExplorerToolbar* toolbar = WINTC_EXPLORER_TOOLBAR(object);
switch (prop_id)
{
case PROP_OWNER_EXPLORER:
toolbar->owner_explorer_wnd =
g_value_dup_object(value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
//
// PUBLIC FUNCTIONS
//
GtkWidget* wintc_explorer_toolbar_get_toolbar(
WinTCExplorerToolbar* toolbar
)
{
return toolbar->toolbar;
}

View File

@@ -0,0 +1,39 @@
#ifndef __TOOLBAR_H__
#define __TOOLBAR_H__
#include <glib.h>
#include <gtk/gtk.h>
//
// GTK OOP BOILERPLATE
//
typedef struct _WinTCExplorerToolbarClass
{
GObjectClass __parent__;
} WinTCExplorerToolbarClass;
typedef struct _WinTCExplorerToolbar
{
GObject __parent__;
GtkWidget* owner_explorer_wnd;
GtkWidget* toolbar;
} WinTCExplorerToolbar;
#define WINTC_TYPE_EXPLORER_TOOLBAR (wintc_explorer_toolbar_get_type())
#define WINTC_EXPLORER_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WINTC_TYPE_EXPLORER_TOOLBAR, WinTCExplorerToolbar))
#define WINTC_EXPLORER_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WINTC_TYPE_EXPLORER_TOOLBAR, WinTCExplorerToolbarClass))
#define IS_WINTC_EXPLORER_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WINTC_TYPE_EXPLORER_TOOLBAR))
#define IS_WINTC_EXPLORER_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WINTC_TYPE_EXPLORER_TOOLBAR))
#define WINTC_EXPLORER_TOOLBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WINTC_TYPE_EXPLORER_TOOLBAR, WinTCExplorerToolbar))
GType wintc_explorer_toolbar_get_type(void) G_GNUC_CONST;
//
// PUBLIC FUNCTIONS
//
GtkWidget* wintc_explorer_toolbar_get_toolbar(
WinTCExplorerToolbar* toolbar
);
#endif

View File

@@ -0,0 +1,235 @@
#include <glib.h>
#include <gtk/gtk.h>
#include <wintc/comgtk.h>
#include <wintc/shellext.h>
#include <wintc/shlang.h>
#include "../toolbar.h"
#include "../window.h"
#include "adrbar.h"
//
// FOWARD DECLARATIONS
//
static void wintc_exp_address_toolbar_constructed(
GObject* object
);
static void on_button_nav_go_clicked(
GtkButton* self,
gpointer user_data
);
static void on_combo_address_entry_activate(
GtkEntry* self,
gpointer user_data
);
static void on_explorer_wnd_location_changed(
WinTCExplorerWindow* wnd,
gpointer user_data
);
//
// GTK OOP CLASS/INSTANCE DEFINITIONS
//
struct _WinTCExpAddressToolbarClass
{
WinTCExplorerToolbarClass __parent__;
};
struct _WinTCExpAddressToolbar
{
WinTCExplorerToolbar __parent__;
// UI
//
GtkWidget* button_nav_go;
GtkWidget* combo_address;
};
//
// GTK TYPE DEFINITION & CTORS
//
G_DEFINE_TYPE(
WinTCExpAddressToolbar,
wintc_exp_address_toolbar,
WINTC_TYPE_EXPLORER_TOOLBAR
)
static void wintc_exp_address_toolbar_class_init(
WinTCExpAddressToolbarClass* klass
)
{
GObjectClass* object_class = G_OBJECT_CLASS(klass);
object_class->constructed = wintc_exp_address_toolbar_constructed;
}
static void wintc_exp_address_toolbar_init(
WinTCExpAddressToolbar* self
)
{
WinTCExplorerToolbar* toolbar = WINTC_EXPLORER_TOOLBAR(self);
GtkBuilder* builder =
gtk_builder_new_from_resource(
"/uk/oddmatics/wintc/explorer/adrbar.ui"
);
wintc_lc_builder_preprocess_widget_text(builder);
// Replace toolbar with the built one
//
g_clear_object(&(toolbar->toolbar));
toolbar->toolbar =
GTK_WIDGET(
g_object_ref_sink(
gtk_builder_get_object(builder, "toolbar")
)
);
// Pull out other widgets we need
//
self->button_nav_go =
GTK_WIDGET(gtk_builder_get_object(builder, "button-nav-go"));
self->combo_address =
GTK_WIDGET(gtk_builder_get_object(builder, "combo-address"));
// Connect signals
//
g_signal_connect(
self->button_nav_go,
"clicked",
G_CALLBACK(on_button_nav_go_clicked),
self
);
g_signal_connect(
gtk_bin_get_child(GTK_BIN(self->combo_address)),
"activate",
G_CALLBACK(on_combo_address_entry_activate),
self
);
}
//
// CLASS VIRTUAL METHODS
//
static void wintc_exp_address_toolbar_constructed(
GObject* object
)
{
WinTCExplorerToolbar* toolbar = WINTC_EXPLORER_TOOLBAR(object);
// Connect to location changed signal to update the entry
//
g_signal_connect(
toolbar->owner_explorer_wnd,
"location_changed",
G_CALLBACK(on_explorer_wnd_location_changed),
object
);
(G_OBJECT_CLASS(wintc_exp_address_toolbar_parent_class))
->constructed(object);
}
//
// PUBLIC FUNCTIONS
//
WinTCExplorerToolbar* wintc_exp_address_toolbar_new(
WinTCExplorerWindow* wnd
)
{
return WINTC_EXPLORER_TOOLBAR(
g_object_new(
WINTC_TYPE_EXP_ADDRESS_TOOLBAR,
"owner-explorer", wnd,
NULL
)
);
}
//
// CALLBACKS
//
static void on_button_nav_go_clicked(
WINTC_UNUSED(GtkButton* self),
gpointer user_data
)
{
WinTCExplorerToolbar* toolbar = WINTC_EXPLORER_TOOLBAR(user_data);
WinTCExpAddressToolbar* toolbar_adr = WINTC_EXP_ADDRESS_TOOLBAR(user_data);
GtkWidget* entry = gtk_bin_get_child(GTK_BIN(toolbar_adr->combo_address));
g_action_activate(
g_action_map_lookup_action(
G_ACTION_MAP(toolbar->owner_explorer_wnd),
"nav-go"
),
g_variant_new_string(
gtk_entry_get_text(GTK_ENTRY(entry))
)
);
}
static void on_combo_address_entry_activate(
WINTC_UNUSED(GtkEntry* self),
gpointer user_data
)
{
WinTCExpAddressToolbar* toolbar_adr = WINTC_EXP_ADDRESS_TOOLBAR(user_data);
gtk_widget_activate(
GTK_WIDGET(toolbar_adr->button_nav_go)
);
}
static void on_explorer_wnd_location_changed(
WinTCExplorerWindow* wnd,
gpointer user_data
)
{
WinTCExpAddressToolbar* toolbar_adr = WINTC_EXP_ADDRESS_TOOLBAR(user_data);
GtkWidget* entry = gtk_bin_get_child(
GTK_BIN(toolbar_adr->combo_address)
);
WinTCShextPathInfo path_info = { 0 };
wintc_explorer_window_get_location(
wnd,
&path_info
);
if (path_info.extended_path)
{
gtk_entry_set_text(
GTK_ENTRY(entry),
path_info.extended_path
);
}
else
{
// Special case for file:// address, we only want to display the actual
// filesystem path - kinda cheeky bunging it in here but it does get
// the job done
//
if (g_str_has_prefix(path_info.base_path, "file://"))
{
gtk_entry_set_text(
GTK_ENTRY(entry),
path_info.base_path + strlen("file://")
);
}
else
{
gtk_entry_set_text(
GTK_ENTRY(entry),
path_info.base_path
);
}
}
wintc_shext_path_info_free_data(&path_info);
}

View File

@@ -0,0 +1,32 @@
#ifndef __ADRBAR_H__
#define __ADRBAR_H__
#include <glib.h>
#include <gtk/gtk.h>
#include "../toolbar.h"
#include "../window.h"
//
// GTK OOP BOILERPLATE
//
typedef struct _WinTCExpAddressToolbarClass WinTCExpAddressToolbarClass;
typedef struct _WinTCExpAddressToolbar WinTCExpAddressToolbar;
#define WINTC_TYPE_EXP_ADDRESS_TOOLBAR (wintc_exp_address_toolbar_get_type())
#define WINTC_EXP_ADDRESS_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WINTC_TYPE_EXP_ADDRESS_TOOLBAR, WinTCExpAddressToolbar))
#define WINTC_EXP_ADDRESS_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WINTC_TYPE_EXP_ADDRESS_TOOLBAR, WinTCExpAddressToolbarClass))
#define IS_WINTC_EXP_ADDRESS_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WINTC_TYPE_EXP_ADDRESS_TOOLBAR))
#define IS_WINTC_EXP_ADDRESS_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WINTC_TYPE_EXP_ADDRESS_TOOLBAR))
#define WINTC_EXP_ADDRESS_TOOLBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WINTC_TYPE_EXP_ADDRESS_TOOLBAR, WinTCExpAddressToolbar))
GType wintc_exp_address_toolbar_get_type(void) G_GNUC_CONST;
//
// PUBLIC FUNCTIONS
//
WinTCExplorerToolbar* wintc_exp_address_toolbar_new(
WinTCExplorerWindow* wnd
);
#endif

View File

@@ -0,0 +1,493 @@
#include <glib.h>
#include <gtk/gtk.h>
#include <wintc/comgtk.h>
#include "../toolbar.h"
#include "../window.h"
#include "stdbar.h"
//
// FORWARD DECLARATIONS
//
static void wintc_exp_standard_toolbar_constructed(
GObject* object
);
GtkToolItem* create_toolbar_button(
gboolean is_important,
gboolean is_menu_button,
const gchar* label,
const gchar* icon_name
);
GtkToolItem* create_toolbar_item_from_char(
gchar c
);
void populate_toolbar(
GtkWidget* toolbar,
const gchar* config_str
);
static void on_toolbar_style_updated(
GtkWidget* self,
gpointer user_data
);
//
// STATIC DATA
//
static const gchar* S_LAYOUT_LOCAL = "bfu|sd|v";
//static const gchar* S_LAYOUT_INTERNET = "bfSRh|sFH|MPEC";
static const gint S_TOOLBAR_ICON_SIZE = 24;
//
// GTK OOP CLASS/INSTANCE DEFINITIONS
//
struct _WinTCExpStandardToolbarClass
{
WinTCExplorerToolbarClass __parent__;
};
struct _WinTCExpStandardToolbar
{
WinTCExplorerToolbar __parent__;
};
//
// GTK TYPE DEFINITION & CTORS
//
G_DEFINE_TYPE(
WinTCExpStandardToolbar,
wintc_exp_standard_toolbar,
WINTC_TYPE_EXPLORER_TOOLBAR
)
static void wintc_exp_standard_toolbar_class_init(
WinTCExpStandardToolbarClass* klass
)
{
GObjectClass* object_class = G_OBJECT_CLASS(klass);
object_class->constructed = wintc_exp_standard_toolbar_constructed;
}
static void wintc_exp_standard_toolbar_init(
WinTCExpStandardToolbar* self
)
{
WinTCExplorerToolbar* toolbar = WINTC_EXPLORER_TOOLBAR(self);
gtk_toolbar_set_style(
GTK_TOOLBAR(toolbar->toolbar),
GTK_TOOLBAR_BOTH_HORIZ
);
g_signal_connect(
toolbar->toolbar,
"style-updated",
G_CALLBACK(on_toolbar_style_updated),
self
);
}
//
// CLASS VIRTUAL METHODS
//
static void wintc_exp_standard_toolbar_constructed(
GObject* object
)
{
WinTCExplorerToolbar* toolbar = WINTC_EXPLORER_TOOLBAR(object);
//
// TODO: In future, the toolbar layout will come from the registry
//
populate_toolbar(
toolbar->toolbar,
S_LAYOUT_LOCAL
);
(G_OBJECT_CLASS(wintc_exp_standard_toolbar_parent_class))
->constructed(object);
}
//
// PUBLIC FUNCTIONS
//
WinTCExplorerToolbar* wintc_exp_standard_toolbar_new(
WinTCExplorerWindow* wnd
)
{
return WINTC_EXPLORER_TOOLBAR(
g_object_new(
WINTC_TYPE_EXP_STANDARD_TOOLBAR,
"owner-explorer", wnd,
NULL
)
);
}
//
// PRIVATE FUNCTIONS
//
GtkToolItem* create_toolbar_button(
gboolean is_important,
gboolean is_menu_button,
const gchar* label,
const gchar* icon_name
)
{
GtkToolItem* tb;
if (is_menu_button)
{
tb = gtk_menu_tool_button_new(NULL, NULL);
}
else
{
tb = gtk_tool_button_new(NULL, NULL);
}
if (icon_name)
{
gtk_tool_button_set_icon_name(
GTK_TOOL_BUTTON(tb),
icon_name
);
}
if (label)
{
gtk_tool_button_set_label(
GTK_TOOL_BUTTON(tb),
label
);
gtk_widget_set_tooltip_text(
GTK_WIDGET(tb),
label
);
}
gtk_tool_item_set_is_important(tb, is_important);
return tb;
}
GtkToolItem* create_toolbar_item_from_char(
gchar c
)
{
GtkToolItem* ret = NULL;
//
// FIXME: Localise strings when possible
//
switch (c)
{
// TODO: Implement this
//
case 'b':
// TODO: The tooltip for the back button should be the first
// item in the history
//
ret =
create_toolbar_button(
TRUE,
TRUE,
"Back",
wintc_icon_name_first_available(
S_TOOLBAR_ICON_SIZE,
"go-previous",
"history-back",
NULL
)
);
break;
// TODO: Implement this
//
case 'C':
ret =
create_toolbar_button(
FALSE,
FALSE,
"Messenger",
wintc_icon_name_first_available(
S_TOOLBAR_ICON_SIZE,
"face-wink",
"windows-messenger",
"internet-group-chat",
NULL
)
);
break;
// TODO: Implement this
//
case 'd':
ret =
create_toolbar_button(
TRUE,
FALSE,
"Folders",
wintc_icon_name_first_available(
S_TOOLBAR_ICON_SIZE,
"inode-directory",
"folders",
NULL
)
);
break;
// TODO: Implement this
//
case 'E':
ret =
create_toolbar_button(
FALSE,
FALSE,
"Edit with Notepad", // FIXME: Might not always be notepad?
wintc_icon_name_first_available(
S_TOOLBAR_ICON_SIZE,
"document-properties",
"document-open-ide",
NULL
)
);
break;
// TODO: Implement this
//
case 'F':
ret =
create_toolbar_button(
TRUE,
FALSE,
"Favorites",
"emblem-favorite"
);
break;
// TODO: Implement this
//
case 'f':
// TODO: See back button tooltip about history, but for Forward,
// since it has no label, the tooltip defaults to Forward
ret =
create_toolbar_button(
FALSE,
FALSE,
"Forward",
wintc_icon_name_first_available(
S_TOOLBAR_ICON_SIZE,
"go-next",
"history-forward",
NULL
)
);
break;
// TODO: Implement this
//
case 'H':
ret =
create_toolbar_button(
FALSE,
FALSE,
"History",
wintc_icon_name_first_available(
S_TOOLBAR_ICON_SIZE,
"media-seek-backward",
"history",
NULL
)
);
break;
// TODO: Implement this
//
case 'h':
ret =
create_toolbar_button(
FALSE,
FALSE,
"Home",
"go-home"
);
break;
// TODO: Implement this
//
case 'M':
ret =
create_toolbar_button(
FALSE,
TRUE,
"Mail",
wintc_icon_name_first_available(
S_TOOLBAR_ICON_SIZE,
"emblem-mail",
"internet-mail",
NULL
)
);
break;
// TODO: Implement this
//
case 'P':
ret =
create_toolbar_button(
FALSE,
FALSE,
"Print",
"printer"
);
break;
// TODO: Implement this
//
case 'R':
ret =
create_toolbar_button(
FALSE,
FALSE,
"Refresh",
wintc_icon_name_first_available(
S_TOOLBAR_ICON_SIZE,
"view-refresh",
"document-refresh",
NULL
)
);
break;
// TODO: Implement this
//
case 'S':
ret =
create_toolbar_button(
FALSE,
FALSE,
"Stop",
wintc_icon_name_first_available(
S_TOOLBAR_ICON_SIZE,
"process-stop",
"document-stop",
NULL
)
);
break;
// TODO: Implement this
//
case 's':
ret =
create_toolbar_button(
TRUE,
FALSE,
"Search",
wintc_icon_name_first_available(
S_TOOLBAR_ICON_SIZE,
"system-search",
"search",
NULL
)
);
break;
case 'u':
ret =
create_toolbar_button(
FALSE,
FALSE,
"Up",
wintc_icon_name_first_available(
S_TOOLBAR_ICON_SIZE,
"go-up",
"go-parent-directory",
NULL
)
);
gtk_actionable_set_action_name(
GTK_ACTIONABLE(ret),
"win.nav-up"
);
break;
// TODO: Implement this
//
case 'v':
ret =
create_toolbar_button(
FALSE,
FALSE,
"Views",
wintc_icon_name_first_available(
S_TOOLBAR_ICON_SIZE,
"video-display",
"views",
NULL
)
);
break;
case '|':
ret = gtk_separator_tool_item_new();
gtk_separator_tool_item_set_draw(
GTK_SEPARATOR_TOOL_ITEM(ret),
TRUE
);
break;
default:
g_warning("explorer: std toolbar unknown button %c", c);
break;
}
return ret;
}
void populate_toolbar(
GtkWidget* toolbar,
const gchar* config_str
)
{
wintc_container_clear(GTK_CONTAINER(toolbar));
WINTC_LOG_DEBUG("explorer: populating std toolbar with %s", config_str);
for (const gchar* p = config_str; *p; p++)
{
gtk_toolbar_insert(
GTK_TOOLBAR(toolbar),
create_toolbar_item_from_char(*p),
-1
);
}
gtk_widget_show_all(toolbar);
}
//
// CALLBACKS
//
static void on_toolbar_style_updated(
GtkWidget* self,
WINTC_UNUSED(gpointer user_data)
)
{
// We repopulate the toolbar upon style change, potentially the icon theme
// changed which requires us to look up the icons again etc. it's easier
// to just reload the whole thing (I'm a lazy git once again)
//
// FIXME: Just reloading the default fs toolbar for now
//
populate_toolbar(self, S_LAYOUT_LOCAL);
}

View File

@@ -0,0 +1,32 @@
#ifndef __STDBAR_H__
#define __STDBAR_H__
#include <glib.h>
#include <gtk/gtk.h>
#include "../toolbar.h"
#include "../window.h"
//
// GTK OOP BOILERPLATE
//
typedef struct _WinTCExpStandardToolbarClass WinTCExpStandardToolbarClass;
typedef struct _WinTCExpStandardToolbar WinTCExpStandardToolbar;
#define WINTC_TYPE_EXP_STANDARD_TOOLBAR (wintc_exp_standard_toolbar_get_type())
#define WINTC_EXP_STANDARD_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WINTC_TYPE_EXP_STANDARD_TOOLBAR, WinTCExpStandardToolbar))
#define WINTC_EXP_STANDARD_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WINTC_TYPE_EXP_STANDARD_TOOLBAR, WinTCExpStandardToolbarClass))
#define IS_WINTC_EXP_STANDARD_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WINTC_TYPE_EXP_STANDARD_TOOLBAR))
#define IS_WINTC_EXP_STANDARD_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WINTC_TYPE_EXP_STANDARD_TOOLBAR))
#define WINTC_EXP_STANDARD_TOOLBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WINTC_TYPE_EXP_STANDARD_TOOLBAR, WinTCExpStandardToolbar))
GType wintc_exp_standard_toolbar_get_type(void) G_GNUC_CONST;
//
// PUBLIC FUNCTIONS
//
WinTCExplorerToolbar* wintc_exp_standard_toolbar_new(
WinTCExplorerWindow* wnd
);
#endif

View File

@@ -7,6 +7,9 @@
#include <wintc/shlang.h>
#include "application.h"
#include "toolbar.h"
#include "toolbars/adrbar.h"
#include "toolbars/stdbar.h"
#include "window.h"
//
@@ -17,6 +20,12 @@ enum
PROP_SHEXT_HOST = 1
};
enum
{
SIGNAL_LOCATION_CHANGED = 0,
N_SIGNALS
};
//
// FORWARD DECLARATIONS
//
@@ -33,28 +42,52 @@ static void wintc_explorer_window_set_property(
GParamSpec* pspec
);
static void do_navigation(
WinTCExplorerWindow* wnd,
const gchar* specified_path
);
static void prepare_new_location(
const gchar* specified_path,
WinTCShextPathInfo* current_path_info
);
static void action_nav_go(
GSimpleAction* action,
GVariant* parameter,
gpointer user_data
);
static void action_nav_up(
GSimpleAction* action,
GVariant* parameter,
gpointer user_data
);
static void on_browser_location_changed(
WinTCShBrowser* self,
gpointer user_data
);
static void on_button_nav_go_clicked(
GtkButton* self,
gpointer user_data
);
static void on_button_nav_up_clicked(
GtkButton* self,
gpointer user_data
);
static void on_combo_address_entry_activate(
GtkEntry* self,
gpointer user_data
);
//
// STATIC DATA
//
static GActionEntry s_window_actions[] = {
{
.name = "nav-go",
.activate = action_nav_go,
.parameter_type = "s",
.state = NULL,
.change_state = NULL
},
{
.name = "nav-up",
.activate = action_nav_up,
.parameter_type = NULL,
.state = NULL,
.change_state = NULL
}
};
static gint wintc_explorer_window_signals[N_SIGNALS] = { 0 };
//
// GTK OOP CLASS/INSTANCE DEFINITIONS
@@ -73,14 +106,16 @@ struct _WinTCExplorerWindow
WinTCShBrowser* browser;
WinTCShextHost* shext_host;
// State
//
WinTCShextPathInfo current_path;
// UI
//
WinTCShIconViewBehaviour* behaviour_icons;
GtkWidget* iconview_browser;
GtkWidget* button_nav_go;
GtkWidget* button_nav_up;
GtkWidget* combo_address;
GtkWidget* box_toolbars;
};
//
@@ -113,6 +148,19 @@ static void wintc_explorer_window_class_init(
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY
)
);
wintc_explorer_window_signals[SIGNAL_LOCATION_CHANGED] =
g_signal_new(
"location-changed",
G_TYPE_FROM_CLASS(object_class),
G_SIGNAL_RUN_FIRST,
0,
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0
);
}
static void wintc_explorer_window_init(
@@ -122,6 +170,28 @@ static void wintc_explorer_window_init(
GtkBuilder* builder;
GtkWidget* main_box;
// Define GActions
//
g_action_map_add_action_entries(
G_ACTION_MAP(self),
s_window_actions,
G_N_ELEMENTS(s_window_actions),
self
);
// FIXME: Defaulting nav-up to disabled, in future this will depend on the
// initial location of the explorer window
//
g_simple_action_set_enabled(
G_SIMPLE_ACTION(
g_action_map_lookup_action(
G_ACTION_MAP(self),
"nav-up"
)
),
FALSE
);
// FIXME: Don't know what the default size should be
//
gtk_window_set_default_size(
@@ -146,35 +216,25 @@ static void wintc_explorer_window_init(
self->iconview_browser =
GTK_WIDGET(gtk_builder_get_object(builder, "browse-view"));
self->combo_address =
GTK_WIDGET(gtk_builder_get_object(builder, "combo-address"));
self->button_nav_go =
GTK_WIDGET(gtk_builder_get_object(builder, "button-nav-go"));
self->button_nav_up =
GTK_WIDGET(gtk_builder_get_object(builder, "button-nav-up"));
self->box_toolbars =
GTK_WIDGET(gtk_builder_get_object(builder, "box-toolbars"));
gtk_container_add(GTK_CONTAINER(self), main_box);
// Link up UI
// FIXME: This is temp, use GActions!
// FIXME: Toolbars are configurable!
//
g_signal_connect(
self->button_nav_go,
"clicked",
G_CALLBACK(on_button_nav_go_clicked),
self
WinTCExplorerToolbar* toolbar_adr =
wintc_exp_address_toolbar_new(self);
WinTCExplorerToolbar* toolbar_std =
wintc_exp_standard_toolbar_new(self);
gtk_container_add(
GTK_CONTAINER(self->box_toolbars),
wintc_explorer_toolbar_get_toolbar(toolbar_std)
);
g_signal_connect(
self->button_nav_up,
"clicked",
G_CALLBACK(on_button_nav_up_clicked),
self
);
g_signal_connect(
gtk_bin_get_child(GTK_BIN(self->combo_address)),
"activate",
G_CALLBACK(on_combo_address_entry_activate),
self
gtk_container_add(
GTK_CONTAINER(self->box_toolbars),
wintc_explorer_toolbar_get_toolbar(toolbar_adr)
);
}
@@ -215,23 +275,10 @@ static void wintc_explorer_window_constructed(
// Navigate to desktop
// FIXME: Need to check if we were initialised with a path in future!
//
GError* error = NULL;
WinTCShextPathInfo path_info = { 0 };
path_info.base_path = wintc_sh_path_for_guid(WINTC_SH_GUID_DESKTOP);
if (
!wintc_sh_browser_set_location(
wnd->browser,
&path_info,
&error
)
)
{
wintc_display_error_and_clear(&error);
}
wintc_shext_path_info_free_data(&path_info);
do_navigation(
wnd,
wintc_sh_get_place_path(WINTC_SH_PLACE_DESKTOP)
);
(G_OBJECT_CLASS(wintc_explorer_window_parent_class))->constructed(object);
}
@@ -288,9 +335,81 @@ GtkWidget* wintc_explorer_window_new(
);
}
void wintc_explorer_window_get_location(
WinTCExplorerWindow* wnd,
WinTCShextPathInfo* path_info
)
{
if (!wnd->current_path.base_path)
{
return;
}
wintc_shext_path_info_copy(
path_info,
&(wnd->current_path)
);
}
//
// PRIVATE FUNCTIONS
//
static void do_navigation(
WinTCExplorerWindow* wnd,
const gchar* specified_path
)
{
GError* error = NULL;
WinTCShextPathInfo path_info = { 0 };
// Don't bother navigating if there's nowhere to go!
//
if (g_strcmp0(specified_path, "") == 0)
{
return;
}
// Retrieve new location
//
wintc_shext_path_info_copy(
&path_info,
&(wnd->current_path)
);
prepare_new_location(
specified_path,
&path_info
);
// Attempt the navigation
//
if (
wintc_sh_browser_set_location(
wnd->browser,
&path_info,
&error
)
)
{
wintc_shext_path_info_move(
&(wnd->current_path),
&path_info
);
g_signal_emit(
wnd,
wintc_explorer_window_signals[SIGNAL_LOCATION_CHANGED],
0
);
}
else
{
wintc_nice_error_and_clear(&error);
}
wintc_shext_path_info_free_data(&path_info);
}
static void prepare_new_location(
const gchar* specified_path,
WinTCShextPathInfo* current_path_info
@@ -361,114 +480,23 @@ static void prepare_new_location(
//
// CALLBACKS
//
static void on_browser_location_changed(
WinTCShBrowser* self,
gpointer user_data
static void action_nav_go(
WINTC_UNUSED(GSimpleAction* action),
GVariant* parameter,
gpointer user_data
)
{
WinTCExplorerWindow* wnd = WINTC_EXPLORER_WINDOW(user_data);
// Just update the address bar for now
//
GtkWidget* entry;
WinTCShextPathInfo path_info = { 0 };
entry =
gtk_bin_get_child(
GTK_BIN(wnd->combo_address)
);
wintc_sh_browser_get_location(self, &path_info);
if (path_info.extended_path)
{
gtk_entry_set_text(
GTK_ENTRY(entry),
path_info.extended_path
);
}
else
{
// Special case for file:// address, we only want to display the actual
// filesystem path - kinda cheeky bunging it in here but it does get
// the job done
//
if (g_str_has_prefix(path_info.base_path, "file://"))
{
gtk_entry_set_text(
GTK_ENTRY(entry),
path_info.base_path + strlen("file://")
);
}
else
{
gtk_entry_set_text(
GTK_ENTRY(entry),
path_info.base_path
);
}
}
wintc_shext_path_info_free_data(&path_info);
do_navigation(
wnd,
g_variant_get_string(parameter, NULL)
);
}
static void on_button_nav_go_clicked(
WINTC_UNUSED(GtkButton* self),
gpointer user_data
)
{
WinTCExplorerWindow* wnd = WINTC_EXPLORER_WINDOW(user_data);
GtkWidget* entry;
GError* error = NULL;
WinTCShextPathInfo path_info = { 0 };
const gchar* target_path;
entry =
gtk_bin_get_child(
GTK_BIN(wnd->combo_address)
);
target_path =
gtk_entry_get_text(GTK_ENTRY(entry));
// Don't bother navigating if there's nowhere to go!
//
if (g_strcmp0(target_path, "") == 0)
{
return;
}
// Retrieve new location
//
wintc_sh_browser_get_location(
wnd->browser,
&path_info
);
prepare_new_location(
target_path,
&path_info
);
// Attempt the navigation
//
if (
!wintc_sh_browser_set_location(
wnd->browser,
&path_info,
&error
)
)
{
wintc_nice_error_and_clear(&error);
}
wintc_shext_path_info_free_data(&path_info);
}
static void on_button_nav_up_clicked(
WINTC_UNUSED(GtkButton* self),
static void action_nav_up(
WINTC_UNUSED(GSimpleAction* action),
WINTC_UNUSED(GVariant* parameter),
gpointer user_data
)
{
@@ -477,14 +505,37 @@ static void on_button_nav_up_clicked(
wintc_sh_browser_navigate_to_parent(wnd->browser);
}
static void on_combo_address_entry_activate(
WINTC_UNUSED(GtkEntry* self),
gpointer user_data
static void on_browser_location_changed(
WinTCShBrowser* self,
gpointer user_data
)
{
WinTCExplorerWindow* wnd = WINTC_EXPLORER_WINDOW(user_data);
gtk_widget_activate(
GTK_WIDGET(wnd->button_nav_go)
// Update our local state and emit on the window
//
wintc_shext_path_info_free_data(&(wnd->current_path));
wintc_sh_browser_get_location(
wnd->browser,
&(wnd->current_path)
);
g_signal_emit(
wnd,
wintc_explorer_window_signals[SIGNAL_LOCATION_CHANGED],
0
);
// Update action(s)
//
g_simple_action_set_enabled(
G_SIMPLE_ACTION(
g_action_map_lookup_action(
G_ACTION_MAP(wnd),
"nav-up"
)
),
wintc_sh_browser_can_navigate_to_parent(self)
);
}

View File

@@ -30,4 +30,9 @@ GtkWidget* wintc_explorer_window_new(
WinTCShextHost* shext_host
);
void wintc_explorer_window_get_location(
WinTCExplorerWindow* wnd,
WinTCShextPathInfo* path_info
);
#endif