~albyrock87/awn-extras/extras_with_pidgineer

« back to all changes in this revision

Viewing changes to applets/maintained/notification-daemon/engines.c

  • Committer: Alberto
  • Date: 2010-08-25 00:14:54 UTC
  • Revision ID: albyrock87+dev@gmail.com-20100825001454-xk2e92svlntj77id
Disabled Middle-Click debug

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#define ENABLE_GRADIENT_LOOK 1
33
33
 
34
34
 
35
 
#include <gconf/gconf-client.h>
36
35
#include "daemon.h"
37
36
#include "engines.h"
38
37
 
41
40
#include <libawn/awn-applet.h>
42
41
#include <glib/gmacros.h>
43
42
#include <glib/gerror.h>
44
 
#include <gconf/gconf-value.h>
45
43
 
46
44
#include <libawn/awn-dialog.h>
47
45
#include <libawn/awn-applet-simple.h>
117
115
 
118
116
  UrlClickedCb url_clicked;
119
117
 
120
 
  gboolean    use_gtk_style;
121
118
  gboolean    show_notification_win_title;
122
119
  gboolean    enable_gradient;
123
120
  int         border_width;
166
163
{
167
164
 
168
165
#if 1
169
 
  GtkStyle *style = gtk_widget_get_style(widget);
170
 
  GdkColor *background_color = &style->bg[GTK_STATE_NORMAL];
171
 
 
172
166
  awn_cairo_set_source_color_with_alpha_multiplier(cr, G_daemon_config.awn_bg, windata->gradient_factor);
173
167
  cairo_rectangle(cr, 0, 0,
174
168
                  widget->allocation.width,
178
172
 
179
173
}
180
174
 
181
 
 
 
175
#if 0
182
176
static void
183
177
draw_stripe(GtkWidget *widget, WindowData *windata, cairo_t *cr)
184
178
{
211
205
  gdk_cairo_set_source_color(cr, &color);
212
206
  cairo_fill(cr);
213
207
}
 
208
#endif
214
209
 
 
210
#if SHOW_SPACERS
215
211
static GtkArrowType
216
212
get_notification_arrow_type(GtkWidget *nw)
217
213
{
231
227
    return GTK_ARROW_UP;
232
228
  }
233
229
}
 
230
#endif
234
231
 
235
232
#define ADD_POINT(_x, _y, shapeoffset_x, shapeoffset_y) \
236
233
  G_STMT_START { \
241
238
    i++;\
242
239
  } G_STMT_END
243
240
 
 
241
#if 0
244
242
static void
245
243
create_border_with_arrow(GtkWidget *nw, WindowData *windata)
246
244
{
452
450
                       GDK_EVEN_ODD_RULE);
453
451
  g_free(shape_points);
454
452
}
 
453
#endif
455
454
 
 
455
#if 0
456
456
static void
457
457
draw_border(GtkWidget *widget, WindowData *windata, cairo_t *cr)
458
458
{
491
491
 
492
492
  cairo_stroke(cr);
493
493
}
 
494
#endif
494
495
 
495
496
static void
496
497
destroy_windata(WindowData *windata)
504
505
  g_free(windata);
505
506
}
506
507
 
 
508
#ifdef SHOW_SPACERS
507
509
static void
508
510
update_spacers(GtkWidget *nw)
509
511
{
534
536
    gtk_widget_hide(windata->bottom_spacer);
535
537
  }
536
538
}
 
539
#endif
537
540
 
538
541
static void
539
542
update_content_hbox_visibility(WindowData *windata)
588
591
  WindowData *windata;
589
592
 
590
593
  windata = g_new0(WindowData, 1);
591
 
  windata->use_gtk_style = G_daemon_config.awn_honour_gtk;
592
594
  windata->show_notification_win_title = FALSE;
593
595
  windata->border_width = G_daemon_config.awn_border_width;
594
596
  windata->gradient_factor = G_daemon_config.awn_gradient_factor;
754
756
  windata->body_label = gtk_label_new(NULL);
755
757
#else
756
758
  windata->body_label = sexy_url_label_new();
 
