Browse Source

Cleanup atk set function handling a bit.

tags/xfce4-panel-4.10.0
Nick Schermer 10 years ago
parent
commit
e632fe3994
7 changed files with 54 additions and 44 deletions
  1. +34
    -0
      common/panel-utils.c
  2. +4
    -0
      common/panel-utils.h
  3. +5
    -11
      plugins/actions/actions.c
  4. +1
    -7
      plugins/directorymenu/directorymenu.c
  5. +5
    -17
      plugins/launcher/launcher.c
  6. +3
    -1
      plugins/showdesktop/Makefile.am
  7. +2
    -8
      plugins/showdesktop/showdesktop.c

+ 34
- 0
common/panel-utils.c View File

@@ -225,3 +225,37 @@ panel_utils_grab_available (void)

return grab_succeed;
}



void
panel_utils_set_atk_info (GtkWidget *widget,
const gchar *name,
const gchar *description)
{
static gboolean initialized = FALSE;
static gboolean atk_enabled = TRUE;
AtkObject *object;

panel_return_if_fail (GTK_IS_WIDGET (widget));

if (atk_enabled)
{
object = gtk_widget_get_accessible (widget);

if (!initialized)
{
initialized = TRUE;
atk_enabled = GTK_IS_ACCESSIBLE (object);

if (!atk_enabled)
return;
}

if (name != NULL)
atk_object_set_name (object, name);

if (description != NULL)
atk_object_set_description (object, description);
}
}

+ 4
- 0
common/panel-utils.h View File

@@ -38,4 +38,8 @@ void panel_utils_show_help (GtkWindow *parent,

gboolean panel_utils_grab_available (void);

void panel_utils_set_atk_info (GtkWidget *widget,
const gchar *name,
const gchar *description);

#endif /* !__PANEL_BUILDER_H__ */

+ 5
- 11
plugins/actions/actions.c View File

@@ -164,7 +164,6 @@ actions_plugin_init (ActionsPlugin *plugin)
{
GtkWidget *widget;
ActionEntry *entry = &action_entries[ACTION_LOG_OUT_DIALOG];
AtkObject *atkobj;

plugin->first_action = ACTION_LOG_OUT_DIALOG;
plugin->second_action = ACTION_DISABLED;
@@ -181,9 +180,7 @@ actions_plugin_init (ActionsPlugin *plugin)
xfce_panel_plugin_add_action_widget (XFCE_PANEL_PLUGIN (plugin), widget);
gtk_widget_show (widget);

atkobj = gtk_widget_get_accessible (widget);
if (atkobj != NULL)
atk_object_set_name (atkobj, _(entry->title));
panel_utils_set_atk_info (widget, _(entry->title), NULL);

plugin->first_image = xfce_panel_image_new_from_source (entry->icon_name);
gtk_container_add (GTK_CONTAINER (widget), plugin->first_image);
@@ -237,7 +234,6 @@ actions_plugin_set_property (GObject *object,
{
ActionsPlugin *plugin = XFCE_ACTIONS_PLUGIN (object);
ActionType action;
AtkObject *atkobj;

switch (prop_id)
{
@@ -250,9 +246,8 @@ actions_plugin_set_property (GObject *object,
XFCE_PANEL_IMAGE (plugin->first_image),
action_entries[action].icon_name);

atkobj = gtk_widget_get_accessible (plugin->first_button);
if (atkobj != NULL)
atk_object_set_name (atkobj, _(action_entries[action].title));
panel_utils_set_atk_info (plugin->first_button,
_(action_entries[action].title), NULL);
break;

case PROP_SECOND_ACTION:
@@ -273,9 +268,8 @@ actions_plugin_set_property (GObject *object,
XFCE_PANEL_IMAGE (plugin->second_image),
action_entries[action].icon_name);

atkobj = gtk_widget_get_accessible (plugin->second_button);
if (atkobj != NULL)
atk_object_set_name (atkobj, _(action_entries[action].title));
panel_utils_set_atk_info (plugin->second_button,
_(action_entries[action].title), NULL);
}

/* update plugin size */


+ 1
- 7
plugins/directorymenu/directorymenu.c View File

@@ -226,7 +226,6 @@ directory_menu_plugin_set_property (GObject *object,
guint i;
GFile *base_directory;
const gchar *path;
AtkObject *atkobj;

switch (prop_id)
{
@@ -244,12 +243,7 @@ directory_menu_plugin_set_property (GObject *object,
display_name = g_file_get_parse_name (plugin->base_directory);
gtk_widget_set_tooltip_text (plugin->button, display_name);

atkobj = gtk_widget_get_accessible (plugin->button);
if (atkobj != NULL)
{
atk_object_set_name (atkobj, _("Directory Menu"));
atk_object_set_description (atkobj, display_name);
}
panel_utils_set_atk_info (plugin->button, _("Directory Menu"), display_name);

g_free (display_name);
break;


+ 5
- 17
plugins/launcher/launcher.c View File

@@ -34,6 +34,7 @@
#include <libxfce4panel/libxfce4panel.h>
#include <common/panel-private.h>
#include <common/panel-xfconf.h>
#include <common/panel-utils.h>

#include "launcher.h"
#include "launcher-dialog.h"
@@ -341,7 +342,6 @@ static void
launcher_plugin_init (LauncherPlugin *plugin)
{
GtkIconTheme *icon_theme;
AtkObject *atkobj;

plugin->disable_tooltips = FALSE;
plugin->move_first = FALSE;
@@ -402,9 +402,7 @@ launcher_plugin_init (LauncherPlugin *plugin)
g_signal_connect (G_OBJECT (plugin->arrow), "drag-leave",
G_CALLBACK (launcher_plugin_arrow_drag_leave), plugin);

atkobj = gtk_widget_get_accessible (plugin->arrow);
if (atkobj != NULL)
atk_object_set_name (atkobj, _("Open launcher menu"));
panel_utils_set_atk_info (plugin->arrow, _("Open launcher menu"), NULL);

/* accept all sorts of drag data, but filter in drag-drop, so we can
* send other sorts of drops to parent widgets */
@@ -1678,8 +1676,6 @@ launcher_plugin_button_update (LauncherPlugin *plugin)
{
GarconMenuItem *item = NULL;
const gchar *icon_name;
AtkObject *atkobj;
const gchar *text;

panel_return_if_fail (XFCE_IS_LAUNCHER_PLUGIN (plugin));

@@ -1708,17 +1704,9 @@ launcher_plugin_button_update (LauncherPlugin *plugin)
xfce_panel_image_set_from_source (XFCE_PANEL_IMAGE (plugin->child),
exo_str_is_empty (icon_name) ? GTK_STOCK_MISSING_IMAGE : icon_name);

atkobj = gtk_widget_get_accessible (plugin->button);
if (atkobj != NULL)
{
text = garcon_menu_item_get_name (item);
if (text != NULL)
atk_object_set_name (atkobj, text);

text = garcon_menu_item_get_comment (item);
if (text != NULL)
atk_object_set_description (atkobj, text);
}
panel_utils_set_atk_info (plugin->button,
garcon_menu_item_get_name (item),
garcon_menu_item_get_comment (item));
}
else
{


+ 3
- 1
plugins/showdesktop/Makefile.am View File

@@ -29,12 +29,14 @@ libshowdesktop_la_LDFLAGS = \

libshowdesktop_la_LIBADD = \
$(top_builddir)/libxfce4panel/libxfce4panel-$(LIBXFCE4PANEL_VERSION_API).la \
$(top_builddir)/common/libpanel-common.la \
$(GTK_LIBS) \
$(LIBXFCE4UTIL_LIBS) \
$(LIBWNCK_LIBS)

libshowdesktop_la_DEPENDENCIES = \
$(top_builddir)/libxfce4panel/libxfce4panel-$(LIBXFCE4PANEL_VERSION_API).la
$(top_builddir)/libxfce4panel/libxfce4panel-$(LIBXFCE4PANEL_VERSION_API).la \
$(top_builddir)/common/libpanel-common.la

#
# .desktop file


+ 2
- 8
plugins/showdesktop/showdesktop.c View File

@@ -23,6 +23,7 @@

#include <libxfce4util/libxfce4util.h>
#include <common/panel-private.h>
#include <common/panel-utils.h>

#include "showdesktop.h"

@@ -178,7 +179,6 @@ show_desktop_plugin_toggled (GtkToggleButton *button,
ShowDesktopPlugin *plugin)
{
gboolean active;
AtkObject *atkobj;
const gchar *text;

panel_return_if_fail (XFCE_IS_SHOW_DESKTOP_PLUGIN (plugin));
@@ -196,13 +196,7 @@ show_desktop_plugin_toggled (GtkToggleButton *button,
text = _("Minimize all open windows and show the desktop");

gtk_widget_set_tooltip_text (GTK_WIDGET (button), text);

atkobj = gtk_widget_get_accessible (GTK_WIDGET (button));
if (atkobj != NULL)
{
atk_object_set_name (atkobj, _("Show Desktop"));
atk_object_set_description (atkobj, text);
}
panel_utils_set_atk_info (GTK_WIDGET (button), _("Show Desktop"), text);
}




Loading…
Cancel
Save