759
  g_signal_connect_swapped(G_OBJECT(windata->body_label), "url_activated",
 
760
                           G_CALLBACK(windata->url_clicked), win);
757
761
#endif
758
762
 
759
763
  gtk_box_pack_start(GTK_BOX(vbox), windata->body_label, TRUE, TRUE, 0);
762
766
 
763
767
  gtk_label_set_line_wrap(GTK_LABEL(windata->body_label), TRUE);
764
768
 
765
 
  g_signal_connect_swapped(G_OBJECT(windata->body_label), "url_activated",
766
 
                           G_CALLBACK(windata->url_clicked), win);
767
 
 
768
769
  atkobj = gtk_widget_get_accessible(windata->body_label);
769
770
 
770
771
  atk_object_set_description(atkobj, "Notification body text.");
779
780
 
780
781
  gtk_container_add(GTK_CONTAINER(alignment), windata->actions_box);
781
782
 
782
 
  if (windata->use_gtk_style)
783
 
  {
784
 
    GtkStyle *style = gtk_widget_get_style(windata->win);
785
 
 
786
 
    G_daemon_config.awn_bg = desktop_agnostic_color_new(&style->bg[GTK_STATE_NORMAL], BACKGROUND_OPACITY);
787
 
    G_daemon_config.awn_border = desktop_agnostic_color_new(&style->fg[GTK_STATE_ACTIVE], G_MAXUSHORT);
788
 
  }
789
 
 
790
783
  return GTK_WINDOW(win);
791
784
}
792
785
 
853
846
 
854
847
  /*FIXME*/
855
848
 
856
 
  if (windata->use_gtk_style)
857
 
  {
858
 
    str = g_strdup_printf("<b><big><span>%s</span></big></b>", summary);
859
 
  }
860
 
  else
861
 
  {
862
 
    str = g_strdup_printf("<b><big><span foreground=\"#%s\">%s</span></big></b>", G_daemon_config.awn_text_str, summary);
863
 
  }
864
 
 
 
849
  str = g_strdup_printf("<b><big><span foreground=\"#%s\">%s</span></big></b>", G_daemon_config.awn_text_str, summary);
865
850
 
866
851
  gtk_label_set_markup(GTK_LABEL(windata->summary_label), str);
867
852
 
868
853
  g_free(str);
869
854
 
870
 
  if (windata->use_gtk_style)
871
 
  {
872
 
    str = g_strdup_printf("%s<small><span> %s%c</span></small>%s", G_daemon_config.bold_text_body ? "<b>" : "",
873
 
                          body, endchar, G_daemon_config.bold_text_body ? "</b>" : "");
874
 
  }
875
 
  else
876
 
  {
877
 
    str = g_strdup_printf("%s<small><span foreground=\"#%s\"> %s%c\n</span></small>%s", G_daemon_config.bold_text_body ? "<b>" : "",
878
 
                          G_daemon_config.awn_text_str, body, endchar, G_daemon_config.bold_text_body ? "</b>" : "");
879
 
  }
 
855
  str = g_strdup_printf("%s<small><span foreground=\"#%s\"> %s%c\n</span></small>%s", G_daemon_config.bold_text_body ? "<b>" : "",
 
856
                        G_daemon_config.awn_text_str, body, endchar, G_daemon_config.bold_text_body ? "</b>" : "");
880
857
 
881
858
#ifdef HAVE_GTK_URL_LABEL
882
 
  gtk_entry_set_markup(GTK_LABEL(windata->body_label), str);
 
859
  gtk_label_set_markup(GTK_LABEL(windata->body_label), str);
883
860
#else
884
861
  sexy_url_label_set_markup(SEXY_URL_LABEL(windata->body_label), str);
885
862
#endif
892
869
                          G_daemon_config.awn_text_str, tmp, endchar, G_daemon_config.bold_text_body ? "</b>" : "");
893
870
 
894
871
#ifdef HAVE_GTK_URL_LABEL
895
 
    gtk_entry_set_markup(GTK_LABEL(windata->body_label), str);
 
872
    gtk_label_set_markup(GTK_LABEL(windata->body_label), str);
896
873
#else
897
874
    sexy_url_label_set_markup(SEXY_URL_LABEL(windata->body_label), str);
898
875
#endif
964
941
    return TRUE;
965
942
  }
966
943
 
967
 
  GtkStyle *style = gtk_widget_get_style(windata->win);
968
 
 
969
944
  cairo_t *context;
970
945
  cairo_surface_t *surface;
971
946
  cairo_t *cr;
983
958
  if (windata->timeout > 0)
984
959
  {
985
960
    gdouble pct = (gdouble)windata->remaining / (gdouble)windata->timeout;
986
 
    gushort old_alpha = G_daemon_config.awn_border->alpha;
 
961
    gushort old_alpha = desktop_agnostic_color_get_alpha(G_daemon_config.awn_border);
987
962
 
988
 
    G_daemon_config.awn_border->alpha = G_MAXUSHORT;
 
963
    desktop_agnostic_color_set_alpha(G_daemon_config.awn_border, G_MAXUSHORT);
989
964
//  gdk_cairo_set_source_color(cr, &style->bg[GTK_STATE_ACTIVE]);
990
965
    awn_cairo_set_source_color(cr, G_daemon_config.awn_border);
991
 
    G_daemon_config.awn_border->alpha = old_alpha;
 
966
    desktop_agnostic_color_set_alpha(G_daemon_config.awn_border, old_alpha);
992
967
    cairo_move_to(cr, PIE_RADIUS, PIE_RADIUS);
993
968
    cairo_arc_negative(cr, PIE_RADIUS, PIE_RADIUS, PIE_RADIUS,
994
969
                       -G_PI_2, -(pct * G_PI * 2) - G_PI_2);
1029
1004
  GtkWidget *hbox;
1030
1005
  GdkPixbuf *pixbuf;
1031
1006
  char *buf;
1032
 
  cairo_t *cr;
1033
1007
  g_assert(windata != NULL);
1034
1008
 
1035
1009
  if ((!G_daemon_config.show_status) && (G_daemon_config.hide_opacity <= 0.01))
1132
1106
    assert(1);
1133
1107
    x = x - WIDTH - 1;
1134
1108
 
1135
 
    if (y + nw->allocation.height >= gdk_screen_get_height(gdk_screen_get_default()))
 
1109
    switch (awn_applet_get_pos_type(G_daemon_config.awn_app))
1136
1110
    {
1137
 
      y = y - nw->allocation.height - 1;
 
1111
      case GTK_POS_TOP:
 
1112
        if (y + nw->allocation.height >= gdk_screen_get_height(gdk_screen_get_default()))
 
1113
        {
 
1114
          y = y + nw->allocation.height - 1;
 
1115
        }
 
1116
        break;
 
1117
      case GTK_POS_BOTTOM:
 
1118
        if (y + nw->allocation.height >= gdk_screen_get_height(gdk_screen_get_default()))
 
1119
        {
 
1120
          y = y - nw->allocation.height - 1;
 
1121
        }
 
1122
        break;
1138
1123
    }
1139
1124
  }
1140
1125
  else if (y + nw->allocation.height >= gdk_screen_get_height(gdk_screen_get_default()))
1141
1126
  {
1142
 
    assert(1);
1143
 
    y = y - nw->allocation.height - 1;
 
1127
    switch (awn_applet_get_pos_type(G_daemon_config.awn_app))
 
1128
    {
 
1129
      case GTK_POS_TOP:
 
1130
        if (y + nw->allocation.height >= gdk_screen_get_height(gdk_screen_get_default()))
 
1131
        {
 
1132
          y = y + nw->allocation.height - 1;
 
1133
        }
 
1134
        break;
 
1135
      case GTK_POS_BOTTOM:
 
1136
        if (y + nw->allocation.height >= gdk_screen_get_height(gdk_screen_get_default()))
 
1137
        {
 
1138
          y = y - nw->allocation.height - 1;
 
1139
        }
 
1140
        break;
 
1141
    }
1144
1142
  }
1145
1143
 
1146
1144
  WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");